diff options
author | Kibum Kim <kb0929.kim@samsung.com> | 2012-01-07 00:42:21 +0900 |
---|---|---|
committer | Kibum Kim <kb0929.kim@samsung.com> | 2012-01-07 00:42:21 +0900 |
commit | 4aea6f5ede38f2d2d20a75895d9b598704fe14d0 (patch) | |
tree | be6f7592ab90a059f1a932bdcfff18631422267e /include | |
parent | f7d3bd8b3884553bbe42d6ece32974d3e26281ee (diff) | |
download | call-log-4aea6f5ede38f2d2d20a75895d9b598704fe14d0.tar.gz call-log-4aea6f5ede38f2d2d20a75895d9b598704fe14d0.tar.bz2 call-log-4aea6f5ede38f2d2d20a75895d9b598704fe14d0.zip |
Git init
Diffstat (limited to 'include')
-rwxr-xr-x | include/calllog.h | 342 | ||||
-rwxr-xr-x | include/calllog_private.h | 125 | ||||
-rwxr-xr-x | include/calllog_types.h | 130 |
3 files changed, 597 insertions, 0 deletions
diff --git a/include/calllog.h b/include/calllog.h new file mode 100755 index 0000000..8f4d58c --- /dev/null +++ b/include/calllog.h @@ -0,0 +1,342 @@ +/* + * Copyright (c) 2011 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 __TIZEN_CALLLOG_H__ +#define __TIZEN_CALLLOG_H__ + +#include <calllog_types.h> + +#ifdef __cplusplus +extern "C" +{ +#endif +/** + * @addtogroup CAPI_SOCIAL_CALLLOG_MODULE + * @{ + */ + +/** + * @brief Opens a connection to call log service. + * + * @details Opening connection is necessary to access call log database. + * All operations like inserting, updating, and deleting call log require opened connection. + + * @remarks If the call log connection has been already established, this function will return #CALLLOG_ERROR_NONE. + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALLLOG_ERROR_NONE Successful + * @retval #CALLLOG_ERROR_DB_FAILED Failed to connect + * + * @see calllog_disconnect() + * + */ + +int calllog_connect(void); + +/** + * @brief Closes the connection to call log service. + * + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALLLOG_ERROR_NONE Successful + * @retval #CALLLOG_ERROR_DB_FAILED Database failed + * + * @see calllog_connect() + */ +int calllog_disconnect(void); + +/** + * @brief Creates a new call log handle. + * @remarks The call log handle must be released with calllog_destroy() by you. + * @remarks The created handle is not added to call log database until calllog_insert_to_db() is called. + * + * @param[out] log A new call log handle + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALLLOG_ERROR_NONE Successful + * @retval #CALLLOG_ERROR_OUT_OF_MEMORY Out of memory + * @retval #CALLLOG_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calllog_destroy() + * + */ +int calllog_create(calllog_h *log); + +/** + * @brief Destroys the call log handle. + * + * + * @param[in] log The call log handle + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALLLOG_ERROR_NONE Successful + * @retval #CALLLOG_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calllog_create() + */ +int calllog_destroy(calllog_h log); + +/** + * @brief Inserts a new call log entry to the call log database. + * + * + * + * @param[in] log The call log handle + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALLLOG_ERROR_NONE Successful + * @retval #CALLLOG_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CALLLOG_ERROR_DB_FAILED Database failed + * + * @pre This function requires an open connection to call log service by calllog_connect(). + * + * @see calllog_connect() + * @see calllog_disconnect() + * @see calllog_delete_from_db() + * @see calllog_delete_all_from_db() + * + */ +int calllog_insert_to_db(calllog_h log); + +/** + * @brief Deletes the call log with given ID from the database. + * + * @param[in] calllog_db_id The database identifier of call log to delete + * + * @return 0 on success, otherwise a negative error value + * @retval #CALLLOG_ERROR_NONE Successful + * @retval #CALLLOG_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CALLLOG_ERROR_DB_FAILED Database failed + * + * @pre This function requires an open connection to call log service by calllog_connect(). + * + * @see calllog_connect() + * @see calllog_disconnect() + * @see calllog_insert_to_db() + * @see calllog_delete_all_from_db() + */ +int calllog_delete_from_db(int calllog_db_id); + +/** + * @brief Deletes all the call log from the database. + * + * @return 0 on success, otherwise a negative error value + * @retval #CALLLOG_ERROR_NONE Successful + * @retval #CALLLOG_ERROR_OUT_OF_MEMORY Out of memory + * @retval #CALLLOG_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CALLLOG_ERROR_DB_FAILED Database failed + * + * @pre This function requires an open connection to call log service by calllog_connect(). + * + * @see calllog_connect() + * @see calllog_disconnect() + * @see calllog_insert_to_db() + * @see calllog_delete_from_db() + */ +int calllog_delete_all_from_db(void); + +/** + * @brief Updates the call log status of missed call from unchecked to checked. + * + * @param[in] calllog_db_id The database ID of call log to update \n + * The type of call log must be #CALLLOG_TYPE_VOICE_MISSED_UNCHECKED or #CALLLOG_TYPE_VIDEO_MISSED_UNCHECKED (If not, #CALLLOG_ERROR_INVALID_PARAMETER occurred) + * + * @return 0 on success, otherwise a negative error value + * @retval #CALLLOG_ERROR_NONE Successful + * @retval #CALLLOG_ERROR_INVALID_PARAMETER Call log doesn't exist + * @retval #CALLLOG_ERROR_DB_FAILED Database failed + * + * @see calllog_query_calllog_by_number() + * @see calllog_set_type() + * @see calllog_get_type() + */ +int calllog_update_missed_unchecked_to_checked_to_db(int calllog_db_id); + +/** + * @brief Gets the time from the call log handle. + * + * + * @param[in] log The call log handle + * @param[out] log_time The log time in UNIX-time format + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALLLOG_ERROR_NONE Successful + * @retval #CALLLOG_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calllog_set_time() + */ +int calllog_get_time(calllog_h log, time_t *log_time); + +/** + * @brief Sets a log time to the call log handle. + * + * + * @param[in] log The call log handle + * @param[in] log_time The log time in UNIX-time format + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALLLOG_ERROR_NONE Successful + * @retval #CALLLOG_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calllog_get_time() + */ +int calllog_set_time(calllog_h log, time_t log_time); + +/** + * @brief Gets the log type from the call log handle. + * + * + * @param[in] log The call log handle + * @param[out] type The log type + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALLLOG_ERROR_NONE Successful + * @retval #CALLLOG_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calllog_set_type() + */ +int calllog_get_type(calllog_h log, calllog_type_e *type); + +/** + * @brief Sets a log type to the call log handle. + * + * + * @param[in] log The call log handle + * @param[in] type The log type + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALLLOG_ERROR_NONE Successful + * @retval #CALLLOG_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calllog_get_type() + */ +int calllog_set_type(calllog_h log, calllog_type_e type); + +/** + * @brief Gets the call duration from the call log handle. + * + * + * @param[in] log The call log handle + * @param[out] duration_sec The call duration (seconds) + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALLLOG_ERROR_NONE Successful + * @retval #CALLLOG_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calllog_set_duration() + */ +int calllog_get_duration(calllog_h log, int *duration_sec); + +/** + * @brief Sets the call duration to the call log handle. + * + * @param[in] log The call log handle + * @param[in] duration_sec The call duration (seconds) + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALLLOG_ERROR_NONE Successful + * @retval #CALLLOG_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calllog_get_duration() + */ +int calllog_set_duration(calllog_h log, int duration_sec); + +/** + * @brief Gets the phone number from the call log handle. + * + * @remarks @a number must be released with free() by you. + * + * @param[in] log The call log handle + * @param[out] number The phone number \n If the number does not exist, it is NULL + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALLLOG_ERROR_NONE Successful + * @retval #CALLLOG_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calllog_set_number() + */ +int calllog_get_number(calllog_h log, char **number); + +/** + * @brief Sets the phone number to the call log handle. + * + * + * @param[in] log The call log handle + * @param[in] number The phone number + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALLLOG_ERROR_NONE Successful + * @retval #CALLLOG_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calllog_get_number() + * + */ +int calllog_set_number(calllog_h log, const char *number); + +/** + * @brief Retrieves all call logs by invoking the given callback function iteratively. + * + * @param[in] callback The callback function + * @param[in] user_data The user data to be passed to the callback function + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALLLOG_ERROR_NONE Successful + * @retval #CALLLOG_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CALLLOG_ERROR_DB_FAILED Database failed + * + * @pre This function requires an open connection to call log service by calllog_connect(). + * + * @post This function invokes calllog_foreach_cb(). + * + * @see calllog_connect() + * @see calllog_foreach_cb() + * @see calllog_query_calllog_by_number() + */ +int calllog_foreach_calllog_from_db(calllog_foreach_cb callback, void *user_data); + +/** + * @brief Retrieves all call logs with the given number. + * + * @param[in] callback The callback function to invoke + * @param[in] number_to_find The number to filter + * @param[in] user_data The user data to be passed to the callback function + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALLLOG_ERROR_NONE Successful + * @retval #CALLLOG_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CALLLOG_ERROR_DB_FAILED Database failed + * + * @pre This function requires an open connection to call log service by calllog_connect(). + * + * @post This function invokes calllog_foreach_cb(). + * + * @see calllog_connect() + * @see calllog_foreach_cb() + * @see calllog_foreach_calllog_from_db() + */ +int calllog_query_calllog_by_number(calllog_foreach_cb callback, const char *number_to_find, void *user_data); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __CONTACTS_LOG_H__ */ + diff --git a/include/calllog_private.h b/include/calllog_private.h new file mode 100755 index 0000000..924cab8 --- /dev/null +++ b/include/calllog_private.h @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2011 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 __TIZEN_CALLLOG_PRIVATE_H__ +#define __TIZEN_CALLLOG_PRIVATE_H__ + + +#ifdef __cplusplus +extern "C" +{ +#endif + +/** + * @internal + */ +typedef struct +{ + int v_type:16; + bool embedded; + bool deleted; + int id; + char *number; + int related_id; /* contact id */ + int log_time; + int calllog_type; + int extra_data1; /* duration, message_id */ + char *extra_data2; /*short message*/ +} _calllog_s;//CTS_PLOG_VAL_ + + +/** + * @internal + * @brief Retrieves the detailed information of each call log in the call log database. + * @details Retrieves just one call log for each phone number. + * If you want to get all the information for the number you can use calllog_query_calllog_by_number(). + * + * @param[in] callback The callback function + * @param[in] user_data The user data to be passed to the callback function + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALLLOG_ERROR_NONE Successful + * @retval #CALLLOG_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CALLLOG_ERROR_DB_FAILED Database failed + * + * @pre This function requires an open connection to call log service by calllog_connect(). + * + * @post This function invokes calllog_foreach_cb(). + * + * @see calllog_connect() + * @see calllog_query_calllog_by_number() + */ +int _calllog_foreach_calllog_grouped_from_db(calllog_foreach_cb callback, void *user_data); + + +/** + * @internal + * @brief Gets the short message from the call log handle. + * + * @remarks @a shortmsg must be released with free() by you. + * + * @param[in] log The call log handle + * @param[out] shortmsg The short message to get + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALLLOG_ERROR_NONE Successful + * @retval #CALLLOG_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CALLLOG_ERROR_NO_DATA Data not found + * + * @see #calllog_h + * @see calllog_set_shortmsg() + */ +int _calllog_get_shortmsg(calllog_h log, char **shortmsg); + +/** + * @internal + * @brief Sets a short message to the call log handle. + * + * + * @param[in] log The call log handle + * @param[in] shortmsg The short message to set + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALLLOG_ERROR_NONE Successful + * @retval #CALLLOG_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calllog_h + * @see calllog_get_shortmsg() + */ +int _calllog_set_shortmsg(calllog_h log, const char *shortmsg); + + + + +#define _calllog_safe_free(_srcx_) { if(NULL != _srcx_) free(_srcx_); } +#define _calllog_safe_strdup(_srcx_) (NULL != _srcx_) ? strdup(_srcx_):NULL +#define _calllog_safe_str(_srcx_) (NULL != _srcx_) ? _srcx_:"" + +#define _calllog_free_strdup(_desty_, _srcx_) \ + { \ + if(_desty_) { free(_desty_); _desty_=NULL; }\ + if(_srcx_) _desty_ = strdup(_srcx_); \ + } + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CALLLOG_H__ */ + diff --git a/include/calllog_types.h b/include/calllog_types.h new file mode 100755 index 0000000..c919107 --- /dev/null +++ b/include/calllog_types.h @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2011 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 __TIZEN_CALLLOG_TYPE_H__ +#define __TIZEN_CALLLOG_TYPE_H__ + +#include <stdbool.h> +#include <tizen.h> +#include <time.h> +#include <contacts.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + +/** + * @addtogroup CAPI_SOCIAL_CALLLOG_MODULE + * @{ + */ + +/** + * @brief Enumerations for call log error. + */ +typedef enum +{ + CALLLOG_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ + CALLLOG_ERROR_DB_FAILED = TIZEN_ERROR_SOCIAL_CLASS | 0x32, /**< Database operation failure */ + CALLLOG_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */ + CALLLOG_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ + CALLLOG_ERROR_NO_DATA = TIZEN_ERROR_SOCIAL_CLASS | 0x33, /**< Requested data does not exist */ +} calllog_error_e; + +/** + * @brief Enumerations for call log types. + */ +typedef enum +{ + CALLLOG_TYPE_VOICE_ANSWERED = 1, /**< Incoming voice answered call log */ + CALLLOG_TYPE_VOICE_OUTGOING = 2, /**< Outgoing voice call log */ + CALLLOG_TYPE_VOICE_MISSED_UNCHECKED = 5, /**< Unchecked log of incoming missed voice call */ + CALLLOG_TYPE_VOICE_MISSED_CHECKED = 6, /**< Already checked log of incoming missed voice call */ + CALLLOG_TYPE_VOICE_REJECTED = 9, /**< Rejected voice call log */ + CALLLOG_TYPE_VOICE_BLOCKED = 11, /**< Blocked voice call log */ + + CALLLOG_TYPE_VIDEO_ANSWERED = 3, /**< Incoming video answered call log */ + CALLLOG_TYPE_VIDEO_OUTGOING = 4, /**< Outgoing video call log */ + CALLLOG_TYPE_VIDEO_MISSED_UNCHECKED = 7, /**< Unchecked log of incoming missed video call */ + CALLLOG_TYPE_VIDEO_MISSED_CHECKED = 8, /**< Already checked log of incoming missed video call */ + CALLLOG_TYPE_VIDEO_REJECTED = 10, /**< Rejected video call log */ + CALLLOG_TYPE_VIDEO_BLOCKED = 12, /**< Blocked video call log */ + + CALLLOG_TYPE_SMS_INCOMING = 103, /**< Incoming SMS log */ + CALLLOG_TYPE_SMS_OUTGOING = 104, /**< Outgoing SMS log */ + CALLLOG_TYPE_SMS_BLOCKED = 105, /**< Blocked SMS log */ + + CALLLOG_TYPE_MMS_INCOMING = 101, /**< Incoming MMS log */ + CALLLOG_TYPE_MMS_OUTGOING = 102, /**< Outgoing MMS log */ + CALLLOG_TYPE_MMS_BLOCKED = 106, /**< Blocked MMS log */ +} calllog_type_e; + +/** + * @brief The call log handle. + */ +typedef struct _calllog_s* calllog_h; + +/** + * @brief The structure of log entry in search results. + * + * @details This structure is passed to callback function in all log related + * iterations through list received from search functions. + * + * @see calllog_foreach_cb() + */ +typedef struct +{ + int calllog_db_id; /**< Call log entry id */ + calllog_type_e calllog_type; /**< Call log entry type */ + int contact_db_id; /**< Contact's id in database */ + char* first_name; /**< Contact's first name (also known as given name) */ + char* last_name; /**< Contact's last name (also known as family name) */ + char* display_name; /**< Display name (how contact's name should be presented) */ + char* contact_image_path; /**< Path to image with contact's picture */ + contact_number_type_e phone_number_type; /**< Phone number type (i.e.: work, cell) */ + char* phone_number; /**< Phone number */ + char* short_message; /**< Short message for this log */ + time_t timestamp; /**< Timestamp of this change */ + int duration_sec; /**< Duration (in seconds) for call logs */ +} calllog_query_detail_s; + +/** + * @brief The callback function to get call log details for each found call log. + * + * @param[in] query_log The log information + * @param[in] user_data The user data passed from the foreach function + * + * @return @c true to continue with the next iteration of the loop or @c false to break out of the loop. + * + * @pre Either calllog_foreach_calllog_from_db() or calllog_query_calllog_by_number() will invoke this callback. + * + * @see calllog_foreach_calllog_from_db() + * @see calllog_query_calllog_by_number() + */ +typedef bool (*calllog_foreach_cb)(calllog_query_detail_s *query_log, void *user_data); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __CALLLOG_H__ */ + |