<option id="gnu.cpp.compiler.option.optimization.level.1679205774" name="Optimization Level" superClass="gnu.cpp.compiler.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
<option defaultValue="gnu.cpp.compiler.debugging.level.max" id="sbi.gnu.cpp.compiler.option.debugging.level.core.1016937387" name="Debug level" superClass="sbi.gnu.cpp.compiler.option.debugging.level.core" valueType="enumerated"/>
<option id="sbi.gnu.cpp.compiler.option.1080100499" name="Tizen-Target" superClass="sbi.gnu.cpp.compiler.option" valueType="userObjs">
- <listOptionValue builtIn="false" value="mobile-3.0-device.core_llvm36.armel.core.app"/>
+ <listOptionValue builtIn="false" value="mobile-3.0-device.core.private_llvm36.armel.core.app"/>
</option>
<option id="sbi.gnu.cpp.compiler.option.frameworks_inc.core.168454849" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.cpp.compiler.option.frameworks_inc.core" valueType="includePath">
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libxml2""/>
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.option.optimization.level.107534150" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" valueType="enumerated"/>
<option defaultValue="gnu.c.debugging.level.max" id="sbi.gnu.c.compiler.option.debugging.level.core.1399910668" name="Debug level" superClass="sbi.gnu.c.compiler.option.debugging.level.core" valueType="enumerated"/>
<option id="sbi.gnu.c.compiler.option.376711470" name="Tizen-Target" superClass="sbi.gnu.c.compiler.option" valueType="userObjs">
- <listOptionValue builtIn="false" value="mobile-3.0-device.core_llvm36.armel.core.app"/>
+ <listOptionValue builtIn="false" value="mobile-3.0-device.core.private_llvm36.armel.core.app"/>
</option>
<option id="sbi.gnu.c.compiler.option.frameworks_inc.core.724287551" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.c.compiler.option.frameworks_inc.core" valueType="includePath">
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libxml2""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/base""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/cairo""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/calendar-service2""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/call-manager""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/chromium-ewk""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ckm""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/contacts-svc""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/content""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/context-service""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/csf""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dali""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dali-toolkit""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dbus-1.0""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eio-1""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eldbus-1""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/elementary-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/email-service""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/embryo-1""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/emile-1""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eo-1""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/metadata-editor""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/minicontrol""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/minizip""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/msg-service""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/network""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/notification""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/nsd/""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/storage""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/system""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony-client""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ug-1""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ui""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/vconf""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/web""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/widget_service""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/widget_viewer_evas""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/base""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/cairo""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/calendar-service2""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/call-manager""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/chromium-ewk""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ckm""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/contacts-svc""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/content""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/context-service""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/csf""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dali""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dali-toolkit""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dbus-1.0""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eio-1""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eldbus-1""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/elementary-1""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/email-service""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/embryo-1""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/emile-1""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eo-1""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/metadata-editor""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/minicontrol""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/minizip""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/msg-service""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/network""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/notification""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/nsd/""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/storage""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/system""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/telephony-client""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ug-1""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ui""/>
- <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/vconf""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/web""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/widget_service""/>
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/widget_viewer_evas""/>
--- /dev/null
+/*
+ * Copyright (c) 2009-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.
+ *
+ */
+
+#ifndef __CALLUI_COMMON_TYPES_H__
+#define __CALLUI_COMMON_TYPES_H__
+
+typedef enum {
+
+ CALLUI_RESULT_OK,
+
+ CALLUI_RESULT_FAIL,
+ CALLUI_RESULT_INVALID_PARAM,
+ CALLUI_RESULT_ALLOCATION_FAIL,
+ CALLUI_RESULT_PERMISSION_DENIED,
+ CALLUI_RESULT_NOT_SUPPORTED,
+ CALLUI_RESULT_NOT_REGISTERED,
+ CALLUI_RESULT_ALREADY_REGISTERED,
+
+ CALLUI_RESULT_UNKNOWN_ERROR
+
+} callui_result_e;
+
+#endif /* __CALLUI_COMMON_TYPES_H__ */
#include "callui-view-manager.h"
#include "callui.h"
+#include "callui-common-types.h"
#define CALLUI_KEY_BACK "XF86Back"
#define CALLUI_KEY_MEDIA "XF86AudioMedia"
LCD_OFF
} callui_lcd_control_t;
-typedef enum {
- CALLUI_RESULT_OK,
- CALLUI_RESULT_FAIL,
- CALLUI_RESULT_INVALID_PARAM,
- CALLUI_RESULT_ALLOCATION_FAIL
-} callui_result_t;
-
/**
* @brief Set call duration
*
--- /dev/null
+/*
+ * Copyright (c) 2009-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.
+ *
+ */
+
+#ifndef __CALLUI_LISTENERS_SET_H__
+#define __CALLUI_LISTENERS_SET_H__
+
+#include <Eina.h>
+#include <stdbool.h>
+
+#include "callui-common-types.h"
+
+typedef struct _callui_listener _callui_listener_t;
+
+typedef void (*cb_func_handler)(_callui_listener_t *listener, va_list args);
+
+struct _callui_listener {
+ cb_func_handler handler;
+ void *cb_func;
+ void *cb_data;
+};
+
+struct _callui_listeners_coll {
+ Eina_List *list;
+ bool is_need_validate;
+ bool is_locked;
+ bool is_initialized;
+};
+typedef struct _callui_listeners_coll _callui_listeners_coll_t;
+
+callui_result_e _callui_listeners_coll_init(_callui_listeners_coll_t *listeners_col);
+
+callui_result_e _callui_listeners_coll_deinit(_callui_listeners_coll_t *listeners_col);
+
+callui_result_e _callui_listeners_coll_add_listener(_callui_listeners_coll_t *listeners_col,
+ cb_func_handler func_handler,
+ void *cb_func,
+ void *cb_data);
+
+callui_result_e _callui_listeners_coll_call_listeners(_callui_listeners_coll_t *listeners_col, ...);
+
+callui_result_e _callui_listeners_coll_remove_listener(_callui_listeners_coll_t *listeners_col,
+ void *cb_func,
+ void *cb_data);
+
+#endif /* __CALLUI_LISTENERS_SET_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2009-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.
+ *
+ */
+
+#ifndef __CALLUI_MANAGER_H__
+#define __CALLUI_MANAGER_H__
+
+#include <stdbool.h>
+
+#include "callui-common-types.h"
+
+typedef enum {
+ CALLUI_CALL_ANSWER_TYPE_NORMAL = 0, /**< Only single call exist, Accept the Incoming call*/
+ CALLUI_CALL_ANSWER_TYPE_HOLD_ACTIVE_AND_ACCEPT, /**< Put the active call on hold and accepts the call*/
+ CALLUI_CALL_ANSWER_TYPE_RELEASE_ACTIVE_AND_ACCEPT, /**< Releases the active call and accept the call*/
+ CALLUI_CALL_ANSWER_TYPE_RELEASE_HOLD_AND_ACCEPT, /**< Releases the held call and accept the call*/
+ CALLUI_CALL_ANSWER_TYPE_RELEASE_ALL_AND_ACCEPT /**< Releases all calls and accept the call*/
+} callui_call_answer_type_e;
+
+typedef enum {
+ CALLUI_CALL_RELEASE_TYPE_BY_CALL_HANDLE = 0, /**< Release call using given call_handle*/
+ CALLUI_CALL_RELEASE_TYPE_ALL_CALLS, /**< Release all Calls*/
+ CALLUI_CALL_RELEASE_TYPE_ALL_HOLD_CALLS, /**< Releases all hold calls*/
+ CALLUI_CALL_RELEASE_TYPE_ALL_ACTIVE_CALLS, /**< Releases all active calls*/
+} callui_call_release_type_e;
+
+typedef enum {
+ CALLUI_SIM_SLOT_1 = 0,
+ CALLUI_SIM_SLOT_2,
+ CALLUI_SIM_SLOT_DEFAULT,
+} callui_sim_slot_type_e;
+
+/* Call manager handler type define */
+typedef struct __callui_manager *callui_manager_h;
+
+/* Forward declaration */
+typedef struct __callui_state_provider *callui_state_provider_h;
+typedef struct __callui_sound_manager *callui_sound_manager_h;
+
+callui_manager_h _callui_manager_create();
+
+void _callui_manager_destroy(callui_manager_h cm_handler);
+
+callui_result_e _callui_manager_dial_voice_call(callui_manager_h cm_handler, const char *number, callui_sim_slot_type_e sim_slot);
+
+callui_result_e _callui_manager_end_call(callui_manager_h cm_handler, unsigned int call_id, callui_call_release_type_e release_type);
+
+callui_result_e _callui_manager_swap_call(callui_manager_h cm_handler);
+
+callui_result_e _callui_manager_hold_call(callui_manager_h cm_handler);
+
+callui_result_e _callui_manager_unhold_call(callui_manager_h cm_handler);
+
+callui_result_e _callui_manager_join_call(callui_manager_h cm_handler);
+
+callui_result_e _callui_manager_reject_call(callui_manager_h cm_handler);
+
+callui_result_e _callui_manager_split_call(callui_manager_h cm_handler, unsigned int call_id);
+
+callui_result_e _callui_manager_answer_call(callui_manager_h cm_handler, callui_call_answer_type_e ans_type);
+
+callui_sound_manager_h _callui_manager_get_sound_manager(callui_manager_h cm_handler);
+
+callui_state_provider_h _callui_manager_get_state_provider(callui_manager_h cm_handler);
+
+
+#endif /* __CALLUI_CALL_MANAGER_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2009-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.
+ *
+ */
+
+#ifndef __CALLUI_MODEL_UTILS_PRIV_H__
+#define __CALLUI_MODEL_UTILS_PRIV_H__
+
+#include <call-manager.h>
+
+#include "callui-common-types.h"
+
+callui_result_e _callui_utils_convert_cm_res(cm_error_e cm_res);
+
+#endif /* __CALLUI_MODEL_UTILS_PRIV_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2009-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.
+ *
+ */
+
+#ifndef __CALLUI_SOUND_MANAGER_PRIV_H__
+#define __CALLUI_SOUND_MANAGER_PRIV_H__
+
+#include <call-manager.h>
+
+typedef struct __callui_sound_manager *callui_sound_manager_h;
+
+callui_sound_manager_h _callui_sdm_create(cm_client_h cm_client);
+
+void _callui_sdm_destroy(callui_sound_manager_h sm_handler);
+
+#endif /* __CALLUI_CALL_SOUND_MANAGER_PRIV_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2009-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.
+ *
+ */
+
+#ifndef __CALLUI_SOUND_MANAGER_H__
+#define __CALLUI_SOUND_MANAGER_H__
+
+#include <stdbool.h>
+
+#include "callui-common-types.h"
+
+typedef enum {
+ CALLUI_AUDIO_STATE_NONE, /**< none */
+ CALLUI_AUDIO_STATE_SPEAKER, /**< System LoudSpeaker path */
+ CALLUI_AUDIO_STATE_RECEIVER, /**< System Receiver*/
+ CALLUI_AUDIO_STATE_EARJACK, /**< Earjack path*/
+ CALLUI_AUDIO_STATE_BT /**< System BT Headset path */
+} callui_audio_state_type_e;
+
+typedef struct __callui_sound_manager *callui_sound_manager_h;
+
+/* Callback functions prototypes */
+typedef void (*audio_state_changed_cb)(void *user_data, callui_audio_state_type_e state);
+typedef void (*mute_state_changed_cb)(void *user_data, bool is_enable);
+
+callui_result_e _callui_sdm_set_speaker_state(callui_sound_manager_h sdm, bool is_enable);
+
+callui_result_e _callui_sdm_set_bluetooth_state(callui_sound_manager_h sdm, bool is_enable);
+
+callui_audio_state_type_e _callui_sdm_get_audio_state(callui_sound_manager_h sdm);
+
+callui_result_e _callui_sdm_start_dtmf(callui_sound_manager_h sdm, unsigned char dtmf_digit);
+
+callui_result_e _callui_sdm_stop_dtmf(callui_sound_manager_h sdm);
+
+callui_result_e _callui_sdm_set_mute_state(callui_sound_manager_h sdm, bool is_enable);
+
+bool _callui_sdm_get_mute_state(callui_sound_manager_h sdm);
+
+callui_result_e _callui_sdm_add_audio_state_changed_cb(callui_sound_manager_h sdm,
+ audio_state_changed_cb cb_func, void *user_data);
+
+callui_result_e _callui_sdm_remove_audio_state_changed_cb(callui_sound_manager_h sdm,
+ audio_state_changed_cb cb_func, void *user_data);
+
+callui_result_e _callui_sdm_add_mute_state_changed_cb(callui_sound_manager_h sdm,
+ mute_state_changed_cb cb_func, void *user_data);
+
+callui_result_e _callui_sdm_remove_mute_state_changed_cb(callui_sound_manager_h sdm,
+ mute_state_changed_cb cb_func, void *user_data);
+
+#endif /* __CALLUI_CALL_SOUND_MANAGER_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2009-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.
+ *
+ */
+
+#ifndef __CALLUI_STATE_PROVIDER_PRIV_H__
+#define __CALLUI_STATE_PROVIDER_PRIV_H__
+
+#include <call-manager.h>
+
+typedef struct __callui_state_provider *callui_state_provider_h;
+
+callui_state_provider_h _callui_stp_create(cm_client_h cm_client);
+
+void _callui_stp_destroy(callui_state_provider_h sp_handler);
+
+#endif /* __CALLUI_CALL_STATE_PROVIDER_PRIV_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2009-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.
+ *
+ */
+
+#ifndef __CALLUI_STATE_PROVIDER_H__
+#define __CALLUI_STATE_PROVIDER_H__
+
+#include <stdbool.h>
+#include <time.h>
+
+#include "callui-common-types.h"
+#include "callui-manager.h"
+
+#define CALLUI_DISPLAY_NAME_LENGTH_MAX (255+1)
+#define CALLUI_IMAGE_PATH_LENGTH_MAX (255+1)
+#define CALLUI_PHONE_NUMBER_LENGTH_MAX (82+1)
+#define CALLUI_PHONE_DISP_NUMBER_LENGTH_MAX (82+10+1)
+
+typedef enum {
+ CALLUI_CALL_DATA_TYPE_ACTIVE = 0, /**< Active call data*/
+ CALLUI_CALL_DATA_TYPE_HELD, /**< Held call data*/
+ CALLUI_CALL_DATA_TYPE_INCOMING, /**< Incoming call data*/
+ CALLUI_CALL_DATA_TYPE_MAX
+} callui_call_data_type_e;
+
+typedef enum {
+ CALLUI_CALL_EVENT_TYPE_END = 0,
+ CALLUI_CALL_EVENT_TYPE_DIALING,
+ CALLUI_CALL_EVENT_TYPE_ACTIVE,
+ CALLUI_CALL_EVENT_TYPE_HELD,
+ CALLUI_CALL_EVENT_TYPE_ALERT,
+ CALLUI_CALL_EVENT_TYPE_INCOMING,
+ CALLUI_CALL_EVENT_TYPE_WAITING,
+ CALLUI_CALL_EVENT_TYPE_JOIN,
+ CALLUI_CALL_EVENT_TYPE_SPLIT,
+ CALLUI_CALL_EVENT_TYPE_SWAPPED,
+ CALLUI_CALL_EVENT_TYPE_RETRIEVED,
+ CALLUI_CALL_EVENT_TYPE_SAT_CALL_CONTROL,
+} callui_call_event_type_e;
+
+typedef struct __callui_state_provider *callui_state_provider_h;
+
+struct _callui_contact_data_t {
+ int person_id; /**< Contact index of the Caller */
+ char call_disp_name[CALLUI_DISPLAY_NAME_LENGTH_MAX]; /**< Caller display name */
+ char caller_id_path[CALLUI_IMAGE_PATH_LENGTH_MAX]; /**< Caller image path */
+};
+typedef struct _callui_contact_data_t callui_contact_data_t;
+
+struct _callui_conf_call_data_t {
+ unsigned int call_id;
+ char call_num[CALLUI_PHONE_NUMBER_LENGTH_MAX];
+ callui_contact_data_t call_ct_info;
+};
+typedef struct _callui_conf_call_data_t callui_conf_call_data_t;
+
+struct _callui_call_state_data_t {
+ unsigned int call_id;
+ char call_num[CALLUI_PHONE_NUMBER_LENGTH_MAX];
+ char call_disp_num[CALLUI_PHONE_DISP_NUMBER_LENGTH_MAX];
+ long start_time;
+ bool is_dialing;
+ bool is_emergency;
+ callui_contact_data_t call_ct_info;
+ int conf_member_count;
+};
+typedef struct _callui_call_state_data_t callui_call_state_data_t;
+
+/* Callback functions prototypes */
+typedef void (*callui_call_state_event_cb)(void *user_data,
+ callui_call_event_type_e call_event_type,
+ unsigned int call_id,
+ callui_sim_slot_type_e sim_type);
+
+typedef void (*callui_last_call_end_event_cb)(void *user_data,
+ const callui_call_state_data_t *last_call_data);
+
+const callui_call_state_data_t *_callui_stp_get_call_data(callui_state_provider_h stp,
+ callui_call_data_type_e call_data_type);
+
+Eina_List *_callui_stp_get_conference_call_list(callui_state_provider_h stp);
+
+struct tm *_callui_stp_get_call_duration(callui_state_provider_h stp,
+ callui_call_data_type_e call_data_type);
+
+callui_result_e _callui_stp_add_call_state_event_cb(callui_state_provider_h stp,
+ callui_call_state_event_cb cb_func,
+ void *cb_data);
+
+callui_result_e _callui_stp_remove_call_state_event_cb(callui_state_provider_h stp,
+ callui_call_state_event_cb cb_func,
+ void *cb_data);
+
+callui_result_e _callui_stp_add_last_call_end_event_cb(callui_state_provider_h stp,
+ callui_last_call_end_event_cb cb_func,
+ void *cb_data);
+
+callui_result_e _callui_stp_remove_last_call_end_event_cb(callui_state_provider_h stp,
+ callui_last_call_end_event_cb cb_func,
+ void *cb_data);
+
+#endif /* __CALLUI_CALL_STATE_PROVIDER_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2009-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 <stdarg.h>
+
+#include "callui-listeners-collection.h"
+#include "callui-debug.h"
+
+static callui_result_e __search_listener(Eina_List *listener_list, void *cb_func, void *cb_data);
+static void __delete_empty_listeners(_callui_listeners_coll_t *listeners_coll);
+
+callui_result_e _callui_listeners_coll_init(_callui_listeners_coll_t *listeners_coll)
+{
+ CALLUI_RETURN_VALUE_IF_FAIL(listeners_coll, CALLUI_RESULT_INVALID_PARAM);
+
+ listeners_coll->list = NULL;
+ listeners_coll->is_need_validate = false;
+ listeners_coll->is_locked = false;
+ listeners_coll->is_initialized = true;
+
+ return CALLUI_RESULT_OK;
+}
+
+callui_result_e _callui_listeners_coll_deinit(_callui_listeners_coll_t *listeners_coll)
+{
+ CALLUI_RETURN_VALUE_IF_FAIL(listeners_coll, CALLUI_RESULT_INVALID_PARAM);
+
+ Eina_List *l;
+ _callui_listener_t *data;
+
+ EINA_LIST_FOREACH(listeners_coll->list, l, data) {
+ free(data);
+ }
+ listeners_coll->list = eina_list_free(listeners_coll->list);
+
+ listeners_coll->is_need_validate = false;
+ listeners_coll->is_locked = false;
+ listeners_coll->is_initialized = false;
+
+ return CALLUI_RESULT_OK;
+}
+
+static callui_result_e __search_listener(Eina_List *listener_list, void *cb_func, void *cb_data)
+{
+ Eina_List *l;
+ _callui_listener_t *data;
+
+ EINA_LIST_FOREACH(listener_list, l, data) {
+ if (data && data->cb_func == cb_func && data->cb_data == cb_data) {
+ return CALLUI_RESULT_ALREADY_REGISTERED;
+ }
+ }
+ return CALLUI_RESULT_OK;
+}
+
+static void __delete_empty_listeners(_callui_listeners_coll_t *listeners_coll)
+{
+ Eina_List *l;
+ Eina_List *l_next;
+ _callui_listener_t *data;
+
+ EINA_LIST_FOREACH_SAFE(listeners_coll->list, l, l_next, data) {
+ if (data == NULL) {
+ listeners_coll->list = eina_list_remove_list(listeners_coll->list, l);
+ }
+ }
+ debug_leave();
+}
+
+callui_result_e _callui_listeners_coll_add_listener(_callui_listeners_coll_t *listeners_coll,
+ cb_func_handler func_handler,
+ void *cb_func,
+ void *cb_data)
+{
+ CALLUI_RETURN_VALUE_IF_FAIL(listeners_coll, CALLUI_RESULT_INVALID_PARAM);
+ CALLUI_RETURN_VALUE_IF_FAIL(func_handler, CALLUI_RESULT_INVALID_PARAM);
+ CALLUI_RETURN_VALUE_IF_FAIL(cb_func, CALLUI_RESULT_INVALID_PARAM);
+
+ CALLUI_RETURN_VALUE_IF_FAIL(listeners_coll->is_initialized, CALLUI_RESULT_FAIL);
+
+ callui_result_e res = __search_listener(listeners_coll->list, cb_func, cb_data);
+ CALLUI_RETURN_VALUE_IF_FAIL(res == CALLUI_RESULT_OK, res);
+
+ _callui_listener_t *listener = (_callui_listener_t *)calloc(1, sizeof(_callui_listener_t));
+ CALLUI_RETURN_VALUE_IF_FAIL(listener, CALLUI_RESULT_ALLOCATION_FAIL);
+
+ listener->handler = func_handler;
+ listener->cb_func = cb_func;
+ listener->cb_data = cb_data;
+
+ listeners_coll->list = eina_list_append(listeners_coll->list, listener);
+ if (listeners_coll->list == NULL) {
+ err("Listener list is empty");
+ free(listener);
+ return CALLUI_RESULT_FAIL;
+ }
+ return res;
+}
+
+callui_result_e _callui_listeners_coll_call_listeners(_callui_listeners_coll_t *listeners_coll, ...)
+{
+ CALLUI_RETURN_VALUE_IF_FAIL(listeners_coll, CALLUI_RESULT_INVALID_PARAM);
+
+ CALLUI_RETURN_VALUE_IF_FAIL(listeners_coll->is_initialized, CALLUI_RESULT_FAIL);
+
+ listeners_coll->is_locked = true;
+
+ Eina_List *l;
+ _callui_listener_t *data;
+
+ EINA_LIST_FOREACH(listeners_coll->list, l, data) {
+ if(data != NULL) {
+ dbg("calling listener start...");
+ va_list args;
+ va_start(args, listeners_coll);
+ data->handler(data, args);
+ va_end(args);
+ dbg("... calling listener done");
+ }
+ }
+
+ listeners_coll->is_locked = false;
+
+ if (listeners_coll->is_need_validate) {
+ dbg("need validate");
+ __delete_empty_listeners(listeners_coll);
+ listeners_coll->is_need_validate = false;
+ }
+ debug_leave();
+ return CALLUI_RESULT_OK;
+}
+
+callui_result_e _callui_listeners_coll_remove_listener(_callui_listeners_coll_t *listeners_coll,
+ void *cb_func,
+ void *cb_data)
+{
+ CALLUI_RETURN_VALUE_IF_FAIL(listeners_coll, CALLUI_RESULT_INVALID_PARAM);
+ CALLUI_RETURN_VALUE_IF_FAIL(cb_func, CALLUI_RESULT_INVALID_PARAM);
+
+ CALLUI_RETURN_VALUE_IF_FAIL(listeners_coll->is_initialized, CALLUI_RESULT_FAIL);
+
+ Eina_List *l;
+ Eina_List *l_next;
+ _callui_listener_t *data;
+
+ EINA_LIST_FOREACH_SAFE(listeners_coll->list, l, l_next, data) {
+ if(cb_func == data->cb_func && cb_data == data->cb_data) {
+ free(data);
+ if (listeners_coll->is_locked) {
+ listeners_coll->is_need_validate = true;
+ eina_list_data_set(l, NULL);
+ } else {
+ listeners_coll->list = eina_list_remove_list(listeners_coll->list, l);
+ }
+ return CALLUI_RESULT_OK;
+ }
+ }
+ return CALLUI_RESULT_NOT_REGISTERED;
+}
--- /dev/null
+/*
+ * Copyright (c) 2009-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 <call-manager.h>
+#include <call-manager-extension.h>
+
+#include "callui-manager.h"
+#include "callui-common.h"
+#include "callui-sound-manager-priv.h"
+#include "callui-state-provider-priv.h"
+#include "callui-model-utils-priv.h"
+
+struct __callui_manager {
+ cm_client_h cm_handler;
+
+ callui_sound_manager_h sound_manager;
+ callui_state_provider_h state_provider;
+};
+typedef struct __callui_manager _callui_manager_t;
+
+static callui_result_e __callui_manager_init(callui_manager_h cm_handler);
+static void __callui_manager_deinit(callui_manager_h cm_handler);
+static cm_call_release_type_e __convert_app_release_type(callui_call_release_type_e type);
+static cm_call_answer_type_e __convert_app_answer_type(callui_call_answer_type_e type);
+
+static cm_call_release_type_e __convert_app_release_type(callui_call_release_type_e type)
+{
+ switch (type) {
+ case CALLUI_CALL_RELEASE_TYPE_BY_CALL_HANDLE:
+ return CALL_RELEASE_TYPE_BY_CALL_HANDLE;
+ case CALLUI_CALL_RELEASE_TYPE_ALL_CALLS:
+ return CALL_RELEASE_TYPE_ALL_CALLS;
+ case CALLUI_CALL_RELEASE_TYPE_ALL_HOLD_CALLS:
+ return CALL_RELEASE_TYPE_ALL_HOLD_CALLS;
+ case CALLUI_CALL_RELEASE_TYPE_ALL_ACTIVE_CALLS:
+ return CALL_RELEASE_TYPE_ALL_ACTIVE_CALLS;
+ default:
+ err("undefined call release type [%d]", type);
+ return CALL_RELEASE_TYPE_BY_CALL_HANDLE;
+ }
+}
+
+static cm_call_answer_type_e __convert_app_answer_type(callui_call_answer_type_e type)
+{
+ switch (type) {
+ case CALLUI_CALL_ANSWER_TYPE_NORMAL:
+ return CALL_ANSWER_TYPE_NORMAL;
+ case CALLUI_CALL_ANSWER_TYPE_HOLD_ACTIVE_AND_ACCEPT:
+ return CALL_ANSWER_TYPE_HOLD_ACTIVE_AND_ACCEPT;
+ case CALLUI_CALL_ANSWER_TYPE_RELEASE_ACTIVE_AND_ACCEPT:
+ return CALL_ANSWER_TYPE_RELEASE_ACTIVE_AND_ACCEPT;
+ case CALLUI_CALL_ANSWER_TYPE_RELEASE_HOLD_AND_ACCEPT:
+ return CALL_ANSWER_TYPE_RELEASE_HOLD_AND_ACCEPT;
+ case CALLUI_CALL_ANSWER_TYPE_RELEASE_ALL_AND_ACCEPT:
+ return CALL_ANSWER_TYPE_RELEASE_ALL_AND_ACCEPT;
+ default:
+ err("undefined call answer type [%d]", type);
+ return CALL_ANSWER_TYPE_NORMAL;
+ }
+}
+
+static callui_result_e __callui_manager_init(callui_manager_h cm_handler)
+{
+ callui_result_e res = _callui_utils_convert_cm_res(cm_init(&cm_handler->cm_handler));
+ CALLUI_RETURN_VALUE_IF_FAIL(res == CALLUI_RESULT_OK, res);
+
+ cm_handler->sound_manager = _callui_sdm_create(cm_handler->cm_handler);
+ CALLUI_RETURN_VALUE_IF_FAIL(cm_handler->sound_manager, CALLUI_RESULT_FAIL);
+
+ cm_handler->state_provider = _callui_stp_create(cm_handler->cm_handler);
+ CALLUI_RETURN_VALUE_IF_FAIL(cm_handler->state_provider, CALLUI_RESULT_FAIL);
+
+ return res;
+}
+
+static void __callui_manager_deinit(callui_manager_h cm_handler)
+{
+ if (cm_handler->state_provider) {
+ _callui_stp_destroy(cm_handler->state_provider);
+ cm_handler->state_provider = NULL;
+ }
+
+ if (cm_handler->sound_manager) {
+ _callui_sdm_destroy(cm_handler->sound_manager);
+ cm_handler->sound_manager = NULL;
+ }
+
+ if (cm_handler->cm_handler) {
+ cm_deinit(cm_handler->cm_handler);
+ cm_handler->cm_handler = NULL;
+ }
+}
+
+callui_manager_h _callui_manager_create()
+{
+ callui_manager_h cm_handler = calloc(1, sizeof(_callui_manager_t));
+ CALLUI_RETURN_NULL_IF_FAIL(cm_handler);
+
+ callui_result_e res = __callui_manager_init(cm_handler);
+ if (res != CALLUI_RESULT_OK) {
+ __callui_manager_deinit(cm_handler);
+ FREE(cm_handler);
+ }
+ return cm_handler;
+}
+
+void _callui_manager_destroy(callui_manager_h cm_handler)
+{
+ CALLUI_RETURN_IF_FAIL(cm_handler);
+
+ __callui_manager_deinit(cm_handler);
+
+ free(cm_handler);
+}
+
+static cm_multi_sim_slot_type_e __convert_callui_sim_type(callui_sim_slot_type_e sim_type)
+{
+ switch (sim_type) {
+ case CALLUI_SIM_SLOT_1:
+ return CM_SIM_SLOT_1_E;
+ case CALLUI_SIM_SLOT_2:
+ return CM_SIM_SLOT_2_E;
+ default:
+ return CM_SIM_SLOT_DEFAULT_E;
+ }
+}
+
+callui_result_e _callui_manager_dial_voice_call(callui_manager_h cm_handler, const char *number, callui_sim_slot_type_e sim_slot)
+{
+ CALLUI_RETURN_VALUE_IF_FAIL(cm_handler, CALLUI_RESULT_INVALID_PARAM);
+ CALLUI_RETURN_VALUE_IF_FAIL(number, CALLUI_RESULT_INVALID_PARAM);
+
+ char *temp_number = (char *)number;
+ return _callui_utils_convert_cm_res(
+ cm_dial_call(cm_handler->cm_handler, temp_number, CM_CALL_TYPE_VOICE, __convert_callui_sim_type(sim_slot)));
+}
+
+callui_result_e _callui_manager_end_call(callui_manager_h cm_handler, unsigned int call_id, callui_call_release_type_e release_type)
+{
+ CALLUI_RETURN_VALUE_IF_FAIL(cm_handler, CALLUI_RESULT_INVALID_PARAM);
+ CALLUI_RETURN_VALUE_IF_FAIL(call_id <= 0, CALLUI_RESULT_INVALID_PARAM);
+
+ return _callui_utils_convert_cm_res(
+ cm_end_call(cm_handler->cm_handler, call_id, __convert_app_release_type(release_type)));
+}
+
+callui_result_e _callui_manager_swap_call(callui_manager_h cm_handler)
+{
+ CALLUI_RETURN_VALUE_IF_FAIL(cm_handler, CALLUI_RESULT_INVALID_PARAM);
+
+ return _callui_utils_convert_cm_res(
+ cm_swap_call(cm_handler->cm_handler));
+}
+
+callui_result_e _callui_manager_hold_call(callui_manager_h cm_handler)
+{
+ CALLUI_RETURN_VALUE_IF_FAIL(cm_handler, CALLUI_RESULT_INVALID_PARAM);
+
+ return _callui_utils_convert_cm_res(
+ cm_hold_call(cm_handler->cm_handler));
+}
+
+callui_result_e _callui_manager_unhold_call(callui_manager_h cm_handler)
+{
+ CALLUI_RETURN_VALUE_IF_FAIL(cm_handler, CALLUI_RESULT_INVALID_PARAM);
+
+ return _callui_utils_convert_cm_res(
+ cm_unhold_call(cm_handler->cm_handler));
+}
+
+callui_result_e _callui_manager_join_call(callui_manager_h cm_handler)
+{
+ CALLUI_RETURN_VALUE_IF_FAIL(cm_handler, CALLUI_RESULT_INVALID_PARAM);
+
+ return _callui_utils_convert_cm_res(
+ cm_join_call(cm_handler->cm_handler));
+}
+
+callui_result_e _callui_manager_reject_call(callui_manager_h cm_handler)
+{
+ CALLUI_RETURN_VALUE_IF_FAIL(cm_handler, CALLUI_RESULT_INVALID_PARAM);
+
+ return _callui_utils_convert_cm_res(
+ cm_reject_call(cm_handler->cm_handler));
+}
+
+callui_result_e _callui_manager_split_call(callui_manager_h cm_handler, unsigned int call_id)
+{
+ CALLUI_RETURN_VALUE_IF_FAIL(cm_handler, CALLUI_RESULT_INVALID_PARAM);
+ CALLUI_RETURN_VALUE_IF_FAIL(call_id <= 0, CALLUI_RESULT_INVALID_PARAM);
+
+ return _callui_utils_convert_cm_res(
+ cm_split_call(cm_handler->cm_handler, call_id));
+}
+
+callui_result_e _callui_manager_answer_call(callui_manager_h cm_handler, callui_call_answer_type_e ans_type)
+{
+ CALLUI_RETURN_VALUE_IF_FAIL(cm_handler, CALLUI_RESULT_INVALID_PARAM);
+
+ return _callui_utils_convert_cm_res(
+ cm_answer_call(cm_handler->cm_handler, __convert_app_answer_type(ans_type)));
+
+}
+
+callui_sound_manager_h _callui_manager_get_sound_manager(callui_manager_h cm_handler)
+{
+ CALLUI_RETURN_NULL_IF_FAIL(cm_handler);
+
+ return cm_handler->sound_manager;
+}
+
+callui_state_provider_h _callui_manager_get_state_provider(callui_manager_h cm_handler)
+{
+ CALLUI_RETURN_NULL_IF_FAIL(cm_handler);
+
+ return cm_handler->state_provider;
+}
--- /dev/null
+/*
+ * Copyright (c) 2009-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 "callui-model-utils-priv.h"
+
+callui_result_e _callui_utils_convert_cm_res(cm_error_e cm_res)
+{
+ switch (cm_res) {
+ case CM_ERROR_NONE:
+ return CALLUI_RESULT_OK;
+ case CM_ERROR_OUT_OF_MEMORY:
+ return CALLUI_RESULT_ALLOCATION_FAIL;
+ case CM_ERROR_INVALID_PARAMETER:
+ return CALLUI_RESULT_INVALID_PARAM;
+ case CM_ERROR_PERMISSION_DENIED:
+ return CALLUI_RESULT_PERMISSION_DENIED;
+ case CM_ERROR_NOT_SUPPORTED:
+ return CALLUI_RESULT_NOT_SUPPORTED;
+ case CM_ERROR_NOT_REGISTERED:
+ return CALLUI_RESULT_NOT_REGISTERED;
+ case CM_ERROR_ALREADY_REGISTERED:
+ return CALLUI_RESULT_ALREADY_REGISTERED;
+ case CM_ERROR_OPERATION_FAILED:
+ return CALLUI_RESULT_FAIL;
+ default:
+ return CALLUI_RESULT_UNKNOWN_ERROR;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2009-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 <Eina.h>
+#include <call-manager.h>
+#include <call-manager-extension.h>
+
+#include "callui-sound-manager.h"
+#include "callui-sound-manager-priv.h"
+#include "callui-debug.h"
+#include "callui-common.h"
+#include "callui-model-utils-priv.h"
+#include "callui-listeners-collection.h"
+
+struct __callui_sound_manager {
+ cm_client_h cm_handler;
+
+ _callui_listeners_coll_t audio_state_lc;
+ _callui_listeners_coll_t mute_status_lc;
+};
+typedef struct __callui_sound_manager _callui_sound_manager_t;
+
+static callui_result_e __callui_sdm_init(callui_sound_manager_h sdm, cm_client_h cm_client);
+static void __callui_sdm_deinit(callui_sound_manager_h sdm);
+
+static callui_audio_state_type_e __convert_cm_audio_state(cm_audio_state_type_e state_type);
+static void __callui_audio_state_changed_cb(cm_audio_state_type_e audio_state, void *user_data);
+static void __callui_mute_state_changed_cb(cm_mute_status_e mute_status, void *user_data);
+
+static void __audio_state_change_handler_func(_callui_listener_t *listener, va_list args);
+static void __mute_status_change_handler_func(_callui_listener_t *listener, va_list args);
+
+static callui_audio_state_type_e __convert_cm_audio_state(cm_audio_state_type_e state_type)
+{
+ switch (state_type) {
+ case CM_AUDIO_STATE_NONE_E:
+ return CALLUI_AUDIO_STATE_NONE;
+ case CM_AUDIO_STATE_SPEAKER_E:
+ return CALLUI_AUDIO_STATE_SPEAKER;
+ case CM_AUDIO_STATE_RECEIVER_E:
+ return CALLUI_AUDIO_STATE_RECEIVER;
+ case CM_AUDIO_STATE_EARJACK_E:
+ return CALLUI_AUDIO_STATE_EARJACK;
+ case CM_AUDIO_STATE_BT_E:
+ return CALLUI_AUDIO_STATE_BT;
+ default:
+ err("Unknown audio state type [%d]", state_type);
+ return CALLUI_AUDIO_STATE_NONE;
+ }
+}
+
+static void __callui_audio_state_changed_cb(cm_audio_state_type_e audio_state, void *user_data)
+{
+ CALLUI_RETURN_IF_FAIL(user_data);
+
+ dbg("AUDIO STATE CHANGED [%d]", audio_state);
+
+ callui_sound_manager_h sdm = (callui_sound_manager_h)user_data;
+
+ if (audio_state == CM_AUDIO_STATE_NONE_E) {
+ err("Unhandled state[%d]", audio_state);
+ return;
+ }
+
+ callui_audio_state_type_e as = __convert_cm_audio_state(audio_state);
+ _callui_listeners_coll_call_listeners(&sdm->audio_state_lc, as);
+}
+
+static void __callui_mute_state_changed_cb(cm_mute_status_e mute_status, void *user_data)
+{
+ CALLUI_RETURN_IF_FAIL(user_data);
+
+ dbg("MUTE STATE CHANGED [%d]", mute_status);
+
+ callui_sound_manager_h sdm = (callui_sound_manager_h)user_data;
+
+ bool is_enable = false;
+ if (mute_status == CM_MUTE_STATUS_ON) {
+ is_enable = true;
+ }
+ _callui_listeners_coll_call_listeners(&sdm->mute_status_lc, is_enable);
+}
+
+static callui_result_e __callui_sdm_init(callui_sound_manager_h sdm, cm_client_h cm_client)
+{
+ sdm->cm_handler = cm_client;
+
+ int res = _callui_listeners_coll_init(&sdm->audio_state_lc);
+ CALLUI_RETURN_VALUE_IF_FAIL(res == CALLUI_RESULT_OK, res);
+ res = _callui_listeners_coll_init(&sdm->mute_status_lc);
+ CALLUI_RETURN_VALUE_IF_FAIL(res == CALLUI_RESULT_OK, res);
+
+ res = cm_set_audio_state_changed_cb(sdm->cm_handler, __callui_audio_state_changed_cb, sdm);
+ CALLUI_RETURN_VALUE_IF_FAIL(res == CM_ERROR_NONE, _callui_utils_convert_cm_res(res));
+
+ res = cm_set_mute_status_cb(sdm->cm_handler, __callui_mute_state_changed_cb, sdm);
+ CALLUI_RETURN_VALUE_IF_FAIL(res == CM_ERROR_NONE, _callui_utils_convert_cm_res(res));
+
+ return CALLUI_RESULT_OK;
+}
+
+static void __callui_sdm_deinit(callui_sound_manager_h sdm)
+{
+ cm_unset_audio_state_changed_cb(sdm->cm_handler);
+ cm_unset_mute_status_cb(sdm->cm_handler);
+
+ _callui_listeners_coll_deinit(&sdm->audio_state_lc);
+ _callui_listeners_coll_deinit(&sdm->mute_status_lc);
+
+ sdm->cm_handler = NULL;
+}
+
+callui_sound_manager_h _callui_sdm_create(cm_client_h cm_client)
+{
+ CALLUI_RETURN_NULL_IF_FAIL(cm_client);
+
+ callui_sound_manager_h sdm = calloc(1, sizeof(_callui_sound_manager_t));
+ CALLUI_RETURN_NULL_IF_FAIL(sdm);
+
+ callui_result_e res = __callui_sdm_init(sdm, cm_client);
+ if (res != CALLUI_RESULT_OK) {
+ __callui_sdm_deinit(sdm);
+ FREE(sdm);
+ }
+ return sdm;
+}
+
+void _callui_sdm_destroy(callui_sound_manager_h sdm)
+{
+ CALLUI_RETURN_IF_FAIL(sdm);
+
+ __callui_sdm_deinit(sdm);
+
+ free(sdm);
+}
+
+callui_result_e _callui_sdm_set_speaker_state(callui_sound_manager_h sdm, bool is_enable)
+{
+ CALLUI_RETURN_VALUE_IF_FAIL(sdm, CALLUI_RESULT_INVALID_PARAM);
+
+ if (is_enable) {
+ return _callui_utils_convert_cm_res(cm_speaker_on(sdm->cm_handler));
+ } else {
+ return _callui_utils_convert_cm_res(cm_speaker_off(sdm->cm_handler));
+ }
+}
+
+callui_result_e _callui_sdm_set_bluetooth_state(callui_sound_manager_h sdm, bool is_enable)
+{
+ CALLUI_RETURN_VALUE_IF_FAIL(sdm, CALLUI_RESULT_INVALID_PARAM);
+
+ if (is_enable) {
+ return _callui_utils_convert_cm_res(cm_bluetooth_on(sdm->cm_handler));
+ } else {
+ return _callui_utils_convert_cm_res(cm_bluetooth_off(sdm->cm_handler));
+ }
+}
+
+callui_result_e _callui_sdm_set_mute_state(callui_sound_manager_h sdm, bool is_enable)
+{
+ CALLUI_RETURN_VALUE_IF_FAIL(sdm, CALLUI_RESULT_INVALID_PARAM);
+
+ return _callui_utils_convert_cm_res(cm_set_mute_state(sdm->cm_handler, is_enable));
+}
+
+bool _callui_sdm_get_mute_state(callui_sound_manager_h sdm)
+{
+ CALLUI_RETURN_VALUE_IF_FAIL(sdm, false);
+
+ cm_mute_status_e mutel_status = CM_MUTE_STATUS_MAX;
+ callui_result_e res = _callui_utils_convert_cm_res(cm_get_mute_status(sdm->cm_handler, &mutel_status));
+ CALLUI_RETURN_VALUE_IF_FAIL(res == CALLUI_RESULT_OK, false);
+
+ return mutel_status == CM_MUTE_STATUS_ON;
+}
+
+callui_result_e _callui_sdm_start_dtmf(callui_sound_manager_h sdm, unsigned char dtmf_digit)
+{
+ CALLUI_RETURN_VALUE_IF_FAIL(sdm, CALLUI_RESULT_INVALID_PARAM);
+
+ return _callui_utils_convert_cm_res(cm_start_dtmf(sdm->cm_handler, dtmf_digit));
+}
+
+callui_result_e _callui_sdm_stop_dtmf(callui_sound_manager_h sdm)
+{
+ CALLUI_RETURN_VALUE_IF_FAIL(sdm, CALLUI_RESULT_INVALID_PARAM);
+
+ return _callui_utils_convert_cm_res(cm_stop_dtmf(sdm->cm_handler));
+}
+
+callui_audio_state_type_e _callui_sdm_get_audio_state(callui_sound_manager_h sdm)
+{
+ CALLUI_RETURN_VALUE_IF_FAIL(sdm, CALLUI_AUDIO_STATE_NONE);
+
+ cm_audio_state_type_e snd_path = CM_AUDIO_STATE_NONE_E;
+ callui_result_e res = _callui_utils_convert_cm_res(
+ cm_get_audio_state(sdm->cm_handler, &snd_path));
+ CALLUI_RETURN_VALUE_IF_FAIL(res == CALLUI_RESULT_OK, CALLUI_AUDIO_STATE_NONE);
+
+ return __convert_cm_audio_state(snd_path);
+}
+
+static void __audio_state_change_handler_func(_callui_listener_t *listener, va_list args)
+{
+ callui_audio_state_type_e status = va_arg(args, callui_audio_state_type_e);
+ ((audio_state_changed_cb)(listener->cb_func))(listener->cb_data, status);
+}
+
+static void __mute_status_change_handler_func(_callui_listener_t *listener, va_list args)
+{
+ bool status = va_arg(args, int);
+ ((mute_state_changed_cb)(listener->cb_func))(listener->cb_data, status);
+}
+
+callui_result_e _callui_sdm_add_audio_state_changed_cb(callui_sound_manager_h sdm,
+ audio_state_changed_cb cb_func, void *cb_data)
+{
+ CALLUI_RETURN_VALUE_IF_FAIL(sdm, CALLUI_RESULT_INVALID_PARAM);
+ CALLUI_RETURN_VALUE_IF_FAIL(cb_func, CALLUI_RESULT_INVALID_PARAM);
+
+ return _callui_listeners_coll_add_listener(&sdm->audio_state_lc,
+ __audio_state_change_handler_func, cb_func, cb_data);
+}
+
+callui_result_e _callui_sdm_remove_audio_state_changed_cb(callui_sound_manager_h sdm,
+ audio_state_changed_cb cb_func, void *cb_data)
+{
+ CALLUI_RETURN_VALUE_IF_FAIL(sdm, CALLUI_RESULT_INVALID_PARAM);
+ CALLUI_RETURN_VALUE_IF_FAIL(cb_func, CALLUI_RESULT_INVALID_PARAM);
+
+ return _callui_listeners_coll_remove_listener(&sdm->audio_state_lc, (void *)cb_func, cb_data);
+}
+
+callui_result_e _callui_sdm_add_mute_state_changed_cb(callui_sound_manager_h sdm,
+ mute_state_changed_cb cb_func, void *cb_data)
+{
+ CALLUI_RETURN_VALUE_IF_FAIL(sdm, CALLUI_RESULT_INVALID_PARAM);
+ CALLUI_RETURN_VALUE_IF_FAIL(cb_func, CALLUI_RESULT_INVALID_PARAM);
+
+ return _callui_listeners_coll_add_listener(&sdm->mute_status_lc,
+ __mute_status_change_handler_func, cb_func, cb_data);
+}
+
+callui_result_e _callui_sdm_remove_mute_state_changed_cb(callui_sound_manager_h sdm,
+ mute_state_changed_cb cb_func, void *cb_data)
+{
+ CALLUI_RETURN_VALUE_IF_FAIL(sdm, CALLUI_RESULT_INVALID_PARAM);
+ CALLUI_RETURN_VALUE_IF_FAIL(cb_func, CALLUI_RESULT_INVALID_PARAM);
+
+ return _callui_listeners_coll_remove_listener(&sdm->mute_status_lc, (void *)cb_func, cb_data);
+}
--- /dev/null
+/*
+ * Copyright (c) 2009-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 <Eina.h>
+#include <call-manager.h>
+#include <call-manager-extension.h>
+#include <contacts.h>
+#include <sys/sysinfo.h>
+
+#include "callui-state-provider.h"
+#include "callui-state-provider-priv.h"
+#include "callui-debug.h"
+#include "callui-common.h"
+#include "callui-model-utils-priv.h"
+#include "callui-listeners-collection.h"
+
+#define CALLUI_NO_HANDLE 0
+#define CALLUI_DEFAULT_PERSON_ID_TXT "default"
+
+struct __callui_state_provider {
+ cm_client_h cm_handler;
+
+ callui_call_state_data_t *st_data_list[CALLUI_CALL_DATA_TYPE_MAX];
+
+ _callui_listeners_coll_t call_state_lc;
+ _callui_listeners_coll_t last_call_end_lc;
+};
+typedef struct __callui_state_provider _callui_state_provider_t;
+
+static callui_result_e __callui_stp_init(callui_state_provider_h stp, cm_client_h cm_client);
+static void __callui_stp_deinit(callui_state_provider_h stp);
+
+static void __get_contact_info_from_contact_srv(callui_contact_data_t *ct_info);
+static callui_result_e __convert_cm_call_event_type(cm_call_event_e cm_call_event, callui_call_event_type_e *call_event_type);
+static callui_sim_slot_type_e __convert_cm_sim_type(cm_multi_sim_slot_type_e cm_sim_type);
+static void __free_call_event_data(callui_state_provider_h stp);
+static callui_call_state_data_t *__call_data_create(cm_call_data_t* cm_call_data);
+static callui_result_e __call_data_init(callui_call_state_data_t *callui_call_data, cm_call_data_t* cm_call_data);
+static callui_result_e __update_stp_call_data(callui_call_state_data_t **stp_call_data, cm_call_data_t* cm_call_data);
+static callui_result_e __update_stp_all_call_data(callui_state_provider_h stp,
+ cm_call_data_t *cm_incom,
+ cm_call_data_t *cm_active,
+ cm_call_data_t *cm_held);
+static void __call_event_cb(cm_call_event_e call_event, cm_call_event_data_t *call_state_data, void *user_data);
+static void __call_state_event_handler_func(_callui_listener_t *listener, va_list args);
+static void __last_call_end_handler_func(_callui_listener_t *listener, va_list args);
+static void __list_free_cb(gpointer data);
+static callui_result_e __conf_call_data_init(callui_conf_call_data_t *conf_call_data, cm_conf_call_data_t *cm_conf_data);
+static callui_conf_call_data_t * __conf_call_data_create(cm_conf_call_data_t *cm_conf_data);
+
+static void __get_contact_info_from_contact_srv(callui_contact_data_t *ct_info)
+{
+ CALLUI_RETURN_IF_FAIL(ct_info);
+
+ contacts_error_e err = CONTACTS_ERROR_NONE;
+ contacts_record_h person_record = NULL;
+
+ int person_id = ct_info->person_id;
+ int res = contacts_db_get_record(_contacts_person._uri, person_id, &person_record);
+ if (res != CONTACTS_ERROR_NONE) {
+ err("contacts_db_get_record error %d", err);
+ } else {
+ char *name = NULL;
+ char *img_path = NULL;
+
+ /* Get display name */
+ res = contacts_record_get_str(person_record, _contacts_person.display_name, &name);
+ if (res != CONTACTS_ERROR_NONE) {
+ err("contacts_record_get_str(display name) error %d", err);
+ } else {
+ g_strlcpy(ct_info->call_disp_name, name, CALLUI_DISPLAY_NAME_LENGTH_MAX);
+ free(name);
+ }
+
+ /* Get caller id path */
+ res = contacts_record_get_str(person_record, _contacts_person.image_thumbnail_path, &img_path);
+ if (res != CONTACTS_ERROR_NONE) {
+ err("contacts_record_get_str(caller id path) error %d", err);
+ } else {
+ g_strlcpy(ct_info->caller_id_path, img_path, CALLUI_IMAGE_PATH_LENGTH_MAX);
+ free(img_path);
+ }
+ contacts_record_destroy(person_record, TRUE);
+ }
+
+ sec_dbg("contact index:[%d]", ct_info->person_id);
+ sec_dbg("display name:[%s]", ct_info->call_disp_name);
+ sec_dbg("img path:[%s]", ct_info->caller_id_path);
+
+ return;
+}
+
+static callui_result_e __convert_cm_call_event_type(cm_call_event_e cm_call_event,
+ callui_call_event_type_e *call_event_type)
+{
+ switch (cm_call_event) {
+ case CM_CALL_EVENT_IDLE:
+ *call_event_type = CALLUI_CALL_EVENT_TYPE_END;
+ break;
+ case CM_CALL_EVENT_DIALING:
+ *call_event_type = CALLUI_CALL_EVENT_TYPE_DIALING;
+ break;
+ case CM_CALL_EVENT_ACTIVE:
+ *call_event_type = CALLUI_CALL_EVENT_TYPE_ACTIVE;
+ break;
+ case CM_CALL_EVENT_HELD:
+ *call_event_type = CALLUI_CALL_EVENT_TYPE_HELD;
+ break;
+ case CM_CALL_EVENT_ALERT:
+ *call_event_type = CALLUI_CALL_EVENT_TYPE_ALERT;
+ break;
+ case CM_CALL_EVENT_INCOMING:
+ *call_event_type = CALLUI_CALL_EVENT_TYPE_INCOMING;
+ break;
+ case CM_CALL_EVENT_WAITING:
+ *call_event_type = CALLUI_CALL_EVENT_TYPE_WAITING;
+ break;
+ case CM_CALL_EVENT_JOIN:
+ *call_event_type = CALLUI_CALL_EVENT_TYPE_JOIN;
+ break;
+ case CM_CALL_EVENT_SPLIT:
+ *call_event_type = CALLUI_CALL_EVENT_TYPE_SPLIT;
+ break;
+ case CM_CALL_EVENT_SWAPPED:
+ *call_event_type = CALLUI_CALL_EVENT_TYPE_SWAPPED;
+ break;
+ case CM_CALL_EVENT_RETRIEVED:
+ *call_event_type = CALLUI_CALL_EVENT_TYPE_RETRIEVED;
+ break;
+ case CM_CALL_EVENT_SAT_CALL_CONTROL:
+ *call_event_type = CALLUI_CALL_EVENT_TYPE_SAT_CALL_CONTROL;
+ break;
+ default:
+ err("Undefined call event type [%d]", cm_call_event);
+ return CALLUI_RESULT_FAIL;
+ }
+ return CALLUI_RESULT_OK;
+}
+
+static callui_sim_slot_type_e __convert_cm_sim_type(cm_multi_sim_slot_type_e cm_sim_type)
+{
+ switch (cm_sim_type) {
+ case CM_SIM_SLOT_1_E:
+ return CALLUI_SIM_SLOT_1;
+ case CM_SIM_SLOT_2_E:
+ return CALLUI_SIM_SLOT_2;
+ default:
+ return CALLUI_SIM_SLOT_DEFAULT;
+ }
+}
+
+static void __free_call_event_data(callui_state_provider_h stp)
+{
+ int i = 0;
+ for (; i < CALLUI_CALL_DATA_TYPE_MAX; i++) {
+ FREE(stp->st_data_list[i]);
+ }
+}
+
+static callui_call_state_data_t *__call_data_create(cm_call_data_t* cm_call_data)
+{
+ callui_call_state_data_t *call_data = calloc(1, sizeof(callui_call_state_data_t));
+ CALLUI_RETURN_NULL_IF_FAIL(call_data);
+
+ int res = __call_data_init(call_data, cm_call_data);
+ if (res != CALLUI_RESULT_OK) {
+ err("Init call data failed. res[%d]", res);
+ FREE(call_data);
+ }
+ return call_data;
+}
+
+static callui_result_e __call_data_init(callui_call_state_data_t *callui_call_data,
+ cm_call_data_t* cm_call_data)
+{
+ callui_call_data->call_id = CALLUI_NO_HANDLE;
+ int res = cm_call_data_get_call_id(cm_call_data, &callui_call_data->call_id);
+ CALLUI_RETURN_VALUE_IF_FAIL(res == CM_ERROR_NONE, _callui_utils_convert_cm_res(res));
+
+ char *call_number = NULL;
+ res = cm_call_data_get_call_number(cm_call_data, &call_number);
+ CALLUI_RETURN_VALUE_IF_FAIL(res == CM_ERROR_NONE, _callui_utils_convert_cm_res(res));
+ if (call_number) {
+ snprintf(callui_call_data->call_num, CALLUI_PHONE_NUMBER_LENGTH_MAX, "%s", call_number);
+ }
+ // XXX: according to documentation it must be free, but it leads to crash
+// free(call_number);
+
+ res = cm_call_data_get_call_member_count(cm_call_data, &callui_call_data->conf_member_count);
+ CALLUI_RETURN_VALUE_IF_FAIL(res == CM_ERROR_NONE, _callui_utils_convert_cm_res(res));
+
+ gboolean is_emergency;
+ res = cm_call_data_is_emergency_call(cm_call_data, &is_emergency);
+ CALLUI_RETURN_VALUE_IF_FAIL(res == CM_ERROR_NONE, _callui_utils_convert_cm_res(res));
+ callui_call_data->is_emergency = is_emergency;
+
+ res = cm_call_data_get_start_time(cm_call_data, &callui_call_data->start_time);
+ CALLUI_RETURN_VALUE_IF_FAIL(res == CM_ERROR_NONE, _callui_utils_convert_cm_res(res));
+
+ cm_call_state_e call_state;
+ res = cm_call_data_get_call_state(cm_call_data, &call_state);
+ CALLUI_RETURN_VALUE_IF_FAIL(res == CM_ERROR_NONE, _callui_utils_convert_cm_res(res));
+
+ callui_call_data->is_dialing = false;
+ if(call_state == CM_CALL_STATE_DIALING) {
+ callui_call_data->is_dialing = true;
+ }
+ callui_call_data->call_ct_info.person_id = -1;
+ res = cm_call_data_get_person_id(cm_call_data, &callui_call_data->call_ct_info.person_id);
+ CALLUI_RETURN_VALUE_IF_FAIL(res == CM_ERROR_NONE, _callui_utils_convert_cm_res(res));
+
+ if (callui_call_data->call_ct_info.person_id != -1) {
+ dbg("contact exists with index:[%d]", callui_call_data->call_ct_info.person_id);
+ __get_contact_info_from_contact_srv(&callui_call_data->call_ct_info);
+ }
+
+ if (strlen(callui_call_data->call_ct_info.caller_id_path) <= 0) {
+ snprintf(callui_call_data->call_ct_info.caller_id_path,
+ CALLUI_IMAGE_PATH_LENGTH_MAX, "%s", CALLUI_DEFAULT_PERSON_ID_TXT);
+ }
+
+ return CALLUI_RESULT_OK;
+}
+
+static callui_result_e __update_stp_call_data(callui_call_state_data_t **stp_call_data, cm_call_data_t* cm_call_data)
+{
+ if (!cm_call_data) {
+ FREE(*stp_call_data);
+ return CALLUI_RESULT_OK;
+ }
+ callui_call_state_data_t *tmp_call_data = __call_data_create(cm_call_data);
+ CALLUI_RETURN_VALUE_IF_FAIL(tmp_call_data, CALLUI_RESULT_FAIL);
+
+ free(*stp_call_data);
+ *stp_call_data = tmp_call_data;
+
+ return CALLUI_RESULT_OK;
+}
+
+static callui_result_e __update_stp_all_call_data(callui_state_provider_h stp,
+ cm_call_data_t *cm_incom,
+ cm_call_data_t *cm_active,
+ cm_call_data_t *cm_held)
+{
+ dbg("Update incoming call data");
+ int res = __update_stp_call_data(&(stp->st_data_list[CALLUI_CALL_DATA_TYPE_INCOMING]), cm_incom);
+ CALLUI_RETURN_VALUE_IF_FAIL(res == CALLUI_RESULT_OK, res);
+
+ dbg("Update active call data");
+ res = __update_stp_call_data(&(stp->st_data_list[CALLUI_CALL_DATA_TYPE_ACTIVE]), cm_active);
+ CALLUI_RETURN_VALUE_IF_FAIL(res == CALLUI_RESULT_OK, res);
+
+ dbg("Update held call data");
+ res = __update_stp_call_data(&(stp->st_data_list[CALLUI_CALL_DATA_TYPE_HELD]), cm_held);
+ CALLUI_RETURN_VALUE_IF_FAIL(res == CALLUI_RESULT_OK, res);
+
+ return res;
+}
+
+static void __call_event_cb(cm_call_event_e call_event, cm_call_event_data_t *call_state_data, void *user_data)
+{
+ CALLUI_RETURN_IF_FAIL(call_state_data);
+ CALLUI_RETURN_IF_FAIL(user_data);
+
+ callui_call_event_type_e event_type;
+ CALLUI_RETURN_IF_FAIL(__convert_cm_call_event_type(call_event, &event_type) == CALLUI_RESULT_OK);
+
+ dbg("Call event changed on [%d]", event_type);
+
+ callui_state_provider_h stp = (callui_state_provider_h)user_data;
+ bool is_need_notify_call_event = true;
+
+ unsigned int call_id = 0;
+ int res = cm_call_event_data_get_call_id(call_state_data, &call_id);
+ CALLUI_RETURN_IF_FAIL(res == CM_ERROR_NONE);
+
+ cm_multi_sim_slot_type_e cm_sim_slot;
+ res = cm_call_event_data_get_sim_slot(call_state_data, &cm_sim_slot);
+ CALLUI_RETURN_IF_FAIL(res == CM_ERROR_NONE);
+ callui_sim_slot_type_e sim_slot_type = __convert_cm_sim_type(cm_sim_slot);
+
+ cm_call_data_t *cm_incom = NULL;
+ cm_call_data_t *cm_active = NULL;
+ cm_call_data_t *cm_held = NULL;
+
+ res = cm_call_event_data_get_active_call(call_state_data, &cm_active);
+ CALLUI_RETURN_IF_FAIL(res == CM_ERROR_NONE);
+ res = cm_call_event_data_get_incom_call(call_state_data, &cm_incom);
+ CALLUI_RETURN_IF_FAIL(res == CM_ERROR_NONE);
+ res = cm_call_event_data_get_held_call(call_state_data, &cm_held);
+ CALLUI_RETURN_IF_FAIL(res == CM_ERROR_NONE);
+
+ switch (event_type) {
+ case CALLUI_CALL_EVENT_TYPE_END:
+ {
+ callui_call_state_data_t *temp = NULL;
+ if (cm_incom == NULL && cm_active == NULL && cm_held == NULL) {
+ if (stp->st_data_list[CALLUI_CALL_DATA_TYPE_ACTIVE]) {
+ temp = stp->st_data_list[CALLUI_CALL_DATA_TYPE_ACTIVE];
+ } else if (stp->st_data_list[CALLUI_CALL_DATA_TYPE_HELD]) {
+ temp = stp->st_data_list[CALLUI_CALL_DATA_TYPE_HELD];
+ } else {
+ return;
+ }
+ _callui_listeners_coll_call_listeners(&stp->last_call_end_lc, temp);
+
+ __update_stp_all_call_data(stp, cm_incom, cm_active, cm_held);
+
+ is_need_notify_call_event = false;
+
+ } else {
+ res = __update_stp_all_call_data(stp, cm_incom, cm_active, cm_held);
+ }
+ }
+ break;
+ case CALLUI_CALL_EVENT_TYPE_ACTIVE:
+ case CALLUI_CALL_EVENT_TYPE_INCOMING:
+ case CALLUI_CALL_EVENT_TYPE_DIALING:
+ case CALLUI_CALL_EVENT_TYPE_HELD:
+ case CALLUI_CALL_EVENT_TYPE_RETRIEVED:
+ case CALLUI_CALL_EVENT_TYPE_SWAPPED:
+ case CALLUI_CALL_EVENT_TYPE_JOIN:
+ case CALLUI_CALL_EVENT_TYPE_SPLIT:
+ res = __update_stp_all_call_data(stp, cm_incom, cm_active, cm_held);
+ break;
+ default:
+ return;
+ }
+
+ if (is_need_notify_call_event && res == CALLUI_RESULT_OK) {
+ _callui_listeners_coll_call_listeners(&stp->call_state_lc, event_type, call_id, sim_slot_type);
+ }
+}
+
+static callui_result_e __callui_stp_init(callui_state_provider_h stp, cm_client_h cm_client)
+{
+ stp->cm_handler = cm_client;
+
+ int res = _callui_listeners_coll_init(&stp->call_state_lc);
+ CALLUI_RETURN_VALUE_IF_FAIL(res == CALLUI_RESULT_OK, res);
+ res = _callui_listeners_coll_init(&stp->last_call_end_lc);
+ CALLUI_RETURN_VALUE_IF_FAIL(res == CALLUI_RESULT_OK, res);
+
+ res = contacts_connect();
+ CALLUI_RETURN_VALUE_IF_FAIL(res == CONTACTS_ERROR_NONE, CALLUI_RESULT_FAIL);
+
+ cm_call_data_t *cm_incom = NULL;
+ cm_call_data_t *cm_active = NULL;
+ cm_call_data_t *cm_held = NULL;
+
+ res = cm_get_all_calldata(stp->cm_handler, &cm_incom, &cm_active, &cm_held);
+ CALLUI_RETURN_VALUE_IF_FAIL(res == CM_ERROR_NONE, _callui_utils_convert_cm_res(res));
+
+ __update_stp_all_call_data(stp, cm_incom, cm_active, cm_held);
+
+ cm_call_data_free(cm_incom);
+ cm_call_data_free(cm_active);
+ cm_call_data_free(cm_held);
+
+ return _callui_utils_convert_cm_res(cm_set_call_event_cb(stp->cm_handler, __call_event_cb, stp));
+}
+
+static void __callui_stp_deinit(callui_state_provider_h stp)
+{
+ cm_unset_call_event_cb(stp->cm_handler);
+
+ contacts_disconnect();
+
+ _callui_listeners_coll_deinit(&stp->call_state_lc);
+ _callui_listeners_coll_deinit(&stp->last_call_end_lc);
+
+ __free_call_event_data(stp);
+}
+
+callui_state_provider_h _callui_stp_create(cm_client_h cm_client)
+{
+ CALLUI_RETURN_NULL_IF_FAIL(cm_client);
+
+ callui_state_provider_h stp = calloc(1, sizeof(_callui_state_provider_t));
+ CALLUI_RETURN_NULL_IF_FAIL(stp);
+
+ callui_result_e res = __callui_stp_init(stp, cm_client);
+ if (res != CALLUI_RESULT_OK) {
+ __callui_stp_deinit(stp);
+ FREE(stp);
+ }
+
+ return stp;
+}
+
+void _callui_stp_destroy(callui_state_provider_h stp)
+{
+ CALLUI_RETURN_IF_FAIL(stp);
+
+ __callui_stp_deinit(stp);
+
+ free(stp);
+}
+
+const callui_call_state_data_t *_callui_stp_get_call_data(callui_state_provider_h stp,
+ callui_call_data_type_e call_data_type)
+{
+ CALLUI_RETURN_NULL_IF_FAIL(stp);
+ CALLUI_RETURN_NULL_IF_FAIL((call_data_type >= CALLUI_CALL_DATA_TYPE_ACTIVE &&
+ call_data_type < CALLUI_CALL_DATA_TYPE_MAX));
+
+ return stp->st_data_list[call_data_type];
+}
+
+static void __call_state_event_handler_func(_callui_listener_t *listener, va_list args)
+{
+ callui_call_event_type_e call_event_type = va_arg(args, callui_call_event_type_e);
+ unsigned int id = va_arg(args, unsigned int);
+ callui_sim_slot_type_e sim_slot = va_arg(args, callui_sim_slot_type_e);
+
+ ((callui_call_state_event_cb)(listener->cb_func))(listener->cb_data, call_event_type, id, sim_slot);
+}
+
+static void __last_call_end_handler_func(_callui_listener_t *listener, va_list args)
+{
+ callui_call_state_data_t *last_call_data = va_arg(args, callui_call_state_data_t *);
+ ((callui_last_call_end_event_cb)(listener->cb_func))(listener->cb_data, last_call_data);
+}
+
+callui_result_e _callui_stp_add_call_state_event_cb(callui_state_provider_h stp,
+ callui_call_state_event_cb cb_func,
+ void *cb_data)
+{
+ CALLUI_RETURN_VALUE_IF_FAIL(stp, CALLUI_RESULT_INVALID_PARAM);
+ CALLUI_RETURN_VALUE_IF_FAIL(cb_func, CALLUI_RESULT_INVALID_PARAM);
+
+ return _callui_listeners_coll_add_listener(&stp->call_state_lc,
+ __call_state_event_handler_func, cb_func, cb_data);
+}
+
+callui_result_e _callui_stp_remove_call_state_event_cb(callui_state_provider_h stp,
+ callui_call_state_event_cb cb_func,
+ void *cb_data)
+{
+ CALLUI_RETURN_VALUE_IF_FAIL(stp, CALLUI_RESULT_INVALID_PARAM);
+ CALLUI_RETURN_VALUE_IF_FAIL(cb_func, CALLUI_RESULT_INVALID_PARAM);
+
+ return _callui_listeners_coll_remove_listener(&stp->call_state_lc, (void *)cb_func, cb_data);
+}
+
+callui_result_e _callui_stp_add_last_call_end_event_cb(callui_state_provider_h stp,
+ callui_last_call_end_event_cb cb_func,
+ void *cb_data)
+{
+ CALLUI_RETURN_VALUE_IF_FAIL(stp, CALLUI_RESULT_INVALID_PARAM);
+ CALLUI_RETURN_VALUE_IF_FAIL(cb_func, CALLUI_RESULT_INVALID_PARAM);
+
+ return _callui_listeners_coll_add_listener(&stp->last_call_end_lc,
+ __last_call_end_handler_func, cb_func, cb_data);
+}
+
+callui_result_e _callui_stp_remove_last_call_end_event_cb(callui_state_provider_h stp,
+ callui_last_call_end_event_cb cb_func,
+ void *cb_data)
+{
+ CALLUI_RETURN_VALUE_IF_FAIL(stp, CALLUI_RESULT_INVALID_PARAM);
+ CALLUI_RETURN_VALUE_IF_FAIL(cb_func, CALLUI_RESULT_INVALID_PARAM);
+
+ return _callui_listeners_coll_remove_listener(&stp->last_call_end_lc, (void *)cb_func, cb_data);
+}
+
+static void __list_free_cb(gpointer data)
+{
+ cm_conf_call_data_t *call_data = (cm_conf_call_data_t *)data;
+ cm_conf_call_data_free(call_data);
+}
+
+static callui_conf_call_data_t * __conf_call_data_create(cm_conf_call_data_t *cm_conf_data)
+{
+ callui_conf_call_data_t *conf_data = (callui_conf_call_data_t *)calloc(1, sizeof(callui_conf_call_data_t));
+ CALLUI_RETURN_NULL_IF_FAIL(conf_data);
+
+ int res = __conf_call_data_init(conf_data, cm_conf_data);
+ if (res != CALLUI_RESULT_OK) {
+ err("Init conference call data failed. res[%d]", res);
+ FREE(conf_data);
+ }
+ return conf_data;
+}
+
+static callui_result_e __conf_call_data_init(callui_conf_call_data_t *conf_call_data,
+ cm_conf_call_data_t *cm_conf_data)
+{
+ int res = cm_conf_call_data_get_call_id(cm_conf_data, &conf_call_data->call_id);
+ CALLUI_RETURN_VALUE_IF_FAIL(res == CM_ERROR_NONE, _callui_utils_convert_cm_res(res));
+
+ char *call_number = NULL;
+ res = cm_conf_call_data_get_call_number(cm_conf_data, &call_number);
+ CALLUI_RETURN_VALUE_IF_FAIL(res == CM_ERROR_NONE, _callui_utils_convert_cm_res(res));
+ if (call_number) {
+ snprintf(conf_call_data->call_num, CALLUI_PHONE_NUMBER_LENGTH_MAX, "%s", call_number);
+ }
+ // XXX: according to documentation it must be free, but it leads to crash
+// free(call_number);
+
+ conf_call_data->call_ct_info.person_id = -1;
+ res = cm_conf_call_data_get_person_id(cm_conf_data, &conf_call_data->call_ct_info.person_id);
+ CALLUI_RETURN_VALUE_IF_FAIL(res == CM_ERROR_NONE, _callui_utils_convert_cm_res(res));
+
+ if (conf_call_data->call_ct_info.person_id != -1) {
+ dbg("contact exists with index:[%d]", conf_call_data->call_ct_info.person_id);
+ __get_contact_info_from_contact_srv(&conf_call_data->call_ct_info);
+ }
+
+ if (strlen(conf_call_data->call_ct_info.caller_id_path) <= 0) {
+ snprintf(conf_call_data->call_ct_info.caller_id_path,
+ CALLUI_IMAGE_PATH_LENGTH_MAX, "%s", CALLUI_DEFAULT_PERSON_ID_TXT);
+ }
+
+ return CALLUI_RESULT_OK;
+}
+
+Eina_List *_callui_stp_get_conference_call_list(callui_state_provider_h stp)
+{
+ CALLUI_RETURN_NULL_IF_FAIL(stp);
+
+ // XXX: must be initialized with NULL. If not an there is no conference calls
+ // cm_get_conference_call_list return CM_ERROR_NONE and pointer will be not changed.
+ GSList *call_list = NULL;
+ Eina_List *res_list = NULL;
+
+ int res = cm_get_conference_call_list(stp->cm_handler, &call_list);
+ CALLUI_RETURN_NULL_IF_FAIL(res == CM_ERROR_NONE);
+
+ if (call_list) {
+ int list_len = g_slist_length(call_list);
+ res = CALLUI_RESULT_OK;
+
+ int idx = 0;
+ for (; idx < list_len; idx++) {
+ callui_conf_call_data_t *conf_call_data = __conf_call_data_create(g_slist_nth_data(call_list, idx));
+ if(conf_call_data == NULL) {
+ err("Create conference call data failed.");
+ res = CALLUI_RESULT_ALLOCATION_FAIL;
+ break;
+ }
+ res_list = eina_list_append(res_list, conf_call_data);
+ if (res_list == NULL) {
+ err("Append item to list failed.");
+ res = CALLUI_RESULT_FAIL;
+ break;
+ }
+ }
+
+ if (res != CALLUI_RESULT_OK) {
+ Eina_List *l;
+ callui_conf_call_data_t *data;
+ EINA_LIST_FOREACH(res_list, l, data) {
+ free(data);
+ }
+ res_list = eina_list_free(res_list);
+ }
+ g_slist_free_full(call_list, __list_free_cb);
+ }
+
+ return res_list;
+}
+
+struct tm*_callui_stp_get_call_duration(callui_state_provider_h stp,
+ callui_call_data_type_e call_data_type)
+{
+ CALLUI_RETURN_NULL_IF_FAIL(stp);
+ CALLUI_RETURN_NULL_IF_FAIL((call_data_type >= CALLUI_CALL_DATA_TYPE_ACTIVE &&
+ call_data_type < CALLUI_CALL_DATA_TYPE_MAX));
+ CALLUI_RETURN_NULL_IF_FAIL(stp->st_data_list[call_data_type]);
+
+ struct tm *time = calloc(1, sizeof (struct tm));
+ CALLUI_RETURN_NULL_IF_FAIL(time);
+
+ long curr_time = 0;
+ struct sysinfo info;
+ if (sysinfo(&info) == 0) {
+ curr_time = info.uptime;
+ }
+
+ long call_time = curr_time - stp->st_data_list[call_data_type]->start_time;
+ gmtime_r((const time_t *)&call_time, time);
+
+ return time;
+}