--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+PROJECT(osp-app-controls)
+
+SET(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/cmake_build_tmp/output)
+SET(CMAKE_SKIP_BUILD_RPATH TRUE)
+
+
+SET(COMMON_INCLUDE_DIRS
+ /usr/include/network
+ /usr/include/osp/net
+ /usr/include/osp/media
+ )
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED
+ appsvc
+ capi-appfw-application
+ osp-appfw
+)
+
+FOREACH(flag ${pkgs_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+
+MACRO(OSP_STRIP _target)
+ENDMACRO(OSP_STRIP)
+
+MACRO(EXE_STRIP _target)
+ENDMACRO(EXE_STRIP)
+
+ADD_SUBDIRECTORY(src/app-control-util osp-ac-util)
+ADD_SUBDIRECTORY(src/bluetooth-app-control osp-ac-bluetooth)
+ADD_SUBDIRECTORY(src/browser-app-control osp-ac-browser)
+ADD_SUBDIRECTORY(src/calendar-app-control osp-ac-calendar)
+ADD_SUBDIRECTORY(src/call-app-control osp-ac-call)
+ADD_SUBDIRECTORY(src/camera-app-control osp-ac-camera)
+ADD_SUBDIRECTORY(src/contact-app-control osp-ac-contact)
+ADD_SUBDIRECTORY(src/filemanager-app-control osp-ac-filemanager)
+ADD_SUBDIRECTORY(src/media-app-control osp-ac-media)
+ADD_SUBDIRECTORY(src/image-app-control osp-ac-image)
+ADD_SUBDIRECTORY(src/message-app-control osp-ac-message)
+ADD_SUBDIRECTORY(src/setting-app-control osp-ac-setting)
+ADD_SUBDIRECTORY(src/platform-app-control osp-ac-platform)
+ADD_SUBDIRECTORY(src/implicit-app-control osp-ac-implicit)
+ADD_SUBDIRECTORY(src/nfc-push-ui-app-control osp-ac-nfc-push-ui)
+
+INSTALL(DIRECTORY ${LIBRARY_OUTPUT_PATH}/ DESTINATION lib/osp
+ FILES_MATCHING PATTERN "*.so*"
+ PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
+ GROUP_EXECUTE GROUP_READ
+ WORLD_EXECUTE WORLD_READ)
--- /dev/null
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
--- /dev/null
+Copyright (c) Samsung Electronics Co., Ltd. All rights reserved.
+Except as noted, this software is licensed under Apache License, Version 2.
+Please, see the LICENSE.APLv2 file for Apache License terms and conditions.
--- /dev/null
+//
+// Copyright (c) 2013 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 FApp_AppControlPluginUtil.h
+ * @brief This is the header file for the _AppControlPluginUtil class.
+ */
+
+#ifndef _FAPP_INTERNAL_APP_CONTROL_PLUGIN_UTIL_H_
+#define _FAPP_INTERNAL_APP_CONTROL_PLUGIN_UTIL_H_
+
+#include <FOspConfig.h>
+#include <FBaseObject.h>
+#include <FBaseSysLog.h>
+
+#include <FApp_AppControlManager.h>
+
+
+namespace Tizen { namespace Base
+{
+class String;
+}}
+
+namespace Tizen { namespace App
+{
+
+class _OSP_EXPORT_ _AppControlPluginUtil
+{
+public:
+ static bool IsAllowedAppControl(const char aTable[][2][96], int count, const Tizen::Base::String& aId, const Tizen::Base::String& oId);
+
+ static result SendStopRequest(int pid);
+
+ static int LaunchImplicit(const _AppMessageImpl& msg, AppSvcResFn Pcb, void* pData, int req, bool& isAppSelector);
+
+private:
+ _OSP_LOCAL_ _AppControlPluginUtil(void);
+
+ _OSP_LOCAL_ ~_AppControlPluginUtil(void);
+
+ _AppControlPluginUtil(const _AppControlPluginUtil& rhs);
+
+ _AppControlPluginUtil& operator =(const _AppControlPluginUtil& rhs);
+
+private:
+}; // _AppControlPluginUtil
+
+}} // Tizen::App
+
+#endif // _FAPP_INTERNAL_APP_CONTROL_PLUGIN_UTIL_H_
--- /dev/null
+//
+// Copyright (c) 2013 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 FApp_AppControlTerminateHandler.h
+ * @brief This is the header file for the _AppControlTerminateHandler class.
+ */
+
+#ifndef _FAPP_INTERNAL_APP_CONTROL_TERMINATE_HANDLER_H_
+#define _FAPP_INTERNAL_APP_CONTROL_TERMINATE_HANDLER_H_
+
+#include <FOspConfig.h>
+#include <FBaseObject.h>
+#include <FBaseSysLog.h>
+#include <FBaseColLinkedListT.h>
+#include <FBaseColHashMapT.h>
+
+#include <FApp_IAppEventListener.h>
+
+
+namespace Tizen { namespace Base
+{
+class String;
+}}
+
+namespace Tizen { namespace App
+{
+
+typedef void (*AppControlResultCallbackType)(int request, int pid, void* data);
+
+
+class _OSP_EXPORT_ _AppControlTerminateHandler
+ : public _IAppEventListener
+ , virtual public Tizen::Base::Runtime::IEventListener
+{
+public:
+ _AppControlTerminateHandler(void)
+ : __pResultCallback(null)
+ , __pData(null)
+ {
+ __processList.Construct();
+ }
+
+ virtual ~_AppControlTerminateHandler(void) {}
+
+ virtual void OnApplicationLaunched(const AppId& appId, int pid) {}
+
+ virtual void OnApplicationTerminated(const AppId& appId, int pid);
+
+ result AddHandler(int req);
+
+ result SetHandlerData(int req, int pid);
+
+ result RemoveHandler(int req);
+
+ void RemoveAllHandlers(void);
+
+ void SetResultCallback(AppControlResultCallbackType callback, void* data);
+
+private:
+ _AppControlTerminateHandler(const _AppControlTerminateHandler& rhs);
+
+ _AppControlTerminateHandler& operator =(const _AppControlTerminateHandler& rhs);
+
+private:
+ AppControlResultCallbackType __pResultCallback;
+ void* __pData;
+ Tizen::Base::Collection::HashMapT<int, int> __processList;
+}; // _AppControlTerminateHandler
+
+}} // Tizen::App
+
+#endif // _FAPP_INTERNAL_APP_CONTROL_TERMINATE_HANDLER_H_
--- /dev/null
+<manifest>
+ <request>
+ <domain name="_"/>
+ </request>
+</manifest>
\ No newline at end of file
--- /dev/null
+%define __strip /bin/true
+
+Name: osp-app-controls
+Summary: osp application controls library
+Version: 1.2.2.1
+Release: 1
+Group: System/Libraries
+License: Apache-2.0
+Source0: %{name}-%{version}.tar.gz
+BuildRequires: cmake
+BuildRequires: pkgconfig(appsvc)
+BuildRequires: pkgconfig(capi-appfw-application)
+BuildRequires: pkgconfig(capi-network-bluetooth)
+BuildRequires: pkgconfig(capi-system-device)
+BuildRequires: pkgconfig(capi-system-info)
+BuildRequires: boost-devel
+BuildRequires: pkgconfig(osp-appfw)
+BuildRequires: pkgconfig(osp-uifw)
+BuildRequires: pkgconfig(osp-bluetooth)
+BuildRequires: osp-bluetooth-internal-devel
+BuildRequires: pkgconfig(osp-nfc)
+BuildRequires: pkgconfig(osp-social)
+BuildRequires: pkgconfig(osp-image)
+BuildRequires: pkgconfig(osp-image-core)
+BuildRequires: osp-image-internal-devel
+BuildRequires: osp-social-internal-devel
+BuildRequires: pkgconfig(contacts-service2)
+BuildRequires: hash-signer
+
+# runtime requires
+Requires: osp-sys-config
+Requires: osp-appfw
+Requires: osp-uifw
+Requires: osp-bluetooth
+Requires: osp-nfc
+Requires: osp-installer
+Requires: osp-social
+Requires: apps.CertificateSelector
+
+Requires(post): coreutils
+
+%description
+osp application controls library
+
+%prep
+%setup -q
+
+%build
+MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
+
+%ifarch %{ix86}
+ ARCH=x86
+ CXXFLAGS="$CXXFLAGS -D_OSP_DEBUG_ -D_OSP_X86_"
+ %if 0%{?simulator}
+ CXXFLAGS="$CXXFLAGS -D_OSP_EMUL_"
+ %endif
+%else
+ ARCH=arm
+ 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_"
+%endif
+
+%if 0%{?tizen_build_binary_release_type_eng}
+ CXXFLAGS="$CXXFLAGS -D_SECURE_LOG"
+%endif
+
+cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DOBS=1 -DFULLVER=%{version} -DMAJORVER=${MAJORVER} -DARCH=${ARCH}
+
+# 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
+%define tizen_sign 1
+%define tizen_sign_base /usr/apps/42KriKjov3
+%define tizen_sign_level platform
+%define tizen_author_sign 1
+%define tizen_dist_sign 1
+
+%post
+/sbin/ldconfig
+
+/usr/etc/package-manager/backend/tpk -i /usr/apps/42KriKjov3
+
+%postun -p /sbin/ldconfig
+
+%files
+%manifest osp-app-controls.manifest
+%attr(0644,root,root) /usr/share/license/%{name}
+/usr/apps/*
+%{_libdir}/osp/*.so*
+
--- /dev/null
+SET (this_target osp-ac-util)
+
+INCLUDE_DIRECTORIES (
+ ${COMMON_INCLUDE_DIRS}
+ ../../inc
+ )
+
+SET (${this_target}_SOURCE_FILES
+ FApp_AppControlPluginUtil.cpp
+ FApp_AppControlTerminateHandler.cpp
+ )
+
+## SET EXTRA COMPILER FLAGS
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fPIC -Wall" )
+
+## 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_LIBRARY (${this_target} SHARED ${${this_target}_SOURCE_FILES})
+
+TARGET_LINK_LIBRARIES(${this_target} -Xlinker --no-undefined -Xlinker)
+TARGET_LINK_LIBRARIES(${this_target} ${pkgs_LDFLAGS})
+
+OSP_STRIP(${this_target})
--- /dev/null
+//
+// Copyright (c) 2013 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 FApp_AppControlPluginUtil.cpp
+ * @brief This is the implementation for the _AppControlPluginUtil class.
+ */
+
+#include <cstdio>
+#include <unique_ptr.h>
+
+#include <aul.h>
+#include <appsvc.h>
+
+#include <FBaseSysLog.h>
+
+#include <FBase_StringConverter.h>
+#include <FApp_AppMessageImpl.h>
+#include <FApp_AppInfo.h>
+#include <FApp_AppArg.h>
+#include <FApp_AppImpl.h>
+#include <FApp_AppControlManager.h>
+
+#include "FApp_AppControlPluginUtil.h"
+
+
+using namespace Tizen::Base;
+
+
+namespace
+{
+
+const char SELECTOR_NOTI_KEY[] = "__APP_SVC_CALLER_NOTI__";
+
+}
+
+namespace Tizen { namespace App
+{
+
+bool
+_AppControlPluginUtil::IsAllowedAppControl(const char aTable[][2][96], int count, const String& aId, const String& oId)
+{
+ for (int i = 0; i < count; i++)
+ {
+ if (aId == aTable[i][0] && oId == aTable[i][1])
+ {
+ SysLog(NID_APP, "Found entry (%s, %s)", aTable[i][0], aTable[i][1]);
+ return true;
+ }
+ }
+
+ return false;
+}
+
+
+result
+_AppControlPluginUtil::SendStopRequest(int pid)
+{
+ appsvc_subapp_terminate_request_pid(pid);
+ return E_SUCCESS;
+}
+
+
+int
+_AppControlPluginUtil::LaunchImplicit(const _AppMessageImpl& message, AppSvcResFn pCb, void* pData, int req, bool& isAppSelector)
+{
+ result r = E_SUCCESS;
+ _AppMessageImpl msg(message);
+ bundle* kb = msg.GetBundle();
+
+ if (req >= 0)
+ {
+ _AppArg::UpdateRequestId(kb, req);
+ const AppId& appId = _AppInfo::GetApplicationId();
+ std::unique_ptr<char[]> pAppId(_StringConverter::CopyToCharArrayN(appId));
+ appsvc_add_data(kb, SELECTOR_NOTI_KEY, pAppId.get());
+ }
+
+ if (_AppImpl::GetInstance() != null)
+ {
+ const long handle = _AppImpl::GetInstance()->GetWindowHandle();
+ _AppArg::UpdateWindowHandle(kb, handle);
+ }
+
+ int pid = appsvc_run_service(kb, req, reinterpret_cast<appsvc_res_fn>(pCb), pData);
+ if (pid >= 0)
+ {
+ if (pid == 0)
+ {
+ SysLog(NID_APP, "Sending local process again.");
+ pid = getpid();
+ }
+
+ char pkgname[255] = {0, };
+ if (aul_app_get_pkgname_bypid(pid, pkgname, 255) != AUL_R_OK)
+ {
+ SysLogException(NID_APP, E_SYSTEM, "[E_SYSTEM] Fail to get package name by pid : (%d).", pid);
+ return E_SYSTEM;
+ }
+
+ if (strncmp(pkgname, APP_SELECTOR, strlen(APP_SELECTOR)) != 0)
+ {
+ const char* pOperation = appsvc_get_operation(kb);
+
+ SysLog(NID_APP, "Starting application without selector : (%s, %s).", pkgname, pOperation);
+
+ _AppControlManager::GetInstance()->SendAppControlStartResponse(req, pkgname, pOperation);
+ }
+ else
+ {
+
+ isAppSelector = true;
+ }
+ }
+ else
+ {
+ switch (pid)
+ {
+ case APPSVC_RET_EINVAL:
+ r = E_OBJ_NOT_FOUND;
+ break;
+ case APPSVC_RET_ENOMATCH:
+ r = E_OBJ_NOT_FOUND;
+ break;
+ case APPSVC_RET_EILLACC:
+ r = E_ILLEGAL_ACCESS;
+ break;
+ case APPSVC_RET_ERROR:
+ // fall through
+ case APPSVC_RET_ELAUNCH:
+ // fall through
+ default:
+ r = E_SYSTEM;
+ break;
+ }
+
+ SetLastResult(r);
+ }
+
+ SysLog(NID_APP, "[%s] Application(%d) launched with reqId(%d).", GetErrorMessage(r), pid, req);
+
+ return pid;
+}
+
+}} // Tizen::App
--- /dev/null
+//
+// Copyright (c) 2013 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 FApp_AppControlTerminateHandler.cpp
+ * @brief This is the implementation for the _AppControlTerminateHandler class.
+ */
+
+#include <unique_ptr.h>
+
+#include <FBaseSysLog.h>
+
+#include <FApp_AppManagerImpl.h>
+
+#include "FApp_AppControlTerminateHandler.h"
+
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+
+namespace Tizen { namespace App
+{
+
+void
+_AppControlTerminateHandler::OnApplicationTerminated(const AppId& appId, int pid)
+{
+ if (__pResultCallback)
+ {
+ std::unique_ptr<IMapEnumeratorT<int, int> > pEnum(__processList.GetMapEnumeratorN());
+ if (pEnum.get())
+ {
+ while (pEnum->MoveNext() == E_SUCCESS)
+ {
+ int val = -1;
+ result r = pEnum->GetValue(val);
+ if (val == pid)
+ {
+ int req = -1;
+ pEnum->GetKey(req);
+ (*__pResultCallback)(req, pid, __pData);
+ SysLog(NID_APP, "%ls(%d) is terminated for request %d.", appId.GetPointer(), pid, req);
+
+ return;
+ }
+ }
+ }
+ else
+ {
+ SysLog(NID_APP, "No proper enumerator.");
+ }
+ }
+
+ SysLog(NID_APP, "No listener found for process %d.", pid);
+}
+
+
+result
+_AppControlTerminateHandler::AddHandler(int req)
+{
+ if (__processList.GetCount() == 0)
+ {
+ _AppManagerImpl::GetInstance()->AddAppEventListener(*this);
+ }
+
+ return __processList.Add(req, -1);
+}
+
+
+result
+_AppControlTerminateHandler::RemoveHandler(int req)
+{
+ const result r = __processList.Remove(req);
+ SysLog(NID_APP, "[%s] Request %d is removed.", GetErrorMessage(r), req);
+
+ if (__processList.GetCount() == 0)
+ {
+ _AppManagerImpl::GetInstance()->RemoveAppEventListener(*this);
+ }
+
+ return r;
+}
+
+
+void
+_AppControlTerminateHandler::RemoveAllHandlers(void)
+{
+ return __processList.RemoveAll();
+}
+
+
+result
+_AppControlTerminateHandler::SetHandlerData(int req, int pid)
+{
+ return __processList.SetValue(req, pid);
+}
+
+
+void
+_AppControlTerminateHandler::SetResultCallback(AppControlResultCallbackType callback, void* pData)
+{
+ __pResultCallback = callback;
+ __pData = pData;
+}
+
+}} // Tizen::App
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file BluetoothAppControlDllEntry.cpp
+ * @brief This is the implementation for the BluetoothAppControlDllEntry.cpp.
+ */
+
+#include <appsvc/appsvc.h>
+
+#include <FBaseSysLog.h>
+#include <FBaseInteger.h>
+#include <FBaseLong.h>
+#include <FBaseColHashMap.h>
+
+#include <FApp_AppControlManager.h>
+#include <FApp_AppMessageImpl.h>
+#include <FNetBt_BluetoothAdapterUtility.h>
+#include <FSys_SystemInfoImpl.h>
+#include <FApp_Aul.h>
+#include <FApp_IAppControlPluginProvider.h>
+
+#include "FApp_AppControlPluginUtil.h"
+
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Net::Bluetooth;
+
+
+namespace
+{
+
+class _AppControlPlugin
+ : public _IAppControlPluginProvider
+ , virtual public Tizen::Base::Runtime::IEventListener
+{
+public:
+ _AppControlPlugin(void) {}
+
+ virtual ~_AppControlPlugin(void) {}
+
+ virtual result StartAppControlPlugin(int req, const AppId& appId, const _AppMessageImpl& message, int* pPid);
+
+ virtual result StopAppControlPlugin(int req);
+
+ virtual result Release(void) { delete this; return E_SUCCESS; }
+
+ static void OnAppControlResult(void* b, int requestCode, service_result_e res, void* userData);
+
+private:
+ static int __req;
+ static int __processId;
+};
+
+int _AppControlPlugin::__req = -1;
+int _AppControlPlugin::__processId = -1;
+
+
+result
+_AppControlPlugin::StartAppControlPlugin(int req, const AppId& appId, const _AppMessageImpl& message, int* pPid)
+{
+ SysLog(NID_APP, "Entry to Bluetooth AppControl");
+
+ result r = E_SUCCESS;
+ bool isBtSupported = false;
+ _AppMessageImpl msg(message);
+
+ r = Tizen::System::_SystemInfoImpl::GetSysInfo(L"http://tizen.org/feature/network.bluetooth", isBtSupported);
+ SysTryReturnResult(NID_APP, (r == E_SUCCESS) && (isBtSupported == true), E_SYSTEM, "Bluetooth is not supported.");
+
+ SysLog(NID_APP, "Bluetooth AppControl.");
+
+ msg.AddData(L"launch-type", L"pick");
+
+ __processId = _AppControlManager::GetInstance()->Launch(msg, _AppControlPlugin::OnAppControlResult, 0);
+
+ r = GetLastResult();
+ SysTryReturnResult(NID_APP, __processId >= 0, r, "StartAppControl: Launching Bluetooth AppControl is failed.");
+ SysLog(NID_APP, "[%s] Launching Bluetooth AppControl succeeded.", GetErrorMessage(r));
+
+ __req = req;
+ if (pPid)
+ {
+ *pPid = __processId;
+ }
+
+ return r;
+}
+
+
+result
+_AppControlPlugin::StopAppControlPlugin(int req)
+{
+ if (__processId >= 0)
+ {
+ _AppControlPluginUtil::SendStopRequest(__processId);
+ SysLog(NID_APP, "Process %d is terminated.", __processId);
+ __processId = -1;
+ }
+
+ return E_SUCCESS;
+}
+
+
+void
+_AppControlPlugin::OnAppControlResult(void* b, int requestCode, service_result_e res, void* userData)
+{
+ result r = E_SYSTEM;
+ bundle* pBundle = static_cast<bundle*>(b);
+ String dataStr;
+ int majClassType = 0;
+ int minClassType = 0;
+ int svcClassType = 0;
+ unsigned long svcType = 0;
+ int result = SERVICE_RESULT_SUCCEEDED;
+ const char* pBuf;
+
+ HashMap* pResult = new (std::nothrow) HashMap();
+ SysTryCatch(NID_APP, pResult != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Allocation failure.");
+
+ r = pResult->Construct();
+
+ pBuf = appsvc_get_data(pBundle, "result");
+ if (strcmp(pBuf, "success") == 0)
+ {
+ result = SERVICE_RESULT_SUCCEEDED;
+ }
+ else
+ {
+ result = SERVICE_RESULT_FAILED;
+ }
+
+ SysLog(NID_APP, "The service result %s", result == SERVICE_RESULT_SUCCEEDED? "succeeded." : "failed.");
+
+ switch (result)
+ {
+ case SERVICE_RESULT_SUCCEEDED:
+ {
+ pBuf = appsvc_get_data(pBundle, "http://tizen.org/appcontrol/data/bluetooth/address");
+ if (pBuf)
+ {
+ pResult->Remove(String(L"http://tizen.org/appcontrol/data/bluetooth/address"));
+ pResult->Add(new (std::nothrow) String(L"http://tizen.org/appcontrol/data/bluetooth/address"), new (std::nothrow) String(pBuf));
+ pResult->Remove(String(L"addr_val"));
+ pResult->Add(new (std::nothrow) String(L"addr_val"), new (std::nothrow) String(pBuf));
+ }
+
+ pBuf = appsvc_get_data(pBundle, "http://tizen.org/appcontrol/data/bluetooth/name");
+ if (pBuf)
+ {
+ pResult->Remove(String(L"http://tizen.org/appcontrol/data/bluetooth/name"));
+ pResult->Add(new (std::nothrow) String(L"http://tizen.org/appcontrol/data/bluetooth/name"), new (std::nothrow) String(pBuf));
+ pResult->Remove(String(L"dev_name"));
+ pResult->Add(new (std::nothrow) String(L"dev_name"), new (std::nothrow) String(pBuf));
+ }
+
+ pBuf = appsvc_get_data(pBundle, "http://tizen.org/appcontrol/data/bluetooth/rssi");
+ if (pBuf)
+ {
+ pResult->Remove(String(L"http://tizen.org/appcontrol/data/bluetooth/rssi"));
+ pResult->Add(new (std::nothrow) String(L"http://tizen.org/appcontrol/data/bluetooth/rssi"), new (std::nothrow) String(pBuf));
+ }
+
+ pBuf = appsvc_get_data(pBundle, "http://tizen.org/appcontrol/data/bluetooth/is_paired");
+ if (pBuf)
+ {
+ if (*pBuf == '1')
+ {
+ pBuf = "true";
+ }
+ else
+ {
+ pBuf = "false";
+ }
+ pResult->Remove(String(L"http://tizen.org/appcontrol/data/bluetooth/is_paired"));
+ pResult->Add(new (std::nothrow) String(L"http://tizen.org/appcontrol/data/bluetooth/is_paired"), new (std::nothrow) String(pBuf));
+ }
+
+ pBuf = appsvc_get_data(pBundle, "http://tizen.org/appcontrol/data/bluetooth/major_class");
+ if (pBuf)
+ {
+ Integer::Decode(String(pBuf), majClassType);
+ majClassType = (int)_BluetoothAdapterUtility::ConvertToMajorDeviceClassType((bt_major_device_class_e)majClassType);
+
+ pResult->Remove(String(L"http://tizen.org/appcontrol/data/bluetooth/major_class"));
+ pResult->Add(new (std::nothrow) String(L"http://tizen.org/appcontrol/data/bluetooth/major_class"), new (std::nothrow) String(Integer::ToString(majClassType)));
+ pResult->Remove(String(L"maj_cls_type"));
+ pResult->Add(new (std::nothrow) String(L"maj_cls_type"), new (std::nothrow) String(Integer::ToString(majClassType)));
+ }
+
+ pBuf = appsvc_get_data(pBundle, "http://tizen.org/appcontrol/data/bluetooth/minor_class");
+ if (pBuf)
+ {
+ Integer::Decode(String(pBuf), minClassType);
+ minClassType = (int)_BluetoothAdapterUtility::ConvertToMinorDeviceClassType((bt_major_device_class_e)majClassType, (bt_minor_device_class_e)minClassType);
+
+ pResult->Remove(String(L"http://tizen.org/appcontrol/data/bluetooth/minor_class"));
+ pResult->Add(new (std::nothrow) String(L"http://tizen.org/appcontrol/data/bluetooth/minor_class"), new (std::nothrow) String(Integer::ToString(minClassType)));
+ pResult->Remove(String(L"min_cls_type"));
+ pResult->Add(new (std::nothrow) String(L"min_cls_type"), new (std::nothrow) String(Integer::ToString(minClassType)));
+ }
+
+ pBuf = appsvc_get_data(pBundle, "http://tizen.org/appcontrol/data/bluetooth/service_class");
+ if (pBuf)
+ {
+ Integer::Decode(String(pBuf), svcClassType);
+ svcClassType = (int)_BluetoothAdapterUtility::ConvertToServiceClassList(svcClassType);
+
+ pResult->Remove(String(L"http://tizen.org/appcontrol/data/bluetooth/service_class"));
+ pResult->Add(new (std::nothrow) String(L"http://tizen.org/appcontrol/data/bluetooth/service_class"), new (std::nothrow) String(Integer::ToString(svcClassType)));
+ pResult->Remove(String(L"svc_cls_type"));
+ pResult->Add(new (std::nothrow) String(L"svc_cls_type"), new (std::nothrow) String(Integer::ToString(svcClassType)));
+ }
+
+ int len = 0;
+ char** ppArrayBuf = (char**)appsvc_get_data_array(pBundle, "http://tizen.org/appcontrol/data/bluetooth/uuid_list", &len);
+ ArrayList* pUuidList = null;
+
+ if (len > 0 && ppArrayBuf != null)
+ {
+ svcType = _BluetoothAdapterUtility::ConvertToServiceList(ppArrayBuf, len);
+ pUuidList = dynamic_cast<ArrayList*>(_BluetoothAdapterUtility::ConvertServiceUuidListN(ppArrayBuf, len));
+
+ pResult->Remove(String(L"http://tizen.org/appcontrol/data/bluetooth/service_type"));
+ pResult->Add(new (std::nothrow) String(L"http://tizen.org/appcontrol/data/bluetooth/service_type"), new (std::nothrow) String(Long::ToString(svcType)));
+ pResult->Remove(String(L"svc_type"));
+ pResult->Add(new (std::nothrow) String(L"svc_type"), new (std::nothrow) String(Long::ToString(svcType)));
+
+ pResult->Remove(String(L"http://tizen.org/appcontrol/data/bluetooth/uuid_list"));
+ pResult->Add(new (std::nothrow) String(L"http://tizen.org/appcontrol/data/bluetooth/uuid_list"), pUuidList);
+ }
+ }
+ break;
+ case SERVICE_RESULT_FAILED:
+ // fall through
+ case SERVICE_RESULT_CANCELED:
+ // fall through
+ default:
+ break;
+ }
+
+ _AppControlManager::GetInstance()->FinishAppControl(__req, result, pResult);
+
+CATCH:
+ __req = -1;
+}
+
+}
+
+
+extern "C" _OSP_EXPORT_ _IAppControlPluginProvider*
+GetAppControlProviderPlugin(void)
+{
+ return new (std::nothrow) _AppControlPlugin;
+}
+
--- /dev/null
+SET (this_target osp-ac-bluetooth)
+
+INCLUDE_DIRECTORIES (
+ ${COMMON_INCLUDE_DIRS}
+ ../../inc
+)
+
+SET (${this_target}_SOURCE_FILES
+ BluetoothAppControlDllEntry.cpp
+)
+
+## SET EXTRA COMPILER FLAGS
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fPIC -Wall" )
+
+## 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_LIBRARY (${this_target} SHARED ${${this_target}_SOURCE_FILES})
+
+TARGET_LINK_LIBRARIES(${this_target} -Xlinker --no-undefined -Xlinker)
+TARGET_LINK_LIBRARIES(${this_target} ${pkgs_LDFLAGS})
+TARGET_LINK_LIBRARIES(${this_target} -losp-bluetooth)
+TARGET_LINK_LIBRARIES(${this_target} osp-ac-util)
+
+OSP_STRIP(${this_target})
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file BrowserAppControlDllEntry.cpp
+ * @brief This is the implementation for the BrowserAppControlDllEntry.cpp.
+ */
+
+#include <FBaseSysLog.h>
+
+#include <FApp_AppControlManager.h>
+#include <FApp_AppMessageImpl.h>
+#include <FApp_IAppControlPluginProvider.h>
+
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+
+
+namespace
+{
+
+class _AppControlPlugin
+ : public _IAppControlPluginProvider
+ , virtual public Tizen::Base::Runtime::IEventListener
+{
+public:
+ _AppControlPlugin(void) {}
+
+ virtual ~_AppControlPlugin(void) {}
+
+ virtual result StartAppControlPlugin(int req, const AppId& appId, const _AppMessageImpl& message, int* pPid);
+
+ virtual result StopAppControlPlugin(int req) { return E_INVALID_OPERATION; }
+
+ virtual result Release(void) { delete this; return E_SUCCESS; }
+};
+
+
+result
+_AppControlPlugin::StartAppControlPlugin(int req, const AppId& appId, const _AppMessageImpl& message, int* pPid)
+{
+ SysLog(NID_APP, "StartAppControl: Entry to Browser AppControl");
+
+ _AppMessageImpl msg(message);
+
+ // force operation
+ msg.SetOperation(SERVICE_OPERATION_VIEW);
+
+ // compatibility
+ const String& uri = msg.GetUri();
+ if (uri.IsEmpty())
+ {
+ const String& extraUri = msg.GetValue(L"url");
+ if (!extraUri.IsEmpty())
+ {
+ msg.SetUri(extraUri);
+ }
+ }
+
+ int pid = _AppControlManager::GetInstance()->LaunchPkg(msg, NULL, 0);
+
+ result r = E_SUCCESS;
+ if (pid <= 0)
+ {
+ r = GetLastResult();
+ SysLog(NID_APP, "[%s] System error.", GetErrorMessage(r));
+ }
+ else
+ {
+ if (pPid)
+ {
+ *pPid = pid;
+ }
+ }
+
+ SysLog(NID_APP, "StartAppControl: Launching Browser AppControl succeeded");
+
+ return r;
+}
+
+}
+
+
+extern "C" _OSP_EXPORT_ _IAppControlPluginProvider*
+GetAppControlProviderPlugin(void)
+{
+ return new (std::nothrow) _AppControlPlugin;
+}
+
--- /dev/null
+SET (this_target osp-ac-browser)
+
+INCLUDE_DIRECTORIES (
+ ${COMMON_INCLUDE_DIRS}
+ )
+
+SET (${this_target}_SOURCE_FILES
+ BrowserAppControlDllEntry.cpp
+ )
+
+## SET EXTRA COMPILER FLAGS
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fPIC -Wall" )
+
+## 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_LIBRARY (${this_target} SHARED ${${this_target}_SOURCE_FILES})
+
+TARGET_LINK_LIBRARIES(${this_target} -Xlinker --no-undefined -Xlinker)
+TARGET_LINK_LIBRARIES(${this_target} ${pkgs_LDFLAGS})
+
+OSP_STRIP(${this_target})
--- /dev/null
+SET (this_target osp-ac-calendar)
+
+INCLUDE_DIRECTORIES (
+ ${COMMON_INCLUDE_DIRS}
+ ../../inc
+ )
+
+SET (${this_target}_SOURCE_FILES
+ CalendarAppControlDllEntry.cpp
+ )
+
+## SET EXTRA COMPILER FLAGS
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fPIC -Wall" )
+
+## 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_LIBRARY (${this_target} SHARED ${${this_target}_SOURCE_FILES})
+
+ADD_DEPENDENCIES(${this_target} osp-ac-util)
+
+TARGET_LINK_LIBRARIES(${this_target} -Xlinker --no-undefined -Xlinker)
+TARGET_LINK_LIBRARIES(${this_target} ${pkgs_LDFLAGS})
+TARGET_LINK_LIBRARIES(${this_target} osp-ac-util)
+
+OSP_STRIP(${this_target})
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file CalendarAppControlDllEntry.cpp
+ * @brief This is the implementation for the CalendarAppControlDllEntry.cpp.
+ */
+
+#include <unique_ptr.h>
+
+#include <FBaseSysLog.h>
+#include <FBaseColHashMap.h>
+
+#include <FBase_StringConverter.h>
+#include <FApp_AppControlManager.h>
+#include <FApp_AppMessageImpl.h>
+#include <FApp_Aul.h>
+#include <FApp_AppArg.h>
+#include <FApp_IAppControlPluginProvider.h>
+
+#include "FApp_AppControlPluginUtil.h"
+
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::System;
+
+
+namespace
+{
+
+static const wchar_t CALENDAR_ITEM_TYPE[] = L"http://tizen.org/appcontrol/data/social/item_type";
+static const wchar_t CALENDAR_RESULT_TYPE[] = L"http://tizen.org/appcontrol/data/social/result_type";
+static const wchar_t CALENDAR_ITEM_ID[] = L"http://tizen.org/appcontrol/data/social/item_id";
+static const wchar_t CALENDAR_SELECTION_MODE[] = L"http://tizen.org/appcontrol/data/selection_mode";
+
+class _AppControlPlugin
+ : public _IAppControlPluginProvider
+ , virtual public Tizen::Base::Runtime::IEventListener
+{
+public:
+ _AppControlPlugin(void) {}
+
+ virtual ~_AppControlPlugin(void) {}
+
+ virtual result StartAppControlPlugin(int req, const AppId& aId, const _AppMessageImpl& message, int* pPid);
+
+ virtual result StopAppControlPlugin(int req);
+
+ virtual result Release(void) { delete this; return E_SUCCESS; }
+
+ static void OnAppControlResult(void* b, int requestCode, service_result_e res, void* userData);
+
+private:
+ static int __req;
+ static int __processId;
+};
+
+
+int _AppControlPlugin::__req = -1;
+int _AppControlPlugin::__processId = -1;
+
+static const char __allowedAppControlPickTable[][2][96] =
+{
+ {"osp.appcontrol.CALENDAR", "osp.appcontrol.operation.PICK"},
+ {"osp.appcontrol.provider.calendar", "osp.appcontrol.operation.pick"},
+ {"tizen.calendar", "http://tizen.org/appcontrol/operation/pick"},
+ {"tizen.calendar", "http://tizen.org/appcontrol/operation/social/pick"},
+ {"tizen.todo", "http://tizen.org/appcontrol/operation/social/pick"},
+};
+
+static const char __allowedAppControlViewTable[][2][96] =
+{
+ {"osp.appcontrol.CALENDAR", "osp.appcontrol.operation.VIEW"},
+ {"osp.appcontrol.provider.calendar", "osp.appcontrol.operation.view"},
+ {"tizen.calendar", "http://tizen.org/appcontrol/operation/social/view"},
+ {"tizen.todo", "http://tizen.org/appcontrol/operation/social/view"},
+};
+
+static const char __allowedAppControlEditTable[][2][96] =
+{
+ {"tizen.calendar", "http://tizen.org/appcontrol/operation/social/edit"},
+};
+
+static const char __allowedAppControlVcsViewTable[][2][96] =
+{
+ {"tizen.calendar", "http://tizen.org/appcontrol/operation/view"},
+ {"tizen.todo", "http://tizen.org/appcontrol/operation/view"},
+};
+
+result
+_AppControlPlugin::StartAppControlPlugin(int req, const AppId& aId, const _AppMessageImpl& message, int* pPid)
+{
+ SysLog(NID_APP, "StartAppControl: Entry to Calendar AppControl");
+
+ result r = E_SUCCESS;
+ bool hasOutput = false;
+
+ const String& oId = message.GetOperation();
+
+ const bool isCalendarVcsView = _AppControlPluginUtil::IsAllowedAppControl(__allowedAppControlVcsViewTable, 2, aId, oId);
+ const bool isCalendarView = _AppControlPluginUtil::IsAllowedAppControl(__allowedAppControlViewTable, 4, aId, oId);
+ const bool isCalendarPick = _AppControlPluginUtil::IsAllowedAppControl(__allowedAppControlPickTable, 5, aId, oId);
+ const bool isCalendarEdit = _AppControlPluginUtil::IsAllowedAppControl(__allowedAppControlEditTable, 1, aId, oId);
+
+ SysTryReturnResult(NID_APP, isCalendarPick || isCalendarEdit || isCalendarView || isCalendarVcsView, E_SYSTEM, "Invalid AppControl entry for (%ls, %ls).", aId.GetPointer(), oId.GetPointer());
+
+ _AppMessageImpl msg(message);
+
+ AppSvcResFn pCb = NULL;
+
+ String providerAppId;
+ String operation;
+ String uri = msg.GetUri();
+
+ if (isCalendarPick)
+ {
+ SysLog(NID_APP, "Calendar AppControl : PICK operation.");
+
+ hasOutput = true;
+
+#if 0
+ const String* pItemTypeValue = static_cast<const String*>(pMap->GetValue(String(L"itemType")));
+ if (pItemTypeValue == null || (*pItemTypeValue != L"event" && *pItemTypeValue != L"todo"))
+ {
+ SysLog(NID_APP, "itemType is invalid.");
+ r = E_SUCCESS;
+ goto CATCH;
+ }
+ const String* pSelectionModeValue = static_cast<const String*>(pMap->GetValue(String(L"selectionMode")));
+ if (pSelectionModeValue == null || (*pSelectionModeValue != L"single" && *pSelectionModeValue != L"multiple"))
+ {
+ SysLog(NID_APP, "selectionMode is invalid.");
+ r = E_SUCCESS;
+ goto CATCH;
+ }
+#endif
+
+ pCb = _AppControlPlugin::OnAppControlResult;
+ providerAppId = L"tizen.calendar_list";
+ operation = L"http://tizen.org/appcontrol/operation/social/pick";
+
+ const String& tmpItemType = msg.GetValue(L"itemType");
+ if (!tmpItemType.IsEmpty())
+ {
+ msg.AddData(CALENDAR_ITEM_TYPE, tmpItemType);
+ }
+ else if (aId == L"tizen.todo")
+ {
+ msg.AddData(CALENDAR_ITEM_TYPE, L"todo");
+ }
+ else
+ {
+ msg.AddData(CALENDAR_ITEM_TYPE, L"event");
+ }
+
+ const String& tmpSelMode = msg.GetValue(L"selectionMode");
+ if (!tmpSelMode.IsEmpty())
+ {
+ msg.AddData(CALENDAR_SELECTION_MODE, tmpSelMode);
+ }
+
+ const String& tmpResultType = msg.GetValue(CALENDAR_RESULT_TYPE);
+ if (tmpResultType.IsEmpty())
+ {
+ msg.AddData(CALENDAR_RESULT_TYPE, L"vcs");
+ }
+
+ }
+ else if (isCalendarEdit)
+ {
+ SysLog(NID_APP, "Calendar AppControl : EDIT operation.");
+
+ hasOutput = true;
+ pCb = _AppControlPlugin::OnAppControlResult;
+ providerAppId = L"tizen.calendar_edit";
+ operation = L"http://tizen.org/appcontrol/operation/social/edit";
+
+ msg.AddData(CALENDAR_ITEM_TYPE, L"event");
+ }
+ else if (isCalendarVcsView || isCalendarView)
+ {
+ if (uri.IsEmpty())
+ {
+ uri = msg.GetValue(L"path");
+ if (!uri.IsEmpty())
+ {
+ msg.SetUri(uri);
+ }
+ }
+
+ providerAppId = L"tizen.calendar_detail";
+
+ if (!uri.IsEmpty())
+ {
+ SysLog(NID_APP, "Calendar AppControl : VIEW operation (vcs).");
+ operation = L"http://tizen.org/appcontrol/operation/view";
+ }
+ else
+ {
+ SysLog(NID_APP, "Calendar AppControl : VIEW operation.");
+
+ operation = L"http://tizen.org/appcontrol/operation/social/view";
+
+ const String& tmpItemType = msg.GetValue(L"viewType");
+ if (!tmpItemType.IsEmpty())
+ {
+ msg.AddData(CALENDAR_ITEM_TYPE, tmpItemType);
+ }
+ else if (aId == L"tizen.todo")
+ {
+ msg.AddData(CALENDAR_ITEM_TYPE, L"todo");
+ }
+ else
+ {
+ msg.AddData(CALENDAR_ITEM_TYPE, L"event");
+ }
+
+ const String& tmpEventId = msg.GetValue(L"eventId");
+ const String& tmpTodoId = msg.GetValue(L"todoId");
+ if (!tmpEventId.IsEmpty())
+ {
+ msg.AddData(CALENDAR_ITEM_ID, tmpEventId);
+ }
+ else if (!tmpTodoId.IsEmpty())
+ {
+ msg.AddData(CALENDAR_ITEM_ID, tmpTodoId);
+ }
+ }
+ }
+
+ msg.SetApplicationId(providerAppId);
+ msg.SetOperation(operation);
+
+ const int pid = _AppControlManager::GetInstance()->Launch(msg, pCb, 0);
+
+ r = GetLastResult();
+ SysTryReturnResult(NID_APP, pid >= 0, r, "StartAppControl: Launching Calendar AppControl is failed.");
+
+ __req = req;
+ __processId = pid;
+
+ if (pPid)
+ {
+ *pPid = pid;
+ }
+
+ SysLog(NID_APP, "StartAppControl: Launching Calendar AppControl succeeded");
+
+ return E_SUCCESS;
+}
+
+result
+_AppControlPlugin::StopAppControlPlugin(int req)
+{
+ if (__processId >= 0)
+ {
+ result r = _AppControlPluginUtil::SendStopRequest(__processId);
+ SysTryReturnResult(NID_APP, !IsFailed(r), r, "Failed to send stop request to %d.", __processId);
+
+ SysLog(NID_APP, "Process %d is terminated.", __processId);
+ __processId = -1;
+ }
+
+ return E_SUCCESS;
+}
+
+
+void
+_AppControlPlugin::OnAppControlResult(void* b, int requestCode, service_result_e res, void* userData)
+{
+ SysLog(NID_APP, "Received request %d.", requestCode);
+
+ result r = E_SYSTEM;
+ bundle* pBundle = static_cast<bundle*>(b);
+
+ HashMap* pResult = new (std::nothrow) HashMap();
+ SysTryCatch(NID_APP, pResult != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Allocation failure.");
+
+ r = pResult->Construct();
+
+ _AppArg::SetArgMap(pBundle, pResult);
+
+ _AppControlManager::GetInstance()->FinishAppControl(__req, res, pResult);
+
+CATCH:
+ __req = -1;
+}
+
+}
+
+extern "C" _OSP_EXPORT_ _IAppControlPluginProvider*
+GetAppControlProviderPlugin(void)
+{
+ return new (std::nothrow) _AppControlPlugin;
+}
+
--- /dev/null
+SET (this_target osp-ac-call)
+
+INCLUDE_DIRECTORIES (
+ ${COMMON_INCLUDE_DIRS}
+ )
+
+SET (${this_target}_SOURCE_FILES
+ PhoneAppControlDllEntry.cpp
+ )
+
+## SET EXTRA COMPILER FLAGS
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fPIC -Wall" )
+
+## 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_LIBRARY (${this_target} SHARED ${${this_target}_SOURCE_FILES})
+
+TARGET_LINK_LIBRARIES(${this_target} -Xlinker --no-undefined -Xlinker)
+TARGET_LINK_LIBRARIES(${this_target} ${pkgs_LDFLAGS})
+
+OSP_STRIP(${this_target})
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file AppControlDllEntry.cpp
+ * @brief This is the implementation for the AppControlDllEntry.cpp class.
+ */
+
+#include <FBaseSysLog.h>
+#include <FBaseColHashMap.h>
+
+#include <FApp_AppControlManager.h>
+#include <FApp_AppMessageImpl.h>
+#include <FApp_AppArg.h>
+#include <FApp_IAppControlPluginProvider.h>
+
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+
+namespace
+{
+
+static const wchar_t OPERATION_CONFIGURE[] = L"http://tizen.org/appcontrol/operation/configure";
+
+class _AppControlPlugin
+ : public _IAppControlPluginProvider
+ , virtual public Tizen::Base::Runtime::IEventListener
+{
+public:
+ _AppControlPlugin(void) {}
+
+ virtual ~_AppControlPlugin(void) {}
+
+ virtual result StartAppControlPlugin(int req, const AppId& appId, const _AppMessageImpl& message, int* pPid);
+
+ virtual result StopAppControlPlugin(int req) { return E_INVALID_OPERATION; }
+
+ virtual result Release(void) { delete this; return E_SUCCESS; }
+
+ static void OnAppControlResult(void* b, int requestCode, service_result_e res, void* userData);
+
+private:
+ static int __req;
+};
+
+
+int _AppControlPlugin::__req = -1;
+
+result
+_AppControlPlugin::StartAppControlPlugin(int req, const AppId& appId, const _AppMessageImpl& message, int* pPid)
+{
+ SysLog(NID_APP, "StartAppControl: Entry to Call AppControl");
+
+ _AppMessageImpl msg(message);
+
+ // compatibility
+ const String& uri = _AppMessageImpl::GetUri(msg.GetBundle());
+ if (uri.IsEmpty())
+ {
+ // if there is not pUri, then search for "tel" key.
+ String data = msg.GetValue(L"tel");
+ if (!data.IsEmpty())
+ {
+ data.Insert(L"tel:", 0);
+ _AppMessageImpl::SetUri(msg.GetBundle(), data);
+ }
+
+ data = msg.GetValue(L"type");
+ if (!data.IsEmpty())
+ {
+ msg.AddData(L"http://tizen.org/appcontrol/data/call/type", data);
+ msg.RemoveData(L"type");
+ }
+ }
+
+ __req = req;
+ int pid = -1;
+
+ const String& operationId = _AppMessageImpl::GetOperation(msg.GetBundle());
+
+ if (operationId == OPERATION_CONFIGURE)
+ {
+ pid = _AppControlManager::GetInstance()->Launch(msg, _AppControlPlugin::OnAppControlResult, 0);
+ }
+ else
+ {
+ pid = _AppControlManager::GetInstance()->LaunchPkg(msg, _AppControlPlugin::OnAppControlResult, 0);
+ }
+
+ result r = E_SUCCESS;
+ if (pid <= 0)
+ {
+ r = GetLastResult();
+ SysLog(NID_APP, "[%s] System error.", GetErrorMessage(r));
+ }
+ else
+ {
+ if (pPid)
+ {
+ *pPid = pid;
+ }
+ }
+
+ SysLog(NID_APP, "StartAppControl: Launching Call AppControl succeeded");
+
+ return r;
+
+}
+
+
+void
+_AppControlPlugin::OnAppControlResult(void* b, int requestCode, service_result_e res, void* userData)
+{
+ SysLog(NID_APP, "Received request %d.", requestCode);
+
+ result r = E_SYSTEM;
+ bundle* pBundle = static_cast<bundle*>(b);
+
+ HashMap* pResult = new (std::nothrow) HashMap();
+ SysTryCatch(NID_APP, pResult != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Allocation failure.");
+
+ r = pResult->Construct();
+
+ _AppArg::SetArgMap(pBundle, pResult);
+
+ _AppControlManager::GetInstance()->FinishAppControl(__req, res, pResult);
+
+CATCH:
+ __req = -1;
+}
+
+}
+
+
+extern "C" _OSP_EXPORT_ _IAppControlPluginProvider*
+GetAppControlProviderPlugin(void)
+{
+ return new (std::nothrow) _AppControlPlugin;
+}
+
--- /dev/null
+SET (this_target osp-ac-camera)
+
+INCLUDE_DIRECTORIES (
+ ${COMMON_INCLUDE_DIRS}
+ ../../inc
+)
+
+SET (${this_target}_SOURCE_FILES
+ CameraAppControlDllEntry.cpp
+)
+
+## SET EXTRA COMPILER FLAGS
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fPIC -Wall" )
+
+## 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_LIBRARY (${this_target} SHARED ${${this_target}_SOURCE_FILES})
+
+TARGET_LINK_LIBRARIES(${this_target} -Xlinker --no-undefined -Xlinker)
+TARGET_LINK_LIBRARIES(${this_target} ${pkgs_LDFLAGS})
+TARGET_LINK_LIBRARIES(${this_target} osp-ac-util)
+
+OSP_STRIP(${this_target})
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file CameraAppControlDllEntry.cpp
+ * @brief This is the implementation for the CameraAppControlDllEntry.cpp class.
+ */
+
+#include <bundle.h>
+#include <appsvc/appsvc.h>
+
+#include <FBaseSysLog.h>
+#include <FBaseColHashMap.h>
+
+#include <FApp_AppControlManager.h>
+#include <FApp_AppMessageImpl.h>
+#include <FApp_Aul.h>
+#include <FApp_AppArg.h>
+#include <FApp_AppMessageImpl.h>
+#include <FApp_IAppControlPluginProvider.h>
+
+#include "FApp_AppControlPluginUtil.h"
+
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+
+namespace
+{
+
+class _AppControlPlugin
+ : public _IAppControlPluginProvider
+ , virtual public Tizen::Base::Runtime::IEventListener
+{
+public:
+ _AppControlPlugin(void) {}
+
+ virtual ~_AppControlPlugin(void) {}
+
+ virtual result StartAppControlPlugin(int req, const AppId& appId, const _AppMessageImpl& message, int* pPid);
+
+ virtual result StopAppControlPlugin(int req);
+
+ virtual result Release(void) { delete this; return E_SUCCESS; }
+
+ static void OnAppControlResult(void* b, int requestCode, service_result_e res, void* userData);
+
+private:
+ static int __req;
+ static int __processId;
+};
+
+int _AppControlPlugin::__req = -1;
+int _AppControlPlugin::__processId = -1;
+
+
+result
+_AppControlPlugin::StartAppControlPlugin(int req, const AppId& aId, const _AppMessageImpl& message, int* pPid)
+{
+ result r = E_SYSTEM;
+ SysLog(NID_APP, "StartAppControl: Entry to Camera AppControl");
+
+ if (aId == "osp.appcontrol.CAMERA"
+ || aId == "osp.appcontrol.provider.camera"
+ || aId == "tizen.camera")
+ {
+ _AppMessageImpl msg(message);
+
+ String mime = message.GetMime();
+ if (mime.IsEmpty())
+ {
+ const String& str = msg.GetValue(L"type");
+ if (str == L"camcorder")
+ {
+ mime = L"video/3gpp";
+ }
+ else
+ {
+ mime = L"image/jpeg";
+ }
+
+ msg.RemoveData(L"type");
+ msg.SetMime(mime);
+ }
+
+ msg.SetOperation(APPSVC_OPERATION_CREATE_CONTENT);
+
+ __req = req;
+ __processId = _AppControlManager::GetInstance()->Launch(msg, OnAppControlResult, 0);
+
+ r = GetLastResult();
+ SysTryReturnResult(NID_APP, __processId >= 0, r, "StartAppControl: Launching Camera AppControl is failed.");
+
+ if (pPid)
+ {
+ *pPid = __processId;
+ }
+
+ r = E_SUCCESS;
+ SysLog(NID_APP, "StartAppControl: Launching Camera AppControl succeeded");
+ }
+
+ return r;
+}
+
+
+result
+_AppControlPlugin::StopAppControlPlugin(int req)
+{
+ if (__processId >= 0)
+ {
+ _AppControlPluginUtil::SendStopRequest(__processId);
+ SysLog(NID_APP, "Process %d is terminated.", __processId);
+ __processId = -1;
+ }
+
+ return E_SUCCESS;
+}
+
+
+void
+_AppControlPlugin::OnAppControlResult(void* b, int requestCode, service_result_e res, void* userData)
+{
+ SysLog(NID_APP, "Camera AppControl result");
+
+ result r = E_SYSTEM;
+ int type = BUNDLE_TYPE_NONE;
+ bundle* pBundle = static_cast<bundle*>(b);
+
+ HashMap* pResult = new (std::nothrow) HashMap();
+ SysTryCatch(NID_APP, pResult != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Allocation failure.");
+
+ r = pResult->Construct();
+
+ _AppArg::SetArgMap(pBundle, pResult);
+
+ type = bundle_get_type(pBundle, SERVICE_DATA_SELECTED);
+ switch (type)
+ {
+ case BUNDLE_TYPE_STR:
+ {
+ const char* pFile = appsvc_get_data(pBundle, SERVICE_DATA_SELECTED);
+ if (pFile)
+ {
+ pResult->Add(new (std::nothrow) String(L"path"), new (std::nothrow) String(pFile));
+ }
+ }
+ break;
+ case BUNDLE_TYPE_STR_ARRAY:
+ {
+ ArrayList* pArray = _AppMessageImpl::GetValueArrayN(pBundle, SERVICE_DATA_SELECTED);
+ if (pArray)
+ {
+ const int count = pArray->GetCount();
+ if (count > 0)
+ {
+ String tmp;
+
+ tmp = * static_cast<String*>(pArray->GetAt(0));
+ for (int i = 1; i < count; i++)
+ {
+ tmp.Append(L';');
+ tmp.Append(* static_cast<String*>(pArray->GetAt(i)));
+ }
+
+ pResult->Add(new (std::nothrow) String(L"path"), new (std::nothrow) String(tmp));
+ }
+ }
+ }
+ break;
+ case BUNDLE_TYPE_NONE:
+ default:
+ break;
+ }
+
+ _AppControlManager::GetInstance()->FinishAppControl(__req, res, pResult);
+
+CATCH:
+ __req = -1;
+}
+
+}
+
+extern "C" _OSP_EXPORT_ _IAppControlPluginProvider*
+GetAppControlProviderPlugin(void)
+{
+ return new (std::nothrow) _AppControlPlugin;
+}
+
--- /dev/null
+SET (this_target osp-ac-contact)
+
+INCLUDE_DIRECTORIES (
+ ${COMMON_INCLUDE_DIRS}
+ /usr/include/contacts-svc
+ ../../inc
+ )
+
+SET (${this_target}_SOURCE_FILES
+ ContactAppControlDllEntry.cpp
+ )
+
+## SET EXTRA COMPILER FLAGS
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fPIC -Wall" )
+
+## 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_LIBRARY (${this_target} SHARED ${${this_target}_SOURCE_FILES})
+
+ADD_DEPENDENCIES(${this_target} osp-ac-util)
+
+TARGET_LINK_LIBRARIES(${this_target} -Xlinker --no-undefined -Xlinker)
+TARGET_LINK_LIBRARIES(${this_target} ${pkgs_LDFLAGS})
+TARGET_LINK_LIBRARIES(${this_target} "-lcontacts-service2")
+TARGET_LINK_LIBRARIES(${this_target} osp-ac-util)
+
+OSP_STRIP(${this_target})
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file ContactAppControlDllEntry.cpp
+ * @brief This is the implementation for the ContactAppControlDllEntry.cpp.
+ */
+
+#include <unique_ptr.h>
+#include <appsvc/appsvc.h>
+#include <contacts.h>
+
+#include <FBaseSysLog.h>
+#include <FBaseInteger.h>
+#include <FBaseColHashMap.h>
+#include <FBaseColAllElementsDeleter.h>
+
+#include <FApp_AppControlManager.h>
+#include <FApp_AppMessageImpl.h>
+#include <FApp_Aul.h>
+#include <FApp_AppArg.h>
+#include <FApp_IAppControlPluginProvider.h>
+
+#include "FApp_AppControlPluginUtil.h"
+
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Social;
+
+
+namespace
+{
+
+//static char PICK_OP_SEL_MODE_KEY[] = "selectionMode";
+static char PICK_OP_RET_KEY_RET_TYPE[] = "returnType";
+static char PICK_OP_RET_KEY_VALUE[] = "value";
+
+static char EDIT_OP_KEY_CONTACT_ID[] = "contactId";
+//static char EDIT_OP_KEY_PHONE[] = "phone";
+//static char EDIT_OP_KEY_EMAIL[] = "email";
+//static char EDIT_OP_KEY_URL[] = "url";
+
+//static char VIEW_OP_KEY_VIEW_TYPE[] = "viewType";
+//static char VIEW_OP_KEY_VCARD_PATH[] = "path";
+//static char VIEW_OP_KEY_CONTACT_ID[] = "contactId";
+
+//static char VIEW_OP_VALUE_CONTACT[] = "contact";
+//static char VIEW_OP_VALUE_VCARD[] = "vcf";
+//static int VIEW_OP_VALUE_LENGTH_MAX = 7;
+
+//static char PICK_OP_SEL_MODE_VALUE_SINGLE[] = "single";
+//static char PICK_OP_SEL_MODE_VALUE_MULTIPLE[] = "multiple";
+
+static char PICK_OP_RET_VALUE_PHONE[] = "phone";
+static char PICK_OP_RET_VALUE_EMAIL[] = "email";
+static char PICK_OP_RET_VALUE_VCARD[] = "vcard";
+static char PICK_OP_RET_VALUE_CONTACT_ID[] = "contactId";
+
+//static int PICK_OP_SEL_MODE_VALUE_LENGTH_MAX = 8;
+//static int PICK_OP_RET_VALUE_LENGTH_MAX = 10;
+
+//static char ADD_OP_KEY_NUMBER[] = "phone";
+//static char ADD_OP_KEY_EMAIL[] = "email";
+//static char ADD_OP_KEY_URL[] = "url";
+
+
+//static char CORE_OP_KEY_TYPE[] = "type";
+//static char CORE_OP_KEY_PERSON_ID[] = "ct_person_id";
+//static char CORE_OP_KEY_NUMBER[] = "ct_num";
+//static char CORE_OP_KEY_EMAIL[] = "ct_email";
+//static char CORE_OP_KEY_URL[] = "ct_web";
+//static char CORE_OP_KEY_VCARD[] = "ct_vcard";
+
+//static char CORE_OP_VALUE_EDIT_PERSON[] = "11";
+//static char CORE_OP_VALUE_EDIT_PERSON_BY_SEL[] = "20";
+
+//static char CORE_OP_VALUE_VIEW_PERSON[] = "0";
+
+// PICK
+//static char CORE_OP_VALUE_PICK_PERSON_ID[] = "11";
+//static char CORE_OP_VALUE_PICK_NUMBER[] = "12";
+//static char CORE_OP_VALUE_PICK_EMAIL[] = "13";
+//static char CORE_OP_VALUE_PICK_VCARD[] = "14";
+//static char CORE_OP_VALUE_PICK_PERSON_ID_LIST[] = "31";
+//static char CORE_OP_VALUE_PICK_NUMBER_LIST[] = "32";
+//static char CORE_OP_VALUE_PICK_EMAIL_LIST[] = "33";
+
+//static char CORE_OP_VALUE_ADD_CONTACT[] = "21";
+
+//static char CORE_RESULT_TYPE_KEY_NUMBER[] = "num_id";
+//static char CORE_RESULT_TYPE_KEY_NUMBER_LIST[] = "num_id_list";
+//static char CORE_RESULT_TYPE_KEY_EMAIL[] = "email_id";
+//static char CORE_RESULT_TYPE_KEY_EMAIL_LIST[] = "email_id_list";
+//static char CORE_RESULT_TYPE_KEY_PERSON[] = "person_id";
+//static char CORE_RESULT_TYPE_KEY_PERSON_LIST[] = "person_id_list";
+//static char CORE_RESULT_TYPE_KEY_VCARD[] = "vcard";
+
+static const wchar_t CONTACT_ITEM_TYPE[] = L"http://tizen.org/appcontrol/data/social/item_type";
+static const wchar_t CONTACT_ITEM_ID[] = L"http://tizen.org/appcontrol/data/social/item_id";
+static const wchar_t CONTACT_RESULT_TYPE[] = L"http://tizen.org/appcontrol/data/social/result_type";
+static const wchar_t SELECTION_MODE[] = L"http://tizen.org/appcontrol/data/selection_mode";
+
+
+class _AppControlPlugin
+ : public _IAppControlPluginProvider
+ , virtual public Tizen::Base::Runtime::IEventListener
+{
+public:
+ _AppControlPlugin(void) {}
+
+ virtual ~_AppControlPlugin(void) {}
+
+ virtual result StartAppControlPlugin(int req, const AppId& appId, const _AppMessageImpl& message, int* pPid);
+
+ virtual result StopAppControlPlugin(int req);
+
+ virtual result Release(void) { delete this; return E_SUCCESS; }
+
+ static void OnAppControlResult(void* b, int requestCode, service_result_e res, void* userData);
+
+ static void OnAppControlResultLegacy(void* b, int requestCode, service_result_e res, void* userData);
+
+private:
+ static int __req;
+ static int __processId;
+};
+
+
+int _AppControlPlugin::__req = -1;
+int _AppControlPlugin::__processId = -1;
+
+static const char __allowedAppControlLegacyPickTable[][2][96] =
+{
+ {"osp.appcontrol.CONTACT", "osp.appcontrol.operation.PICK"},
+ {"osp.appcontrol.provider.contact", "osp.appcontrol.operation.pick"},
+ {"tizen.contacts", "http://tizen.org/appcontrol/operation/pick"},
+};
+
+
+static const char __allowedAppControlPickTable[][2][96] =
+{
+ {"tizen.contacts", "http://tizen.org/appcontrol/operation/social/pick"},
+};
+
+static const char __allowedAppControlLegacyAddTable[][2][96] =
+{
+ {"osp.appcontrol.CONTACT", "osp.appcontrol.operation.ADD"},
+ {"osp.appcontrol.provider.contact", "osp.appcontrol.operation.add"},
+ {"tizen.contacts", "http://tizen.org/appcontrol/operation/add"},
+};
+
+
+static const char __allowedAppControlAddTable[][2][96] =
+{
+ {"tizen.contacts", "http://tizen.org/appcontrol/operation/social/add"},
+};
+
+static const char __allowedAppControlLegacyEditTable[][2][96] =
+{
+ {"osp.appcontrol.CONTACT", "osp.appcontrol.operation.EDIT"},
+ {"osp.appcontrol.provider.contact", "osp.appcontrol.operation.edit"},
+ {"tizen.contacts", "http://tizen.org/appcontrol/operation/edit"},
+};
+
+
+static const char __allowedAppControlEditTable[][2][96] =
+{
+ {"tizen.contacts", "http://tizen.org/appcontrol/operation/social/edit"},
+};
+
+static const char __allowedAppControlLegacyViewTable[][2][96] =
+{
+ {"osp.appcontrol.CONTACT", "osp.appcontrol.operation.VIEW"},
+ {"osp.appcontrol.provider.contact", "osp.appcontrol.operation.view"},
+ {"tizen.contacts", "http://tizen.org/appcontrol/operation/view"},
+};
+
+
+static const char __allowedAppControlViewTable[][2][96] =
+{
+ {"tizen.contacts", "http://tizen.org/appcontrol/operation/social/view"},
+};
+
+static const char __allowedAppControlChooseTable[][2][96] =
+{
+ {"tizen.contacts", "http://tizen.org/appcontrol/operation/social/choose"},
+};
+
+
+class ScopedConnection
+{
+public:
+ ScopedConnection(void)
+ : __connected(false)
+ {
+ int ret = contacts_connect2();
+ if (ret == CONTACTS_ERROR_NONE)
+ {
+ __connected = true;
+ }
+ }
+
+ ~ScopedConnection(void)
+ {
+ if (__connected)
+ {
+ contacts_disconnect2();
+ }
+ }
+
+ bool IsConnected(void) const
+ {
+ return __connected;
+ }
+
+private:
+ bool __connected;
+};
+
+
+class ScopedHandle
+{
+public:
+ ScopedHandle(contacts_record_h handle)
+ : __handle(handle)
+ {
+ }
+
+ ~ScopedHandle(void)
+ {
+ if (__handle != null)
+ {
+ contacts_record_destroy(__handle, true);
+ }
+ }
+
+ contacts_record_h Get(void)
+ {
+ return __handle;
+ }
+
+ contacts_record_h Release(void)
+ {
+ contacts_record_h handle = __handle;
+ __handle = null;
+
+ return handle;
+ }
+
+private:
+ contacts_record_h __handle;
+};
+
+class ScopedList
+{
+public:
+ ScopedList(contacts_list_h handle)
+ : __handle(handle)
+ {
+ }
+
+ ~ScopedList(void)
+ {
+ if (__handle != null)
+ {
+ contacts_list_destroy(__handle, true);
+ }
+ }
+
+ contacts_list_h Get(void)
+ {
+ return __handle;
+ }
+
+private:
+ contacts_list_h __handle;
+};
+
+class ScopedFilter
+{
+public:
+ ScopedFilter(contacts_filter_h filter)
+ : __filter(filter)
+ {
+ }
+
+ ~ScopedFilter(void)
+ {
+ if (__filter != null)
+ {
+ contacts_filter_destroy(__filter);
+ }
+ }
+
+ contacts_filter_h Get(void)
+ {
+ return __filter;
+ }
+
+private:
+ contacts_filter_h __filter;
+};
+
+class ScopedQuery
+{
+public:
+ ScopedQuery(contacts_query_h query)
+ : __query(query)
+ {
+ }
+
+ ~ScopedQuery(void)
+ {
+ if (__query != null)
+ {
+ contacts_query_destroy(__query);
+ }
+ }
+
+ contacts_query_h Get(void)
+ {
+ return __query;
+ }
+
+private:
+ contacts_query_h __query;
+};
+
+
+result
+_AppControlPlugin::StartAppControlPlugin(int req, const AppId& aId, const _AppMessageImpl& message, int* pPid)
+{
+ SysLog(NID_APP, "StartAppControl: Entry to Contact AppControl");
+
+ result r = E_SUCCESS;
+
+ const String& oId = message.GetOperation();
+
+ const bool isLegacyContactPick = _AppControlPluginUtil::IsAllowedAppControl(__allowedAppControlLegacyPickTable, 3, aId, oId);
+ const bool isContactPick = _AppControlPluginUtil::IsAllowedAppControl(__allowedAppControlPickTable, 1, aId, oId);
+ const bool isLegacyContactAdd = _AppControlPluginUtil::IsAllowedAppControl(__allowedAppControlLegacyAddTable, 3, aId, oId);
+ const bool isContactAdd = _AppControlPluginUtil::IsAllowedAppControl(__allowedAppControlAddTable, 1, aId, oId);
+ const bool isLegacyContactEdit = _AppControlPluginUtil::IsAllowedAppControl(__allowedAppControlLegacyEditTable, 3, aId, oId);
+ const bool isContactEdit = _AppControlPluginUtil::IsAllowedAppControl(__allowedAppControlEditTable, 1, aId, oId);
+ const bool isLegacyContactView = _AppControlPluginUtil::IsAllowedAppControl(__allowedAppControlLegacyViewTable, 3, aId, oId);
+ const bool isContactView = _AppControlPluginUtil::IsAllowedAppControl(__allowedAppControlViewTable, 1, aId, oId);
+ const bool isContactChoose = _AppControlPluginUtil::IsAllowedAppControl(__allowedAppControlChooseTable, 1, aId, oId);
+
+ SysTryReturnResult(NID_APP, isLegacyContactPick || isContactPick || isLegacyContactAdd || isContactAdd || isLegacyContactEdit || isContactEdit || isLegacyContactView || isContactView || isContactChoose, E_SYSTEM, "Invalid AppControl entry for (%ls, %ls).", aId.GetPointer(), oId.GetPointer());
+
+ _AppMessageImpl msg(message);
+
+ AppSvcResFn pCb = NULL;
+
+ String providerAppId;
+ String operation;
+ String uri = msg.GetUri();
+ const char* pBuf = null;
+
+ if (isContactAdd || isLegacyContactAdd)
+ {
+ providerAppId = L"tizen.contact_detail";
+ operation = L"http://tizen.org/appcontrol/operation/social/add";
+
+ if (isLegacyContactAdd)
+ {
+ msg.AddData(CONTACT_ITEM_TYPE, L"contact");
+
+ pBuf = appsvc_get_data(msg.GetBundle(), "phone");
+ if (pBuf != null)
+ {
+ msg.AddData(L"http://tizen.org/appcontrol/data/social/phone", String(pBuf));
+ }
+
+ pBuf = appsvc_get_data(msg.GetBundle(), "email");
+ if (pBuf != null)
+ {
+ msg.AddData(L"http://tizen.org/appcontrol/data/social/email", String(pBuf));
+ }
+
+ pBuf = appsvc_get_data(msg.GetBundle(), "url");
+ if (pBuf != null)
+ {
+ msg.AddData(L"http://tizen.org/appcontrol/data/social/url", String(pBuf));
+ }
+ }
+ else
+ {
+ pCb = _AppControlPlugin::OnAppControlResult;
+ }
+ }
+ else if (isContactEdit || isLegacyContactEdit)
+ {
+ providerAppId = L"tizen.contact_detail";
+
+ if (isLegacyContactEdit)
+ {
+ msg.AddData(CONTACT_ITEM_TYPE, L"person");
+
+ pBuf = appsvc_get_data(msg.GetBundle(), EDIT_OP_KEY_CONTACT_ID);
+ if (pBuf != null)
+ {
+ operation = L"http://tizen.org/appcontrol/operation/social/edit";
+
+ int contactId = atoi(pBuf);
+ int personId = -1;
+
+ ScopedConnection conn;
+ if (conn.IsConnected())
+ {
+ contacts_record_h contactHandle = null;
+ int ret = contacts_db_get_record(_contacts_simple_contact._uri, contactId, &contactHandle);
+ if (ret == CONTACTS_ERROR_NONE)
+ {
+ contacts_record_get_int(contactHandle, _contacts_simple_contact.person_id, &personId);
+ contacts_record_destroy(contactHandle, true);
+ }
+ }
+
+ msg.AddData(L"http://tizen.org/appcontrol/data/social/item_id", Integer::ToString(personId));
+ }
+ else
+ {
+ operation = L"http://tizen.org/appcontrol/operation/social/choose";
+ }
+
+ pBuf = appsvc_get_data(msg.GetBundle(), "phone");
+ if (pBuf != null)
+ {
+ msg.AddData(L"http://tizen.org/appcontrol/data/social/phone", String(pBuf));
+ }
+
+ pBuf = appsvc_get_data(msg.GetBundle(), "email");
+ if (pBuf != null)
+ {
+ msg.AddData(L"http://tizen.org/appcontrol/data/social/email", String(pBuf));
+ }
+
+ pBuf = appsvc_get_data(msg.GetBundle(), "url");
+ if (pBuf != null)
+ {
+ msg.AddData(L"http://tizen.org/appcontrol/data/social/url", String(pBuf));
+ }
+ }
+ else
+ {
+ operation = L"http://tizen.org/appcontrol/operation/social/edit";
+ }
+ }
+ else if (isContactView || isLegacyContactView)
+ {
+ if (uri.IsEmpty())
+ {
+ uri = msg.GetValue(L"path");
+ if (!uri.IsEmpty())
+ {
+ msg.SetUri(uri);
+ }
+ }
+
+ if (!uri.IsEmpty())
+ {
+ providerAppId = L"tizen.contact_viewer";
+ operation = L"http://tizen.org/appcontrol/operation/view";
+ }
+ else
+ {
+ providerAppId = L"tizen.contact_detail";
+ operation = L"http://tizen.org/appcontrol/operation/social/view";
+ msg.AddData(CONTACT_ITEM_TYPE, L"person");
+
+ pBuf = appsvc_get_data(msg.GetBundle(), "contactId");
+ if (pBuf != null)
+ {
+ int contactId = atoi(pBuf);
+ int personId = -1;
+
+ ScopedConnection conn;
+ if (conn.IsConnected())
+ {
+ contacts_record_h contactHandle = null;
+ int ret = contacts_db_get_record(_contacts_simple_contact._uri, contactId, &contactHandle);
+ if (ret == CONTACTS_ERROR_NONE)
+ {
+ contacts_record_get_int(contactHandle, _contacts_simple_contact.person_id, &personId);
+ contacts_record_destroy(contactHandle, true);
+ }
+ }
+
+ msg.AddData(L"http://tizen.org/appcontrol/data/social/item_id", Integer::ToString(personId));
+ }
+ }
+ }
+ else if (isContactPick || isLegacyContactPick)
+ {
+ providerAppId = L"tizen.contact_list";
+ operation = L"http://tizen.org/appcontrol/operation/social/pick";
+
+ if (isLegacyContactPick)
+ {
+ msg.AddData(CONTACT_ITEM_TYPE, L"person");
+
+ const String& mode = msg.GetValue(L"selectionMode");
+ if (!mode.IsEmpty())
+ {
+ msg.AddData(SELECTION_MODE, mode);
+ msg.RemoveData(L"selectionMode");
+ }
+
+ const String& retType = msg.GetValue(L"returnType");
+ if (!retType.IsEmpty())
+ {
+ if (retType == L"contactId")
+ {
+ msg.AddData(CONTACT_RESULT_TYPE, L"item_id");
+ }
+ else
+ {
+ msg.AddData(CONTACT_RESULT_TYPE, retType);
+ }
+
+ msg.RemoveData(L"returnType");
+ }
+
+ pCb = _AppControlPlugin::OnAppControlResultLegacy;
+ }
+ else
+ {
+ pCb = _AppControlPlugin::OnAppControlResult;
+ }
+ }
+ else if (isContactChoose)
+ {
+ providerAppId = L"tizen.contact_list";
+ operation = L"http://tizen.org/appcontrol/operation/social/choose";
+ pCb = OnAppControlResult;
+ }
+
+ msg.SetApplicationId(providerAppId);
+ msg.SetOperation(operation);
+
+ __processId = _AppControlManager::GetInstance()->Launch(msg, pCb, 0);
+
+ r = GetLastResult();
+ SysTryReturnResult(NID_APP, __processId >= 0, r, "StartAppControl: Launching Contact AppControl is failed.");
+ __req = req;
+
+ if (pPid)
+ {
+ *pPid = __processId;
+ }
+
+ r = E_SUCCESS;
+ SysLog(NID_APP, "StartAppControl: Launching Contact AppControl succeeded");
+
+ return r;
+}
+
+
+result
+_AppControlPlugin::StopAppControlPlugin(int req)
+{
+ if (__processId >= 0)
+ {
+ result r = _AppControlPluginUtil::SendStopRequest(__processId);
+ SysTryReturnResult(NID_APP, !IsFailed(r), r, "Failed to send stop request to %d.", __processId);
+
+ SysLog(NID_APP, "Process %d is terminated.", __processId);
+ __processId = -1;
+
+ }
+
+ return E_SUCCESS;
+}
+
+
+void
+_AppControlPlugin::OnAppControlResult(void* b, int requestCode, service_result_e res, void* userData)
+{
+ result r = E_SYSTEM;
+ bundle* pBundle = static_cast<bundle*>(b);
+
+ HashMap* pResult = new (std::nothrow) HashMap();
+ SysTryCatch(NID_APP, pResult != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Allocation failure.");
+
+ r = pResult->Construct();
+
+ _AppArg::SetArgMap(pBundle, pResult);
+
+ _AppControlManager::GetInstance()->FinishAppControl(__req, res, pResult);
+
+CATCH:
+ __req = -1;
+}
+
+
+void
+_AppControlPlugin::OnAppControlResultLegacy(void* b, int requestCode, service_result_e res, void* userData)
+{
+ result r = E_SYSTEM;
+ bundle* pBundle = static_cast<bundle*>(b);
+
+ HashMap* pResult = new (std::nothrow) HashMap();
+ SysTryCatch(NID_APP, pResult != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Allocation failure.");
+
+ r = pResult->Construct();
+
+ switch (res)
+ {
+ case SERVICE_RESULT_SUCCEEDED:
+ {
+ _AppArg::SetArgMap(pBundle, pResult);
+
+ ArrayList* pList = static_cast<ArrayList*>(pResult->GetValue(String(L"http://tizen.org/appcontrol/data/social/phone")));
+ if (pList != null)
+ {
+ bool isFirst = true;
+ String retValue;
+
+ std::unique_ptr<IEnumerator> pEnum(pList->GetEnumeratorN());
+ SysTryCatch(NID_APP, pEnum != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Allocation failure.");
+
+ while (pEnum->MoveNext() == E_SUCCESS)
+ {
+ String* pPhoneNumber = static_cast<String*>(pEnum->GetCurrent());
+
+ if (!isFirst)
+ {
+ retValue.Append(L";");
+ }
+ else
+ {
+ isFirst = false;
+ }
+
+ retValue.Append(*pPhoneNumber);
+ }
+
+ pResult->Add(new (std::nothrow) String(PICK_OP_RET_KEY_RET_TYPE), new (std::nothrow) String(PICK_OP_RET_VALUE_PHONE));
+ pResult->Add(new (std::nothrow) String(PICK_OP_RET_KEY_VALUE), new (std::nothrow) String(retValue));
+ }
+
+ pList = static_cast<ArrayList*>(pResult->GetValue(String(L"http://tizen.org/appcontrol/data/social/email")));
+ if (pList != null)
+ {
+ bool isFirst = true;
+ String retValue;
+
+ std::unique_ptr<IEnumerator> pEnum(pList->GetEnumeratorN());
+ SysTryCatch(NID_APP, pEnum != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Allocation failure.");
+
+ while (pEnum->MoveNext() == E_SUCCESS)
+ {
+ String* pEmail = static_cast<String*>(pEnum->GetCurrent());
+
+ if (!isFirst)
+ {
+ retValue.Append(L";");
+ }
+ else
+ {
+ isFirst = false;
+ }
+
+ retValue.Append(*pEmail);
+ }
+
+ pResult->Add(new (std::nothrow) String(PICK_OP_RET_KEY_RET_TYPE), new (std::nothrow) String(PICK_OP_RET_VALUE_EMAIL));
+ pResult->Add(new (std::nothrow) String(PICK_OP_RET_KEY_VALUE), new (std::nothrow) String(retValue));
+ }
+
+ String* pString = dynamic_cast<String*>(pResult->GetValue(String(L"http://tizen.org/appcontrol/data/path")));
+ if (pString != null)
+ {
+ pResult->Add(new (std::nothrow) String(PICK_OP_RET_KEY_RET_TYPE), new (std::nothrow) String(PICK_OP_RET_VALUE_VCARD));
+ pResult->Add(new (std::nothrow) String(PICK_OP_RET_KEY_VALUE), new (std::nothrow) String(*pString));
+ }
+ else
+ {
+ String* pString = static_cast<String*>(pResult->GetValue(String(L"http://tizen.org/appcontrol/data/path")));
+ if (pString != null)
+ {
+ pResult->Add(new (std::nothrow) String(PICK_OP_RET_KEY_RET_TYPE), new (std::nothrow) String(PICK_OP_RET_VALUE_VCARD));
+ pResult->Add(new (std::nothrow) String(PICK_OP_RET_KEY_VALUE), new (std::nothrow) String(*pString));
+ }
+ }
+
+ pList = static_cast<ArrayList*>(pResult->GetValue(String(L"http://tizen.org/appcontrol/data/social/item_id")));
+ if (pList != null)
+ {
+ bool isFirst = true;
+ int contactId = 0;
+ int id = 0;
+ String retValue;
+
+ std::unique_ptr<IEnumerator> pEnum(pList->GetEnumeratorN());
+ SysTryCatch(NID_APP, pEnum != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Allocation failure.");
+
+ ScopedConnection conn;
+ if (conn.IsConnected())
+ {
+ unsigned int simple_contact_projection[] = {
+ _contacts_simple_contact.id,
+ _contacts_simple_contact.address_book_id,
+ };
+
+
+ while (pEnum->MoveNext() == E_SUCCESS)
+ {
+ String* pPersonId = static_cast<String*>(pEnum->GetCurrent());
+ Integer::Decode(*pPersonId, id);
+
+ contacts_filter_h filterHandle = null;
+ int ret = contacts_filter_create(_contacts_simple_contact._uri, &filterHandle);
+ if (ret != CONTACTS_ERROR_NONE)
+ {
+ break;
+ }
+
+ ScopedFilter filter(filterHandle);
+
+ contacts_filter_add_int(filter.Get(), _contacts_simple_contact.person_id, CONTACTS_MATCH_EQUAL, id);
+
+ contacts_query_h queryHandle = null;
+ ret = contacts_query_create(_contacts_simple_contact._uri, &queryHandle);
+ if (ret != CONTACTS_ERROR_NONE)
+ {
+ break;
+ }
+
+ ScopedQuery query(queryHandle);
+
+ ret = contacts_query_set_filter(query.Get(), filter.Get());
+ if (ret != CONTACTS_ERROR_NONE)
+ {
+ break;
+ }
+
+ ret = contacts_query_set_projection(query.Get(), simple_contact_projection, sizeof(simple_contact_projection)/sizeof(unsigned int));
+ if (ret != CONTACTS_ERROR_NONE)
+ {
+ break;
+ }
+
+ ret = contacts_query_set_sort(query.Get(), _contacts_simple_contact.address_book_id, true);
+ if (ret != CONTACTS_ERROR_NONE)
+ {
+ break;
+ }
+
+
+ contacts_list_h listHandle = null;
+ ret = contacts_db_get_records_with_query(query.Get(), 0, 0, &listHandle);
+ if (ret != CONTACTS_ERROR_NONE)
+ {
+ break;
+ }
+
+ ScopedList contactList(listHandle);
+ unsigned int count = 0;
+ contacts_list_get_count(contactList.Get(), &count);
+ if (count > 0)
+ {
+ contacts_record_h contactHandle = null;
+ contacts_list_get_current_record_p(contactList.Get(), &contactHandle);
+ contacts_record_get_int(contactHandle, _contacts_simple_contact.id, &contactId);
+ }
+
+ if (!isFirst)
+ {
+ retValue.Append(L";");
+ }
+ else
+ {
+ isFirst = false;
+ }
+
+ retValue.Append(contactId);
+ }
+ }
+
+ pResult->Add(new (std::nothrow) String(PICK_OP_RET_KEY_RET_TYPE), new (std::nothrow) String(PICK_OP_RET_VALUE_CONTACT_ID));
+ pResult->Add(new (std::nothrow) String(PICK_OP_RET_KEY_VALUE), new (std::nothrow) String(retValue));
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ _AppControlManager::GetInstance()->FinishAppControl(__req, res, pResult);
+
+CATCH:
+ __req = -1;
+}
+
+}
+
+extern "C" _OSP_EXPORT_ _IAppControlPluginProvider*
+GetAppControlProviderPlugin(void)
+{
+ return new (std::nothrow) _AppControlPlugin;
+}
+
--- /dev/null
+SET (this_target osp-ac-filemanager)
+
+INCLUDE_DIRECTORIES (
+ ${COMMON_INCLUDE_DIRS}
+ ../../inc
+)
+
+SET (${this_target}_SOURCE_FILES
+ FileManagerAppControlDllEntry.cpp
+)
+
+## SET EXTRA COMPILER FLAGS
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fPIC -Wall" )
+
+## 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_LIBRARY (${this_target} SHARED ${${this_target}_SOURCE_FILES})
+
+TARGET_LINK_LIBRARIES(${this_target} -Xlinker --no-undefined -Xlinker)
+TARGET_LINK_LIBRARIES(${this_target} ${pkgs_LDFLAGS})
+TARGET_LINK_LIBRARIES(${this_target} osp-ac-util)
+
+OSP_STRIP(${this_target})
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file FileManagerAppControlDllEntry.cpp
+ * @brief This is the implementation for the FileManagerAppControlDllEntry.cpp.
+ */
+
+#include <bundle.h>
+#include <appsvc/appsvc.h>
+
+#include <FBaseSysLog.h>
+#include <FBaseColHashMap.h>
+
+#include <FApp_AppControlManager.h>
+#include <FApp_AppMessageImpl.h>
+#include <FApp_AppArg.h>
+#include <FApp_Aul.h>
+#include <FApp_IAppControlPluginProvider.h>
+
+#include "FApp_AppControlPluginUtil.h"
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+
+namespace
+{
+
+class _AppControlPlugin
+ : public _IAppControlPluginProvider
+ , virtual public Tizen::Base::Runtime::IEventListener
+{
+public:
+ _AppControlPlugin(void) {}
+
+ virtual ~_AppControlPlugin(void) {}
+
+ virtual result StartAppControlPlugin(int req, const AppId& appId, const _AppMessageImpl& message, int* pPid);
+
+ virtual result StopAppControlPlugin(int req);
+
+ virtual result Release(void) { delete this; return E_SUCCESS; }
+
+ static void OnAppControlResult(void* b, int requestCode, service_result_e res, void* userData);
+
+private:
+ static int __req;
+ static int __processId;
+};
+
+
+int _AppControlPlugin::__req = -1;
+int _AppControlPlugin::__processId = -1;
+
+
+result
+_AppControlPlugin::StartAppControlPlugin(int req, const AppId& aId, const _AppMessageImpl& message, int* pPid)
+{
+ result r = E_SYSTEM;
+ SysLog(NID_APP, "StartAppControl: Entry to FileManager AppControl");
+
+ _AppMessageImpl msg(message);
+
+ const String& mode = msg.GetValue(L"selectionType");
+ if (!mode.IsEmpty())
+ {
+ msg.AddData(L"http://tizen.org/appcontrol/data/selection_mode", mode);
+ msg.RemoveData(L"selectionType");
+ }
+
+ String mime = message.GetMime();
+ if (mime.IsEmpty())
+ {
+ const String& type = msg.GetValue(L"type");
+
+ if (type == L"all")
+ {
+ mime = L"*/*";
+ }
+ else if (type == L"image")
+ {
+ mime = L"image/*";
+ }
+ else if (type == L"audio")
+ {
+ mime = L"audio/*";
+ }
+ else if (type == L"video")
+ {
+ mime = L"video/*";
+ }
+
+ msg.SetMime(mime);
+ }
+
+ __req = req;
+ __processId = _AppControlManager::GetInstance()->Launch(msg, OnAppControlResult, 0);
+
+ r = GetLastResult();
+ SysTryReturnResult(NID_APP, __processId >= 0, r, "StartAppControl: Launching FileManager AppControl is failed.");
+ r = E_SUCCESS;
+
+ if (pPid)
+ {
+ *pPid = __processId;
+ }
+
+ SysLog(NID_APP, "StartAppControl: Launching ImageViewer AppControl succeeded");
+
+ return r;
+}
+
+
+result
+_AppControlPlugin::StopAppControlPlugin(int req)
+{
+ if (__processId >= 0)
+ {
+ _AppControlPluginUtil::SendStopRequest(__processId);
+ SysLog(NID_APP, "Process %d is terminated.", __processId);
+ __processId = -1;
+ }
+
+ return E_SUCCESS;
+}
+
+
+void
+_AppControlPlugin::OnAppControlResult(void* b, int requestCode, service_result_e res, void* userData)
+{
+ SysLog(NID_APP, "@@@@@@ OnAppControlResult for myfiles");
+
+ result r = E_SYSTEM;
+ int type = BUNDLE_TYPE_NONE;
+ bundle* pBundle = static_cast<bundle*>(b);
+
+ HashMap* pResult = new (std::nothrow) HashMap();
+ SysTryCatch(NID_APP, pResult != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Allocation failure.");
+
+ r = pResult->Construct();
+
+ _AppArg::SetArgMap(pBundle, pResult);
+
+ type = bundle_get_type(pBundle, SERVICE_DATA_SELECTED);
+ switch (type)
+ {
+ case BUNDLE_TYPE_STR:
+ {
+ const char* pFile = appsvc_get_data(pBundle, SERVICE_DATA_SELECTED);
+ if (pFile)
+ {
+ pResult->Add(new (std::nothrow) String(L"path"), new (std::nothrow) String(pFile));
+ }
+ }
+ break;
+ case BUNDLE_TYPE_STR_ARRAY:
+ {
+ ArrayList* pArray = _AppMessageImpl::GetValueArrayN(pBundle, SERVICE_DATA_SELECTED);
+ if (pArray)
+ {
+ const int count = pArray->GetCount();
+ if (count > 0)
+ {
+ String tmp;
+
+ tmp = * static_cast<String*>(pArray->GetAt(0));
+ for (int i = 1; i < count; i++)
+ {
+ tmp.Append(L';');
+ tmp.Append(* static_cast<String*>(pArray->GetAt(i)));
+ }
+
+ pResult->Add(new (std::nothrow) String(L"path"), new (std::nothrow) String(tmp));
+ }
+ }
+ }
+ break;
+ case BUNDLE_TYPE_NONE:
+ default:
+ break;
+ }
+
+ _AppControlManager::GetInstance()->FinishAppControl(__req, res, pResult);
+
+CATCH:
+ __req = -1;
+}
+
+}
+
+extern "C" _OSP_EXPORT_ _IAppControlPluginProvider*
+GetAppControlProviderPlugin(void)
+{
+ return new (std::nothrow) _AppControlPlugin;
+}
+
--- /dev/null
+SET (this_target osp-ac-image)
+
+INCLUDE_DIRECTORIES (
+ ${COMMON_INCLUDE_DIRS}
+ ../../inc
+ )
+
+SET (${this_target}_SOURCE_FILES
+ ImageAppControlDllEntry.cpp
+ )
+
+## SET EXTRA COMPILER FLAGS
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fPIC -Wall" )
+
+## 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_LIBRARY (${this_target} SHARED ${${this_target}_SOURCE_FILES})
+
+ADD_DEPENDENCIES(${this_target} osp-ac-util)
+
+TARGET_LINK_LIBRARIES(${this_target} -Xlinker --no-undefined -Xlinker)
+TARGET_LINK_LIBRARIES(${this_target} ${pkgs_LDFLAGS})
+TARGET_LINK_LIBRARIES(${this_target} osp-ac-util)
+
+OSP_STRIP(${this_target})
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file ImageAppControlDllEntry.cpp
+ * @brief This is the implementation for the ImageAppControlDllEntry.cpp.
+ */
+
+#include <FBaseSysLog.h>
+#include <FBaseColHashMap.h>
+
+#include <FApp_AppControlManager.h>
+#include <FApp_AppMessageImpl.h>
+#include <FApp_Aul.h>
+#include <FApp_AppArg.h>
+#include <FApp_IAppControlPluginProvider.h>
+
+#include "FApp_AppControlPluginUtil.h"
+
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+
+namespace
+{
+
+class _AppControlPlugin
+ : public _IAppControlPluginProvider
+ , virtual public Tizen::Base::Runtime::IEventListener
+{
+public:
+ _AppControlPlugin(void) {}
+
+ virtual ~_AppControlPlugin(void) {}
+
+ virtual result StartAppControlPlugin(int req, const AppId& appId, const _AppMessageImpl& message, int* pPid);
+
+ virtual result StopAppControlPlugin(int req);
+
+ virtual result Release(void) { delete this; return E_SUCCESS; }
+
+ static void OnAppControlResult(void* b, int requestCode, service_result_e res, void* userData);
+
+private:
+ static int __req;
+ static int __processId;
+};
+
+
+int _AppControlPlugin::__req = -1;
+int _AppControlPlugin::__processId = -1;
+
+static const char __allowedAppControlImageTable[][2][96] =
+{
+ {"osp.appcontrol.IMAGE", "osp.appcontrol.operation.VIEW"},
+ {"osp.appcontrol.provider.image", "osp.appcontrol.operation.view"},
+ {"http://tizen.org/appcontrol/provider/image", "http://tizen.org/appcontrol/operation/view"},
+ {"tizen.imageviewer", "http://tizen.org/appcontrol/operation/view"},
+};
+
+static const char __allowedAppControlCropTable[][2][96] =
+{
+ {"tizen.imageviewer", "http://tizen.org/appcontrol/operation/image/crop"},
+};
+
+
+result
+_AppControlPlugin::StartAppControlPlugin(int req, const AppId& aId, const _AppMessageImpl& message, int* pPid)
+{
+ result r = E_SYSTEM;
+ SysLog(NID_APP, "StartAppControl: Entry to Image AppControl");
+
+ const String& oId = message.GetOperation();
+
+ const bool isImage = _AppControlPluginUtil::IsAllowedAppControl(__allowedAppControlImageTable, 4, aId, oId);
+ const bool isCrop = _AppControlPluginUtil::IsAllowedAppControl(__allowedAppControlCropTable, 1, aId, oId);
+ SysTryReturnResult(NID_APP, isImage || isCrop, E_SYSTEM, "Invalid AppControl entry for (%ls, %ls).", aId.GetPointer(), oId.GetPointer());
+
+ _AppMessageImpl msg(message);
+
+ String uri = msg.GetUri();
+ if (uri.IsEmpty())
+ {
+ uri = msg.GetValue(L"path");
+ if (!uri.IsEmpty())
+ {
+ msg.SetUri(uri);
+ }
+ }
+
+ if (!isCrop)
+ {
+ __processId = _AppControlManager::GetInstance()->Launch(msg, NULL, 0);
+ }
+ else
+ {
+ __req = req;
+ __processId = _AppControlManager::GetInstance()->Launch(msg, _AppControlPlugin::OnAppControlResult, 0);
+ }
+
+ r = GetLastResult();
+ SysTryReturnResult(NID_APP, __processId >= 0, r, "StartAppControl: Launching Image AppControl is failed.");
+ r = E_SUCCESS;
+
+ if (pPid)
+ {
+ *pPid = __processId;
+ }
+
+ SysLog(NID_APP, "StartAppControl: Launching ImageViewer AppControl succeeded");
+
+ return r;
+}
+
+
+result
+_AppControlPlugin::StopAppControlPlugin(int req)
+{
+ if (__processId >= 0)
+ {
+ _AppControlPluginUtil::SendStopRequest(__processId);
+ SysLog(NID_APP, "Process %d is terminated.", __processId);
+ __processId = -1;
+ }
+
+ return E_SUCCESS;
+}
+
+
+void
+_AppControlPlugin::OnAppControlResult(void* b, int requestCode, service_result_e res, void* userData)
+{
+ SysLog(NID_APP, "@@@@@@ OnAppControlResult");
+
+ result r = E_SYSTEM;
+ bundle* pBundle = static_cast<bundle*>(b);
+
+ HashMap* pResult = new (std::nothrow) HashMap();
+ SysTryCatch(NID_APP, pResult != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Allocation failure.");
+
+ r = pResult->Construct();
+
+ _AppArg::SetArgMap(pBundle, pResult);
+
+ _AppControlManager::GetInstance()->FinishAppControl(__req, res, pResult);
+
+CATCH:
+ __req = -1;
+}
+
+}
+
+extern "C" _OSP_EXPORT_ _IAppControlPluginProvider*
+GetAppControlProviderPlugin(void)
+{
+ return new (std::nothrow) _AppControlPlugin;
+}
+
--- /dev/null
+SET (this_target osp-ac-implicit)
+
+INCLUDE_DIRECTORIES (
+ ${COMMON_INCLUDE_DIRS}
+ ../../inc
+)
+
+SET (${this_target}_SOURCE_FILES
+ ImplicitAppControlEntry.cpp
+ FApp_RequestManagerT.cpp
+)
+
+## SET EXTRA COMPILER FLAGS
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fPIC -Wall" )
+
+## 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_LIBRARY (${this_target} SHARED ${${this_target}_SOURCE_FILES})
+
+ADD_DEPENDENCIES(${this_target} osp-ac-util)
+
+TARGET_LINK_LIBRARIES(${this_target} -Xlinker --no-undefined -Xlinker)
+TARGET_LINK_LIBRARIES(${this_target} ${pkgs_LDFLAGS})
+TARGET_LINK_LIBRARIES(${this_target} osp-ac-util)
+
+OSP_STRIP(${this_target})
--- /dev/null
+//
+// 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 FApp_ImplicitInfo.h
+ * @brief This is the header file for the _ImplicitInfo class.
+ */
+
+#ifndef _FAPP_INTERNAL_IMPLICIT_INFO_H_
+#define _FAPP_INTERNAL_IMPLICIT_INFO_H_
+
+
+#include <FOspConfig.h>
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FAppTypes.h>
+
+
+namespace Tizen { namespace App
+{
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// _ImplicitInfo handles the launch request from this process
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+const long _REQUEST_INFO_MAGIC = 0x494C;
+
+class _ImplicitInfo
+{
+public:
+ _ImplicitInfo(int reqId, int pid, const Tizen::Base::String& oId)
+ : magic(_REQUEST_INFO_MAGIC)
+ , reqId(reqId)
+ , processId(pid)
+ , operationId(oId)
+ {
+ }
+
+ ~_ImplicitInfo(void) { magic = 0; }
+
+ bool IsValid(void) { return magic == _REQUEST_INFO_MAGIC; }
+
+private:
+ _ImplicitInfo(const _ImplicitInfo& rhs);
+ _ImplicitInfo& operator =(const _ImplicitInfo& rhs);
+
+public:
+ long magic;
+ int reqId;
+ int processId;
+ const Tizen::Base::String operationId;
+}; // _ImplicitInfo
+
+}} // Tizen::App
+
+#endif // _FAPP_INTERNAL_IMPLICIT_INFO_H_
--- /dev/null
+//
+// 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 FApp_RequestManagerT.cpp
+ * @brief This is the implementationfor the _RequestManagerT class.
+ */
+
+#include <limits.h>
+
+#include "FApp_RequestManagerT.h"
+#include "FApp_ImplicitInfo.h"
+
+
+namespace Tizen { namespace App
+{
+
+template<typename T>
+_RequestManagerT<T>::_RequestManagerT(void)
+: __reqId(-1)
+{
+ __requestList.Construct();
+}
+
+template<typename T>
+_RequestManagerT<T>::~_RequestManagerT(void)
+{
+ RequestListEnumType* pIter = __requestList.GetMapEnumeratorN();
+ if (pIter == null)
+ {
+ return;
+ }
+
+ while (pIter->MoveNext() == E_SUCCESS)
+ {
+ T* pInfo = null;
+ result r = pIter->GetValue(pInfo);
+
+ if (IsFailed(r))
+ {
+ continue;
+ }
+
+ delete pInfo;
+ }
+
+ delete pIter;
+}
+
+template<typename T> int
+_RequestManagerT<T>::InsertItem(T* pItem)
+{
+ SysTryReturn(NID_APP, pItem != null, -1, E_INVALID_ARG, "[E_INVALID_ARG] Empty argument.");
+
+ const int& req = pItem->reqId;
+ __requestList.Add(req, pItem);
+
+ return req;
+}
+
+template<typename T> void
+_RequestManagerT<T>::RemoveItem(int reqId)
+{
+ T* pItem = FindItem(reqId);
+ if (pItem && pItem->IsValid())
+ {
+ __requestList.Remove(reqId);
+ delete pItem;
+ }
+}
+
+template<typename T> void
+_RequestManagerT<T>::RemoveItem(T* pItem)
+{
+ RequestListEnumType* pIter = __requestList.GetMapEnumeratorN();
+ if (pItem == null || pIter == null)
+ {
+ return;
+ }
+
+ while (pIter->MoveNext() == E_SUCCESS)
+ {
+ T* pInfo = null;
+ result r = pIter->GetValue(pInfo);
+
+ if (pInfo == pItem)
+ {
+ int id = -1;
+ r = pIter->GetKey(id);
+ if (r == E_SUCCESS)
+ {
+ __requestList.Remove(id);
+ }
+
+ delete pItem;
+ delete pIter;
+
+ return;
+ }
+ }
+
+ delete pIter;
+}
+
+template<typename T> T*
+_RequestManagerT<T>::FindItem(int reqId) const
+{
+ T* pItem = null;
+ result r = __requestList.GetValue(reqId, pItem);
+
+ return (r == E_SUCCESS) ? pItem : null;
+}
+
+template<typename T> void
+_RequestManagerT<T>::Dump(void) const
+{
+ RequestListEnumType* pIter = __requestList.GetMapEnumeratorN();
+ if (pIter == null)
+ {
+ return;
+ }
+
+ while (pIter->MoveNext() == E_SUCCESS)
+ {
+ T* pInfo = null;
+ pIter->GetValue(pInfo);
+
+ if (pInfo)
+ {
+ SysLog(NID_APP, "magic 0x%x, req %d", pInfo->magic, pInfo->reqId);
+ }
+ }
+}
+
+
+// explicit template initialization
+template class _RequestManagerT<_ImplicitInfo>;
+
+} } // Tizen::App
+
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file ImplicitAppControlEntry.cpp
+ * @brief This is the implementation for the ImplicitAppControlEntry.cpp.
+ */
+
+#include <FBaseSysLog.h>
+#include <FBaseColHashMap.h>
+
+#include <FApp_Aul.h>
+#include <FApp_AppArg.h>
+#include <FApp_AppControlManager.h>
+#include <FApp_AppControlImpl.h>
+#include <FApp_AppMessageImpl.h>
+#include <FApp_IAppControlPluginProvider.h>
+#include <FApp_RequestManagerT.h>
+
+#include "FApp_ImplicitInfo.h"
+#include "FApp_AppControlPluginUtil.h"
+#include "FApp_AppControlTerminateHandler.h"
+
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+
+namespace
+{
+
+class _AppControlPlugin
+ : public _IAppControlPluginProvider
+ , virtual public Tizen::Base::Runtime::IEventListener
+{
+public:
+ _AppControlPlugin(void) { __handler.SetResultCallback(OnAppControlTerminate, this); }
+
+ virtual ~_AppControlPlugin(void) { SysLog(NID_APP, "Finalizing."); }
+
+ virtual result StartAppControlPlugin(int req, const AppId& appId, const _AppMessageImpl& message, int* pPid);
+
+ virtual result StopAppControlPlugin(int req);
+
+ virtual result Release(void) { return E_SUCCESS; }
+
+ static void OnAppControlResult(void* b, int requestCode, service_result_e res, void* userData);
+
+ static void OnAppControlTerminate(int req, int pid, void* data);
+
+private:
+ _RequestManagerT<_ImplicitInfo> __requestManager;
+ _AppControlTerminateHandler __handler;
+};
+
+
+// singleton provider
+static _AppControlPlugin* __pPlugin = null;
+
+result
+_AppControlPlugin::StartAppControlPlugin(int req, const AppId& appId, const _AppMessageImpl& message, int* pPid)
+{
+ const String& op = message.GetOperation();
+ SysLog(NID_APP, "StartAppControl for operation %ls with req %d.", op.GetPointer(), req);
+
+ AppSvcResFn pCb = NULL;
+
+ if (req >= 0)
+ {
+ // if there is no listener, then req is -1.
+ pCb = OnAppControlResult;
+ __handler.AddHandler(req);
+ }
+
+ bool isAppSelector = false;
+ int pid = _AppControlPluginUtil::LaunchImplicit(message, pCb, this, req, isAppSelector);
+
+ result r = GetLastResult();
+ SysTryReturnResult(NID_APP, pid >=0, r, "System error.");
+
+ if (pPid)
+ {
+ *pPid = pid;
+ }
+
+ // appId is empty for implicit AppControl launch.
+ _ImplicitInfo* pItem = new (std::nothrow) _ImplicitInfo(req, pid, op);
+ if (pItem)
+ {
+ const int ret = __requestManager.InsertItem(pItem);
+ SysLog(NID_APP, "Request is added with %d.", ret);
+ }
+
+ if (req >= 0)
+ {
+ __handler.SetHandlerData(req, pid);
+ }
+
+ if (isAppSelector)
+ {
+ // do not add to the list for app selector response
+ __handler.RemoveHandler(req);
+ SysLog(NID_APP, "Destination watch for app selector response is disabled for request %d.", req);
+ }
+
+ SysLog(NID_APP, "StartAppControl: Launching AppControl succeeded for process %d with 0x%x.", pid, this);
+
+ return r;
+}
+
+
+result
+_AppControlPlugin::StopAppControlPlugin(int req)
+{
+ __handler.RemoveHandler(req);
+
+ _ImplicitInfo* pItem = __requestManager.FindItem(req);
+ SysTryReturnResult(NID_APP, pItem != null, E_SYSTEM, "No request found for %d.", req);
+
+ const int processId = pItem->processId;
+ if (processId <=0)
+ {
+ SysLogException(NID_APP, E_SYSTEM, "Request %d has invalid state with %ls operation.", req, pItem->operationId.GetPointer());
+ __requestManager.RemoveItem(req);
+ return E_SUCCESS;
+ }
+
+ result r = _AppControlPluginUtil::SendStopRequest(processId);
+ if (IsFailed(r))
+ {
+ SysLogException(NID_APP, E_INVALID_OPERATION, "Failed to send stop request to %d.", processId);
+ }
+
+ SysLog(NID_APP, "Process %d is terminated.", processId);
+
+ __requestManager.RemoveItem(req);
+
+ return r;
+}
+
+
+void
+_AppControlPlugin::OnAppControlResult(void* b, int requestCode, service_result_e res, void* userData)
+{
+ SysLog(NID_APP, "AppControl result received with req code %d with 0x%x.", requestCode, userData);
+
+ result r = E_SYSTEM;
+ bundle* pBundle = static_cast<bundle*>(b);
+ _AppControlPlugin* pThis = static_cast<_AppControlPlugin*>(userData);
+ SysTryReturnVoidResult(NID_APP, pThis != null, E_SYSTEM, "[E_SYSTEM] Invalid state for request %d.", requestCode);
+
+ _ImplicitInfo* pInfo = pThis->__requestManager.FindItem(requestCode);
+ SysTryReturnVoidResult(NID_APP, pInfo != null, E_SYSTEM, "[E_SYSTEM] Invalid request instance(%d).", requestCode);
+
+ pThis->__handler.RemoveHandler(requestCode);
+
+ HashMap* pResult = new (std::nothrow) HashMap();
+ SysTryReturnVoidResult(NID_APP, pResult != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Allocation failure.");
+
+ r = pResult->Construct();
+
+ _AppArg::SetArgMap(pBundle, pResult);
+
+
+ const AppId& provider = _AppArg::GetCalleeAppId(pBundle);
+ const String& operation = pInfo->operationId;
+ const bool isSubMode = _AppArg::IsSubMode(pBundle);
+
+ _AppControlManager::GetInstance()->FinishAppControl(requestCode, res, provider, operation, pResult, (isSubMode) ? _APPCONTROL_PROPERTY_SUBMODE : 0);
+ pThis->__requestManager.RemoveItem(requestCode);
+
+ SysLog(NID_APP, "Request %d is removed from the list successfully.", requestCode);
+}
+
+
+void
+_AppControlPlugin::OnAppControlTerminate(int req, int pid, void* userData)
+{
+ SysLog(NID_APP, "AppControl terminate event received with req code %d for process %d.", req, pid);
+
+ _AppControlPlugin* pThis = static_cast<_AppControlPlugin*>(userData);
+ if (pThis)
+ {
+ pThis->__handler.RemoveHandler(req);
+ pThis->__requestManager.RemoveItem(req);
+ }
+
+ // APPSVC_OSP_RES_TERMINATE matches APP_CTRL_RESULT_TERMINATED
+ _AppControlManager::GetInstance()->FinishAppControl(req, APPSVC_OSP_RES_TERMINATE, null);
+}
+
+}
+
+
+extern "C" _OSP_EXPORT_ _IAppControlPluginProvider*
+GetAppControlProviderPlugin(void)
+{
+ if (__pPlugin == null)
+ {
+ __pPlugin = new (std::nothrow) _AppControlPlugin;
+ }
+
+ return __pPlugin;
+}
+
+__attribute__((destructor))
+void
+Plugin_Finalize(void)
+{
+ delete __pPlugin;
+ __pPlugin = null;
+}
+
+
--- /dev/null
+SET (this_target osp-ac-media)
+
+INCLUDE_DIRECTORIES (
+ ${COMMON_INCLUDE_DIRS}
+ ../../inc
+ )
+
+SET (${this_target}_SOURCE_FILES
+ MediaAppControlDllEntry.cpp
+ )
+
+## SET EXTRA COMPILER FLAGS
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fPIC -Wall" )
+
+## 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_LIBRARY (${this_target} SHARED ${${this_target}_SOURCE_FILES})
+
+ADD_DEPENDENCIES(${this_target} osp-ac-util)
+
+TARGET_LINK_LIBRARIES(${this_target} -Xlinker --no-undefined -Xlinker)
+TARGET_LINK_LIBRARIES(${this_target} ${pkgs_LDFLAGS})
+TARGET_LINK_LIBRARIES(${this_target} osp-ac-util)
+
+OSP_STRIP(${this_target})
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file MediaAppControlDllEntry.cpp
+ * @brief This is the implementation for the MediaAppControlDllEntry.cpp.
+ */
+
+#include <bundle.h>
+
+#include <FBaseSysLog.h>
+#include <FBaseColHashMap.h>
+
+#include <FApp_AppControlManager.h>
+#include <FApp_AppMessageImpl.h>
+#include <FApp_Aul.h>
+#include <FApp_IAppControlPluginProvider.h>
+
+#include "FApp_AppControlPluginUtil.h"
+
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+
+namespace
+{
+
+class _AppControlPlugin
+ : public _IAppControlPluginProvider
+ , virtual public Tizen::Base::Runtime::IEventListener
+{
+public:
+ _AppControlPlugin(void) {}
+
+ virtual ~_AppControlPlugin(void) {}
+
+ virtual result StartAppControlPlugin(int req, const AppId& appId, const _AppMessageImpl& message, int* pPid);
+
+ virtual result StopAppControlPlugin(int req);
+
+ virtual result Release(void) { delete this; return E_SUCCESS; }
+
+private:
+ static int __processId;
+};
+
+
+int _AppControlPlugin::__processId = -1;
+
+static const char __allowedAppControlVideoTable[][2][96] =
+{
+ {"osp.appcontrol.VIDEO", "osp.appcontrol.operation.PLAY"},
+ {"osp.appcontrol.provider.video", "osp.appcontrol.operation.play"},
+ {"http://tizen.org/appcontrol/provider/video", "http://tizen.org/appcontrol/operation/play"},
+ {"tizen.videoplayer", "http://tizen.org/appcontrol/operation/view"},
+};
+
+static const char __allowedAppControlAudioTable[][2][96] =
+{
+ {"osp.appcontrol.AUDIO", "osp.appcontrol.operation.PLAY"},
+ {"osp.appcontrol.provider.audio", "osp.appcontrol.operation.play"},
+ {"http://tizen.org/appcontrol/provider/audio", "http://tizen.org/appcontrol/operation/play"},
+ {"tizen.musicplayer", "http://tizen.org/appcontrol/operation/view"},
+};
+
+result
+_AppControlPlugin::StartAppControlPlugin(int req, const AppId& aId, const _AppMessageImpl& message, int* pPid)
+{
+ result r = E_SYSTEM;
+ SysLog(NID_APP, "StartAppControl: Entry to Media AppControl");
+
+ const String& oId = message.GetOperation();
+
+ const bool isVideo = _AppControlPluginUtil::IsAllowedAppControl(__allowedAppControlVideoTable, 4, aId, oId);
+ const bool isAudio = _AppControlPluginUtil::IsAllowedAppControl(__allowedAppControlAudioTable, 4, aId, oId);
+
+ _AppMessageImpl msg(message);
+
+ String uri = msg.GetUri();
+ if (uri.IsEmpty())
+ {
+ uri = msg.GetValue(L"path");
+ if (!uri.IsEmpty())
+ {
+ if (uri.StartsWith(L"/", 0))
+ {
+ uri.Insert(L"file://", 0);
+ }
+
+ msg.SetUri(uri);
+
+ msg.RemoveData(L"path");
+ msg.RemoveData(L"type");
+ }
+ }
+
+ if (isAudio)
+ {
+ // Check the exit on back option.
+ const String& exit = msg.GetValue(L"ExitOnBack");
+ if (!exit.IsEmpty())
+ {
+ bundle_del(msg.GetBundle(), "__APP_SVC_K_WIN_ID__");
+ }
+ }
+ else if (isVideo)
+ {
+ SysLog(NID_APP, "Video AppControl.");
+ }
+
+ __processId = _AppControlManager::GetInstance()->Launch(msg, NULL, 0);
+
+ r = GetLastResult();
+ SysTryReturnResult(NID_APP, __processId >= 0, r, "StartAppControl: Launching Image AppControl is failed.");
+ r = E_SUCCESS;
+
+ if (pPid)
+ {
+ *pPid = __processId;
+ }
+
+ SysLog(NID_APP, "StartAppControl: Launching ImageViewer AppControl succeeded");
+
+ return r;
+}
+
+
+result
+_AppControlPlugin::StopAppControlPlugin(int req)
+{
+ if (__processId >= 0)
+ {
+ result r = _AppControlPluginUtil::SendStopRequest(__processId);
+ SysTryReturnResult(NID_APP, !IsFailed(r), r, "Failed to send stop request to %d.", __processId);
+
+ SysLog(NID_APP, "Process %d is terminated.", __processId);
+ __processId = -1;
+ }
+
+ return E_SUCCESS;
+}
+
+}
+
+extern "C" _OSP_EXPORT_ _IAppControlPluginProvider*
+GetAppControlProviderPlugin(void)
+{
+ return new (std::nothrow) _AppControlPlugin;
+}
+
--- /dev/null
+SET (this_target osp-ac-message)
+
+INCLUDE_DIRECTORIES (
+ ${COMMON_INCLUDE_DIRS}
+ ../../inc
+ )
+
+SET (${this_target}_SOURCE_FILES
+ MessageAppControlDllEntry.cpp
+ )
+
+## SET EXTRA COMPILER FLAGS
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fPIC -Wall" )
+
+## 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_LIBRARY (${this_target} SHARED ${${this_target}_SOURCE_FILES})
+
+ADD_DEPENDENCIES(${this_target} osp-ac-util)
+
+TARGET_LINK_LIBRARIES(${this_target} -Xlinker --no-undefined -Xlinker)
+TARGET_LINK_LIBRARIES(${this_target} ${pkgs_LDFLAGS})
+TARGET_LINK_LIBRARIES(${this_target} osp-ac-util)
+
+OSP_STRIP(${this_target})
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file MessageAppControlDllEntry.cpp
+ * @brief This is the implementation for the MessageAppControlDllEntry.cpp.
+ */
+
+#include <FBaseSysLog.h>
+#include <FBaseUtilStringTokenizer.h>
+#include <FBaseColHashMap.h>
+
+#include <FBase_StringConverter.h>
+#include <FApp_AppControlManager.h>
+#include <FApp_AppMessageImpl.h>
+#include <FApp_Aul.h>
+#include <FApp_AppArg.h>
+#include <FApp_IAppControlPluginProvider.h>
+
+#include "FApp_AppControlPluginUtil.h"
+
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Utility;
+
+
+namespace
+{
+
+static const wchar_t APP_CONTROL_ATTACH_PATH[] = L"http://tizen.org/appcontrol/data/path";
+static const wchar_t APP_CONTROL_MESSAGE_TYPE[] = L"http://tizen.org/appcontrol/data/message/type";
+
+class _AppControlPlugin
+ : public _IAppControlPluginProvider
+ , virtual public Tizen::Base::Runtime::IEventListener
+{
+public:
+ _AppControlPlugin(void) {}
+
+ virtual ~_AppControlPlugin(void) {}
+
+ virtual result StartAppControlPlugin(int req, const AppId& appId, const _AppMessageImpl& message, int* pPid);
+
+ virtual result StopAppControlPlugin(int req);
+
+ virtual result Release(void) { delete this; return E_SUCCESS; }
+
+ static void OnAppControlResult(void* b, int requestCode, service_result_e res, void* userData);
+
+private:
+ static int __req;
+ static int __processId;
+};
+
+
+int _AppControlPlugin::__req = -1;
+int _AppControlPlugin::__processId = -1;
+
+static const char __allowedAppControlMessageTable[][2][96] =
+{
+ {"osp.appcontrol.MESSAGE", "osp.appcontrol.operation.EDIT"},
+ {"osp.appcontrol.provider.message", "osp.appcontrol.operation.compose"},
+ {"tizen.messages", "http://tizen.org/appcontrol/operation/compose"},
+ {"tizen.smsmessages", "http://tizen.org/appcontrol/operation/compose"},
+ {"tizen.mmsmessages", "http://tizen.org/appcontrol/operation/compose"},
+};
+
+static const char __allowedAppControlEmailTable[][2][96] =
+{
+ {"osp.appcontrol.EMAIL", "osp.appcontrol.operation.EDIT"},
+ {"osp.appcontrol.provider.email", "osp.appcontrol.operation.compose"},
+ {"tizen.email", "http://tizen.org/appcontrol/operation/compose"},
+};
+
+
+result
+_AppControlPlugin::StartAppControlPlugin(int req, const AppId& aId, const _AppMessageImpl& message, int* pPid)
+{
+ SysLog(NID_APP, "StartAppControl: Entry to Message AppControl");
+
+ result r = E_SUCCESS;
+
+ const String& oId = message.GetOperation();
+ SysLog(NID_APP, "aId : %ls, oId : %ls", aId.GetPointer(), oId.GetPointer());
+
+ const bool isMessage = _AppControlPluginUtil::IsAllowedAppControl(__allowedAppControlMessageTable, 5, aId, oId);
+ const bool isEmail = _AppControlPluginUtil::IsAllowedAppControl(__allowedAppControlEmailTable, 3, aId, oId);
+
+ SysTryReturnResult(NID_APP, isMessage || isEmail, E_SYSTEM, "Invalid AppControl entry for (%ls, %ls).", aId.GetPointer(), oId.GetPointer());
+
+ _AppMessageImpl msg(message);
+
+ if (isMessage)
+ {
+ SysLog(NID_APP, "Message AppControl starts..");
+
+ // type
+ const String& type = msg.GetValue(APP_CONTROL_MESSAGE_TYPE);
+ if (type.IsEmpty())
+ {
+ String legacyType = msg.GetValue(L"type");
+ if (!legacyType.IsEmpty())
+ {
+ legacyType.ToLowerCase();
+
+ msg.AddData(APP_CONTROL_MESSAGE_TYPE, legacyType);
+ }
+ }
+
+ // to
+ String tmp = msg.GetValue(L"to");
+ if (!tmp.IsEmpty())
+ {
+ // cc
+ String tmpCc = msg.GetValue(L"cc");
+ if (!tmpCc.IsEmpty())
+ {
+ tmp.Append(L';' + tmpCc);
+ }
+
+ // bcc
+ String tmpBcc = msg.GetValue(L"bcc");
+ if (!tmpBcc.IsEmpty())
+ {
+ tmp.Append(L';' + tmpBcc);
+ }
+
+ tmp.Replace(L';', L',');
+ msg.AddData(SERVICE_DATA_TO, tmp);
+ }
+
+ // subject
+ tmp = msg.GetValue(L"subject");
+ if (!tmp.IsEmpty())
+ {
+ SysLog(NID_APP, "subject: [%ls]", tmp.GetPointer());
+ msg.AddData(SERVICE_DATA_SUBJECT, tmp);
+ }
+
+ // text
+ tmp = msg.GetValue(L"text");
+ if (!tmp.IsEmpty())
+ {
+ SysLog(NID_APP, "text: [%ls]", tmp.GetPointer());
+ msg.AddData(SERVICE_DATA_TEXT, tmp);
+ }
+
+ const String& path = msg.GetValue(APP_CONTROL_ATTACH_PATH);
+ if (path.IsEmpty())
+ {
+ ArrayList list;
+ list.Construct();
+
+ // vcard
+ const String& tmpVcard = msg.GetValue(L"attachVcard");
+ if (!tmpVcard.IsEmpty())
+ {
+ list.Add(tmpVcard);
+ }
+
+ // vcalendar
+ const String& tmpVcal = msg.GetValue(L"attachVcalendar");
+ if (!tmpVcal.IsEmpty())
+ {
+ list.Add(tmpVcal);
+ }
+
+ // video
+ const String& tmpVideo = msg.GetValue(L"attachVideo");
+ if (!tmpVideo.IsEmpty())
+ {
+ list.Add(tmpVideo);
+ }
+
+ // image
+ const String& tmpImage = msg.GetValue(L"attachImage");
+ if (!tmpImage.IsEmpty())
+ {
+ list.Add(tmpImage);
+ }
+
+ // audio
+ const String& tmpAudio = msg.GetValue(L"attachAudio");
+ if (!tmpAudio.IsEmpty())
+ {
+ list.Add(tmpAudio);
+ }
+
+ if (list.GetCount() != 0)
+ {
+ SysLog(NID_APP, "Attaching %d items.", list.GetCount());
+
+ _AppMessageImpl::AddValueArray(msg.GetBundle(), APP_CONTROL_ATTACH_PATH, &list);
+ //msg.AddValueArray(APP_CONTROL_ATTACH_PATH, &list);
+ }
+ }
+
+ __req = req;
+ __processId = _AppControlManager::GetInstance()->Launch(msg, OnAppControlResult, 0);
+
+ r = GetLastResult();
+ SysTryReturnResult(NID_APP, __processId >= 0, r, "StartAppControl: Launching Email AppControl is failed.");
+
+ if (pPid)
+ {
+ *pPid = __processId;
+ }
+
+ SysLog(NID_APP, "StartAppControl: Launching Message AppControl succeeded.");
+ }
+ if (isEmail)
+ {
+ SysLog(NID_APP, "Email AppControl starts..");
+
+ String tmp = msg.GetValue(L"to");
+ if (!tmp.IsEmpty())
+ {
+ msg.AddData(SERVICE_DATA_TO, tmp);
+ }
+
+ tmp = msg.GetValue(L"cc");
+ if (!tmp.IsEmpty())
+ {
+ msg.AddData(SERVICE_DATA_CC, tmp);
+ }
+
+ tmp = msg.GetValue(L"bcc");
+ if (!tmp.IsEmpty())
+ {
+ msg.AddData(SERVICE_DATA_BCC, tmp);
+ }
+
+ tmp = msg.GetValue(L"subject");
+ if (!tmp.IsEmpty())
+ {
+ msg.AddData(SERVICE_DATA_SUBJECT, tmp);
+ }
+
+ tmp = msg.GetValue(L"text");
+ if (!tmp.IsEmpty())
+ {
+ msg.AddData(SERVICE_DATA_TEXT, tmp);
+ }
+
+ tmp = msg.GetValue(L"attachments");
+ if (!tmp.IsEmpty())
+ {
+ const String& path = msg.GetValue(APP_CONTROL_ATTACH_PATH);
+ // if path is delivered, then ignore "attachments" data
+ if (path.IsEmpty())
+ {
+ const String delim = L";";
+ StringTokenizer strTok(tmp, delim);
+
+ const int count = strTok.GetTokenCount();
+ if (count > 0)
+ {
+ ArrayList list(SingleObjectDeleter);
+ list.Construct();
+
+ String token;
+ while (strTok.HasMoreTokens())
+ {
+ strTok.GetNextToken(token);
+ list.Add(new (std::nothrow) String(token));
+ }
+
+ _AppMessageImpl::AddValueArray(msg.GetBundle(), APP_CONTROL_ATTACH_PATH, &list);
+ //msg.AddValueArray(APP_CONTROL_ATTACH_PATH, &list);
+ }
+ }
+ }
+
+ __req = req;
+ __processId = _AppControlManager::GetInstance()->Launch(msg, OnAppControlResult, 0);
+
+ r = GetLastResult();
+ SysTryReturnResult(NID_APP, __processId >= 0, r, "StartAppControl: Launching Email AppControl is failed.");
+ if (pPid)
+ {
+ *pPid = __processId;
+ }
+
+ SysLog(NID_APP, "StartAppControl: Launching Email AppControl succeeded.");
+ }
+
+ return r;
+}
+
+
+result
+_AppControlPlugin::StopAppControlPlugin(int req)
+{
+ if (__processId >= 0)
+ {
+ result r = _AppControlPluginUtil::SendStopRequest(__processId);
+ SysTryReturnResult(NID_APP, !IsFailed(r), r, "Failed to send stop request to %d.", __processId);
+
+ SysLog(NID_APP, "Process %d is terminated.", __processId);
+ __processId = -1;
+ }
+
+ return E_SUCCESS;
+}
+
+
+void
+_AppControlPlugin::OnAppControlResult(void* b, int requestCode, service_result_e res, void* userData)
+{
+ SysLog(NID_APP, "OnAppControlResult with %d.", res);
+
+ result r = E_SYSTEM;
+ //int req = -1;
+ bundle* pBundle = static_cast<bundle*>(b);
+
+ HashMap* pResult = new (std::nothrow) HashMap();
+ SysTryCatch(NID_APP, pResult != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Allocation failure.");
+
+ r = pResult->Construct();
+
+ _AppArg::SetArgMap(pBundle, pResult);
+
+ _AppControlManager::GetInstance()->FinishAppControl(__req, res, pResult);
+
+CATCH:
+ __processId = -1;
+ __req = -1;
+}
+
+}
+
+extern "C" _OSP_EXPORT_ _IAppControlPluginProvider*
+GetAppControlProviderPlugin(void)
+{
+ return new (std::nothrow) _AppControlPlugin;
+}
+
--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+SET (this_target nfc-push-ui-app-control)
+SET (APPID 42KriKjov3)
+
+SET(CMAKE_EXECUTABLE_SUFFIX ".exe")
+SET(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/output")
+
+INCLUDE_DIRECTORIES (
+ ${COMMON_INCLUDE_DIRS}
+ inc
+ )
+
+SET (${this_target}_SOURCE_FILES
+ src/NfcPushUi.cpp
+ src/NfcPushUiEntry.cpp
+ src/NfcPushUiForm.cpp
+ src/NfcPushUiFrame.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 -pie)
+TARGET_LINK_LIBRARIES(${this_target} -Xlinker --version-script=${CMAKE_CURRENT_SOURCE_DIR}/system-service-export.ver)
+TARGET_LINK_LIBRARIES(${this_target} ${pkgs_LDFLAGS})
+TARGET_LINK_LIBRARIES(${this_target} -L/usr/lib/osp -losp-nfc -losp-uifw -losp-image -losp-image-core -lchromium)
+
+## strip
+EXE_STRIP(${this_target})
+
+## Copy 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}/res DESTINATION ../usr/apps/${APPID})
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+* @file NfcPushUi.h
+* @brief This file contains the declaration of NfcPushUiApp class.
+*/
+
+#ifndef _NFC_PUSH_UI_H_
+#define _NFC_PUSH_UI_H_
+
+#include <FAppUiApp.h>
+#include <FAppIAppControlProviderEventListener.h>
+#include <FSysIScreenEventListener.h>
+
+class NfcPushUiApp
+ : public Tizen::App::UiApp
+ , public Tizen::System::IScreenEventListener
+ , public Tizen::App::IAppControlProviderEventListener
+{
+public:
+ static Tizen::App::UiApp* CreateInstance(void);
+
+public:
+ NfcPushUiApp(void);
+ virtual~NfcPushUiApp(void);
+
+public:
+ // Called when the UiApp is initializing.
+ bool OnAppInitializing(Tizen::App::AppRegistry& appRegistry);
+
+ // Called when the UiApp initializing is finished.
+ bool OnAppInitialized(void);
+
+ // Called when the UiApp is requested to terminate.
+ bool OnAppWillTerminate(void);
+
+ // Called when the UiApp is terminating.
+ bool OnAppTerminating(Tizen::App::AppRegistry& appRegistry, bool forcedTermination = false);
+
+ // Called when the UiApp's frame moves to the top of the screen.
+ void OnForeground(void);
+
+ // Called when this UiApp's frame is moved from top of the screen to the background.
+ void OnBackground(void);
+
+ // Called when the system memory is not sufficient to run the UiApp any further.
+ void OnLowMemory(void);
+
+ // Called when the battery level changes.
+ void OnBatteryLevelChanged(Tizen::System::BatteryLevel batteryLevel);
+
+ // Called when the screen turns on.
+ void OnScreenOn(void);
+
+ // Called when the screen turns off.
+ void OnScreenOff(void);
+
+ // IAppControlProviderEventListener
+ virtual void OnAppControlRequestReceived(RequestId reqId, const Tizen::Base::String& operationId, const Tizen::Base::String* pUriData, const Tizen::Base::String* pMimeType, const Tizen::Base::Collection::IMap* pExtraData);
+
+private:
+ RequestId __reqId;
+ Tizen::Base::String __iconPath;
+ Tizen::Base::String __description;
+};
+
+#endif // _NFC_PUSH_UI_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+* @file NfcPushUiForm.h
+* @brief This file contains the declaration of NfcPushUiForm class.
+*/
+
+#ifndef _NFC_PUSH_UI_FORM_H_
+#define _NFC_PUSH_UI_FORM_H_
+
+#include <FGrpRectangle.h>
+#include <FUiCtrlForm.h>
+#include <FUiITouchEventListener.h>
+#include <FNetNfcINfcDeviceDiscoveryEventListener.h>
+#include <FNetNfcINfcManagerEventListener.h>
+#include <FNetNfcNfcManager.h>
+#include <FUiAnimIVisualElementAnimationStatusEventListener.h>
+
+class NfcPushUiForm
+ : public Tizen::Ui::Controls::Form
+ , public Tizen::Ui::ITouchEventListener
+ , public Tizen::Net::Nfc::INfcDeviceDiscoveryEventListener
+ , public Tizen::Net::Nfc::INfcManagerEventListener
+ , public Tizen::Ui::Animations::IVisualElementAnimationStatusEventListener
+{
+public:
+ NfcPushUiForm(void);
+ virtual ~NfcPushUiForm(void);
+ bool Initialize(RequestId reqId, const Tizen::Graphics::Rectangle& rect);
+ void SetAppInfo(const Tizen::Base::String& iconPath, const Tizen::Base::String& description);
+
+public:
+ result DrawAppInfoToCanvas(const Tizen::Graphics::Rectangle& rect, Tizen::Graphics::Canvas* pCanvas);
+ result DrawGuideTextToCanvas(const Tizen::Graphics::Rectangle& rect, Tizen::Graphics::Canvas* pCanvas);
+ void FinishAppControl(RequestId reqId, Tizen::App::AppCtrlResult appCtrlResult);
+
+ void PlayBoundsAnimation(const Tizen::Base::String& animationName, int repeatCount, int duration, bool autoReverse = false);
+ void PlayOpacityAnimation(const Tizen::Base::String& animationName, int duration);
+
+public:
+ virtual result OnInitializing(void);
+ virtual result OnTerminating(void);
+
+ result OnDraw(void) { return E_SUCCESS; }
+
+ // ITouchEventListener
+ void OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo & touchInfo) {}
+ void OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo) {}
+ void OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo);
+ void OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo) {}
+ void OnTouchDoublePressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo) {}
+ void OnTouchFocusIn(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo) {}
+ void OnTouchFocusOut(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo) {}
+ void OnTouchCanceled(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo) {}
+
+ //IVisualElementAnimationStatusEventListener
+ virtual void OnVisualElementAnimationStarted(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target){}
+ virtual void OnVisualElementAnimationRepeated(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, long currentRepeatCount){}
+ virtual void OnVisualElementAnimationFinished(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, bool completedNormally);
+
+ // INfcDeviceDiscoveryEventListener
+ virtual void OnNfcDeviceDetected(void) {}
+ virtual void OnNfcDeviceLost(void);
+
+ // INfcManagerEventListener
+ virtual void OnNfcActivated(result r) {}
+ virtual void OnNfcDeactivated(result r) {}
+
+public:
+ static const int _DURATION_GROW_ = 667;
+ static const int _DURATION_REPEAT_ = 516;
+ static const int _DURATION_OPACITY_ICON_APPEAR_ = 497;
+ static const int _DURATION_OPACITY_BACKGROUND_ = 333;
+ static const int _DURATION_OPACITY_ICON_DISAPPEAR_ = 431;
+
+ static const int _DELAY_GROW_ = 167;
+ static const int _DELAY_BACKGROUND_DISAPPEAR_ = 500;
+ static const int _DELAY_GUIDE_TEXT_DISAPPEAR_ = 500;
+ static const int _DELAY_APPINFO_TEXT_DISAPPEAR_ = 500;
+ static const int _DELAY_OPACITY_ICON_APPEAR_ = 336;
+
+ static const int _GUIDE_TEXT_WIDTH_ = 720;
+ static const int _GUIDE_TEXT_HEIGHT_ = 42;
+ static const int _GUIDE_TEXT_COORDINATES_X_ = 0;
+ static const int _GUIDE_TEXT_COORDINATES_Y_ = 250;
+ static const int _APPINFO_TEXT_WIDTH_ = 720;
+ static const int _APPINFO_TEXT_HEIGHT_ = 42;
+ static const int _APPINFO_TEXT_COORDINATES_X_ = 0;
+ static const int _APPINFO_TEXT_COORDINATES_Y_ = 770;
+ static const int _CIRCLE_WIDTH_ = 242;
+ static const int _CIRCLE_HEIGHT_ = 242;
+ static const int _CIRCLE_COORDINATES_X_ = 239;
+ static const int _CIRCLE_COORDINATES_Y_ = 486;
+ static const int _ICON_WIDTH_ = 106;
+ static const int _ICON_HEIGHT_ = 106;
+ static const int _ICON_COORDINATES_X_ = 307;
+ static const int _ICON_COORDINATES_Y_ = 554;
+
+
+private:
+ RequestId __reqId;
+ Tizen::Graphics::Rectangle __rect;
+ Tizen::Base::String __iconPath;
+ Tizen::Base::String __description;
+ Tizen::Net::Nfc::NfcManager* __pNfcManager;
+ Tizen::Ui::Animations::VisualElement* __pVisualElementBounds;
+ Tizen::Ui::Animations::VisualElement* __pVisualElementOpacity;
+ Tizen::Ui::Animations::VisualElement* __pVisualElementBackground;
+ Tizen::Ui::Animations::VisualElement* __pVisualElementGuideText;
+ Tizen::Ui::Animations::VisualElement* __pVisualElementAppInfo;
+ Tizen::Ui::Animations::VisualElement* __pVisualElement;
+ Tizen::Graphics::FloatRectangle __startRect;
+ Tizen::Graphics::FloatRectangle __endRect;
+ float __startOpacity;
+ float __endOpacity;
+};
+
+#endif //_NFC_PUSH_UI_FORM_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+* @file NfcPushUiFrame.h
+* @brief This file contains the declaration of NfcPushUiFrame class.
+*/
+
+#ifndef _NFC_PUSH_UI_FRAME_H_
+#define _NFC_PUSH_UI_FRAME_H_
+
+#include <FUiCtrlFrame.h>
+
+class NfcPushUiFrame
+ : public Tizen::Ui::Controls::Frame
+{
+public:
+ NfcPushUiFrame(void);
+ virtual ~NfcPushUiFrame(void);
+
+ void SetRequestId(RequestId reqId);
+ void SetAppInfo(const Tizen::Base::String& iconPath, const Tizen::Base::String& description);
+
+public:
+ virtual result OnInitializing(void);
+ virtual result OnTerminating(void);
+
+private:
+ RequestId __reqId;
+ Tizen::Base::String __iconPath;
+ Tizen::Base::String __description;
+};
+
+#endif //_NFC_PUSH_UI_FRAME_H_
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<Manifest xmlns="http://schemas.tizen.org/2012/06/manifest">
+ <Id>42KriKjov3</Id>
+ <Version>1.0.0</Version>
+ <Type>C++App</Type>
+ <Vendors></Vendors>
+ <Descriptions></Descriptions>
+ <Url></Url>
+ <Apps>
+ <ApiVersion>3.0</ApiVersion>
+ <Privileges>
+ <Privilege>http://tizen.org/privilege/nfc.common</Privilege>
+ <Privilege>http://tizen.org/privilege/nfc.p2p</Privilege>
+ <Privilege>http://tizen.org/privilege/systeminfo</Privilege>
+ <Privilege>http://tizen.org/privilege/inputmanager</Privilege>
+ </Privileges>
+ <UiApp ExecutableName="nfc-push-ui-app-control" Default="True" MainmenuVisible="True" MenuIconVisible="False">
+ <UiScalability CoordinateSystem="Logical" BaseScreenSize="Normal" LogicalCoordinate="720"></UiScalability>
+ <UiTheme SystemTheme="White"></UiTheme>
+ <Names>
+ <Name Locale="eng-GB">NfcPushUi</Name>
+ </Names>
+ <Icons>
+ <Icon Section="MainMenu" Type="Xhigh">mainmenu.png</Icon>
+ </Icons>
+ <LaunchConditions></LaunchConditions>
+ <Notifications></Notifications>
+ </UiApp>
+ </Apps>
+</Manifest>
--- /dev/null
+<manifest>
+ <define>
+ <domain name="nfc-push-ui-app-control"/>
+ </define>
+ <request>
+ <domain name="nfc-push-ui-app-control"/>
+ </request>
+ <assign>
+ <filesystem path="/usr/apps/42KriKjov3/bin/nfc-push-ui-app-control.exe" label="nfc-push-ui-app-control" exec_label="nfc-push-ui-app-control"/>
+ <filesystem path="/usr/share/license/nfc-push-ui-app-control" label="_"/>
+ </assign>
+</manifest>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<string_table Bversion="2.0.0.201304241223" Dversion="20120315">
+ <text id="IDS_NFC_BODY_TAP_TO_SEND">انقر للإرسال</text>
+</string_table>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<string_table Bversion="2.0.0.201304241223" Dversion="20120315">
+ <text id="IDS_NFC_BODY_TAP_TO_SEND">Göndəmək üçün vurun</text>
+</string_table>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<string_table Bversion="2.0.0.201304241223" Dversion="20120315">
+ <text id="IDS_NFC_BODY_TAP_TO_SEND">Чукнете, за да изпратите</text>
+</string_table>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<string_table Bversion="2.0.0.201304241223" Dversion="20120315">
+ <text id="IDS_NFC_BODY_TAP_TO_SEND">Tocar per enviar</text>
+</string_table>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<string_table Bversion="2.0.0.201304241223" Dversion="20120315">
+ <text id="IDS_NFC_BODY_TAP_TO_SEND">Klepnutím odešlete</text>
+</string_table>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<string_table Bversion="2.0.0.201304241223" Dversion="20120315">
+ <text id="IDS_NFC_BODY_TAP_TO_SEND">Tap for at sende</text>
+</string_table>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<string_table Bversion="2.0.0.201304241223" Dversion="20120315">
+ <text id="IDS_NFC_BODY_TAP_TO_SEND">Zum Senden tippen</text>
+</string_table>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<string_table Bversion="2.0.0.201304241223" Dversion="20120315">
+ <text id="IDS_NFC_BODY_TAP_TO_SEND">Πατήστε για την αποστολή</text>
+</string_table>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<string_table Bversion="2.0.0.201304241223" Dversion="20120315">
+ <text id="IDS_NFC_BODY_TAP_TO_SEND">Tap to send</text>
+</string_table>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<string_table Bversion="2.0.0.201304241223" Dversion="20120315">
+ <text id="IDS_NFC_BODY_TAP_TO_SEND">Tap to send</text>
+</string_table>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<string_table Bversion="2.0.0.201304241223" Dversion="20120315">
+ <text id="IDS_NFC_BODY_TAP_TO_SEND">Tap to send</text>
+</string_table>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<string_table Bversion="2.0.0.201304241223" Dversion="20120315">
+ <text id="IDS_NFC_BODY_TAP_TO_SEND">Toksake, et saata</text>
+</string_table>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<string_table Bversion="2.0.0.201304241223" Dversion="20120315">
+ <text id="IDS_NFC_BODY_TAP_TO_SEND">Ukitu bidaltzeko</text>
+</string_table>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<string_table Bversion="2.0.0.201304241223" Dversion="20120315">
+ <text id="IDS_NFC_BODY_TAP_TO_SEND">Lähetä napauttamalla</text>
+</string_table>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<string_table Bversion="2.0.0.201304241223" Dversion="20120315">
+ <text id="IDS_NFC_BODY_TAP_TO_SEND">Touchez pour envoyer</text>
+</string_table>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<string_table Bversion="2.0.0.201304241223" Dversion="20120315">
+ <text id="IDS_NFC_BODY_TAP_TO_SEND">Appuyez pour envoyer</text>
+</string_table>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<string_table Bversion="2.0.0.201304241223" Dversion="20120315">
+ <text id="IDS_NFC_BODY_TAP_TO_SEND">Tapáil le seoladh</text>
+</string_table>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<string_table Bversion="2.0.0.201304241223" Dversion="20120315">
+ <text id="IDS_NFC_BODY_TAP_TO_SEND">Tocar para enviar</text>
+</string_table>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<string_table Bversion="2.0.0.201304241223" Dversion="20120315">
+ <text id="IDS_NFC_BODY_TAP_TO_SEND">भेजने के लिए टैप करें</text>
+</string_table>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<string_table Bversion="2.0.0.201304241223" Dversion="20120315">
+ <text id="IDS_NFC_BODY_TAP_TO_SEND">Dotaknite za slanje</text>
+</string_table>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<string_table Bversion="2.0.0.201304241223" Dversion="20120315">
+ <text id="IDS_NFC_BODY_TAP_TO_SEND">Érintse meg a küldéshez</text>
+</string_table>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<string_table Bversion="2.0.0.201304241223" Dversion="20120315">
+ <text id="IDS_NFC_BODY_TAP_TO_SEND">Թակեք ուղարկելու համար</text>
+</string_table>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<string_table Bversion="2.0.0.201304241223" Dversion="20120315">
+ <text id="IDS_NFC_BODY_TAP_TO_SEND">Pikkaðu til að senda</text>
+</string_table>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<string_table Bversion="2.0.0.201304241223" Dversion="20120315">
+ <text id="IDS_NFC_BODY_TAP_TO_SEND">Tocca per inviare</text>
+</string_table>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<string_table Bversion="2.0.0.201304241223" Dversion="20120315">
+ <text id="IDS_NFC_BODY_TAP_TO_SEND">タップして送信します。</text>
+</string_table>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<string_table Bversion="2.0.0.201304241223" Dversion="20120315">
+ <text id="IDS_NFC_BODY_TAP_TO_SEND">შეეხეთ და გაგზავნეთ</text>
+</string_table>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<string_table Bversion="2.0.0.201304241223" Dversion="20120315">
+ <text id="IDS_NFC_BODY_TAP_TO_SEND">Жіберу үшін түртіңіз</text>
+</string_table>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<string_table Bversion="2.0.0.201304241223" Dversion="20120315">
+ <text id="IDS_NFC_BODY_TAP_TO_SEND">전송하려면 누르세요</text>
+</string_table>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<string_table Bversion="2.0.0.201304241223" Dversion="20120315">
+ <text id="IDS_NFC_BODY_TAP_TO_SEND">Pieskarieties, lai sūtītu</text>
+</string_table>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<string_table Bversion="2.0.0.201304241223" Dversion="20120315">
+ <text id="IDS_NFC_BODY_TAP_TO_SEND">Bakstelėkite ir išsiųskite žinutę</text>
+</string_table>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<string_table Bversion="2.0.0.201304241223" Dversion="20120315">
+ <text id="IDS_NFC_BODY_TAP_TO_SEND">Допрете за праќање</text>
+</string_table>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<string_table Bversion="2.0.0.201304241223" Dversion="20120315">
+ <text id="IDS_NFC_BODY_TAP_TO_SEND">Tik om te verzenden</text>
+</string_table>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<string_table Bversion="2.0.0.201304241223" Dversion="20120315">
+ <text id="IDS_NFC_BODY_TAP_TO_SEND">Trykk for å sende</text>
+</string_table>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<string_table Bversion="2.0.0.201304241223" Dversion="20120315">
+ <text id="IDS_NFC_BODY_TAP_TO_SEND">Dotknij, aby wysłać</text>
+</string_table>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<string_table Bversion="2.0.0.201304241223" Dversion="20120315">
+ <text id="IDS_NFC_BODY_TAP_TO_SEND">Toque para enviar</text>
+</string_table>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<string_table Bversion="2.0.0.201304241223" Dversion="20120315">
+ <text id="IDS_NFC_BODY_TAP_TO_SEND">Tocar para enviar</text>
+</string_table>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<string_table Bversion="2.0.0.201304241223" Dversion="20120315">
+ <text id="IDS_NFC_BODY_TAP_TO_SEND">Atingeţi pentru a trimite</text>
+</string_table>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<string_table Bversion="2.0.0.201304241223" Dversion="20120315">
+ <text id="IDS_NFC_BODY_TAP_TO_SEND">Нажмите для отправки</text>
+</string_table>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<string_table Bversion="2.0.0.201304241223" Dversion="20120315">
+ <text id="IDS_NFC_BODY_TAP_TO_SEND">Ťuknutím vykonáte odoslanie</text>
+</string_table>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<string_table Bversion="2.0.0.201304241223" Dversion="20120315">
+ <text id="IDS_NFC_BODY_TAP_TO_SEND">Pritisnite za pošiljanje</text>
+</string_table>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<string_table Bversion="2.0.0.201304241223" Dversion="20120315">
+ <text id="IDS_NFC_BODY_TAP_TO_SEND">Toque para enviar</text>
+</string_table>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<string_table Bversion="2.0.0.201304241223" Dversion="20120315">
+ <text id="IDS_NFC_BODY_TAP_TO_SEND">Pulsar enviar</text>
+</string_table>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<string_table Bversion="2.0.0.201304241223" Dversion="20120315">
+ <text id="IDS_NFC_BODY_TAP_TO_SEND">Kucni za slanje</text>
+</string_table>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<string_table Bversion="2.0.0.201304241223" Dversion="20120315">
+ <text id="IDS_NFC_BODY_TAP_TO_SEND">Tryck för att skicka</text>
+</string_table>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<string_table Bversion="2.0.0.201304241223" Dversion="20120315">
+ <text id="IDS_NFC_BODY_TAP_TO_SEND">Göndermek için dokunun</text>
+</string_table>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<string_table Bversion="2.0.0.201304241223" Dversion="20120315">
+ <text id="IDS_NFC_BODY_TAP_TO_SEND">Натисніть щоб відправити</text>
+</string_table>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<string_table Bversion="2.0.0.201304241223" Dversion="20120315">
+ <text id="IDS_NFC_BODY_TAP_TO_SEND">Yuborish uchun cherting</text>
+</string_table>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<string_table Bversion="2.0.0.201304241223" Dversion="20120315">
+ <text id="IDS_NFC_BODY_TAP_TO_SEND">轻敲以发送</text>
+</string_table>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<string_table Bversion="2.0.0.201304241223" Dversion="20120315">
+ <text id="IDS_NFC_BODY_TAP_TO_SEND">輕觸以發送</text>
+</string_table>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<string_table Bversion="2.0.0.201304241223" Dversion="20120315">
+ <text id="IDS_NFC_BODY_TAP_TO_SEND">轻敲以发送</text>
+</string_table>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<string_table Bversion="2.0.0.201304241223" Dversion="20120315">
+ <text id="IDS_NFC_BODY_TAP_TO_SEND">輕觸以發送</text>
+</string_table>
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+* @file NfcPushUi.cpp
+* @brief This file contains the implementation of NfcPushUi class.
+*/
+
+#include <FBaseSysLog.h>
+#include <FAppAppControlProviderManager.h>
+#include <FApp_AppMessageImpl.h>
+#include <FGraphics.h>
+#include "NfcPushUi.h"
+#include "NfcPushUiFrame.h"
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::System;
+using namespace Tizen::Ui;
+using namespace Tizen::Ui::Controls;
+using namespace Tizen::Graphics;
+
+NfcPushUiApp::NfcPushUiApp(void) : __reqId(-1)
+{
+}
+
+NfcPushUiApp::~NfcPushUiApp(void)
+{
+}
+
+UiApp*
+NfcPushUiApp::CreateInstance(void)
+{
+ // Create the instance through the constructor.
+ return new NfcPushUiApp();
+}
+
+bool
+NfcPushUiApp::OnAppInitializing(AppRegistry& appRegistry)
+{
+ // SetAppControlProviderEventListener - to get reqId of this app
+ result r = Tizen::App::AppControlProviderManager::GetInstance()->SetAppControlProviderEventListener(this);
+ SysTryReturn(NID_NET_NFC, r == E_SUCCESS, false, r, "[%s] exception occurred.", GetErrorMessage(r));
+
+ return true;
+}
+
+bool
+NfcPushUiApp::OnAppInitialized(void)
+{
+ // Create a Frame
+ NfcPushUiFrame* pNfcPushUiFrame = new NfcPushUiFrame();
+ pNfcPushUiFrame->Construct();
+ pNfcPushUiFrame->SetName(L"NfcPushUi");
+ pNfcPushUiFrame->SetRequestId(__reqId);
+ pNfcPushUiFrame->SetAppInfo(__iconPath, __description);
+ pNfcPushUiFrame->SetBackgroundColor(Color(0, 0, 0, 0));
+ AddFrame(*pNfcPushUiFrame);
+
+
+ return true;
+}
+
+bool
+NfcPushUiApp::OnAppWillTerminate(void)
+{
+ return true;
+}
+
+
+bool
+NfcPushUiApp::OnAppTerminating(AppRegistry& appRegistry, bool forcedTermination)
+{
+ return true;
+}
+
+void
+NfcPushUiApp::OnForeground(void)
+{
+}
+
+void
+NfcPushUiApp::OnBackground(void)
+{
+}
+
+void
+NfcPushUiApp::OnLowMemory(void)
+{
+}
+
+void
+NfcPushUiApp::OnBatteryLevelChanged(BatteryLevel batteryLevel)
+{
+}
+
+void
+NfcPushUiApp::OnScreenOn(void)
+{
+}
+
+void
+NfcPushUiApp::OnScreenOff(void)
+{
+}
+
+void
+NfcPushUiApp::OnAppControlRequestReceived(RequestId reqId, const Tizen::Base::String& operationId, const Tizen::Base::String* pUriData, const Tizen::Base::String* pMimeType, const Tizen::Base::Collection::IMap* pExtraData)
+{
+ SysLog(NID_NET_NFC, "nfc-push-ui-app-control RequestId [%d]", reqId);
+
+ __reqId = reqId;
+
+ SysTryReturnVoidResult(NID_NET_NFC, pExtraData != null, E_OPERATION_FAILED, "[E_OPERATION_FAILED] There is no extra data.");
+
+ // set extra data
+ _AppMessageImpl msg;
+ msg.AddData(pExtraData);
+
+ __iconPath = msg.GetValue(L"iconPath");
+ __description = msg.GetValue(L"description");
+}
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+* @file NfcPushUiEntry.cpp
+* @brief This file contains the Tizen application entry point.
+*/
+
+#include <FBaseSysLog.h>
+#include "NfcPushUi.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif // __cplusplus
+
+_EXPORT_ int OspMain(int argc, char *pArgv[]);
+
+/**
+ * The entry function of Tizen application called by the operating system.
+ */
+int
+OspMain(int argc, char *pArgv[])
+{
+ result r = E_SUCCESS;
+
+ SysLog(NID_NET_NFC,"Application started.[%d]", argc);
+ ArrayList* pArgs = new ArrayList();
+ pArgs->Construct();
+ for (int i = 0; i < argc; i++)
+ {
+ pArgs->Add(*(new String(pArgv[i])));
+ }
+
+ r = Tizen::App::UiApp::Execute(NfcPushUiApp::CreateInstance, pArgs);
+ if (IsFailed(r))
+ {
+ SysLogException(NID_NET_NFC, r, "Application execution failed-[%s].", GetErrorMessage(r));
+ r &= 0x0000FFFF;
+ }
+
+ pArgs->RemoveAll(true);
+ delete pArgs;
+ SysLog(NID_NET_NFC,"Application finished.");
+
+ return static_cast<int>(r);
+}
+#ifdef __cplusplus
+}
+#endif // __cplusplus
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+* @file NfcPushUiForm.cpp
+* @brief This file contains the implementation of NfcPushUiForm class.
+*/
+
+#include <unique_ptr.h>
+#include <FAppApp.h>
+#include <FAppAppControl.h>
+#include <FAppAppResource.h>
+#include <FAppAppControlProviderManager.h>
+#include <FUiAnimVisualElement.h>
+#include <FUiSystemUtil.h>
+#include <FUiAnimAnimationTransaction.h>
+#include <FUiAnimEaseInOutTimingFunction.h>
+#include <FUiAnimVisualElementPropertyAnimation.h>
+#include <FBaseSysLog.h>
+#include <FBaseColAllElementsDeleter.h>
+#include <FIoFile.h>
+#include <FMediaImage.h>
+#include "NfcPushUiForm.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::App;
+using namespace Tizen::Ui;
+using namespace Tizen::Ui::Controls;
+using namespace Tizen::Ui::Animations;
+using namespace Tizen::Graphics;
+using namespace Tizen::Net::Nfc;
+using namespace Tizen::Media;
+
+NfcPushUiForm::NfcPushUiForm(void)
+ : __reqId(-1)
+ , __rect()
+ , __iconPath()
+ , __description()
+ , __pNfcManager(null)
+ , __pVisualElementBounds(null)
+ , __pVisualElementOpacity(null)
+ , __pVisualElementBackground(null)
+ , __pVisualElementGuideText(null)
+ , __pVisualElementAppInfo(null)
+ , __pVisualElement(null)
+ , __startRect()
+ , __endRect()
+ , __startOpacity(0.0f)
+ , __endOpacity(0.0f)
+{
+}
+
+NfcPushUiForm::~NfcPushUiForm(void)
+{
+ delete __pNfcManager;
+
+ if (__pVisualElement)
+ {
+ __pVisualElement->Destroy();
+ }
+}
+
+bool
+NfcPushUiForm::Initialize(RequestId reqId, const Tizen::Graphics::Rectangle& rect)
+{
+ result r = E_SUCCESS;
+ std::unique_ptr<NfcManager> pNfcManager;
+
+ r = Construct(FORM_STYLE_NORMAL);
+ SysTryReturn(NID_NET_NFC, r == E_SUCCESS, false, r, "[%s] exception occurred.", GetErrorMessage(r));
+
+ // set app size
+ __rect = rect;
+
+ // set request ID
+ __reqId = reqId;
+
+ // NfcManager
+ pNfcManager.reset(new (std::nothrow) NfcManager());
+ SysTryCatch(NID_NET_NFC, pNfcManager != null, r = E_OUT_OF_MEMORY, r, "[%s] exception occurred.", GetErrorMessage(r));
+
+ // construct
+ r = pNfcManager->Construct(*this);
+ SysTryCatch(NID_NET_NFC, r == E_SUCCESS, , r, "[%s] exception occurred.", GetErrorMessage(r));
+
+ // set INfcDeviceDiscoveryEventListener
+ r = pNfcManager->AddDeviceDiscoveryEventListener(*this);
+ SysTryCatch(NID_NET_NFC, r == E_SUCCESS, , r, "[%s] exception occurred.", GetErrorMessage(r));
+
+ __pNfcManager = pNfcManager.release();
+
+ return true;
+
+CATCH:
+ FinishAppControl(__reqId, APP_CTRL_RESULT_FAILED);
+ return false;
+}
+
+void
+NfcPushUiForm::SetAppInfo(const String& iconPath, const String& description)
+{
+ // icon path
+ if (Tizen::Io::File::IsFileExist(iconPath))
+ {
+ __iconPath = iconPath;
+ }
+ else // if icon path is empty, use default icon.
+ {
+ SysLog(NID_NET_NFC, "There is not such icon. [%ls]", iconPath.GetPointer());
+ __iconPath = App::GetInstance()->GetAppRootPath() + L"res/icon.png";
+ SysLog(NID_NET_NFC, "So use default icon: [%ls]", __iconPath.GetPointer());
+ }
+
+ // description
+ __description = description;
+}
+
+result
+NfcPushUiForm::OnInitializing(void)
+{
+ result r = E_SUCCESS;
+
+ // touch event
+ AddTouchEventListener(*this);
+
+ // visual element
+ __pVisualElement = new (std::nothrow) VisualElement();
+ __pVisualElement->Construct();
+ __pVisualElement->SetName(L"VisualElement");
+ __pVisualElement->SetBounds(FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f));
+ __pVisualElement->SetClipChildrenEnabled(false);
+ __pVisualElement->SetShowState(true);
+ GetVisualElement()->AttachChild(*__pVisualElement);
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // Opacity background
+ ////////////////////////////////////////////////////////////////////////////////
+ Rectangle rect = GetClientAreaBounds();
+ __pVisualElementBackground = new (std::nothrow) VisualElement();
+ __pVisualElementBackground->Construct();
+ __pVisualElementBackground->SetName(L"Background");
+ __pVisualElementBackground->SetBounds(FloatRectangle(0, 0, __rect.width, __rect.height));
+ __pVisualElementBackground->SetShowState(true);
+ __pVisualElementBackground->SetImplicitAnimationEnabled(false);
+ __pVisualElement->AttachChild(*__pVisualElementBackground);
+
+ std::unique_ptr<Canvas> pCanvas(__pVisualElementBackground->GetCanvasN());
+ SysTryReturnResult(NID_NET_NFC, pCanvas != null, E_OUT_OF_MEMORY, "Failed to get canvas.");
+
+ __startOpacity = 0.0f;
+ __endOpacity = 1.0f;
+
+ // darkening
+ pCanvas->SetBackgroundColor(Color(0x00000000));
+ pCanvas->Clear();
+ r = pCanvas->FillRectangle(Color(0xC0000000), rect);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Failed to darken the captured screen.");
+
+ // set an opacity level
+ __pVisualElementBackground->SetOpacity(__startOpacity);
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // Opacity guide text
+ ////////////////////////////////////////////////////////////////////////////////
+ __pVisualElementGuideText = new (std::nothrow) VisualElement();
+ __pVisualElementGuideText->Construct();
+ __pVisualElementGuideText->SetName(L"GuideText");
+ __pVisualElementGuideText->SetBounds(FloatRectangle(_GUIDE_TEXT_COORDINATES_X_, _GUIDE_TEXT_COORDINATES_Y_,
+ _GUIDE_TEXT_WIDTH_, 100));
+ __pVisualElementGuideText->SetShowState(true);
+ __pVisualElementGuideText->SetImplicitAnimationEnabled(false);
+ __pVisualElement->AttachChild(*__pVisualElementGuideText);
+
+ pCanvas.reset(__pVisualElementGuideText->GetCanvasN());
+ SysTryReturnResult(NID_NET_NFC, pCanvas != null, E_OUT_OF_MEMORY, "Failed to get canvas.");
+
+ // draw guide text
+ pCanvas->SetBackgroundColor(Color(0x00000000));
+ pCanvas->Clear();
+ DrawGuideTextToCanvas(rect, pCanvas.get());
+ // set an opacity level
+ __pVisualElementGuideText->SetOpacity(__startOpacity);
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // Opacity app info
+ ////////////////////////////////////////////////////////////////////////////////
+ __pVisualElementAppInfo = new (std::nothrow) VisualElement();
+ __pVisualElementAppInfo->Construct();
+ __pVisualElementAppInfo->SetName(L"AppInfo");
+ __pVisualElementAppInfo->SetBounds(FloatRectangle(_APPINFO_TEXT_COORDINATES_X_, _APPINFO_TEXT_COORDINATES_Y_,
+ _APPINFO_TEXT_WIDTH_, 100));
+ __pVisualElementAppInfo->SetShowState(true);
+ __pVisualElementAppInfo->SetImplicitAnimationEnabled(false);
+ __pVisualElement->AttachChild(*__pVisualElementAppInfo);
+
+ pCanvas.reset(__pVisualElementAppInfo->GetCanvasN());
+ SysTryReturnResult(NID_NET_NFC, pCanvas != null, E_OUT_OF_MEMORY, "Failed to get canvas.");
+
+ // draw app info
+ pCanvas->SetBackgroundColor(Color(0x00000000));
+ pCanvas->Clear();
+ DrawAppInfoToCanvas(rect, pCanvas.get());
+ // set an opacity level
+ __pVisualElementAppInfo->SetOpacity(__startOpacity);
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // bounds
+ ////////////////////////////////////////////////////////////////////////////////
+ __pVisualElementBounds = new (std::nothrow) VisualElement();
+ __pVisualElementBounds->Construct();
+ __pVisualElementBounds->SetName(L"Grow");
+ __pVisualElementBounds->SetBounds(FloatRectangle(_CIRCLE_COORDINATES_X_, _CIRCLE_COORDINATES_Y_, _CIRCLE_WIDTH_, _CIRCLE_HEIGHT_));
+ __pVisualElementBounds->SetShowState(true);
+ __pVisualElementBounds->SetImplicitAnimationEnabled(false);
+ __pVisualElement->AttachChild(*__pVisualElementBounds);
+
+ __endRect = __pVisualElementBounds->GetBounds();
+ __startRect = FloatRectangle(__endRect.x + (_CIRCLE_WIDTH_ / 2), __endRect.y + (_CIRCLE_HEIGHT_ / 2), 0, 0);
+
+ pCanvas.reset(__pVisualElementBounds->GetCanvasN());
+ SysTryReturnResult(NID_NET_NFC, pCanvas != null, E_OUT_OF_MEMORY, "Failed to get canvas.");
+
+ std::unique_ptr<Bitmap> pBitmap;
+ Image image;
+
+ r = image.Construct();
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Failed to construct an Image instance.");
+
+ // decode the bitmap
+ String iconPath = App::GetInstance()->GetAppRootPath() + L"res/bounds.png";
+ pBitmap.reset(image.DecodeN(iconPath, BITMAP_PIXEL_FORMAT_ARGB8888));
+ SysTryReturnResult(NID_NET_NFC, pBitmap != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+ // scale the bitmap
+ r = pBitmap->Scale(Dimension(_CIRCLE_WIDTH_, _CIRCLE_HEIGHT_));
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Failed to scale the bitmap.");
+
+ // draw the bitmap
+ pCanvas->SetBackgroundColor(Color(0x00000000));
+ pCanvas->Clear();
+ r = pCanvas->DrawBitmap(Point(__rect.x, __rect.y), *pBitmap);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Failed to draw the bitmap.");
+
+ __pVisualElementBounds->SetBounds(__startRect);
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // Opacity rectangle
+ ////////////////////////////////////////////////////////////////////////////////
+ __pVisualElementOpacity = new (std::nothrow) VisualElement();
+ __pVisualElementOpacity->Construct();
+ __pVisualElementOpacity->SetName(L"Opacity");
+ __pVisualElementOpacity->SetBounds(FloatRectangle(_ICON_COORDINATES_X_, _ICON_COORDINATES_Y_, _ICON_WIDTH_, _ICON_HEIGHT_));
+ __pVisualElementOpacity->SetShowState(true);
+ __pVisualElementOpacity->SetImplicitAnimationEnabled(false);
+ __pVisualElement->AttachChild(*__pVisualElementOpacity);
+
+ pCanvas.reset(__pVisualElementOpacity->GetCanvasN());
+ SysTryReturnResult(NID_NET_NFC, pCanvas != null, E_OUT_OF_MEMORY, "Failed to get canvas.");
+
+ // decode the bitmap
+ pBitmap.reset(image.DecodeN(__iconPath, BITMAP_PIXEL_FORMAT_ARGB8888));
+ SysTryReturnResult(NID_NET_NFC, pBitmap != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+ // scale the bitmap
+ r = pBitmap->Scale(Dimension(_ICON_WIDTH_, _ICON_HEIGHT_));
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Failed to scale the bitmap.");
+
+ // draw the bitmap
+ pCanvas->SetBackgroundColor(Color(0x00000000));
+ pCanvas->Clear();
+ r = pCanvas->DrawBitmap(Point(__rect.x, __rect.y), *pBitmap);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Failed to draw the bitmap.");
+
+ // set an opacity level
+ __pVisualElementOpacity->SetOpacity(__startOpacity);
+
+ SysLog(NID_NET_NFC, "start to play animation");
+ AnimationTransaction::Begin();
+ PlayOpacityAnimation(L"background_appear", _DURATION_OPACITY_BACKGROUND_);
+ PlayOpacityAnimation(L"guidetext_appear", _DURATION_OPACITY_BACKGROUND_);
+ PlayOpacityAnimation(L"appinfo_appear", _DURATION_OPACITY_BACKGROUND_);
+ PlayBoundsAnimation(L"grow", 1, _DURATION_GROW_);
+ PlayOpacityAnimation(L"icon_appear", _DURATION_OPACITY_ICON_APPEAR_);
+ AnimationTransaction::Commit();
+
+ return r;
+}
+
+result
+NfcPushUiForm::OnTerminating(void)
+{
+ return E_SUCCESS;
+}
+
+result
+NfcPushUiForm::DrawAppInfoToCanvas(const Tizen::Graphics::Rectangle& rect, Tizen::Graphics::Canvas* pCanvas)
+{
+ result r = E_SUCCESS;
+ const int textAreaWidth = rect.width;
+
+ std::unique_ptr<EnrichedText> pEnrichedText(new (std::nothrow) EnrichedText());
+ SysTryReturnResult(NID_NET_NFC, pEnrichedText != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+ std::unique_ptr<TextElement> pTextElement(new (std::nothrow) TextElement());
+ SysTryReturnResult(NID_NET_NFC, pTextElement != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+ r = pEnrichedText->Construct(Dimension(textAreaWidth, 100));
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Failed to construct an enriched text.");
+
+ pEnrichedText->SetHorizontalAlignment(TEXT_ALIGNMENT_CENTER);
+ pEnrichedText->SetVerticalAlignment(TEXT_ALIGNMENT_MIDDLE);
+ pEnrichedText->SetTextWrapStyle(TEXT_WRAP_CHARACTER_WRAP);
+ pEnrichedText->SetTextAbbreviationEnabled(true);
+
+ // Creates a TextElement and sets attributes
+ r = pTextElement->Construct(__description);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Failed to construct a text element.");
+
+ pTextElement->SetTextColor(Color::GetColor(COLOR_ID_WHITE));
+ {
+ Font font;
+ font.Construct(FONT_STYLE_PLAIN, _APPINFO_TEXT_HEIGHT_);
+ pTextElement->SetFont(font);
+ }
+
+ // Adds the TextElement and the bitmap to the EnrichedText
+ pEnrichedText->Add(*pTextElement);
+
+ // Draws the EnrichedText at the specified Point
+ pCanvas->DrawText(Point(__rect.x, __rect.y), *pEnrichedText);
+
+ return r;
+}
+
+result
+NfcPushUiForm::DrawGuideTextToCanvas(const Tizen::Graphics::Rectangle& rect, Tizen::Graphics::Canvas* pCanvas)
+{
+ result r = E_SUCCESS;
+ const int textAreaWidth = rect.width;
+ String sendNotiStr(L"Tap to send");
+ AppResource* pAppResource = App::GetInstance()->GetAppResource();
+
+ if (pAppResource)
+ {
+ pAppResource->GetString(L"IDS_NFC_BODY_TAP_TO_SEND", sendNotiStr);
+ }
+
+ std::unique_ptr<EnrichedText> pEnrichedText(new (std::nothrow) EnrichedText());
+ SysTryReturnResult(NID_NET_NFC, pEnrichedText != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+ std::unique_ptr<TextElement> pTextElement(new (std::nothrow) TextElement());
+ SysTryReturnResult(NID_NET_NFC, pTextElement != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+ r = pEnrichedText->Construct(Dimension(textAreaWidth, 100));
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Failed to construct an enriched text.");
+
+ r = pEnrichedText->SetHorizontalAlignment(TEXT_ALIGNMENT_CENTER);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Failed to set horizontal alignment.");
+
+ pEnrichedText->SetVerticalAlignment(TEXT_ALIGNMENT_MIDDLE);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Failed to set vertical alignment.");
+
+ pEnrichedText->SetTextWrapStyle(TEXT_WRAP_CHARACTER_WRAP);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Failed to set text wrap style.");
+
+ pEnrichedText->SetTextAbbreviationEnabled(true);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Failed to set abbreviation enabled.");
+
+ // Creates a TextElement and sets attributes
+ r = pTextElement->Construct(sendNotiStr);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Failed to construct a text element.");
+
+ pTextElement->SetTextColor(Color::GetColor(COLOR_ID_WHITE));
+ {
+ Font font;
+ font.Construct(FONT_STYLE_PLAIN, _GUIDE_TEXT_HEIGHT_);
+ pTextElement->SetFont(font);
+ }
+
+ // Adds the TextElement and the bitmap to the EnrichedText
+ r = pEnrichedText->Add(*pTextElement);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Failed to add text element to enriched text.");
+
+ // Draws the EnrichedText at the specified Point
+ r = pCanvas->DrawText(Point(__rect.x, __rect.y), *pEnrichedText);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Failed to draw text to canvas.");
+
+ return r;
+}
+
+void
+NfcPushUiForm::PlayBoundsAnimation(const Tizen::Base::String& animationName, int repeatCount, int duration, bool autoReverse)
+{
+ std::unique_ptr<EaseInOutTimingFunction> pTimingFunction;
+ std::unique_ptr<VisualElementPropertyAnimation> pAnimation(new (std::nothrow) VisualElementPropertyAnimation());
+ SysTryReturnVoidResult(NID_NET_NFC, pAnimation != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+ // bounds
+ pAnimation->SetPropertyName(L"bounds");
+ pAnimation->SetStartValue(Variant(__startRect));
+ pAnimation->SetEndValue(Variant(__endRect));
+ pAnimation->SetDuration(duration);
+ pAnimation->SetRepeatCount(repeatCount);
+ pAnimation->SetAutoReverseEnabled(autoReverse);
+ pAnimation->SetVisualElementAnimationStatusEventListener(this);
+ if (animationName == L"grow")
+ {
+ pTimingFunction.reset(new (std::nothrow) EaseInOutTimingFunction());
+ pAnimation->SetDelay(_DELAY_GROW_);
+ pAnimation->SetTimingFunction(pTimingFunction.release());
+ __pVisualElementBounds->AddAnimation(animationName, *pAnimation);
+ }
+ else if (animationName == L"shrink")
+ {
+ pTimingFunction.reset(new (std::nothrow) EaseInOutTimingFunction());
+ pAnimation->SetTimingFunction(pTimingFunction.release());
+ __pVisualElementBounds->AddAnimation(animationName, *pAnimation);
+ }
+ else
+ {
+ __pVisualElementBounds->AddAnimation(animationName, *pAnimation);
+ }
+}
+
+void
+NfcPushUiForm::PlayOpacityAnimation(const Tizen::Base::String& animationName, int duration)
+{
+ std::unique_ptr<VisualElementPropertyAnimation> pAnimation(new (std::nothrow) VisualElementPropertyAnimation());
+ SysTryReturnVoidResult(NID_NET_NFC, pAnimation != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+ //opacity
+ pAnimation->SetPropertyName(L"opacity");
+ pAnimation->SetStartValue(Variant(__startOpacity));
+ pAnimation->SetEndValue(Variant(__endOpacity));
+ pAnimation->SetDuration(duration);
+ pAnimation->SetVisualElementAnimationStatusEventListener(this);
+ if (animationName == L"background_appear")
+ {
+ __pVisualElementBackground->AddAnimation(animationName, *pAnimation);
+ }
+ else if (animationName == L"background_disappear")
+ {
+ pAnimation->SetDelay(_DELAY_BACKGROUND_DISAPPEAR_);
+ __pVisualElementBackground->AddAnimation(animationName, *pAnimation);
+ }
+ else if (animationName == L"guidetext_appear")
+ {
+ __pVisualElementGuideText->AddAnimation(animationName, *pAnimation);
+ }
+ else if (animationName == L"guidetext_disappear")
+ {
+ pAnimation->SetDelay(_DELAY_GUIDE_TEXT_DISAPPEAR_);
+ __pVisualElementGuideText->AddAnimation(animationName, *pAnimation);
+ }
+ else if (animationName == L"appinfo_appear")
+ {
+ __pVisualElementAppInfo->AddAnimation(animationName, *pAnimation);
+ }
+ else if (animationName == L"appinfo_disappear")
+ {
+ pAnimation->SetDelay(_DELAY_APPINFO_TEXT_DISAPPEAR_);
+ __pVisualElementAppInfo->AddAnimation(animationName, *pAnimation);
+ }
+ else if (animationName == L"icon_appear")
+ {
+ pAnimation->SetDelay(_DELAY_OPACITY_ICON_APPEAR_);
+ __pVisualElementOpacity->AddAnimation(animationName, *pAnimation);
+ }
+ else if (animationName == L"icon_disappear")
+ {
+ __pVisualElementOpacity->AddAnimation(animationName, *pAnimation);
+ }
+
+}
+
+void
+NfcPushUiForm::FinishAppControl(RequestId reqId, AppCtrlResult appCtrlResult)
+{
+ result r = E_SUCCESS;
+
+ // send result
+ r = AppControlProviderManager::GetInstance()->SendAppControlResult(reqId, appCtrlResult, null);
+ SysTryReturnVoidResult(NID_NET_NFC, r == E_SUCCESS, r, "[%s] exception occurred.", GetErrorMessage(r));
+
+ // terminate
+ SysLog(NID_NET_NFC, "Terminating this app control. [%d]", __reqId);
+ App::GetInstance()->Terminate();
+}
+
+void
+NfcPushUiForm::OnVisualElementAnimationFinished(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, bool completedNormally)
+{
+ if(completedNormally)
+ {
+ if (keyName == L"icon_appear")
+ {
+ float margin = (__endRect.width * 0.05f) / 2;
+ __startRect = __endRect;
+ __endRect = FloatRectangle(__startRect.x - margin, __startRect.y - margin,
+ __startRect.width + (margin * 2), __startRect.height + (margin * 2));
+
+ // start second animation - repeat
+ PlayBoundsAnimation(L"repeat", 0, _DURATION_REPEAT_, true);
+ }
+ else if (keyName == L"background_disappear")
+ {
+ // finish this app control with success
+
+ // remove the guide text and app info
+ Rectangle rect = GetClientAreaBounds();
+
+ result r = E_SUCCESS;
+
+ FinishAppControl(__reqId, APP_CTRL_RESULT_SUCCEEDED);
+ }
+ }
+}
+
+// ITouchEventListener
+void
+NfcPushUiForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
+{
+ __startOpacity = __endOpacity;
+ __endOpacity = 0.0f;
+
+ // reset the circles size
+ __startRect = __endRect;
+ __endRect = FloatRectangle(_CIRCLE_COORDINATES_X_ + (_CIRCLE_WIDTH_ / 2), _CIRCLE_COORDINATES_Y_ + (_CIRCLE_HEIGHT_ / 2), 0, 0);
+
+ // play animation
+ AnimationTransaction::Begin();
+ PlayOpacityAnimation(L"icon_disappear", _DURATION_OPACITY_ICON_DISAPPEAR_);
+ PlayBoundsAnimation(L"shrink", 1, _DURATION_GROW_, false);
+ PlayOpacityAnimation(L"background_disappear", _DURATION_OPACITY_BACKGROUND_);
+ PlayOpacityAnimation(L"guidetext_disappear", _DURATION_OPACITY_BACKGROUND_);
+ PlayOpacityAnimation(L"appinfo_disappear", _DURATION_OPACITY_BACKGROUND_);
+ AnimationTransaction::Commit();
+}
+
+// INfcDeviceDiscoveryEventListener
+void
+NfcPushUiForm::OnNfcDeviceLost(void)
+{
+ SysLog(NID_NET_NFC, "Devices are lost each other. (User-Cancelled) Terminating this app-control...");
+ FinishAppControl(__reqId, APP_CTRL_RESULT_CANCELED);
+}
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+* @file NfcPushUiFrame.cpp
+* @brief This file contains the implementation of NfcPushUiFrame class.
+*/
+
+#include <FAppAppControlProviderManager.h>
+#include <FBaseSysLog.h>
+#include <FGraphics.h>
+#include "NfcPushUiFrame.h"
+#include "NfcPushUiForm.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Graphics;
+
+NfcPushUiFrame::NfcPushUiFrame(void)
+ : __reqId(-1)
+ , __iconPath()
+ , __description()
+{
+}
+
+NfcPushUiFrame::~NfcPushUiFrame(void)
+{
+}
+
+void
+NfcPushUiFrame::SetRequestId(RequestId reqId)
+{
+ __reqId = reqId;
+}
+
+void
+NfcPushUiFrame::SetAppInfo(const String& iconPath, const String& description)
+{
+ __iconPath = iconPath;
+ __description = description;
+}
+
+result
+NfcPushUiFrame::OnInitializing(void)
+{
+ result r = E_SUCCESS;
+ NfcPushUiForm* pNfcPushUiForm = null;
+ Tizen::Graphics::Rectangle rect;
+
+ // get size of frame
+ rect = GetBounds();
+
+ // Create a form
+ pNfcPushUiForm = new (std::nothrow) NfcPushUiForm();
+ SysTryReturn(NID_NET_NFC, pNfcPushUiForm != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] exception occurred.");
+
+ // initialize a form
+ pNfcPushUiForm->Initialize(__reqId, rect);
+
+ // set app info.
+ pNfcPushUiForm->SetAppInfo(__iconPath, __description);
+
+ // Add the form to the frame
+ r = AddControl(*pNfcPushUiForm);
+ SysTryReturn(NID_NET_NFC, r == E_SUCCESS, r, r, "[%s] exception occurred.", GetErrorMessage(r));
+
+ pNfcPushUiForm->SetBackgroundColor(Color(0, 0, 0, 0));
+ // Set the current form
+ r = SetCurrentForm(*pNfcPushUiForm);
+ SysTryReturn(NID_NET_NFC, r == E_SUCCESS, r, r, "[%s] exception occurred.", GetErrorMessage(r));
+
+ // Draw and Show the form
+ pNfcPushUiForm->Invalidate(true);
+
+ return r;
+}
+
+result
+NfcPushUiFrame::OnTerminating(void)
+{
+ return E_SUCCESS;
+}
--- /dev/null
+{
+global:
+ OspMain;
+local:
+ *;
+};
--- /dev/null
+SET (this_target osp-ac-platform)
+
+INCLUDE_DIRECTORIES (
+ ${COMMON_INCLUDE_DIRS}
+ ../../inc
+)
+
+SET (${this_target}_SOURCE_FILES
+ PlatformAppControlEntry.cpp
+ FApp_RequestManagerT.cpp
+)
+
+## SET EXTRA COMPILER FLAGS
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fPIC -Wall" )
+
+## 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_LIBRARY (${this_target} SHARED ${${this_target}_SOURCE_FILES})
+
+ADD_DEPENDENCIES(${this_target} osp-ac-util)
+
+TARGET_LINK_LIBRARIES(${this_target} -Xlinker --no-undefined -Xlinker)
+TARGET_LINK_LIBRARIES(${this_target} ${pkgs_LDFLAGS})
+TARGET_LINK_LIBRARIES(${this_target} osp-ac-util)
+
+OSP_STRIP(${this_target})
--- /dev/null
+//
+// 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 FApp_RequestInfo.h
+ * @brief This is the header file for the _RequestInfo class.
+ */
+
+#ifndef _FAPP_INTERNAL_REQUEST_INFO_H_
+#define _FAPP_INTERNAL_REQUEST_INFO_H_
+
+
+#include <FOspConfig.h>
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FAppTypes.h>
+
+
+namespace Tizen { namespace App
+{
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// _RequestInfo handles the launch request from this process
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+const long _REQUEST_INFO_MAGIC = 0x494C;
+
+class _RequestInfo
+{
+public:
+ _RequestInfo(int reqId, int pid, const Tizen::Base::String& oaId, const Tizen::Base::String& aId, const Tizen::Base::String& oId)
+ : magic(_REQUEST_INFO_MAGIC)
+ , reqId(reqId)
+ , processId(pid)
+ , originalAppId(oaId)
+ , actualAppId(aId)
+ , operationId(oId)
+ {
+ }
+
+ ~_RequestInfo(void) {}
+
+private:
+ _RequestInfo(const _RequestInfo& rhs);
+ _RequestInfo& operator =(const _RequestInfo& rhs);
+
+public:
+ const long magic;
+ int reqId;
+ int processId;
+ const Tizen::Base::String originalAppId;
+ const Tizen::Base::String actualAppId;
+ const Tizen::Base::String operationId;
+}; // _RequestInfo
+
+}} // Tizen::App
+
+#endif // _FAPP_INTERNAL_REQUEST_INFO_H_
--- /dev/null
+//
+// 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 FApp_RequestManagerT.cpp
+ * @brief This is the implementationfor the _RequestManagerT class.
+ */
+
+#include <limits.h>
+
+#include "FApp_RequestManagerT.h"
+#include "FApp_RequestInfo.h"
+
+
+namespace Tizen { namespace App
+{
+
+template<typename T>
+_RequestManagerT<T>::_RequestManagerT(void)
+: __reqId(-1)
+{
+ __requestList.Construct();
+}
+
+template<typename T>
+_RequestManagerT<T>::~_RequestManagerT(void)
+{
+ RequestListEnumType* pIter = __requestList.GetMapEnumeratorN();
+ if (pIter == null)
+ {
+ return;
+ }
+
+ while (pIter->MoveNext() == E_SUCCESS)
+ {
+ T* pInfo = null;
+ result r = pIter->GetValue(pInfo);
+
+ if (IsFailed(r))
+ {
+ continue;
+ }
+
+ delete pInfo;
+ }
+
+ delete pIter;
+}
+
+template<typename T> int
+_RequestManagerT<T>::InsertItem(T* pItem)
+{
+ SysTryReturn(NID_APP, pItem != null, -1, E_INVALID_ARG, "[E_INVALID_ARG] Empty argument.");
+
+ const int& req = pItem->reqId;
+ __requestList.Add(req, pItem);
+
+ return req;
+}
+
+template<typename T> void
+_RequestManagerT<T>::RemoveItem(int reqId)
+{
+ T* pItem = FindItem(reqId);
+ if (pItem)
+ {
+ __requestList.Remove(reqId);
+ delete pItem;
+ }
+}
+
+template<typename T> void
+_RequestManagerT<T>::RemoveItem(T* pItem)
+{
+ RequestListEnumType* pIter = __requestList.GetMapEnumeratorN();
+ if (pItem == null || pIter == null)
+ {
+ return;
+ }
+
+ while (pIter->MoveNext() == E_SUCCESS)
+ {
+ T* pInfo = null;
+ result r = pIter->GetValue(pInfo);
+
+ if (pInfo == pItem)
+ {
+ int id = -1;
+ r = pIter->GetKey(id);
+ if (r == E_SUCCESS)
+ {
+ __requestList.Remove(id);
+ }
+
+ delete pItem;
+ delete pIter;
+
+ return;
+ }
+ }
+
+ delete pIter;
+}
+
+template<typename T> T*
+_RequestManagerT<T>::FindItem(int reqId) const
+{
+ T* pItem = null;
+ result r = __requestList.GetValue(reqId, pItem);
+
+ return (r == E_SUCCESS) ? pItem : null;
+}
+
+// explicit template initialization
+template class _RequestManagerT<_RequestInfo>;
+
+} } // Tizen::App
+
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file PlatformAppControlEntry.cpp
+ * @brief This is the implementation for the PlatformAppControlEntry.cpp.
+ */
+
+#include <FBaseSysLog.h>
+#include <FBaseColHashMap.h>
+
+#include <FApp_Aul.h>
+#include <FApp_AppArg.h>
+#include <FApp_AppControlManager.h>
+#include <FApp_AppMessageImpl.h>
+#include <FApp_AppControlImpl.h>
+#include <FApp_IAppControlPluginProvider.h>
+#include <FApp_RequestManagerT.h>
+
+#include "FApp_RequestInfo.h"
+#include "FApp_AppControlPluginUtil.h"
+#include "FApp_AppControlTerminateHandler.h"
+
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+
+namespace
+{
+
+class _AppControlPlugin
+ : public _IAppControlPluginProvider
+ , virtual public Tizen::Base::Runtime::IEventListener
+{
+public:
+ _AppControlPlugin(void) { __handler.SetResultCallback(OnAppControlTerminate, this); }
+
+ virtual ~_AppControlPlugin(void) {}
+
+ virtual result StartAppControlPlugin(int req, const AppId& appId, const _AppMessageImpl& message, int* pPid);
+
+ virtual result StopAppControlPlugin(int req);
+
+ virtual result Release(void) { delete this; return E_SUCCESS; }
+
+ static void OnAppControlResult(void* b, int requestCode, service_result_e res, void* userData);
+
+ static void OnAppControlTerminate(int req, int pid, void* data);
+
+private:
+ _RequestManagerT<_RequestInfo> __requestManager;
+ _AppControlTerminateHandler __handler;
+};
+
+
+result
+_AppControlPlugin::StartAppControlPlugin(int req, const AppId& appId, const _AppMessageImpl& message, int* pPid)
+{
+ SysLog(NID_APP, "StartAppControl for %ls.", appId.GetPointer());
+
+ AppSvcResFn pCb = NULL;
+
+ if (req >= 0)
+ {
+ // if there is no listener, then req is -1.
+ pCb = OnAppControlResult;
+ __handler.AddHandler(req);
+ }
+
+ int pid = _AppControlManager::GetInstance()->Launch(message, pCb, this, req);
+
+ result r = GetLastResult();
+ SysTryReturnResult(NID_APP, pid >0, r, "System error.");
+
+ if (pPid)
+ {
+ *pPid = pid;
+ }
+
+ // appId is empty for implicit AppControl launch.
+ _RequestInfo* pItem = new (std::nothrow) _RequestInfo(req, pid, appId, message.GetApplicationId(), message.GetOperation());
+ if (pItem)
+ {
+ const int ret = __requestManager.InsertItem(pItem);
+ SysLog(NID_APP, "Request is added with %d.", ret);
+ }
+
+ if (req >= 0)
+ {
+ __handler.SetHandlerData(req, pid);
+ }
+
+ SysLog(NID_APP, "StartAppControl: Launching %ls AppControl succeeded for process %d.", appId.GetPointer(), pid);
+
+ return r;
+}
+
+
+result
+_AppControlPlugin::StopAppControlPlugin(int req)
+{
+ __handler.RemoveHandler(req);
+
+ _RequestInfo* pItem = __requestManager.FindItem(req);
+ SysTryReturnResult(NID_APP, pItem != null, E_SYSTEM, "No request found for %d.", req);
+
+ const int processId = pItem->processId;
+ if (processId <=0)
+ {
+ SysLogException(NID_APP, E_SYSTEM, "Request %d has invalid state with %ls.", req, pItem->originalAppId.GetPointer());
+ __requestManager.RemoveItem(req);
+ return E_SUCCESS;
+ }
+
+ result r = _AppControlPluginUtil::SendStopRequest(processId);
+ if (IsFailed(r))
+ {
+ SysLogException(NID_APP, E_INVALID_OPERATION, "Failed to send stop request to %d.", processId);
+ }
+
+ SysLog(NID_APP, "Process %d is terminated.", processId);
+
+ __requestManager.RemoveItem(req);
+
+ return r;
+}
+
+
+void
+_AppControlPlugin::OnAppControlResult(void* b, int requestCode, service_result_e res, void* userData)
+{
+ SysLog(NID_APP, "AppControl result received with req code %d.", requestCode);
+
+ result r = E_SYSTEM;
+ bundle* pBundle = static_cast<bundle*>(b);
+ _AppControlPlugin* pThis = static_cast<_AppControlPlugin*>(userData);
+ SysTryReturnVoidResult(NID_APP, pThis != null, E_SYSTEM, "[E_SYSTEM] Invalid state for request %d", requestCode);
+
+ pThis->__handler.RemoveHandler(requestCode);
+
+ HashMap* pResult = new (std::nothrow) HashMap();
+ SysTryReturnVoidResult(NID_APP, pResult != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Allocation failure.");
+
+ r = pResult->Construct();
+
+ _AppArg::SetArgMap(pBundle, pResult);
+
+ pThis->__requestManager.RemoveItem(requestCode);
+
+ const bool isSubMode = _AppArg::IsSubMode(pBundle);
+ _AppControlManager::GetInstance()->FinishAppControl(requestCode, res, L"", L"", pResult, (isSubMode) ? _APPCONTROL_PROPERTY_SUBMODE : 0);
+
+ SysLog(NID_APP, "Request %d is removed from the list successfully.", requestCode);
+}
+
+
+void
+_AppControlPlugin::OnAppControlTerminate(int req, int pid, void* userData)
+{
+ SysLog(NID_APP, "AppControl terminate event received with req code %d for process %d.", req, pid);
+
+ _AppControlPlugin* pThis = static_cast<_AppControlPlugin*>(userData);
+ if (pThis)
+ {
+ pThis->__handler.RemoveHandler(req);
+ pThis->__requestManager.RemoveItem(req);
+ }
+
+ // APPSVC_OSP_RES_TERMINATE matches APP_CTRL_RESULT_TERMINATED
+ _AppControlManager::GetInstance()->FinishAppControl(req, APPSVC_OSP_RES_TERMINATE, null);
+}
+
+}
+
+
+extern "C" _OSP_EXPORT_ _IAppControlPluginProvider*
+GetAppControlProviderPlugin(void)
+{
+ return new (std::nothrow) _AppControlPlugin;
+}
+
--- /dev/null
+SET (this_target osp-ac-setting)
+
+INCLUDE_DIRECTORIES (
+ ${COMMON_INCLUDE_DIRS}
+ ../../inc
+ )
+
+SET (${this_target}_SOURCE_FILES
+ SettingAppControlDllEntry.cpp
+ )
+
+## SET EXTRA COMPILER FLAGS
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fPIC -Wall" )
+
+## 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_LIBRARY (${this_target} SHARED ${${this_target}_SOURCE_FILES})
+
+ADD_DEPENDENCIES(${this_target} osp-ac-util)
+
+TARGET_LINK_LIBRARIES(${this_target} -Xlinker --no-undefined -Xlinker)
+TARGET_LINK_LIBRARIES(${this_target} ${pkgs_LDFLAGS})
+TARGET_LINK_LIBRARIES(${this_target} osp-ac-util)
+
+OSP_STRIP(${this_target})
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file SettingAppControlDllEntry.cpp
+ * @brief This is the implementation for the SettingAppControlDllEntry.cpp.
+ */
+
+#include <appsvc/appsvc.h>
+
+#include <FBaseSysLog.h>
+#include <FBaseColHashMap.h>
+
+#include <FApp_AppControlManager.h>
+#include <FApp_AppMessageImpl.h>
+#include <FSys_SystemInfoImpl.h>
+#include <FApp_Aul.h>
+#include <FApp_AppArg.h>
+#include <FApp_IAppControlPluginProvider.h>
+
+#include "FApp_AppControlPluginUtil.h"
+
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+
+namespace
+{
+
+const String CATEGORY_LOCATION = L"Location";
+const String LOCATION_GPS_ENABLED = L"GPSEnabled";
+const String LOCATION_WPS_ENABLED = L"WPSEnabled";
+
+const String CATEGORY_BLUETOOTH_VISIBILITY = L"Bluetooth.Visibility";
+const String BLUETOOTH_VISIBILITY_OFF = L"GPSEnabled";
+const String BLUETOOTH_VISIBILITY_ALWAYS_ON = L"GPSEnabled";
+const String BLUETOOTH_VISIBILITY_1MIN_ON = L"GPSEnabled";
+const String BLUETOOTH_VISIBILITY_2MIN_ON = L"GPSEnabled";
+
+const String CATEGORY_FONT_TYPE = L"FontType";
+const String FONT_TYPE_DEFAULT = L"Unknown";
+
+const String CATEGORY_FONT_SIZE = L"FontSize";
+const String FONT_SIZE_SMALL = L"Small";
+const String FONT_SIZE_MEDIUM = L"Medium";
+const String FONT_SIZE_LARGE = L"Large";
+
+
+class _AppControlPlugin
+ : public _IAppControlPluginProvider
+ , virtual public Tizen::Base::Runtime::IEventListener
+{
+public:
+ _AppControlPlugin(void) {}
+
+ virtual ~_AppControlPlugin(void) {}
+
+ virtual result StartAppControlPlugin(int req, const AppId& appId, const _AppMessageImpl& message, int* pPid);
+
+ virtual result StopAppControlPlugin(int req);
+
+ virtual result Release(void) { delete this; return E_SUCCESS; }
+
+ static void OnLocationAppControlResult(void* b, int requestCode, service_result_e res, void* userData);
+
+ static void OnBluetoothAppControlResult(void* b, int requestCode, service_result_e res, void* userData);
+
+ static void OnFontSizeAppControlResult(void* b, int requestCode, service_result_e res, void* userData);
+
+ static void OnFontTypeAppControlResult(void* b, int requestCode, service_result_e res, void* userData);
+
+private:
+ static int __req;
+ static int __processId;
+};
+
+
+int _AppControlPlugin::__req = -1;
+int _AppControlPlugin::__processId = -1;
+
+static const char __allowedLegacyAppControlTable[][2][96] =
+{
+ {"osp.appcontrol.SETTINGS", "osp.appcontrol.operation.DEFAULT"},
+ {"osp.appcontrol.provider.settings", "osp.appcontrol.operation.configure"},
+ {"tizen.settings", "http://tizen.org/appcontrol/operation/configure"},
+};
+
+static const char __allowedLocationAppControlTable[][2][96] =
+{
+ {"tizen.settings", "http://tizen.org/appcontrol/operation/configure/location"},
+};
+
+static const char __allowedBluetoothAppControlTable[][2][96] =
+{
+ {"tizen.settings", "http://tizen.org/appcontrol/operation/configure/bluetooth/visibility"},
+};
+
+static const char __allowedFontSizeAppControlTable[][2][96] =
+{
+ {"tizen.settings", "http://tizen.org/appcontrol/operation/configure/font/size"},
+};
+
+static const char __allowedFontTypeAppControlTable[][2][96] =
+{
+ {"tizen.settings", "http://tizen.org/appcontrol/operation/configure/font/type"},
+};
+
+
+result
+_AppControlPlugin::StartAppControlPlugin(int req, const AppId& aId, const _AppMessageImpl& message, int* pPid)
+{
+ SysLog(NID_APP, "StartAppControl: Entry to Setting AppControl");
+
+ result r = E_SUCCESS;
+ const String& oId = message.GetOperation();
+
+ const bool isLegacy = _AppControlPluginUtil::IsAllowedAppControl(__allowedLegacyAppControlTable, 3, aId, oId);
+ bool isLocation = _AppControlPluginUtil::IsAllowedAppControl(__allowedLocationAppControlTable, 1, aId, oId);
+ bool isBluetooth = _AppControlPluginUtil::IsAllowedAppControl(__allowedBluetoothAppControlTable, 1, aId, oId);
+ bool isFontSize = _AppControlPluginUtil::IsAllowedAppControl(__allowedFontSizeAppControlTable, 1, aId, oId);
+ bool isFontType = _AppControlPluginUtil::IsAllowedAppControl(__allowedFontTypeAppControlTable, 1, aId, oId);
+ SysTryReturnResult(NID_APP, isLegacy || isLocation || isBluetooth || isFontSize || isFontType, E_SYSTEM, "Invalid AppControl entry for (%ls, %ls).", aId.GetPointer(), oId.GetPointer());
+
+
+ SysLog(NID_APP, "Setting AppControl.");
+
+ _AppMessageImpl msg(message);
+
+ AppSvcResFn pCb = NULL;
+
+ String operation;
+
+ if (isLegacy)
+ {
+ String category = msg.GetValue(L"category");
+ if (category == CATEGORY_LOCATION)
+ {
+ operation = L"http://tizen.org/appcontrol/operation/configure/location";
+ isLocation = true;
+ }
+ else if (category == CATEGORY_BLUETOOTH_VISIBILITY)
+ {
+ operation = L"http://tizen.org/appcontrol/operation/configure/bluetooth/visibility";
+ isBluetooth = true;
+ }
+ else if (category == CATEGORY_FONT_TYPE)
+ {
+ operation = L"http://tizen.org/appcontrol/operation/configure/font/type";
+ isFontType = true;
+ }
+ else if (category == CATEGORY_FONT_SIZE)
+ {
+ operation = L"http://tizen.org/appcontrol/operation/configure/font/size";
+ isFontSize = true;
+ }
+ else
+ {
+ SysLog(NID_APP, "Unknown category %ls for legacy AppControl.", category.GetPointer());
+ }
+ }
+ else
+ {
+ operation = oId;
+ }
+
+ AppId providerAppId;
+
+ if (isLocation)
+ {
+ pCb = OnLocationAppControlResult;
+ providerAppId = "tizen.setting_location";
+ }
+ else if (isBluetooth)
+ {
+ bool isBtSupported = false;
+ r = Tizen::System::_SystemInfoImpl::GetSysInfo(L"http://tizen.org/feature/network.bluetooth", isBtSupported);
+ SysTryReturnResult(NID_APP, (r == E_SUCCESS) && (isBtSupported == true), E_SYSTEM, "Bluetooth is not supported.");
+
+ pCb = OnBluetoothAppControlResult;
+ providerAppId = "tizen.setting_bluetooth";
+ }
+ else if (isFontSize)
+ {
+ pCb = OnFontSizeAppControlResult;
+ providerAppId = "tizen.setting_font";
+ }
+ else if (isFontType)
+ {
+ pCb = OnFontTypeAppControlResult;
+ providerAppId = "tizen.setting_font";
+ }
+ else
+ {
+ providerAppId = aId;
+ }
+
+ msg.SetApplicationId(providerAppId);
+ msg.SetOperation(operation);
+
+ __req = req;
+ __processId = _AppControlManager::GetInstance()->Launch(msg, pCb, 0);
+
+ r = GetLastResult();
+ SysTryReturnResult(NID_APP, __processId >= 0, r, "StartAppControl: Launching Camera AppControl is failed.");
+
+ r = E_SUCCESS;
+ SysLog(NID_APP, "StartAppControl: Launching Camera AppControl succeeded");
+
+ return r;
+}
+
+
+result
+_AppControlPlugin::StopAppControlPlugin(int req)
+{
+ if (__processId >= 0)
+ {
+ result r = _AppControlPluginUtil::SendStopRequest(__processId);
+ SysTryReturnResult(NID_APP, !IsFailed(r), r, "Failed to send stop request to %d.", __processId);
+
+ SysLog(NID_APP, "Process %d is terminated.", __processId);
+ __processId = -1;
+ }
+
+ return E_SUCCESS;
+}
+
+
+void
+_AppControlPlugin::OnLocationAppControlResult(void* b, int requestCode, service_result_e res, void* userData)
+{
+ SysLog(NID_APP, "Setting AppControl result received.");
+
+ result r = E_SYSTEM;
+ const char* pBuf = NULL;
+ bundle* pBundle = static_cast<bundle*>(b);
+
+ HashMap* pResult = new (std::nothrow) HashMap();
+ SysTryCatch(NID_APP, pResult != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Allocation failure.");
+
+ r = pResult->Construct();
+
+ _AppArg::SetArgMap(pBundle, pResult);
+
+ pResult->Add(new (std::nothrow) String(L"category"), new (std::nothrow) String(L"Location"));
+
+ pBuf = appsvc_get_data(pBundle, "http://tizen.org/appcontrol/data/location/gps");
+ if (pBuf)
+ {
+ pResult->Add(new (std::nothrow) String(L"GPS"), new (std::nothrow) String(pBuf));
+ }
+
+ pBuf = appsvc_get_data(pBundle, "http://tizen.org/appcontrol/data/location/wps");
+ if (pBuf)
+ {
+ pResult->Add(new (std::nothrow) String(L"WPS"), new (std::nothrow) String(pBuf));
+ }
+
+ _AppControlManager::GetInstance()->FinishAppControl(__req, res, pResult);
+
+CATCH:
+ __req = -1;
+}
+
+
+void
+_AppControlPlugin::OnBluetoothAppControlResult(void* b, int requestCode, service_result_e res, void* userData)
+{
+ result r = E_SYSTEM;
+ const char* pBuf = NULL;
+ bundle* pBundle = static_cast<bundle*>(b);
+
+ HashMap* pResult = new (std::nothrow) HashMap();
+ SysTryCatch(NID_APP, pResult != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Allocation failure.");
+
+ r = pResult->Construct();
+
+ _AppArg::SetArgMap(pBundle, pResult);
+
+ pResult->Add(new (std::nothrow) String(L"category"), new (std::nothrow) String(L"Bluetooth.Visibility"));
+
+ pBuf = appsvc_get_data(pBundle, "http://tizen.org/appcontrol/data/bluetooth/visibility");
+ if (pBuf)
+ {
+ switch (*pBuf)
+ {
+ case '0':
+ pBuf = "off";
+ break;
+ case '1':
+ pBuf = "always";
+ break;
+ case '2':
+ pBuf = "time_limited";
+ break;
+ default:
+ pBuf = "off";
+ break;
+ }
+ pResult->Remove(String(L"http://tizen.org/appcontrol/data/bluetooth/visibility"));
+ pResult->Add(new (std::nothrow) String(L"http://tizen.org/appcontrol/data/bluetooth/visibility"), new (std::nothrow) String(pBuf));
+
+ pResult->Remove(String(L"visibility"));
+ pResult->Add(new (std::nothrow) String(L"visibility"), new (std::nothrow) String(pBuf));
+ }
+
+ _AppControlManager::GetInstance()->FinishAppControl(__req, res, pResult);
+
+CATCH:
+ __req = -1;
+}
+
+
+void
+_AppControlPlugin::OnFontSizeAppControlResult(void* b, int requestCode, service_result_e res, void* userData)
+{
+ SysLog(NID_APP, "Setting AppControl result received.");
+
+ result r = E_SYSTEM;
+ const char* pBuf = NULL;
+ bundle* pBundle = static_cast<bundle*>(b);
+
+ HashMap* pResult = new (std::nothrow) HashMap();
+ SysTryCatch(NID_APP, pResult != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Allocation failure.");
+
+ r = pResult->Construct();
+
+ _AppArg::SetArgMap(pBundle, pResult);
+
+ pResult->Add(new (std::nothrow) String(L"category"), new (std::nothrow) String(L"FontSize"));
+
+ pBuf = appsvc_get_data(pBundle, "http://tizen.org/appcontrol/data/font/size");
+ if (pBuf)
+ {
+ pResult->Add(new (std::nothrow) String(L"size"), new (std::nothrow) String(pBuf));
+ }
+
+ _AppControlManager::GetInstance()->FinishAppControl(__req, res, pResult);
+
+CATCH:
+ __req = -1;
+}
+
+
+void
+_AppControlPlugin::OnFontTypeAppControlResult(void* b, int requestCode, service_result_e res, void* userData)
+{
+ SysLog(NID_APP, "Setting AppControl result received.");
+
+ result r = E_SYSTEM;
+ const char* pBuf = NULL;
+ bundle* pBundle = static_cast<bundle*>(b);
+
+ HashMap* pResult = new (std::nothrow) HashMap();
+ SysTryCatch(NID_APP, pResult != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Allocation failure.");
+
+ r = pResult->Construct();
+
+ _AppArg::SetArgMap(pBundle, pResult);
+
+ pResult->Add(new (std::nothrow) String(L"category"), new (std::nothrow) String(L"FontType"));
+
+ pBuf = appsvc_get_data(pBundle, "http://tizen.org/appcontrol/data/font/type");
+ if (pBuf)
+ {
+ pResult->Add(new (std::nothrow) String(L"type"), new (std::nothrow) String(pBuf));
+ }
+
+ _AppControlManager::GetInstance()->FinishAppControl(__req, res, pResult);
+
+CATCH:
+ __req = -1;
+}
+
+}
+
+extern "C" _OSP_EXPORT_ _IAppControlPluginProvider*
+GetAppControlProviderPlugin(void)
+{
+ return new (std::nothrow) _AppControlPlugin;
+}
+