'mmi-ipc.c',
'mmi-dbg.h',
'mmi_proxy.h',
- 'mmi_proxy.c'
+ 'mmi_proxy.c',
+ 'mmi-core.h',
+ 'mmi-core.c',
]
install_headers(
'mmi.h',
- 'mmi-event-types.h'
+ 'mmi-common.h'
)
glib_dep = dependency('glib-2.0', method : 'pkg-config')
--- /dev/null
+/*
+* Copyright © 2021 Samsung Electronics co., Ltd. All Rights Reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
+* copy of this software and associated documentation files (the "Software"),
+* to deal in the Software without restriction, including without limitation
+* the rights to use, copy, modify, merge, publish, distribute, sublicense,
+* and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice (including the next
+* paragraph) shall be included in all copies or substantial portions of the
+* Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+* DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef __MMI_COMMON_H__
+#define __MMI_COMMON_H__
+
+#include <tizen.h>
+
+#define MMI_API __attribute__ ((visibility("default")))
+
+typedef void* mmi_rpc_h;
+
+typedef enum {
+ MMI_RESULT_NONE,
+ MMI_RESULT_FAIL,
+ MMI_RESULT_SUCCESS
+} mmi_result_e;
+
+typedef enum {
+ MMI_STATE_NONE,
+} mmi_state_e;
+
+typedef enum {
+ MMI_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
+ MMI_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of Memory */
+ MMI_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< I/O error */
+ MMI_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
+ MMI_ERROR_OUT_OF_NETWORK = TIZEN_ERROR_NETWORK_DOWN, /**< Network is down */
+ MMI_ERROR_TIMED_OUT = TIZEN_ERROR_TIMED_OUT, /**< No answer from the daemon */
+ MMI_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
+ MMI_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< MMI NOT supported */
+} mmi_error_e;
+
+typedef struct {
+ mmi_rpc_h rpc_h;
+ const char *stub_appid;
+ int state;
+} mmi_struct_s;
+
+typedef mmi_struct_s* mmi_handle;
+
+#endif //__MMI_COMMON_H__
--- /dev/null
+/*
+* Copyright © 2022 Samsung Electronics co., Ltd. All Rights Reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
+* copy of this software and associated documentation files (the "Software"),
+* to deal in the Software without restriction, including without limitation
+* the rights to use, copy, modify, merge, publish, distribute, sublicense,
+* and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice (including the next
+* paragraph) shall be included in all copies or substantial portions of the
+* Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+* DEALINGS IN THE SOFTWARE.
+*/
+
+#include "mmi-ipc.h"
+#include "mmi-dbg.h"
+
+static mmi_handle mmi_h = NULL;
+
+int mmi_instance_create(void)
+{
+ mmi_h = (mmi_handle)calloc(1, sizeof(mmi_struct_s));
+
+ if (mmi_h == NULL) {
+ LOGE("Failed to allocate memory for mmi_h !\n");
+ return MMI_ERROR_OUT_OF_MEMORY;
+ }
+
+ if (mmi_ipc_init()) {
+ LOGE("Failed to init mmi ipc !\n");
+ if(mmi_h != NULL) {
+ free(mmi_h);
+ mmi_h = NULL;
+ }
+ return MMI_ERROR_NOT_SUPPORTED;
+ }
+
+ mmi_h->rpc_h = mmi_ipc_get_rpc_h();
+ mmi_h->stub_appid = mmi_ipc_get_stub_appid();
+ mmi_h->state = mmi_ipc_get_state();
+
+ return MMI_ERROR_NONE;
+}
+
+int mmi_instance_destroy()
+{
+ if (mmi_h == NULL) {
+ LOGE("A mmi_h is already NULL");
+ return MMI_ERROR_NONE;
+ }
+
+ mmi_ipc_shutdown();
+ free(mmi_h);
+ mmi_h = NULL;
+
+ return MMI_ERROR_NONE;
+}
/*
-* Copyright © 2021 Samsung Electronics co., Ltd. All Rights Reserved.
+* Copyright © 2022 Samsung Electronics co., Ltd. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* DEALINGS IN THE SOFTWARE.
*/
-#ifndef __MMI_EVENT_TYPES_H__
-#define __MMI_EVENT_TYPES_H__
+#ifndef __MMI_CORE_H__
+#define __MMI_CORE_H__
-#include <stdbool.h>
+#include "mmi-common.h"
-typedef struct
-{
- bool connected;
-} mmi_event_connection;
+#ifdef __cplusplus
+extern "C" {
+#endif
-#endif //__MMI_EVENT_TYPES_H__
+int mmi_instance_create(void);
+int mmi_instance_destroy();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //__MMI_CORE_H__
\ No newline at end of file
static rpc_port_proxy_mmi_h _rpc_h;
static const char* _stub_appid = "mmi-manager";
static int _connected = 0;
-static mmi_state _state = MMI_STATE_NONE;
+static mmi_state_e _state = MMI_STATE_NONE;
rpc_port_proxy_mmi_h
mmi_ipc_get_rpc_h(void)
return _rpc_h;
}
-mmi_state
-mmi_ipc_get_state(void)
+mmi_state_e mmi_ipc_get_state(void)
{
return _state;
}
static void _on_connected(rpc_port_proxy_mmi_h h, void *user_data)
{
int r;
- mmi_event_connection *ev = NULL;
-
- ev = (mmi_event_connection *)calloc(1, sizeof(mmi_event_connection));
-
- if (!ev)
- {
- LOGE("Failed to allocate memory for connection event !\n");
- return;
- }
_connected = 1;
- ev->connected = true;
LOGI("...");
return;
-err:
- if (ev)
- free(ev);
}
static void _on_disconnected(rpc_port_proxy_mmi_h h, void *user_data)
{
- mmi_event_connection *ev = NULL;
-
- ev = (mmi_event_connection *)calloc(1, sizeof(mmi_event_connection));
-
- if (!ev)
- {
- LOGE("Failed to allocate memory for connection event !\n");
- return;
- }
-
_connected = 0;
- ev->connected = false;
LOGI("...");
}
#define __MMI_IPC_H__
#include "mmi_proxy.h"
+#include "mmi-common.h"
#ifdef __cplusplus
extern "C" {
void mmi_ipc_shutdown(void);
rpc_port_proxy_mmi_h mmi_ipc_get_rpc_h(void);
-mmi_state mmi_ipc_get_state(void);
+mmi_state_e mmi_ipc_get_state(void);
int mmi_ipc_get_uid(void);
bool mmi_ipc_is_connected(void);
const char *mmi_ipc_get_appid(void);
*/
#include "mmi.h"
-#include "mmi-ipc.h"
+#include "mmi-core.h"
#include "mmi-dbg.h"
-#define ERR(x)
-
-static int _mmi_init_count = 0;
-
-MMI_API int
-mmi_init(void)
-{
- return 1;
-}
-
-MMI_API int
-mmi_shutdown(void)
-{
- return 0;
-}
-
-MMI_API mmi_handle
-mmi_instance_create(void)
+MMI_API int mmi_init(void)
{
- mmi_handle h = NULL;
-
- h = (mmi_handle)calloc(1, sizeof(mmi_struct));
-
- if (!h)
- {
- ERR("Failed to allocate memory for mmi_handle !\n");
- return NULL;
- }
-
- if (mmi_ipc_init())
- {
- ERR("Failed to init mmi ipc !\n");
- goto err;
+ int ret = mmi_instance_create();
+ if(ret != MMI_ERROR_NONE) {
+ LOGE("Fail to create mmi handle instance(%d)", ret);
+ return MMI_ERROR_NOT_SUPPORTED;
}
- h->rpc_h = mmi_ipc_get_rpc_h();
- h->stub_appid = mmi_ipc_get_stub_appid();
- h->state = mmi_ipc_get_state();
-
- return h;
-err:
- if (h)
- free(h);
- return NULL;
+ return MMI_ERROR_NONE;
}
-MMI_API void
-mmi_instance_destroy(mmi_handle *h)
+MMI_API int mmi_shutdown(void)
{
- if (!h)
- return;
+ int ret = mmi_instance_destroy();
+ if(ret != MMI_ERROR_NONE) {
+ LOGE("Fail to destroy mmi handle instance(%d)", ret);
+ return MMI_ERROR_NOT_SUPPORTED;
+ }
- mmi_ipc_shutdown();
- free(*h);
- *h = NULL;
+ return MMI_ERROR_NONE;
}
-
#ifndef __MMI_H__
#define __MMI_H__
-#include <mmi-event-types.h>
-
-#define MMI_API __attribute__ ((visibility("default")))
-
-typedef void* mmi_rpc_h;
-
-typedef enum
-{
- MMI_RESULT_NONE,
- MMI_RESULT_FAIL,
- MMI_RESULT_SUCCESS
-} mmi_result;
-
-typedef enum
-{
- MMI_STATE_NONE,
-} mmi_state;
-
-typedef struct
-{
- mmi_rpc_h rpc_h;
- const char *stub_appid;
- int state;
-} mmi_struct;
-
-typedef mmi_struct* mmi_handle;
+#include "mmi-common.h"
#ifdef __cplusplus
extern "C" {
MMI_API int mmi_init(void);
MMI_API int mmi_shutdown(void);
-MMI_API mmi_handle mmi_instance_create(void);
-MMI_API void mmi_instance_destroy(mmi_handle *h);
#ifdef __cplusplus
}
#endif
-#endif //__MMIFW_H__
+#endif //__MMI_H__
{
int res = mmi_init();
- EXPECT_EQ(res, 1);
+ EXPECT_EQ(res, MMI_ERROR_NONE);
- if(res)
- mmi_shutdown();
+ mmi_shutdown();
}
TEST_F(MMIIpcTest, MMIIpcInitFail)
{
int res = mmi_init();
- EXPECT_EQ(res, 1);
+ EXPECT_EQ(res, MMI_ERROR_NONE);
- if(res)
- mmi_shutdown();
+ mmi_shutdown();
}
*/
#include "mmi.h"
+#include "mmi-core.h"
#include "mmi-tests.h"
#include "mmi-ipc.h"
{
int res = mmi_init();
- EXPECT_EQ(res, 1);
+ EXPECT_EQ(res, MMI_ERROR_NONE);
- if(res)
- mmi_shutdown();
+ mmi_shutdown();
+}
+
+TEST_F(MMIMainTest, MmiInstanceCreateSuccess)
+{
+ int res = mmi_instance_create();
+
+ EXPECT_EQ(res, MMI_ERROR_NONE);
+
+ mmi_instance_destroy();
}