BuildRequires: pkgconfig(elementary)
BuildRequires: pkgconfig(capi-appfw-application)
BuildRequires: pkgconfig(evas)
-Requires: libdpm = %{version}-%{release}
+Requires: libzone = %{version}-%{release}
%description -n org.tizen.zone-setup-wizard
Tizen ZONE setup wizard interface for zone
SET(ZONE_MODULE ${DPM_ZONE}/module)
SET(ZONE_LIBS ${DPM_ZONE}/libs)
+SET(ZONE_CLI ${DPM_ZONE}/cli)
SET(ZONE_SETUP_WIZARD ${DPM_ZONE}/setup-wizard)
ADD_SUBDIRECTORY(${ZONE_MODULE})
-ADD_SUBDIRECTORY(${ZONE_SETUP_WIZARD})
ADD_SUBDIRECTORY(${ZONE_LIBS})
+ADD_SUBDIRECTORY(${ZONE_CLI})
+ADD_SUBDIRECTORY(${ZONE_SETUP_WIZARD})
--- /dev/null
+#
+# Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+#
+# 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.
+#
+
+PROJECT(zone-cli)
+
+FILE(GLOB ZONE_CLI_SRCS zone-admin-cli.cpp
+ ${ZONE_MODULE}/session.cpp
+ ${ZONE_MODULE}/zone-builder.cpp
+)
+
+SET(ZONE_CLI_NAME "zone-admin-cli")
+
+ADD_EXECUTABLE(${ZONE_CLI_NAME} ${ZONE_CLI_SRCS})
+SET_TARGET_PROPERTIES(${ZONE_CLI_NAME} PROPERTIES PREFIX ""
+ COMPILE_DEFINITIONS PID_FILE_PATH="${RUN_INSTALL_DIR}/zone"
+ COMPILE_FLAGS "-fPIE"
+ LINK_FLAGS "-pie"
+)
+
+PKG_CHECK_MODULES(ZONE_CLI_DEPS REQUIRED
+ glib-2.0
+ capi-appfw-package-manager
+ capi-appfw-app-manager
+)
+
+INCLUDE_DIRECTORIES(SYSTEM ${ZONE_CLI_DEPS_INCLUDE_DIRS} ${DPM_COMMON} ${ZONE_MODULE} ${ZONE_LIBS})
+TARGET_LINK_LIBRARIES(${ZONE_CLI_NAME} ${ZONE_CLI_DEPS_LIBRARIES} dpm-common zone)
+
+INSTALL(TARGETS ${ZONE_CLI_NAME} DESTINATION sbin)
{
int num = 0;
+ zone_manager_h zoneMgr;
zone_package_proxy_h pkgMgr;
- zone_package_proxy_create(&pkgMgr);
+ zone_manager_create(&zoneMgr);
+ zone_package_proxy_create(zoneMgr, &pkgMgr);
zone_package_proxy_foreach_package_info(pkgMgr, name.c_str(), PackgeListCallback, &num);
std::cout << num << " packages are found" << std::endl;
zone_package_proxy_destroy(pkgMgr);
+ zone_manager_destroy(zoneMgr);
return 0;
}
if (checked) {
std::cout <<" NoDisplay ";
}
- std::cout << ")"<<std::endl;
+ std::cout << ")"<< std::endl;
app_info_get_label(info, &val);
std::cout << " Label : " << val << std::endl;
{
int num = 0;
+ zone_manager_h zoneMgr;
zone_app_proxy_h appMgr;
- zone_app_proxy_create(&appMgr);
+ zone_manager_create(&zoneMgr);
+ zone_app_proxy_create(zoneMgr, &appMgr);
zone_app_proxy_foreach_app_info(appMgr, name.c_str(), ApplicationListCallback, &num);
std::cout << num << " applications are found" << std::endl;
zone_app_proxy_destroy(appMgr);
+ zone_manager_destroy(zoneMgr);
return 0;
}
SET(SOURCES ${DPM_LIBS}/policy-client.cpp
package-proxy.cpp
app-proxy.cpp
+ zone/zone.cpp
zone/package-proxy.cpp
zone/app-proxy.cpp
)
using namespace DevicePolicyManager;
-typedef struct zone_app_proxy_s {
- std::unique_ptr<DevicePolicyContext> pContext;
- std::unique_ptr<ZoneAppProxy> pManager;
-} zone_app_proxy_s;
-
inline ZoneAppProxy* getManager(zone_app_proxy_h handle)
{
- return reinterpret_cast<zone_app_proxy_s *>(handle)->pManager.get();
+ return reinterpret_cast<ZoneAppProxy*>(handle);
}
static app_info_h make_app_info_handle(const ZoneAppProxy::AppInfo& info)
return reinterpret_cast<app_info_h>(appinfo);
}
-int zone_app_proxy_create(zone_app_proxy_h *manager)
+int zone_app_proxy_create(zone_manager_h manager, zone_app_proxy_h *handle)
{
RET_ON_FAILURE(manager, ZONE_ERROR_INVALID_PARAMETER);
+ RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
- zone_app_proxy_s* handle = new(std::nothrow) zone_app_proxy_s();
-
- handle->pContext.reset(new(std::nothrow) DevicePolicyContext());
- if (handle->pContext->connect() < 0) {
- delete handle;
- return ZONE_ERROR_CONNECTION_REFUSED;
- }
-
- handle->pManager.reset(handle->pContext->createPolicyInterface<ZoneAppProxy>());
- *manager = reinterpret_cast<zone_app_proxy_h>(handle);
+ auto& client = GetDevicePolicyContext(manager);
+ *handle = reinterpret_cast<zone_app_proxy_h*>(client.createPolicyInterface<ZoneAppProxy>());
return ZONE_ERROR_NONE;
}
{
RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
- delete reinterpret_cast<zone_app_proxy_s *>(handle);
+ delete reinterpret_cast<ZoneAppProxy*>(handle);
+
return ZONE_ERROR_NONE;
}
#include <app_info.h>
#include <app_manager.h>
+
#include <zone/zone.h>
/**
* @details This API acquires zone application manager handle required to call
* the zone application manager APIs.
* @since_tizen 3.0
- * @param[in] handle Device policy manager context handle
- * @return Zone application manager handle on success, otherwise NULL
- * @remark The specific error code can be obtained by using the
- * get_last_result() method. Error codes are described in
- * exception section.
- * @exception #ZONE_ERROR_NONE No error
- * @exception #ZONE_ERROR_CONNECTION_REFUSED Connection refused
- * @exception #ZONE_ERROR_INVALID_PARAMETER Invalid parameter
- * @exception #ZONE_ERROR_TIMED_OUT Time out
+ * @param[in] manager The zone manager handle
+ * @param[out] handle The zone app proxy handle
+ * @return #ZONE_ERROR_NONE on success, otherwise a negative value
+ * @retval #ZONE_ERROR_NONE Successful
+ * @retval #ZONE_ERROR_CONNECTION_REFUSED Connection refused
+ * @retval #ZONE_ERROR_TIMED_OUT Time out
+ * @see zone_manager_create()
* @see zone_app_proxy_create()
* @see get_last_result()
*/
-ZONE_API int zone_app_proxy_create(zone_app_proxy_h* handle);
+ZONE_API int zone_app_proxy_create(zone_manager_h manager, zone_app_proxy_h* handle);
/**
* @brief Releases the zone application manager handle
using namespace DevicePolicyManager;
typedef struct zone_package_proxy_s {
- std::unique_ptr<DevicePolicyContext> pContext;
std::unique_ptr<ZonePackageProxy> pManager;
pkgmgr_client* pNativeHandle;
zone_package_proxy_event_cb pCallback;
return reinterpret_cast<package_info_h>(packageinfo);
}
-int zone_package_proxy_create(zone_package_proxy_h *handle)
+int zone_package_proxy_create(zone_manager_h manager, zone_package_proxy_h *handle)
{
+ RET_ON_FAILURE(manager, ZONE_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
zone_package_proxy_s* instance = new zone_package_proxy_s;
- instance->pContext.reset(new(std::nothrow) DevicePolicyContext());
-
- if (instance->pContext->connect() < 0) {
- delete handle;
- return ZONE_ERROR_CONNECTION_REFUSED;
- }
-
- instance->pManager.reset(instance->pContext->createPolicyInterface<ZonePackageProxy>());
+ instance->pManager.reset(GetDevicePolicyContext(manager).
+ createPolicyInterface<ZonePackageProxy>());
instance->pNativeHandle = ::pkgmgr_client_new(PC_LISTENING);
::pkgmgr_client_free(instance->pNativeHandle);
delete instance;
+
return ZONE_ERROR_NONE;
}
* @details This API acquires zone package proxy handle required to call
* the zone package_manager APIs.
* @since_tizen 3.0
- * @param[in] handle The zone package proxy handle
- * @return Zone package proxy handle on success, otherwise NULL
- * @remark The specific error code can be obtained by using the
- * get_last_result() method. Error codes are described in
- * exception section.
- * @exception #ZONE_ERROR_NONE No error
- * @exception #ZONE_ERROR_CONNECTION_REFUSED Connection refused
- * @exception #ZONE_ERROR_INVALID_PARAMETER Invalid parameter
- * @exception #ZONE_ERROR_TIMED_OUT Time out
+ * @param[in] manager The zone manager handle
+ * @param[out] handle The zone package proxy handle
+ * @return #ZONE_ERROR_NONE on success, otherwise a negative value
+ * @retval #ZONE_ERROR_NONE Successful
+ * @retval #ZONE_ERROR_CONNECTION_REFUSED Connection refused
+ * @retval #ZONE_ERROR_TIMED_OUT Time out
+ * @see zone_manager_create()
* @see zone_package_proxy_destroy()
* @see get_last_result()
*/
-ZONE_API int zone_package_proxy_create(zone_package_proxy_h *handle);
+ZONE_API int zone_package_proxy_create(zone_manager_h manager, zone_package_proxy_h *handle);
/**
* @brief Releases the zone package proxy handle.
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+#include "zone/zone.h"
+
+#include "error.h"
+#include "debug.h"
+#include "policy-client.h"
+
+DevicePolicyContext& GetDevicePolicyContext(void* handle)
+{
+ return *reinterpret_cast<DevicePolicyContext*>(handle);
+}
+
+int zone_manager_create(zone_manager_h* handle)
+{
+ RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
+
+ DevicePolicyContext* client = new(std::nothrow) DevicePolicyContext();
+
+ RET_ON_FAILURE(handle, ZONE_ERROR_CONNECTION_REFUSED);
+
+ if (client->connect() < 0) {
+ delete client;
+ RET_ON_FAILURE(handle, ZONE_ERROR_CONNECTION_REFUSED);
+ }
+
+ *handle = reinterpret_cast<zone_manager_h>(client);
+
+ return ZONE_ERROR_NONE;
+}
+
+int zone_manager_destroy(zone_manager_h handle)
+{
+ RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
+
+ delete &GetDevicePolicyContext(handle);
+
+ return ZONE_ERROR_NONE;
+}
+
+int zone_manager_add_event_cb(zone_manager_h handle, const char* event, zone_event_cb callback, void* user_data, int *id)
+{
+ RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
+ RET_ON_FAILURE(event, ZONE_ERROR_INVALID_PARAMETER);
+ RET_ON_FAILURE(callback, ZONE_ERROR_INVALID_PARAMETER);
+
+ auto& context = GetDevicePolicyContext(handle);
+ int ret = context.subscribeSignal(std::string("ZonePolicy::") +event,
+ callback, user_data);
+ if (ret < 0)
+ return ZONE_ERROR_INVALID_PARAMETER;
+
+ *id = ret;
+ return ZONE_ERROR_NONE;
+}
+
+int zone_manager_remove_event_cb(zone_manager_h handle, int callback_id)
+{
+ RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
+ RET_ON_FAILURE(callback_id >= 0, ZONE_ERROR_INVALID_PARAMETER);
+
+ auto& context = *reinterpret_cast<DevicePolicyContext*>(handle);
+ int ret = context.unsubscribeSignal(callback_id);
+ if (ret)
+ return ZONE_ERROR_INVALID_PARAMETER;
+
+ return ZONE_ERROR_NONE;
+}
#endif
/**
+ * @addtogroup CAPI_ZONE_ZONE_MODULE
+ * @{
+ */
+
+/**
* @brief Enumeration of device policy API errors
* @since_tizen 3.0
*/
ZONE_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY /**< Out of memory */
} zone_error_type_e;
+/**
+ * @brief The zone manager handle
+ * @details The zone manager handle is an abstraction of the
+ * logical connection between the zone manager and it's client.
+ * The zone manager handle must be created by using
+ * zone_manager_create() before attempting to use almost any of
+ * the zone related APIs, and it should be freed when interaction
+ * with the zone manager is no longer required.
+ * To release the handle, use zone_manager_destroy().
+ * @since_tizen 3.0
+ * @see zone_manager_create()
+ * @see zone_manager_destroy()
+ */
+typedef void* zone_manager_h;
+
+/**
+ * @brief Creates the zone manager handle.
+ * @details This API creates zone manager handle required to
+ * the zone related APIs.
+ * This API is also used to verify whether caller is authorized
+ * or not.
+ * @since_tizen 3.0
+ * @param[out] handle The zone manager handle
+ * @return #ZONE_ERROR_NONE on success, otherwise a negative value
+ * @retval #ZONE_ERROR_NONE Successful
+ * @retval #ZONE_ERROR_CONNECTION_REFUSED Connection refused
+ * @retval #ZONE_ERROR_TIMED_OUT Time out
+ * @see zone_manager_destroy()
+ * @see get_last_result()
+ */
+ZONE_API int zone_manager_create(zone_manager_h *handle);
+
+/**
+ * @brief Releases the zone manager handle.
+ * @details This API must be called if interaction with the zone manager is
+ * no longer required.
+ * @since_tizen 3.0
+ * @param[in] handle The zone manager handle
+ * @return #ZONE_ERROR_NONE on success, otherwise a negative value
+ * @retval #ZONE_ERROR_NONE Successful
+ * @retval #ZONE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre The handle must be created by zone_manager_create()
+ * @see zone_manager_create()
+ */
+ZONE_API int zone_manager_destroy(zone_manager_h handle);
+
+/**
+ * @brief Called when a zone raises a event.
+ * @since_tizen 3.0
+ * @param[in] name The zone name
+ * @param[in] object The object name triggered the event
+ * @param[in] user_data The user data passed from zone_manager_add_event_cb
+ * @see zone_manager_add_event_cb()
+ * @see zone_manager_remove_event_cb()
+ */
+typedef void(*zone_event_cb)(const char* name, const char* object, void *user_data);
+
+/**
+ * @brief Adds zone event callback.
+ * @details This API can be used to receive events sent by zone
+ * The callback specified to this function is automatically called when
+ * the zone is created or removed.
+ * @since_tizen 3.0
+ * @param[in] context The zone_manager handle
+ * @param[in] event The event name to receive
+ * @param[in] callback The event callback
+ * @param[in] user_data The user data passed to the callback function
+ * @param[out] id Signal identifier
+ * @return #ZONE_ERROR_NONE on success, otherwise a negative value
+ * @retval #ZONE_ERROR_NONE Successful
+ * @retval #ZONE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ZONE_ERROR_TIMED_OUT Time out
+ * @pre The handle must be created by zone_manager_create().
+ * @see zone_manager_create()
+ * @see zone_manager_destroy()
+ * @see zone_manager_remove_event_cb()
+ */
+ZONE_API int zone_manager_add_event_cb(zone_manager_h handle,
+ const char* event,
+ zone_event_cb callback, void* user_data,
+ int* id);
+
+/**
+ * @brief Removes zone event callback.
+ * @details This API removes zone event callback
+ * @since_tizen 3.0
+ * @param[in] context The zone manager handle
+ * @param[in] id Signal identifier
+ * @return #ZONE_ERROR_NONE on success, otherwise a negative value
+ * @retval #ZONE_ERROR_NONE Successful
+ * @retval #ZONE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ZONE_ERROR_TIMED_OUT Time out
+ * @pre The context must be created by zone_manager_create().
+ * @see zone_manager_create()
+ * @see zone_manager_destroy()
+ * @see zone_manager_add_event_cb()
+ */
+ZONE_API int zone_manager_remove_event_cb(zone_manager_h handle, int id);
+
+/**
+ * @}
+ */
#ifdef __cplusplus
}
zone.cpp
)
-FILE(GLOB ZONE_CLI_SRCS zone-builder.cpp
- session.cpp
- zone-admin-cli.cpp
-)
-
SET (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,noexecstack")
SET(ZONE_PAM_NAME "pam_zone")
INSTALL(TARGETS ${ZONE_PAM_NAME} DESTINATION ${LIB_INSTALL_DIR}/security)
INSTALL(FILES data/DefaultZoneManifest.xml DESTINATION ${CONF_INSTALL_DIR}/zone RENAME owner.xml)
INSTALL(FILES pam.d/systemd-user-zone DESTINATION ${PAMD_INSTALL_DIR})
-
-
-
-SET(ZONE_CLI_NAME "zone-admin-cli")
-ADD_EXECUTABLE(${ZONE_CLI_NAME} ${ZONE_CLI_SRCS})
-SET_TARGET_PROPERTIES(${ZONE_CLI_NAME} PROPERTIES PREFIX ""
- COMPILE_DEFINITIONS PID_FILE_PATH="${RUN_INSTALL_DIR}/zone"
- COMPILE_FLAGS "-fPIE"
- LINK_FLAGS "-pie"
-)
-
-PKG_CHECK_MODULES(ZONE_CLI_DEPS REQUIRED
- glib-2.0
- capi-appfw-package-manager
- capi-appfw-app-manager
-)
-
-INCLUDE_DIRECTORIES(SYSTEM ${ZONE_CLI_DEPS_INCLUDE_DIRS} ${DPM_COMMON} ${DPM_POLICY} ${DPM_LIBS} ${ZONE_LIBS})
-TARGET_LINK_LIBRARIES(${ZONE_CLI_NAME} ${ZONE_CLI_DEPS_LIBRARIES} dpm-common zone)
-
-INSTALL(TARGETS ${ZONE_CLI_NAME} DESTINATION sbin)
evas
)
-INCLUDE_DIRECTORIES(${tools_pkgs_INCLUDE_DIRS} ${DPM_LIBS})
+INCLUDE_DIRECTORIES(${tools_pkgs_INCLUDE_DIRS} ${ZONE_LIBS})
LINK_DIRECTORIES(${tools_pkgs_LIBRARY_DIRS})
SET(PKG_NAME "${PROJECT_NAME}")
ADD_EXECUTABLE(${PKG_NAME} ${PKG_SRC})
INSTALL(TARGETS ${PKG_NAME} DESTINATION ${APP_INSTALL_PREFIX}/${PKG_NAME}/bin)
-TARGET_LINK_LIBRARIES(${PKG_NAME} ${tools_pkgs_LIBRARIES} dpm)
+TARGET_LINK_LIBRARIES(${PKG_NAME} ${tools_pkgs_LIBRARIES} zone)
#Create edj file
ADD_CUSTOM_TARGET(org.tizen.zone-setup-wizard.edj
#include <dlog.h>
#include <Elementary.h>
#include <efl_extension.h>
-#include <dpm/zone.h>
+#include <zone/zone.h>
#ifdef LOG_TAG
#undef LOG_TAG
typedef struct {
char *zone_name;
char *provision_path;
- dpm_context_h dpm_client;
- int dpm_zone_signal_cb_id;
+ zone_manager_h zone_manager;
+ int zone_event_cb_id;
bool create_done;
} appdata_s;
{
appdata_s *ad = (appdata_s *) data;
- dpm_context_remove_signal_cb(ad->dpm_client, ad->dpm_zone_signal_cb_id);
- dpm_context_destroy(ad->dpm_client);
- ad->dpm_client = NULL;
+ zone_manager_remove_event_cb(ad->zone_manager, ad->zone_event_cb_id);
+ zone_manager_destroy(ad->zone_manager);
+ ad->zone_manager = NULL;
return ;
}
ui_app_exit();
}
- ad->dpm_client = dpm_context_create();
- if (ad->dpm_client == NULL) {
- dlog_print(DLOG_ERROR, LOG_TAG, "failed to get dpm client");
+ ret = zone_manager_create(&ad->zone_manager);
+ if (ret != ZONE_ERROR_NONE) {
+ dlog_print(DLOG_ERROR, LOG_TAG, "failed to get zone manager handle");
ui_app_exit();
}
- if (dpm_context_add_signal_cb(ad->dpm_client, "ZonePolicy::created", __create_zone_done, ad, &id) != DPM_ERROR_NONE) {
- dlog_print(DLOG_ERROR, LOG_TAG, "Failed to add zone signal callback");
+ if (zone_manager_add_event_cb(ad->zone_manager, "created", __create_zone_done, ad, &id) != ZONE_ERROR_NONE) {
+ dlog_print(DLOG_ERROR, LOG_TAG, "Failed to add zone event callback");
ui_app_exit();
}
- ad->dpm_zone_signal_cb_id = id;
+ ad->zone_event_cb_id = id;
elm_app_base_scale_set(1.8);
_create_base_window(ad);