--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(contact-adaptor C)
+
+set(BUILD_TYPE "DEBUG")
+
+# variable holds path to config files
+set(CONFIG_FILES_PATH "" CACHE FILEPATH "Path to coniguration files")
+
+include_directories(${CMAKE_BINARY_DIR})
+
+file(GLOB SRCS src/*.c)
+
+if(BUILD_TYPE STREQUAL "DEBUG")
+ message("DEBUG build!")
+ set(BUILD_TYPE_FLAGS "")
+elseif(BUILD_TYPE STREQUAL "RELEASE")
+ message("RELEASE build!")
+ set(BUILD_TYPE_FLAGS "-DRELEASE")
+else()
+ message(FATAL_ERROR "####\nBUILD_TYPE should be DEBUG or RELEASE! Have: ${BUILD_TYPE} . Aborting.\n####")
+endif(BUILD_TYPE STREQUAL "DEBUG")
+
+set(PREFIX "/usr")
+set(BINDIR "${PREFIX}/bin")
+set(LIBDIR "${PREFIX}/lib")
+
+include_directories(${CMAKE_SOURCE_DIR}/inc)
+
+include(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED glib-2.0 dlog)
+
+foreach(flag ${pkgs_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+endforeach(flag)
+
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror -std=gnu99 -D_GNU_SOURCE")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+SET(CMAKE_C_FLAGS_RELEASE "-O2")
+
+
+ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS} )
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${client_pkgs_LDFLAGS} contact-adaptor "-lm -ldl -lrt")
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIBDIR})
+
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/inc/contact-adaptor.h DESTINATION /usr/include/contact-adaptor/)
+
+CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/contact-adaptor.pc.in ${CMAKE_SOURCE_DIR}/contact-adaptor.pc @ONLY)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/contact-adaptor.pc DESTINATION ${LIBDIR}/pkgconfig)
--- /dev/null
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
--- /dev/null
+Copyright (c) Samsung Electronics Co., Ltd. All rights reserved.
+Except as noted, this software is licensed under Apache License, Version 2.
+Please, see the LICENSE.Apache-2.0 file for Apache License terms and conditions.
--- /dev/null
+<manifest>
+ <define>
+ <domain name="contact-adaptor" />
+ <request>
+ </request>
+ </define>
+ <assign>
+ <filesystem path="/usr/lib/libcontact-adaptor.so" label="_" exec_label="none"/>
+ </assign>
+ <request>
+ <domain name="contact-adaptor" />
+ </request>
+</manifest>
--- /dev/null
+prefix=@PREFIX@
+libdir=@PREFIX@/lib
+includedir=@PREFIX@/include
+
+Name: contact adaptor API
+Description: contact adaptor API
+Requires: glib-2.0
+Version: 1.0
+Libs: -L${libdir} -lcontact-adaptor -pthread
+Cflags: -I${includedir}/contact-adaptor
--- /dev/null
+/*
+* 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 __CONTACT_ADAPTOR_LOG_H__
+#define __CONTACT_ADAPTOR_LOG_H__
+
+/**
+ * HOW TO USE IT:
+ * First you need to set platform logging on the device:
+ *
+ * # dlogctrl set platformlog 1
+ *
+ * After reboot you are able to see logs from this application, when you launch dlogutil with a proper filter e.g.:
+ *
+ * # dlogutil CONTACT_ADAPTOR:D
+ *
+ * You may use different logging levels as: D (debug), I (info), W (warning), E (error) or F (fatal).
+ * Higher level messages are included by default e.g. dlogutil CLOUDBOX:W prints warnings but also errors and fatal messages.
+ */
+
+#include <unistd.h>
+#include <linux/unistd.h>
+
+/* These defines must be located before #include <dlog.h> */
+#define TIZEN_ENGINEER_MODE
+// TODO: Investigate why this macro is defined somewhere else
+#ifndef TIZEN_DEBUG_ENABLE
+#define TIZEN_DEBUG_ENABLE
+#endif
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+/* Literal to filter logs from dlogutil */
+#define LOG_TAG "CONTACT_ADAPTOR"
+
+#include <dlog.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif /* __cplusplus */
+
+ /**
+ * Colors of font
+ */
+#define FONT_COLOR_RESET "\033[0m"
+#define FONT_COLOR_BLACK "\033[30m" /* Black */
+#define FONT_COLOR_RED "\033[31m" /* Red */
+#define FONT_COLOR_GREEN "\033[32m" /* Green */
+#define FONT_COLOR_YELLOW "\033[33m" /* Yellow */
+#define FONT_COLOR_BLUE "\033[34m" /* Blue */
+#define FONT_COLOR_PURPLE "\033[35m" /* Purple */
+#define FONT_COLOR_CYAN "\033[36m" /* Cyan */
+#define FONT_COLOR_WHITE "\033[37m" /* White */
+#define FONT_COLOR_BOLDBLACK "\033[1m\033[30m" /* Bold Black */
+#define FONT_COLOR_BOLDRED "\033[1m\033[31m" /* Bold Red */
+#define FONT_COLOR_BOLDGREEN "\033[1m\033[32m" /* Bold Green */
+#define FONT_COLOR_BOLDYELLOW "\033[1m\033[33m" /* Bold Yellow */
+#define FONT_COLOR_BOLDBLUE "\033[1m\033[34m" /* Bold Blue */
+#define FONT_COLOR_BOLDPURPLE "\033[1m\033[35m" /* Bold Purple */
+#define FONT_COLOR_BOLDCYAN "\033[1m\033[36m" /* Bold Cyan */
+#define FONT_COLOR_BOLDWHITE "\033[1m\033[37m" /* Bold White */
+
+ /**
+ * Gets thread ID
+ */
+#define contact_adaptor_gettid() syscall(__NR_gettid)
+
+/**
+ * @brief Macro for returning value if expression is satisfied
+ * @param[in] expr Expression to be checked
+ * @param[out] val Value to be returned when expression is true
+ */
+#define contact_adaptor_retv_if(expr, val) do { \
+ if(expr) { \
+ LOGE(FONT_COLOR_PURPLE"[%d]"FONT_COLOR_RESET, contact_adaptor_gettid()); \
+ return (val); \
+ } \
+ } while (0)
+
+/**
+ * @brief Prints debug messages
+ * @param[in] fmt Format of data to be displayed
+ * @param[in] args Arguments to be displayed
+ */
+#define contact_adaptor_debug(fmt, arg...) do { \
+ LOGD(FONT_COLOR_GREEN"[%d]"fmt""FONT_COLOR_RESET, contact_adaptor_gettid(), ##arg); \
+ } while (0)
+
+/**
+ * @brief Prints info messages
+ * @param[in] fmt Format of data to be displayed
+ * @param[in] args Arguments to be displayed
+ */
+#define contact_adaptor_info(fmt, arg...) do { \
+ LOGI(FONT_COLOR_BLUE"[%d]"fmt""FONT_COLOR_RESET, contact_adaptor_gettid() ,##arg); \
+ } while (0)
+
+/**
+ * @brief Prints warning messages
+ * @param[in] fmt Format of data to be displayed
+ * @param[in] args Arguments to be displayed
+ */
+#define contact_adaptor_warning(fmt, arg...) do { \
+ LOGW(FONT_COLOR_YELLOW"[%d]"fmt""FONT_COLOR_RESET,contact_adaptor_gettid(), ##arg); \
+ } while (0)
+
+/**
+ * @brief Prints error messages
+ * @param[in] fmt Format of data to be displayed
+ * @param[in] args Arguments to be displayed
+ */
+#define contact_adaptor_error(fmt, arg...) do { \
+ LOGE(FONT_COLOR_RED"[%d]"fmt""FONT_COLOR_RESET,contact_adaptor_gettid(), ##arg); \
+ } while (0)
+
+/**
+ * @brief Prints fatal messages
+ * @param[in] fmt Format of data to be displayed
+ * @param[in] args Arguments to be displayed
+ */
+#define contact_adaptor_fatal(fmt, arg...) do { \
+ LOGF(FONT_COLOR_BOLDRED"[%d]"fmt""FONT_COLOR_RESET,contact_adaptor_gettid(), ##arg); \
+ } while (0)
+
+/**
+ * @brief Prints debug message on entry to particular function
+ * @param[in] fmt Format of data to be displayed
+ * @param[in] args Arguments to be displayed
+ */
+#define contact_adaptor_debug_func(fmt, arg...) do { \
+ LOGD(FONT_COLOR_CYAN"[%d]"fmt""FONT_COLOR_RESET, contact_adaptor_gettid(), ##arg); \
+ } while (0)
+
+/**
+ * @brief Prints debug message on entry to particular function
+ * @param[in] fmt Format of data to be displayed
+ * @param[in] args Arguments to be displayed
+ */
+#define contact_adaptor_debug_secure(fmt, arg...) do { \
+ SECURE_LOGD(FONT_COLOR_CYAN"[%d]"fmt""FONT_COLOR_RESET, contact_adaptor_gettid(), ##arg); \
+ } while (0)
+
+
+#define plugin_req_enter() do { \
+ contact_adaptor_info("[ENTER] plugin API call -)) -)) -)) -)) -)) -)) -)) -)) -)) -))"); \
+ } while (0)
+
+#define plugin_req_exit(ret, plugin, error) do { \
+ contact_adaptor_info("[EXIT] plugin API called (%d) ((- ((- ((- ((- ((- ((- ((- ((- ((- ((-", (int)(ret)); \
+ if ((error)) { \
+ if ((*error)) { \
+ contact_adaptor_error("plugin issued error (%lld) (%s)", (long long int)((*error)->code), (char *)((*error)->msg)); \
+ char *tem = g_strdup_printf("[PLUGIN_ERROR] URI(%s), MSG(%s)", (char *)((plugin)->handle->plugin_uri), (char *)((*error)->msg)); \
+ if (tem) { \
+ free((*error)->msg); \
+ (*error)->msg = tem; \
+ } \
+ } \
+ } \
+ } while (0)
+
+#define plugin_req_exit_void() do { \
+ contact_adaptor_info("[EXIT] plugin API called ((- ((- ((- ((- ((- ((- ((- ((- ((- ((-"); \
+ } while (0)
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __CONTACT_ADAPTOR_LOG_H__ */
--- /dev/null
+/*
+* 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 __CONTACT_ADAPTOR_H__
+#define __CONTACT_ADAPTOR_H__
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__((visibility("default")))
+#endif
+
+#include <glib.h>
+#include <stdint.h>
+#include <inttypes.h>
+
+/**
+* @brief Contact Adaptor error code
+*/
+typedef enum contact_error_code_e
+{
+ CONTACT_ADAPTOR_ERROR_NONE = 0,
+ CONTACT_ADAPTOR_ERROR_LAUNCH = 1, /**< 1 ~ 99: internal error*/
+ CONTACT_ADAPTOR_ERROR_INIT = 2,
+ CONTACT_ADAPTOR_ERROR_DEINIT = 3,
+ CONTACT_ADAPTOR_ERROR_CREATE = 4,
+ CONTACT_ADAPTOR_ERROR_DESTROY = 5,
+ CONTACT_ADAPTOR_ERROR_START = 6,
+ CONTACT_ADAPTOR_ERROR_STOP = 7,
+ CONTACT_ADAPTOR_ERROR_CONNECT = 8,
+ CONTACT_ADAPTOR_ERROR_DISCONNECT = 9,
+ CONTACT_ADAPTOR_ERROR_NOT_FOUND = 10,
+ CONTACT_ADAPTOR_ERROR_CORRUPTED = 11,
+ CONTACT_ADAPTOR_ERROR_UNSUPPORTED = 12,
+ CONTACT_ADAPTOR_ERROR_INVALID_HANDLE = 13,
+ CONTACT_ADAPTOR_ERROR_INVALID_ARGUMENT = 14,
+ CONTACT_ADAPTOR_ERROR_INVALID_ARGUMENT_TYPE = 15,
+ CONTACT_ADAPTOR_ERROR_NOT_AUTHORIZED = 16,
+ CONTACT_ADAPTOR_ERROR_ADAPTOR_INTERNAL = 17,
+ CONTACT_ADAPTOR_ERROR_PLUGIN_INTERNAL = 18,
+ CONTACT_ADAPTOR_ERROR_SERVER_INTERNAL = 19,
+ CONTACT_ADAPTOR_ERROR_DBUS = 20,
+ CONTACT_ADAPTOR_ERROR_CALLBACK_TIME_OUT = 21,
+ CONTACT_ADAPTOR_ERROR_MAX
+} contact_error_code_t;
+
+
+typedef enum _contact_plugin_internal_error_code_e
+{
+ CONTACT_PLUGIN_ERROR_HTTP_BAD_REQUEST = 400,
+ CONTACT_PLUGIN_ERROR_HTTP_UNAUTHORIZED = 401,
+ CONTACT_PLUGIN_ERROR_HTTP_FORBIDDEN = 403,
+ CONTACT_PLUGIN_ERROR_HTTP_NOT_FOUND = 404,
+ CONTACT_PLUGIN_ERROR_HTTP_METHOD_NOT_ALLOWED = 405,
+
+ CONTACT_PLUGIN_ERROR_CURL_COULDNT_CONNECT = 601,
+ CONTACT_PLUGIN_ERROR_CURL_TIME_OUT = 602,
+ CONTACT_PLUGIN_ERROR_CURL_ETC = 698,
+ CONTACT_PLUGIN_ERROR_CURL_UNKNOWN = 699,
+
+ CONTACT_PLUGIN_ERROR_URL = 997,
+ CONTACT_PLUGIN_ERROR_ETC = 998,
+ CONTACT_PLUGIN_ERROR_UNKNOWN = 999,
+} contact_plugin_internal_error_code_e;
+
+
+
+
+/**
+* @brief Contact Adaptor plugin handle
+*/
+typedef struct contact_adaptor_plugin_s *contact_adaptor_plugin_h;
+
+/**
+* @brief Contact Adaptor handle
+*/
+typedef struct contact_adaptor_s *contact_adaptor_h;
+
+/**
+* @brief Contact Adaptor plugin context structure
+*/
+typedef struct contact_adaptor_plugin_context_s
+{
+ char *duid; /**< header: access control >*/
+ char *access_token; /**< header: access control >*/
+ void *plugin_info; /**< plugin's own context >*/
+
+ // Adaptor define
+ char *plugin_uri;
+ char *service_name;
+
+} contact_adaptor_plugin_context_t;
+typedef struct contact_adaptor_plugin_context_s *contact_adaptor_plugin_context_h;
+
+/**
+* @brief Contact Adaptor error code
+*/
+typedef struct contact_adaptor_error_code_s
+{
+ int64_t code;
+ char *msg;
+
+} contact_adaptor_error_code_t;
+typedef struct contact_adaptor_error_code_s *contact_adaptor_error_code_h;
+
+/**
+* @brief Contact Adaptor contact API information request format
+*/
+typedef struct contact_adaptor_contact_info_req_s
+{
+ char *tp; /**< mandatory >*/
+ char *id; /**< mandatory >*/
+ char *pn; /**< mandatory >*/
+ char *nm; /**< mandatory >*/
+
+ char *cc; /**< optional >*/
+
+} contact_adaptor_contact_info_req_t;
+typedef struct contact_adaptor_contact_info_req_s *contact_adaptor_contact_info_req_h;
+
+/**
+* @brief Contact Adaptor contact API request format
+*/
+typedef struct contact_adaptor_contact_req_s
+{
+ long long int tt;
+ contact_adaptor_contact_info_req_h *cts;
+ unsigned int cts_len;
+
+} contact_adaptor_contact_req_t;
+typedef struct contact_adaptor_contact_req_s *contact_adaptor_contact_req_h;
+
+typedef enum
+{
+ CONTACT_ADAPTOR_REQUEST_SET = 1,
+ CONTACT_ADAPTOR_REQUEST_DEL = 2,
+} contact_adaptor_request_type_e;
+
+typedef struct contact_adaptor_contact_image_s
+{
+ int req_type;
+ int no; /**< mandatory >*/
+ char *img; /**< mandatory >*/
+} contact_adaptor_contact_image_t;
+typedef struct contact_adaptor_contact_image_s *contact_adaptor_contact_image_h;
+
+/**
+* @brief Contact Adaptor contact API information response format
+*/
+typedef struct contact_adaptor_contact_info_res_s
+{
+ char *duid; /**< mandatory >*/
+ char *id; /**< mandatory >*/
+ char *msisdn; /**< mandatory >*/
+
+ char *ty; /**< optional >*/
+ char *cc; /**< optional >*/
+ char *pn; /**< optional >*/
+ char *nm; /**< optional >*/
+ char **evnt; /**< optional >*/
+ unsigned int evnt_len; /**< optional >*/
+ contact_adaptor_contact_image_h *imgs; /**< optional >*/
+ unsigned int imgs_len; /**< optional >*/
+ char **adrs; /**< optional >*/
+ unsigned int adrs_len; /**< optional >*/
+ char **mail; /**< optional >*/
+ unsigned int mail_len; /**< optional >*/
+ char *org; /**< optional >*/
+ char *prsc; /**< optional >*/
+ char *status; /**< optional >*/
+ unsigned int sids; /**< optional >*/
+ int type; /**< optional >*/
+ char *url; /**< optional >*/
+} contact_adaptor_contact_info_res_t;
+typedef struct contact_adaptor_contact_info_res_s *contact_adaptor_contact_info_res_h;
+
+/**
+* @brief Contact Adaptor contact API response format
+*/
+typedef struct contact_adaptor_contact_res_s
+{
+ long long int tt;
+ contact_adaptor_contact_info_res_h *cts;
+ unsigned int cts_len;
+
+} contact_adaptor_contact_res_t;
+typedef struct contact_adaptor_contact_res_s *contact_adaptor_contact_res_h;
+
+/**
+* @brief Contact Adaptor profile API request format
+*/
+typedef struct contact_adaptor_profile_req_s
+{
+ char* cc;
+ char* pn;
+ char* nm;
+ char** evnt;
+ unsigned int evnt_len;
+ char* img;
+ char** adrs;
+ unsigned int adrs_len;
+ char** mail;
+ unsigned int mail_len;
+ char* org;
+ char* prsc;
+ char* status;
+
+} contact_adaptor_profile_req_t;
+typedef struct contact_adaptor_profile_req_s *contact_adaptor_profile_req_h;
+
+/**
+* @brief Contact Adaptor profile API response format
+*/
+typedef struct contact_adaptor_profile_res_s
+{
+ char* nm;
+ char* img;
+ char* prsc;
+ char* status;
+
+} contact_adaptor_profile_res_t;
+typedef struct contact_adaptor_profile_res_s *contact_adaptor_profile_res_h;
+
+/**
+* @brief Contact Adaptor profile API image file path format
+*/
+typedef struct contact_adaptor_file_path_s
+{
+ char** file_paths;
+ unsigned int file_paths_len;
+
+} contact_adaptor_file_path_t;
+typedef struct contact_adaptor_file_path_s *contact_adaptor_file_path_h;
+
+/**
+* @brief Contact Adaptor privacy API information request format
+*/
+typedef struct contact_adaptor_privacy_info_req_s
+{
+ char* cc;
+ char* pn;
+
+} contact_adaptor_privacy_info_req_t;
+typedef struct contact_adaptor_privacy_info_req_s *contact_adaptor_privacy_info_req_h;
+
+/**
+* @brief Contact Adaptor privacy API request format
+*/
+typedef struct contact_adaptor_privacy_req_s
+{
+ unsigned int lvl;
+ contact_adaptor_privacy_info_req_h* cts;
+ unsigned int cts_len;
+
+} contact_adaptor_privacy_req_t;
+typedef struct contact_adaptor_privacy_req_s *contact_adaptor_privacy_req_h;
+
+/**
+* @brief Contact Adaptor privacy API response format
+*/
+typedef struct contact_adaptor_privacy_res_s
+{
+ unsigned int lvl;
+ unsigned int prscon;
+
+} contact_adaptor_privacy_res_t;
+typedef struct contact_adaptor_privacy_res_s *contact_adaptor_privacy_res_h;
+
+/**
+* @brief Contact Adaptor presence API information format
+*/
+typedef struct contact_adaptor_presence_info_s
+{
+ char *prsc;
+ unsigned int prscon;
+ char *status;
+
+} contact_adaptor_presence_info_t;
+typedef struct contact_adaptor_presence_info_s *contact_adaptor_presence_info_h;
+
+/**
+* @brief Callback on pushed message received for Service Adaptor (not in use)
+*
+* @param[in] user_data specifies user_data passed to message received API
+* @return void
+*/
+typedef void(*contact_adaptor_service_on_message_received_cb)(void *user_data);
+
+/**
+* @brief Callback on pushed message received for contact plugin (not in use)
+*
+* @param[in] user_data specifies user_data passed to message received API
+* @return void
+*/
+typedef void(*contact_adaptor_plugin_on_message_received_cb)(void *user_data);
+
+/**
+* @brief Contact Adaptor listener for Service Adaptor
+*/
+typedef struct contact_adaptor_listener_s
+{
+ contact_adaptor_service_on_message_received_cb _on_message_received;
+
+} contact_adaptor_listener_t;
+typedef struct contact_adaptor_listener_s *contact_adaptor_listener_h;
+
+/**
+* @brief Contact Adaptor listener for plugins
+*/
+typedef struct contact_adaptor_plugin_listener_s
+{
+ contact_adaptor_plugin_on_message_received_cb _on_message_received;
+
+} contact_adaptor_plugin_listener_t;
+typedef struct contact_adaptor_plugin_listener_s *contact_adaptor_plugin_listener_h;
+
+/**
+* @brief Contact Adaptor plugin handle
+*/
+typedef struct contact_adaptor_plugin_handle_s
+{
+ /**< mandatory >*/
+ contact_error_code_t (*create_context)(contact_adaptor_plugin_context_h *context,
+ const char *duid,
+ const char *access_token);
+
+ /**< mandatory >*/
+ contact_error_code_t (*destroy_context)(contact_adaptor_plugin_context_h context);
+
+ /**< mandatory >*/
+ contact_error_code_t (*destroy_handle)(struct contact_adaptor_plugin_handle_s *handle);
+
+ /**< mandatory >*/
+ contact_error_code_t (*set_listener)(contact_adaptor_plugin_listener_h listener);
+
+ /**< mandatory >*/
+ contact_error_code_t (*unset_listener)(void);
+
+ /**< optional >*/
+ contact_error_code_t (*set_server_info)(contact_adaptor_plugin_context_h context,
+ GHashTable *server_info,
+ void *user_data,
+ contact_adaptor_error_code_h *error,
+ void **server_data);
+
+ /**< optional >*/
+ contact_error_code_t (*new_contact_list)(contact_adaptor_plugin_context_h context,
+ contact_adaptor_contact_req_h request,
+ void *user_data,
+ contact_adaptor_contact_res_h *response,
+ contact_adaptor_error_code_h *error,
+ void **server_data);
+
+ /**< optional >*/
+ contact_error_code_t (*set_contact_list)(contact_adaptor_plugin_context_h context,
+ contact_adaptor_contact_req_h request,
+ void *user_data,
+ contact_adaptor_contact_res_h *response,
+ contact_adaptor_error_code_h *error,
+ void **server_data);
+
+ /**< optional >*/
+ contact_error_code_t (*get_contact_infos_latest)(contact_adaptor_plugin_context_h context,
+ contact_adaptor_contact_req_h request,
+ void *user_data,
+ contact_adaptor_contact_res_h *response,
+ contact_adaptor_error_code_h *error,
+ void **server_data);
+
+ /**< optional >*/
+ contact_error_code_t (*get_contact_infos_polling)(contact_adaptor_plugin_context_h context,
+ contact_adaptor_contact_req_h request,
+ void *user_data,
+ contact_adaptor_contact_res_h *response,
+ contact_adaptor_error_code_h *error,
+ void **server_data);
+
+ /**< optional >*/
+ contact_error_code_t (*set_me_profile_with_push)(contact_adaptor_plugin_context_h context,
+ contact_adaptor_profile_req_h request,
+ void *user_data,
+ contact_adaptor_profile_res_h *response,
+ contact_adaptor_error_code_h *error,
+ void **server_data);
+
+ /**< optional >*/
+ contact_error_code_t (*get_profile)(contact_adaptor_plugin_context_h context,
+ contact_adaptor_profile_req_h request,
+ void *user_data,
+ contact_adaptor_profile_res_h *response,
+ contact_adaptor_error_code_h *error,
+ void **server_data);
+
+ /**< optional >*/
+ contact_error_code_t (*set_me_profile_image_meta_with_push)
+ (contact_adaptor_plugin_context_h context,
+ contact_adaptor_contact_image_h *imgs,
+ unsigned int imgs_len,
+ void *user_data,
+ contact_adaptor_error_code_h *error,
+ void **server_data);
+
+ /**< optional >*/
+ contact_error_code_t (*delete_me_profile_image_meta_with_push)
+ (contact_adaptor_plugin_context_h context,
+ void *user_data,
+ contact_adaptor_error_code_h *error,
+ void **server_data);
+
+ /**< optional >*/
+ contact_error_code_t (*set_me_profile_privacy)(contact_adaptor_plugin_context_h context,
+ contact_adaptor_privacy_req_h request,
+ void *user_data,
+ contact_adaptor_privacy_res_h *response,
+ contact_adaptor_error_code_h *error,
+ void **server_data);
+
+ /**< optional >*/
+ contact_error_code_t (*get_me_profile_privacy)(contact_adaptor_plugin_context_h context,
+ contact_adaptor_privacy_req_h request,
+ void *user_data,
+ contact_adaptor_privacy_res_h *response,
+ contact_adaptor_error_code_h *error,
+ void **server_data);
+
+ /**< optional >*/
+ contact_error_code_t (*set_me_presence_with_push)(contact_adaptor_plugin_context_h context,
+ contact_adaptor_presence_info_h request,
+ void *user_data,
+ contact_adaptor_presence_info_h *response,
+ contact_adaptor_error_code_h *error,
+ void **server_data);
+
+ /**< optional >*/
+ contact_error_code_t (*set_me_presence_on_off_with_push)(contact_adaptor_plugin_context_h context,
+ contact_adaptor_presence_info_h request,
+ void *user_data,
+ contact_adaptor_presence_info_h *response,
+ contact_adaptor_error_code_h *error,
+ void **server_data);
+
+ contact_error_code_t (*set_me_profile_type)(contact_adaptor_plugin_context_h context,
+ int req_type,
+ void *user_data,
+ char **url,
+ contact_adaptor_error_code_h *error,
+ void **server_data);
+
+ /**< mandatory >*/
+ char *plugin_uri; // get from config file
+
+} contact_adaptor_plugin_handle_t;
+typedef struct contact_adaptor_plugin_handle_s *contact_adaptor_plugin_handle_h;
+
+/**
+* @brief Creates Contact Adaptor.
+*
+* @param[in] plugin_dir specifies directory path where plugins are stored
+* @return contact_adaptor_h on success, otherwise NULL value
+*/
+EXPORT_API
+contact_adaptor_h contact_adaptor_create(const char *plugins_dir);
+
+/**
+* @brief Destroys contact adaptor. If contact adaptor was started it is stopped first.
+*
+* @param[in] adaptor specifies contact adaptor handle to be destroyed
+* @return void
+*/
+EXPORT_API
+void contact_adaptor_destroy(contact_adaptor_h adaptor);
+
+/**
+* @brief Starts contact adaptor and loads plugins that are found in contact_adaptor_create().
+*
+* @param[in] adaptor specifies contact adaptor handle
+* @return 0 on success, otherwise a positive error value
+* @retval error code defined in contact_error_code_e - CONTACT_ADAPTOR_ERROR_NONE if successful
+*/
+EXPORT_API
+int contact_adaptor_start(contact_adaptor_h adaptor);
+
+/**
+* @brief Stops contact adaptor.
+*
+* @param[in] adaptor specifies contact adaptor handle
+* @return 0 on success, otherwise a positive error value
+* @retval error code defined in contact_error_code_e - CONTACT_ADAPTOR_ERROR_NONE if successful
+*/
+EXPORT_API
+int contact_adaptor_stop(contact_adaptor_h adaptor);
+
+/**
+* @brief Registers plugin state listener
+*
+* @param[in] adaptor specifies contact adaptor handle
+* @param[in] listener specifies contact adaptor listener handle
+* @return 0 on success, otherwise a positive error value
+* @retval error code defined in contact_error_code_e - CONTACT_ADAPTOR_ERROR_NONE if successful
+*/
+EXPORT_API
+int contact_adaptor_register_listener(contact_adaptor_h adaptor,
+ contact_adaptor_listener_h listener);
+
+/**
+* @brief Unregisters plugin state listener
+*
+* @param[in] adaptor specifies contact adaptor handle
+* @param[in] listener specifies contact adaptor listener handle
+* @return 0 on success, otherwise a positive error value
+* @retval error code defined in contact_error_code_e - CONTACT_ADAPTOR_ERROR_NONE if successful
+*/
+EXPORT_API
+int contact_adaptor_unregister_listener(contact_adaptor_h adaptor,
+ contact_adaptor_listener_h listener);
+
+/**
+* @brief Creates plugin context
+*
+* @param[in] plugin specifies contact adaptor plugin handle
+* @param[in] duid specifies device unique ID
+* @param[in] access_token specifies access token issued by Auth Adaptor
+* @return contact_adaptor_plugin_context_h on success, otherwise NULL value
+*/
+EXPORT_API
+contact_adaptor_plugin_context_h contact_adaptor_create_plugin_context(contact_adaptor_plugin_h plugin,
+ const char *duid,
+ const char *access_token,
+ const char *service_name);
+
+/**
+* @brief Destroys plugin context.
+*
+* @param[in] plugin specifies contact adaptor plugin handle
+* @param[in] context specifies contact adaptor plugin context handle
+* @return void
+*/
+EXPORT_API
+void contact_adaptor_destroy_plugin_context(contact_adaptor_plugin_h plugin,
+ contact_adaptor_plugin_context_h context);
+
+/**
+* @brief Gets plugin with specified unique name
+*
+* @param[in] adaptor specifies contact adaptor handle
+* @param[in] plugin_name specifies plugin name to be searched for
+* @return contact_adaptor_plugin_h on success, otherwise NULL value
+*/
+EXPORT_API
+contact_adaptor_plugin_h contact_adaptor_get_plugin_by_name(contact_adaptor_h adaptor,
+ const char *plugin_uri);
+
+
+/**
+* @brief Loads plugin from selected path
+*
+* @param[in] adaptor specifies contact adaptor handle
+* @param[in] plugin_path specifies plugin's saved path
+* @return 0 on success, otherwise a positive error value
+* @retval error code defined in contact_error_code_e - CONTACT_ADAPTOR_ERROR_NONE if successful
+*/
+EXPORT_API
+int contact_adaptor_load_plugin(contact_adaptor_h adaptor,
+ const char *plugin_path);
+
+/**
+* @brief Unloads selected plugin
+*
+* @param[in] adaptor specifies contact adaptor handle
+* @param[in] plugin specifies contact adaptor plugin handle
+* @return 0 on success, otherwise a positive error value
+* @retval error code defined in contact_error_code_e - CONTACT_ADAPTOR_ERROR_NONE if successful
+*/
+EXPORT_API
+int contact_adaptor_unload_plugin(contact_adaptor_h adaptor,
+ contact_adaptor_plugin_h plugin);
+
+/**
+* @brief Get plugin list of contact adaptor handle has
+*
+* @param[in] adaptor specifies contact adaptor handle
+* @return GList pointer on success, otherwise NULL value
+*/
+EXPORT_API
+GList *contact_adaptor_get_plugins(contact_adaptor_h adaptor);
+
+/**
+* @brief Gets plugin name
+*
+* @param[in] plugin specifies contact adaptor plugin handle
+* @return const char pointer on success, otherwise NULL value
+*/
+EXPORT_API
+const char* contact_adaptor_get_plugin_name(contact_adaptor_plugin_h plugin);
+
+/**
+ * @brief Refresh access token was issued from auth-adaptor
+ *
+ * @param[in] context specifies Contact Adaptor Plugin Context handle
+ * @param[in] new_access_token specifies New access token
+ * @return contact_adaptor_error_code_h on success, otherwise NULL value
+*/
+EXPORT_API
+contact_error_code_t contact_adaptor_refresh_access_token(contact_adaptor_plugin_context_h context,
+ const char *new_access_token);
+
+/**
+ * @brief Refresh unique id was issued from auth-adaptor
+ *
+ * @param[in] context specifies Contact Adaptor Plugin Context handle
+ * @param[in] new_access_token specifies New access token
+ * @return contact_adaptor_error_code_h on success, otherwise NULL value
+*/
+EXPORT_API
+contact_error_code_t contact_adaptor_refresh_uid(contact_adaptor_plugin_context_h context,
+ const char *new_uid);
+
+/**
+* @brief Create error code
+*
+* @param[in] code specifies error code number
+* @param[in] msg specifies error message
+* @return contact_adaptor_error_code_h on success, otherwise NULL value
+*/
+EXPORT_API
+contact_adaptor_error_code_h contact_adaptor_create_error_code(const int64_t code,
+ const char *msg);
+
+/**
+* @brief Destroy error code
+*
+* @param[in] error_code specifies error code handle
+* @return void
+*/
+EXPORT_API
+void contact_adaptor_destroy_error_code(contact_adaptor_error_code_h *error_code);
+
+EXPORT_API
+void contact_adaptor_destroy_contact_req_s(contact_adaptor_contact_req_h req);
+
+EXPORT_API
+void contact_adaptor_destroy_contact_res_s(contact_adaptor_contact_res_h res);
+
+EXPORT_API
+void contact_adaptor_destroy_profile_req_s(contact_adaptor_profile_req_h req);
+
+EXPORT_API
+void contact_adaptor_destroy_profile_res_s(contact_adaptor_profile_res_h res);
+
+EXPORT_API
+void contact_adaptor_destroy_file_path_s(contact_adaptor_file_path_h path);
+
+EXPORT_API
+void contact_adaptor_destroy_privacy_req_s(contact_adaptor_privacy_req_h req);
+
+EXPORT_API
+void contact_adaptor_destroy_privacy_res_s(contact_adaptor_privacy_res_h res);
+
+EXPORT_API
+void contact_adaptor_destroy_presence_info_s(contact_adaptor_presence_info_h info);
+
+/**
+ * @brief Set server information for Contact Plugin
+ *
+ * @param[in] plugin specifies Contact Adaptor Plugin handle
+ * @param[in] context specifies Contact Adaptor Plugin Context handle
+ * @param[in] server_info specifies server information for Contact Plugin
+ * @param[in] user_data specifies optional parameter
+ * @param[out] error specifies error code
+ * @param[out] server_data specifies optional parameter
+ * @return 0 on success, otherwise a positive error value
+ * @retval error code defined in contact_error_code_t - CONTACT_ADAPTOR_ERROR_NONE if Successful
+ */
+EXPORT_API
+contact_error_code_t contact_adaptor_set_server_info(contact_adaptor_plugin_h plugin,
+ contact_adaptor_plugin_context_h context,
+ GHashTable *server_info,
+ void *user_data,
+ contact_adaptor_error_code_h *error,
+ void **server_data);
+
+/**
+* @brief Resets contact information in Contact server and upload native contact information of device to
+* the server
+*
+* @param[in] plugin specifies contact adaptor plugin handle
+* @param[in] context specifies contact adaptor plugin context handle
+* @param[in] request specifies contact adaptor contact API request handle
+* @param[in] user_data specifies user side arbitrary data
+* @param[out] response specifies contact adaptor contact API response handle
+* @param[out] error specifies returned error code handle
+* @param[out] server_data specifies server side arbitrary data
+* @return 0 on success, otherwise a positive error value
+* @retval error code defined in contact_error_code_e - CONTACT_ADAPTOR_ERROR_NONE if successful
+*/
+EXPORT_API
+contact_error_code_t contact_adaptor_new_contact_list(contact_adaptor_plugin_h plugin,
+ contact_adaptor_plugin_context_h context,
+ contact_adaptor_contact_req_h request,
+ void *user_data,
+ contact_adaptor_contact_res_h *response,
+ contact_adaptor_error_code_h *error,
+ void **server_data);
+
+/**
+* @brief Synchronized native contact information of device with contact server according to type
+* "type" field of each contact
+*
+* @param[in] plugin specifies contact adaptor plugin handle
+* @param[in] context specifies contact adaptor plugin context handle
+* @param[in] request specifies contact adaptor contact API request handle
+* @param[in] user_data specifies user side arbitrary data
+* @param[out] response specifies contact adaptor contact API response handle
+* @param[out] error specifies returned error code handle
+* @param[out] server_data specifies server side arbitrary data
+* @return 0 on success, otherwise a positive error value
+* @retval error code defined in contact_error_code_e - CONTACT_ADAPTOR_ERROR_NONE if successful
+*/
+EXPORT_API
+contact_error_code_t contact_adaptor_set_contact_list(contact_adaptor_plugin_h plugin,
+ contact_adaptor_plugin_context_h context,
+ contact_adaptor_contact_req_h request,
+ void *user_data,
+ contact_adaptor_contact_res_h *response,
+ contact_adaptor_error_code_h *error,
+ void **server_data);
+
+/**
+* @brief Gets profile and service registration information of each contact
+*
+* @param[in] plugin specifies contact adaptor plugin handle
+* @param[in] context specifies contact adaptor plugin context handle
+* @param[in] request specifies contact adaptor contact API request handle
+* @param[in] user_data specifies user side arbitrary data
+* @param[out] response specifies contact adaptor contact API response handle
+* @param[out] error specifies returned error code handle
+* @param[out] server_data specifies server side arbitrary data
+* @return 0 on success, otherwise a positive error value
+* @retval error code defined in contact_error_code_e - CONTACT_ADAPTOR_ERROR_NONE if successful
+*/
+EXPORT_API
+contact_error_code_t contact_adaptor_get_contact_infos_latest(contact_adaptor_plugin_h plugin,
+ contact_adaptor_plugin_context_h context,
+ contact_adaptor_contact_req_h request,
+ void *user_data,
+ contact_adaptor_contact_res_h *response,
+ contact_adaptor_error_code_h *error,
+ void **server_data);
+
+/**
+* @brief Gets profile and service registration information of contact that have been updated since
+* last update
+*
+* @param[in] plugin specifies contact adaptor plugin handle
+* @param[in] context specifies contact adaptor plugin context handle
+* @param[in] request specifies contact adaptor contact API request handle
+* @param[in] user_data specifies user side arbitrary data
+* @param[out] response specifies contact adaptor contact API response handle
+* @param[out] error specifies returned error code handle
+* @param[out] server_data specifies server side arbitrary data
+* @return 0 on success, otherwise a positive error value
+* @retval error code defined in contact_error_code_e - CONTACT_ADAPTOR_ERROR_NONE if successful
+*/
+EXPORT_API
+contact_error_code_t contact_adaptor_get_contact_infos_polling(contact_adaptor_plugin_h plugin,
+ contact_adaptor_plugin_context_h context,
+ contact_adaptor_contact_req_h request,
+ void *user_data,
+ contact_adaptor_contact_res_h *response,
+ contact_adaptor_error_code_h *error,
+ void **server_data);
+
+/**
+* @brief Sets or updates device's profile to server
+*
+* @param[in] plugin specifies contact adaptor plugin handle
+* @param[in] context specifies contact adaptor plugin context handle
+* @param[in] request specifies contact adaptor profile API request handle
+* @param[in] user_data specifies user side arbitrary data
+* @param[out] response specifies contact adaptor profile API response handle
+* @param[out] error specifies returned error code handle
+* @param[out] server_data specifies server side arbitrary data
+* @return 0 on success, otherwise a positive error value
+* @retval error code defined in contact_error_code_e - CONTACT_ADAPTOR_ERROR_NONE if successful
+*/
+EXPORT_API
+contact_error_code_t contact_adaptor_set_me_profile_with_push(contact_adaptor_plugin_h plugin,
+ contact_adaptor_plugin_context_h context,
+ contact_adaptor_profile_req_h request,
+ void *user_data,
+ contact_adaptor_profile_res_h *response,
+ contact_adaptor_error_code_h *error,
+ void **server_data);
+
+/**
+* @brief Gets the profile information of a contact which is correspondent with country code and phone number
+*
+* @param[in] plugin specifies contact adaptor plugin handle
+* @param[in] context specifies contact adaptor plugin context handle
+* @param[in] request specifies contact adaptor profile API request handle
+* @param[in] user_data specifies user side arbitrary data
+* @param[out] response specifies contact adaptor profile API response handle
+* @param[out] error specifies returned error code handle
+* @param[out] server_data specifies server side arbitrary data
+* @return 0 on success, otherwise a positive error value
+* @retval error code defined in contact_error_code_e - CONTACT_ADAPTOR_ERROR_NONE if successful
+*/
+EXPORT_API
+contact_error_code_t contact_adaptor_get_profile(contact_adaptor_plugin_h plugin,
+ contact_adaptor_plugin_context_h context,
+ contact_adaptor_profile_req_h request,
+ void *user_data,
+ contact_adaptor_profile_res_h *response,
+ contact_adaptor_error_code_h *error,
+ void **server_data);
+
+/**
+* @brief Uploads profile image meta to file server
+*
+* @param[in] plugin specifies contact adaptor plugin handle
+* @param[in] context specifies contact adaptor plugin context handle
+* @param[in] request specifies contact adaptor profile API image file request handle
+* @param[in] user_data specifies user side arbitrary data
+* @param[out] response specifies contact adaptor profile API image file response handle
+* @param[out] error specifies returned error code handle
+* @param[out] server_data specifies server side arbitrary data
+* @return 0 on success, otherwise a positive error value
+* @retval error code defined in contact_error_code_e - CONTACT_ADAPTOR_ERROR_NONE if successful
+*/
+EXPORT_API
+contact_error_code_t contact_adaptor_set_me_profile_image_meta_with_push(contact_adaptor_plugin_h plugin,
+ contact_adaptor_plugin_context_h context,
+ contact_adaptor_contact_image_h *imgs,
+ unsigned int imgs_len,
+ void *user_data,
+ contact_adaptor_error_code_h *error,
+ void **server_data);
+
+/**
+* @brief Deletes profile image meta from profile server
+*
+* @param[in] plugin specifies contact adaptor plugin handle
+* @param[in] context specifies contact adaptor plugin context handle
+* @param[in] request specifies contact adaptor profile API image file request handle
+* @param[in] user_data specifies user side arbitrary data
+* @param[out] response specifies contact adaptor profile API image file response handle
+* @param[out] error specifies returned error code handle
+* @param[out] server_data specifies server side arbitrary data
+* @return 0 on success, otherwise a positive error value
+* @retval error code defined in contact_error_code_e - CONTACT_ADAPTOR_ERROR_NONE if successful
+*/
+EXPORT_API
+contact_error_code_t contact_adaptor_delete_me_profile_image_meta_with_push(
+ contact_adaptor_plugin_h plugin,
+ contact_adaptor_plugin_context_h context,
+ void *user_data,
+ contact_adaptor_error_code_h *error,
+ void **server_data);
+
+/**
+* @brief Sets the level of privacy
+*
+* @param[in] plugin specifies contact adaptor plugin handle
+* @param[in] context specifies contact adaptor plugin context handle
+* @param[in] request specifies contact adaptor privacy API request handle
+* @param[in] user_data specifies user side arbitrary data
+* @param[out] response specifies contact adaptor privacy API response handle
+* @param[out] error specifies returned error code handle
+* @param[out] server_data specifies server side arbitrary data
+* @return 0 on success, otherwise a positive error value
+* @retval error code defined in contact_error_code_e - CONTACT_ADAPTOR_ERROR_NONE if successful
+*/
+EXPORT_API
+contact_error_code_t contact_adaptor_set_me_profile_privacy(contact_adaptor_plugin_h plugin,
+ contact_adaptor_plugin_context_h context,
+ contact_adaptor_privacy_req_h request,
+ void *user_data,
+ contact_adaptor_privacy_res_h *response,
+ contact_adaptor_error_code_h *error,
+ void **server_data);
+
+/**
+* @brief Gets my profile's privacy level
+*
+* @param[in] plugin specifies contact adaptor plugin handle
+* @param[in] context specifies contact adaptor plugin context handle
+* @param[in] request specifies contact adaptor privacy API request handle
+* @param[in] user_data specifies user side arbitrary data
+* @param[out] response specifies contact adaptor privacy API response handle
+* @param[out] error specifies returned error code handle
+* @param[out] server_data specifies server side arbitrary data
+* @return 0 on success, otherwise a positive error value
+* @retval error code defined in contact_error_code_e - CONTACT_ADAPTOR_ERROR_NONE if successful
+*/
+EXPORT_API
+contact_error_code_t contact_adaptor_get_me_profile_privacy(contact_adaptor_plugin_h plugin,
+ contact_adaptor_plugin_context_h context,
+ contact_adaptor_privacy_req_h request,
+ void *user_data,
+ contact_adaptor_privacy_res_h *response,
+ contact_adaptor_error_code_h *error,
+ void **server_data);
+
+/**
+* @brief Sets my presence information
+*
+* @param[in] plugin specifies contact adaptor plugin handle
+* @param[in] context specifies contact adaptor plugin context handle
+* @param[in] request specifies contact adaptor presence API request handle
+* @param[in] user_data specifies user side arbitrary data
+* @param[out] response specifies contact adaptor presence API response handle
+* @param[out] error specifies returned error code handle
+* @param[out] server_data specifies server side arbitrary data
+* @return 0 on success, otherwise a positive error value
+* @retval error code defined in contact_error_code_e - CONTACT_ADAPTOR_ERROR_NONE if successful
+*/
+EXPORT_API
+contact_error_code_t contact_adaptor_set_me_presence_with_push(contact_adaptor_plugin_h plugin,
+ contact_adaptor_plugin_context_h context,
+ contact_adaptor_presence_info_h request,
+ void *user_data,
+ contact_adaptor_presence_info_h *response,
+ contact_adaptor_error_code_h *error,
+ void **server_data);
+
+/**
+* @brief Sets my presence on/off information
+*
+* @param[in] plugin specifies contact adaptor plugin handle
+* @param[in] context specifies contact adaptor plugin context handle
+* @param[in] request specifies contact adaptor presence API request handle
+* @param[in] user_data specifies user side arbitrary data
+* @param[out] response specifies contact adaptor presence API response handle
+* @param[out] error specifies returned error code handle
+* @param[out] server_data specifies server side arbitrary data
+* @return 0 on success, otherwise a positive error value
+* @retval error code defined in contact_error_code_e - CONTACT_ADAPTOR_ERROR_NONE if successful
+*/
+EXPORT_API
+contact_error_code_t contact_adaptor_set_me_presence_on_off_with_push(contact_adaptor_plugin_h plugin,
+ contact_adaptor_plugin_context_h context,
+ contact_adaptor_presence_info_h request,
+ void *user_data,
+ contact_adaptor_presence_info_h *response,
+ contact_adaptor_error_code_h *error,
+ void **server_data);
+
+EXPORT_API
+contact_error_code_t contact_adaptor_set_me_profile_type(contact_adaptor_plugin_h plugin,
+ contact_adaptor_plugin_context_h context,
+ int req_type,
+ void *user_data,
+ char **url,
+ contact_adaptor_error_code_h *error,
+ void **server_data);
+
+#endif /* __CONTACT_ADAPTOR_H__ */
--- /dev/null
+Name: contact-adaptor
+Summary: Contact Adaptor
+Version: 1.0.0
+Release: 1
+Group: Social & Content
+License: Apache-2.0
+Source0: %{name}-%{version}.tar.gz
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(dlog)
+
+BuildRequires: cmake
+
+%description
+Contact Adaptor
+
+%package -n contact-adaptor-devel
+Summary: Headers for contact adaptor
+Group: Development/Libraries
+Requires: contact-adaptor = %{version}-%{release}
+
+%description -n contact-adaptor-devel
+This package contains the header and pc files.
+
+%prep
+%setup -q
+
+%build
+export PREFIX="/usr/apps/contact-adaptor"
+export CFLAGS+=" -fPIC"
+export LDFLAGS+=" -Wl,--rpath=$(PREFIX)/lib -Wl,--as-needed -Wl,--hash-style=both"
+
+cmake . -DCMAKE_INSTALL_PREFIX="$PREFIX"
+
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+%make_install
+
+%files
+%manifest contact-adaptor.manifest
+%defattr(-,root,root,-)
+%{_libdir}/libcontact-adaptor.so
+
+%files -n contact-adaptor-devel
+%manifest contact-adaptor.manifest
+%defattr(-,root,root,-)
+%{_includedir}/contact-adaptor/*.h
+%{_libdir}/pkgconfig/contact-adaptor.pc
+
--- /dev/null
+/*
+* 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.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <dirent.h>
+#include <dlfcn.h>
+#include <glib.h>
+
+#include "contact-adaptor.h"
+#include "contact-adaptor-log.h"
+
+/**
+ * Contact adaptor plugin
+ */
+typedef struct contact_adaptor_plugin_s {
+ contact_adaptor_h adaptor; /* Adaptor */
+ char *path; /* Plugin library path */
+ contact_adaptor_plugin_handle_h handle; /* Plugin handle */
+ void *dl_handle; /* Plugin library handle */
+ int ref_counter; /* Plugin reference counter */
+ GMutex ref_counter_mutex; /* Plugin reference counter mutex */
+ contact_adaptor_plugin_listener_h plugin_listener; /* Plugin callback listener */
+ GMutex plugin_listener_mutex; /* Plugin callback listener mutex */
+} contact_adaptor_plugin_t;
+
+/**
+ * Contact adaptor
+ */
+typedef struct contact_adaptor_s {
+ GMutex contact_adaptor_mutex; /* Adaptor mutex */
+ int started; /* Started flag */
+ char *plugins_dir; /* Plugins directory path */
+ GList *plugins; /* List of loaded plugins */
+ GMutex plugins_mutex; /* Plugin list mutex */
+ GList *adaptor_listeners; /* List of vservice channel listener (for now not effective) */
+ GMutex adaptor_listeners_mutex; /* Listener list mutex */
+} contact_adaptor_t;
+
+/**
+ * Creates plugin
+ */
+static contact_adaptor_plugin_h contact_adaptor_create_plugin(const char *plugin_path);
+
+/**
+ * Destroys plugin and deletes all resources associated with it
+ */
+static void contact_adaptor_destroy_plugin(contact_adaptor_plugin_h plugin);
+
+/**
+ * Loads plugins from selected directory
+ */
+static int contact_adaptor_load_plugins_from_directory(contact_adaptor_h adaptor,
+ const char *dir_path);
+
+/**
+ * Checks if plugin is loaded by selected plugin adaptor
+ */
+static int contact_adaptor_has_plugin(contact_adaptor_h adaptor,
+ contact_adaptor_plugin_h plugin);
+
+/**
+ * Increases adaptor's plugin references counter
+ */
+static void contact_adaptor_plugin_ref(contact_adaptor_plugin_h);
+
+/**
+ * Decreases adaptor's plugin references counter
+ */
+static void contact_adaptor_plugin_unref(contact_adaptor_plugin_h);
+
+/**
+ * On message received callback for service adaptor
+ */
+contact_adaptor_service_on_message_received_cb _service_adaptor_on_message_received = NULL;
+
+/**
+ * Callback on message received from plugin
+ */
+void
+contact_adaptor_on_message_received(void *user_data)
+{
+ if (NULL != _service_adaptor_on_message_received) {
+ _service_adaptor_on_message_received(user_data);
+ }
+}
+
+/* /////////////////////////////////////////////////////////////
+ // Plugin create / destroy / ref. count / get plugin name
+ ///////////////////////////////////////////////////////////// */
+
+/**
+* Creates plugin
+*/
+static contact_adaptor_plugin_h contact_adaptor_create_plugin(const char *plugin_path)
+{
+ contact_adaptor_debug("Create plugin");
+
+ if (NULL == plugin_path) {
+ contact_adaptor_error("Invalid argument");
+ return NULL;
+ }
+
+ void *dl_handle = dlopen(plugin_path, RTLD_LAZY);
+ if (NULL == dl_handle) {
+ contact_adaptor_error("Could not load plugin %s: %s", plugin_path, dlerror());
+ return NULL;
+ }
+
+ contact_adaptor_plugin_handle_h (*get_adaptee_handle)(void) = NULL;
+
+ get_adaptee_handle = (contact_adaptor_plugin_handle_h (*)(void))(dlsym(dl_handle, "create_plugin_handle"));
+ if (NULL == get_adaptee_handle) {
+ dlclose(dl_handle);
+ contact_adaptor_error("Could not get function pointer to create_plugin_handle");
+ return NULL;
+ }
+
+ plugin_req_enter();
+ contact_adaptor_plugin_handle_h handle = get_adaptee_handle();
+ plugin_req_exit_void();
+
+ if (NULL == handle) {
+ dlclose(dl_handle);
+ contact_adaptor_error("Could not get adaptee handle");
+ return NULL;
+ }
+
+ contact_adaptor_plugin_h plugin = (contact_adaptor_plugin_h) calloc(1, sizeof(contact_adaptor_plugin_t));
+ if (NULL == plugin) {
+ dlclose(dl_handle);
+ contact_adaptor_error("Could not create plugin object");
+ return NULL;
+ }
+
+ contact_adaptor_plugin_listener_h listener =
+ (contact_adaptor_plugin_listener_h) calloc(1, sizeof(contact_adaptor_plugin_listener_t));
+ if (NULL == listener) {
+ free(plugin);
+ dlclose(dl_handle);
+ contact_adaptor_error("Could not create listener object");
+ return NULL;
+ }
+
+ plugin->path = g_strdup(plugin_path);
+ plugin->handle = handle;
+ plugin->dl_handle = dl_handle;
+ plugin->ref_counter = 0;
+
+ g_mutex_init(&plugin->ref_counter_mutex);
+ g_mutex_init(&plugin->plugin_listener_mutex);
+
+ listener->_on_message_received = contact_adaptor_on_message_received;
+
+ plugin_req_enter();
+ plugin->handle->set_listener(listener);
+ plugin_req_exit_void();
+
+ g_mutex_lock(&plugin->plugin_listener_mutex);
+ plugin->plugin_listener = listener;
+ g_mutex_unlock(&plugin->plugin_listener_mutex);
+
+ return plugin;
+}
+
+/**
+* Destroys plugin and deletes all resources associated with it
+*/
+static void contact_adaptor_destroy_plugin(contact_adaptor_plugin_h plugin)
+{
+ contact_adaptor_debug("Destroy plugin");
+
+ if (NULL == plugin) {
+ contact_adaptor_error("Invalid argument");
+ return;
+ }
+
+ if (NULL != plugin->handle) {
+ plugin->handle->destroy_handle(plugin->handle);
+
+ g_mutex_lock(&plugin->plugin_listener_mutex);
+ plugin_req_enter();
+ plugin->handle->unset_listener();
+ plugin_req_exit_void();
+ g_mutex_unlock(&plugin->plugin_listener_mutex);
+
+ plugin->handle = NULL;
+ }
+
+ if (NULL != plugin->dl_handle) {
+ dlclose(plugin->dl_handle);
+ plugin->dl_handle = NULL;
+ }
+
+ free(plugin->path);
+ plugin->path = NULL;
+
+ free(plugin);
+}
+
+/**
+* Loads plugins from selected directory
+*/
+static int contact_adaptor_load_plugins_from_directory(contact_adaptor_h adaptor,
+ const char *dir_path)
+{
+ contact_adaptor_debug("Load plugins from directory");
+
+ char *plugin_path = NULL;
+ DIR *dir = NULL;
+ struct dirent dir_entry, *result = NULL;
+
+ if ((NULL == adaptor) || (NULL == dir_path)) {
+ contact_adaptor_error("Invalid argument");
+ return CONTACT_ADAPTOR_ERROR_INVALID_ARGUMENT;
+ }
+
+ dir = opendir(dir_path);
+ if (NULL == dir) {
+ contact_adaptor_error("Could not open dir path (%s)", dir_path);
+ return CONTACT_ADAPTOR_ERROR_NOT_FOUND;
+ }
+
+ int ret = CONTACT_ADAPTOR_ERROR_NONE;
+ while (0 == (readdir_r(dir, &dir_entry, &result))) {
+
+ if (NULL == result) {
+ contact_adaptor_error("Could not open directory %s", plugin_path);
+ break;
+ }
+
+ if (dir_entry.d_type & DT_DIR) {
+ continue;
+ }
+
+ plugin_path = g_strconcat(dir_path, "/", dir_entry.d_name, NULL);
+ contact_adaptor_plugin_h plugin = contact_adaptor_create_plugin(plugin_path);
+
+ if (NULL != plugin) {
+ contact_adaptor_debug("Loaded plugin: %s", plugin_path);
+ plugin->adaptor = adaptor;
+ contact_adaptor_plugin_ref(plugin);
+ g_mutex_lock(&adaptor->plugins_mutex);
+ adaptor->plugins = g_list_append(adaptor->plugins, plugin);
+ g_mutex_unlock(&adaptor->plugins_mutex);
+ } else {
+ contact_adaptor_error("Could not load plugin %s", plugin_path);
+ }
+
+ free(plugin_path);
+ plugin_path = NULL;
+ }
+
+ contact_adaptor_debug("End load plugins from directory");
+ closedir(dir);
+ return ret;
+}
+
+/**
+* Checks if plugin is loaded by selected plugin adaptor
+*/
+static int contact_adaptor_has_plugin(contact_adaptor_h adaptor,
+ contact_adaptor_plugin_h plugin)
+{
+ contact_adaptor_debug("Find plugin in plugin list");
+
+ if ((NULL == adaptor) || (NULL == plugin)) {
+ contact_adaptor_error("Invalid argument");
+ return 0;
+ }
+
+ int result = 0;
+
+ g_mutex_lock(&adaptor->plugins_mutex);
+ if (NULL != g_list_find(adaptor->plugins, plugin)) {
+ result = 1;
+ }
+ g_mutex_unlock(&adaptor->plugins_mutex);
+
+ return result;
+}
+
+/**
+* Increases adaptor's plugin references counter
+*/
+static void contact_adaptor_plugin_ref(contact_adaptor_plugin_h plugin)
+{
+ contact_adaptor_debug("Increase plugin reference count");
+
+ if (NULL == plugin) {
+ contact_adaptor_error("Invalid argument");
+ return;
+ }
+
+ g_mutex_lock(&plugin->ref_counter_mutex);
+ plugin->ref_counter = plugin->ref_counter + 1;
+ contact_adaptor_info("ref_counter: %d", plugin->ref_counter);
+ g_mutex_unlock(&plugin->ref_counter_mutex);
+}
+
+/**
+* Decreases adaptor's plugin references counter
+*/
+static void contact_adaptor_plugin_unref(contact_adaptor_plugin_h plugin)
+{
+ contact_adaptor_debug("Decrease plugin reference count");
+
+ if (NULL == plugin) {
+ contact_adaptor_error("Invalid argument");
+ return ;
+ }
+
+ int should_destroy = 0;
+
+ g_mutex_lock(&plugin->ref_counter_mutex);
+ plugin->ref_counter = plugin->ref_counter - 1;
+ contact_adaptor_info("ref_counter: %d", plugin->ref_counter);
+ if (0 >= plugin->ref_counter) {
+ should_destroy = 1;
+ }
+ g_mutex_unlock(&plugin->ref_counter_mutex);
+
+ if (should_destroy) {
+ contact_adaptor_debug("Plugin is being destroyed");
+ contact_adaptor_destroy_plugin(plugin);
+ }
+}
+
+/* //////////////////////////////////////////////////////
+ // Mandatory: External adaptor management function
+ ////////////////////////////////////////////////////// */
+
+/**
+* @brief Creates Contact Adaptor.
+*
+* @param[in] plugin_dir specifies directory path where plugins are stored
+* @return contact_adaptor_h on success, otherwise NULL value
+*/
+contact_adaptor_h contact_adaptor_create(const char *plugins_dir)
+{
+ contact_adaptor_warning("Create contact adaptor");
+
+ contact_adaptor_h contact_adaptor = (contact_adaptor_h) malloc(sizeof(contact_adaptor_t));
+ if (NULL == contact_adaptor) {
+ return NULL;
+ }
+
+ contact_adaptor->started = 0;
+ contact_adaptor->plugins_dir = strdup(plugins_dir);
+
+ g_mutex_init(&contact_adaptor->contact_adaptor_mutex);
+ g_mutex_init(&contact_adaptor->plugins_mutex);
+ g_mutex_init(&contact_adaptor->adaptor_listeners_mutex);
+
+ g_mutex_lock(&contact_adaptor->adaptor_listeners_mutex);
+ contact_adaptor->adaptor_listeners = NULL;
+ g_mutex_unlock(&contact_adaptor->adaptor_listeners_mutex);
+
+ g_mutex_lock(&contact_adaptor->plugins_mutex);
+ contact_adaptor->plugins = NULL;
+ g_mutex_unlock(&contact_adaptor->plugins_mutex);
+
+ return contact_adaptor;
+}
+
+/**
+* @brief Destroys contact adaptor. If contact adaptor was started it is stopped first.
+*
+* @param[in] adaptor specifies contact adaptor handle to be destroyed
+* @return void
+*/
+void contact_adaptor_destroy(contact_adaptor_h adaptor)
+{
+ contact_adaptor_warning("Destroy contact adaptor");
+
+ if (NULL == adaptor) {
+ contact_adaptor_error("Invalid argument");
+ return ;
+ }
+
+ g_mutex_lock(&adaptor->contact_adaptor_mutex);
+ if (adaptor->started) {
+ contact_adaptor_error("Contact adaptor is running. Forcing stop before destroy");
+ contact_adaptor_stop(adaptor);
+ }
+
+ g_mutex_lock(&adaptor->plugins_mutex);
+ if (NULL != adaptor->plugins) {
+ g_list_free_full(adaptor->plugins, (GDestroyNotify) contact_adaptor_plugin_unref);
+ adaptor->plugins = NULL;
+ }
+ g_mutex_unlock(&adaptor->plugins_mutex);
+
+ g_mutex_lock(&adaptor->adaptor_listeners_mutex);
+ if (NULL != adaptor->adaptor_listeners) {
+ g_list_free(adaptor->adaptor_listeners);
+ adaptor->adaptor_listeners = NULL;
+ }
+ g_mutex_unlock(&adaptor->adaptor_listeners_mutex);
+
+ _service_adaptor_on_message_received = NULL;
+
+ free(adaptor->plugins_dir);
+ adaptor->plugins_dir = NULL;
+
+ g_mutex_unlock(&adaptor->contact_adaptor_mutex);
+
+ free(adaptor);
+}
+
+/**
+* @brief Starts contact adaptor and loads plugins that are found in contact_adaptor_create().
+*
+* @param[in] adaptor specifies contact adaptor handle
+* @return 0 on success, otherwise a positive error value
+* @retval error code defined in contact_error_code_e - CONTACT_ADAPTOR_ERROR_NONE if successful
+*/
+int contact_adaptor_start(contact_adaptor_h adaptor)
+{
+ contact_adaptor_warning("Start contact adaptor");
+
+ if (NULL == adaptor) {
+ contact_adaptor_error("Invalid argument");
+ return CONTACT_ADAPTOR_ERROR_INVALID_ARGUMENT;
+ }
+
+ g_mutex_lock(&adaptor->contact_adaptor_mutex);
+ int result = CONTACT_ADAPTOR_ERROR_NONE;
+ if (adaptor->started) {
+ contact_adaptor_error("Contact adaptor is already started");
+ result = CONTACT_ADAPTOR_ERROR_START;
+ } else {
+ adaptor->started = 1;
+ result = contact_adaptor_load_plugins_from_directory(adaptor, adaptor->plugins_dir);
+ if (CONTACT_ADAPTOR_ERROR_NONE != result) {
+ adaptor->started = 0;
+ contact_adaptor_error("Could not load plugins from directory");
+ } else {
+ contact_adaptor_debug("Contact adaptor started successfully");
+ }
+ }
+ g_mutex_unlock(&adaptor->contact_adaptor_mutex);
+
+ return result;
+}
+
+/**
+* @brief Stops contact adaptor.
+*
+* @param[in] adaptor specifies contact adaptor handle
+* @return 0 on success, otherwise a positive error value
+* @retval error code defined in contact_error_code_e - CONTACT_ADAPTOR_ERROR_NONE if successful
+*/
+int contact_adaptor_stop(contact_adaptor_h adaptor)
+{
+ contact_adaptor_warning("Stop contact adaptor");
+
+ if (NULL == adaptor) {
+ contact_adaptor_error("Invalid argument");
+ return CONTACT_ADAPTOR_ERROR_INVALID_ARGUMENT;
+ }
+
+ g_mutex_lock(&adaptor->contact_adaptor_mutex);
+ int result = CONTACT_ADAPTOR_ERROR_NONE;
+ if (!adaptor->started) {
+ result = CONTACT_ADAPTOR_ERROR_START;
+ } else {
+ if (NULL != adaptor->plugins) {
+ g_mutex_lock(&adaptor->plugins_mutex);
+ g_list_free_full(adaptor->plugins, (GDestroyNotify) contact_adaptor_plugin_unref);
+ adaptor->plugins = NULL;
+ g_mutex_unlock(&adaptor->plugins_mutex);
+ }
+ adaptor->started = 0;
+ contact_adaptor_debug("Contact adaptor stopped");
+ }
+
+ g_mutex_unlock(&adaptor->contact_adaptor_mutex);
+ return result;
+}
+
+/**
+* @brief Registers plugin state listener
+*
+* @param[in] adaptor specifies contact adaptor handle
+* @param[in] listener specifies contact adaptor listener handle
+* @return 0 on success, otherwise a positive error value
+* @retval error code defined in contact_error_code_e - CONTACT_ADAPTOR_ERROR_NONE if successful
+*/
+int contact_adaptor_register_listener(contact_adaptor_h adaptor,
+ contact_adaptor_listener_h listener)
+{
+ contact_adaptor_warning("Register contact adaptor listener");
+
+ if ((NULL == adaptor) || (NULL == listener)) {
+ contact_adaptor_error("Invalid argument");
+ return CONTACT_ADAPTOR_ERROR_INVALID_ARGUMENT;
+ }
+
+ g_mutex_lock(&adaptor->adaptor_listeners_mutex);
+
+ adaptor->adaptor_listeners = g_list_append(adaptor->adaptor_listeners, listener);
+
+ g_mutex_unlock(&adaptor->adaptor_listeners_mutex);
+
+ _service_adaptor_on_message_received =
+ (contact_adaptor_service_on_message_received_cb) listener->_on_message_received;
+
+ return CONTACT_ADAPTOR_ERROR_NONE;
+}
+
+/**
+* @brief Unregisters plugin state listener
+*
+* @param[in] adaptor specifies contact adaptor handle
+* @param[in] listener specifies contact adaptor listener handle
+* @return 0 on success, otherwise a positive error value
+* @retval error code defined in contact_error_code_e - CONTACT_ADAPTOR_ERROR_NONE if successful
+*/
+int contact_adaptor_unregister_listener(contact_adaptor_h adaptor,
+ contact_adaptor_listener_h listener)
+{
+ contact_adaptor_warning("Deregister contact adaptor listener");
+
+ if ((NULL == adaptor) || (NULL == listener)) {
+ contact_adaptor_error("Invalid argument");
+ return CONTACT_ADAPTOR_ERROR_INVALID_ARGUMENT;
+ }
+
+ g_mutex_lock(&adaptor->adaptor_listeners_mutex);
+
+ if (NULL == g_list_find(adaptor->adaptor_listeners, listener)) {
+ g_mutex_unlock(&adaptor->adaptor_listeners_mutex);
+ contact_adaptor_error("Could not find listener");
+ return CONTACT_ADAPTOR_ERROR_NOT_FOUND;
+ }
+
+ adaptor->adaptor_listeners = g_list_remove(adaptor->adaptor_listeners, listener);
+
+ g_mutex_unlock(&adaptor->adaptor_listeners_mutex);
+
+ _service_adaptor_on_message_received = NULL;
+
+ return CONTACT_ADAPTOR_ERROR_NONE;
+}
+
+/* //////////////////////////////////////////////////////
+ // Plugin context create / destroy
+ ////////////////////////////////////////////////////// */
+
+/**
+* @brief Creates plugin context
+*
+* @param[in] plugin specifies contact adaptor plugin handle
+* @param[in] duid specifies device unique ID
+* @param[in] access_token specifies access token issued by Auth Adaptor
+* @return contact_adaptor_plugin_context_h on success, otherwise NULL value
+*/
+contact_adaptor_plugin_context_h contact_adaptor_create_plugin_context(contact_adaptor_plugin_h plugin,
+ const char *duid,
+ const char *access_token,
+ const char *service_name)
+{
+ contact_adaptor_warning("Create plugin context");
+
+ if ((NULL == plugin) || (NULL == duid) || (NULL == access_token) || (NULL == service_name)) {
+ contact_adaptor_error("Invalid argument: %p, %p", duid, access_token);
+ return NULL;
+ }
+
+ if (NULL != plugin->handle) {
+ contact_adaptor_plugin_context_h plugin_context = NULL;
+
+ plugin_req_enter();
+ plugin->handle->create_context(&plugin_context, duid, access_token);
+ plugin_req_exit_void();
+
+ plugin_context->plugin_uri = strdup(plugin->handle->plugin_uri);
+ plugin_context->service_name = strdup(service_name);
+ return plugin_context;
+ } else {
+ contact_adaptor_error("Plugin handle is null");
+ }
+
+ return NULL;
+}
+
+/**
+* @brief Destroys plugin context.
+*
+* @param[in] plugin specifies contact adaptor plugin handle
+* @param[in] context specifies contact adaptor plugin context handle
+* @return void
+*/
+void contact_adaptor_destroy_plugin_context(contact_adaptor_plugin_h plugin,
+ contact_adaptor_plugin_context_h plugin_context)
+{
+ contact_adaptor_warning("Destroy plugin context");
+
+ if ((NULL == plugin) || (NULL == plugin_context)) {
+ contact_adaptor_error("Invalid argument");
+ return;
+ }
+
+ if (NULL != plugin->handle) {
+ free(plugin_context->plugin_uri);
+ plugin_context->plugin_uri = NULL;
+ free(plugin_context->service_name);
+ plugin_context->service_name = NULL;
+
+ plugin_req_enter();
+ plugin->handle->destroy_context(plugin_context);
+ plugin_req_exit_void();
+ } else {
+ contact_adaptor_error("Plugin handle is null");
+ }
+}
+
+/* //////////////////////////////////////////////////////
+ // Get plugin by plugin name
+ ////////////////////////////////////////////////////// */
+
+/**
+* @brief Gets plugin with specified unique name
+*
+* @param[in] adaptor specifies contact adaptor handle
+* @param[in] plugin_name specifies plugin name to be searched for
+* @return contact_adaptor_plugin_h on success, otherwise NULL value
+*/
+contact_adaptor_plugin_h contact_adaptor_get_plugin_by_name(contact_adaptor_h adaptor,
+ const char *plugin_name)
+{
+ contact_adaptor_warning("Get plugin by name: %s", plugin_name);
+
+ if ((NULL == adaptor) || (NULL == plugin_name)) {
+ contact_adaptor_error("Invalid argument");
+ return NULL;
+ }
+
+ contact_adaptor_plugin_h plugin = NULL;
+ g_mutex_lock(&adaptor->plugins_mutex);
+ int count = g_list_length(adaptor->plugins);
+ int i = 0;
+ for (i = 0; i < count; i++) {
+ contact_adaptor_plugin_h temp_plugin = g_list_nth_data(adaptor->plugins, i);
+ if (NULL != temp_plugin) {
+ if (0 == strcmp(temp_plugin->handle->plugin_uri, plugin_name)) {
+ contact_adaptor_plugin_ref(temp_plugin);
+ plugin = temp_plugin;
+ contact_adaptor_debug("Plugin is found by name");
+ g_mutex_unlock(&adaptor->plugins_mutex);
+ return plugin;
+ }
+ }
+ }
+ g_mutex_unlock(&adaptor->plugins_mutex);
+
+ if (NULL == plugin) {
+ contact_adaptor_debug("Plugin is not found by name");
+ }
+
+ return plugin;
+}
+
+/* //////////////////////////////////////////////////////
+ // Plugin load / unload / get plugin list
+ ////////////////////////////////////////////////////// */
+
+/**
+* @brief Loads plugin from selected path
+*
+* @param[in] adaptor specifies contact adaptor handle
+* @param[in] plugin_path specifies plugin's saved path
+* @return 0 on success, otherwise a positive error value
+* @retval error code defined in contact_error_code_e - CONTACT_ADAPTOR_ERROR_NONE if successful
+*/
+int contact_adaptor_load_plugin(contact_adaptor_h adaptor,
+ const char *plugin_path)
+{
+ contact_adaptor_warning("Load plugin by plugin path: %s", plugin_path);
+
+ if ((NULL == adaptor) || (NULL == plugin_path)) {
+ contact_adaptor_error("Invalid argument");
+ return CONTACT_ADAPTOR_ERROR_INVALID_ARGUMENT;
+ }
+
+ if (!adaptor->started) {
+ contact_adaptor_error("Contact adaptor is not started");
+ return CONTACT_ADAPTOR_ERROR_START;
+ }
+
+ contact_adaptor_plugin_h plugin = contact_adaptor_create_plugin(plugin_path);
+ if (NULL == plugin) {
+ contact_adaptor_error("Could not load plugin %s", plugin_path);
+ return CONTACT_ADAPTOR_ERROR_CREATE;
+ }
+
+ plugin->adaptor = adaptor;
+ contact_adaptor_plugin_ref(plugin);
+
+ g_mutex_lock(&adaptor->plugins_mutex);
+ adaptor->plugins = g_list_append(adaptor->plugins, plugin);
+ g_mutex_unlock(&adaptor->plugins_mutex);
+
+ return CONTACT_ADAPTOR_ERROR_NONE;
+}
+
+/**
+* @brief Unloads selected plugin
+*
+* @param[in] adaptor specifies contact adaptor handle
+* @param[in] plugin specifies contact adaptor plugin handle
+* @return 0 on success, otherwise a positive error value
+* @retval error code defined in contact_error_code_e - CONTACT_ADAPTOR_ERROR_NONE if successful
+*/
+int contact_adaptor_unload_plugin(contact_adaptor_h adaptor,
+ contact_adaptor_plugin_h plugin)
+{
+ contact_adaptor_warning("Unload plugin");
+
+ if ((NULL == adaptor) || (NULL == plugin)) {
+ contact_adaptor_error("Invalid argument");
+ return CONTACT_ADAPTOR_ERROR_INVALID_ARGUMENT;
+ }
+
+ if (!adaptor->started) {
+ contact_adaptor_error("Contact adaptor is not started");
+ return CONTACT_ADAPTOR_ERROR_START;
+ }
+
+ if (!contact_adaptor_has_plugin(adaptor, plugin)) {
+ contact_adaptor_error("Contact adaptor has no plugin");
+ return CONTACT_ADAPTOR_ERROR_NOT_FOUND;
+ }
+
+ plugin->adaptor = NULL;
+
+ g_mutex_lock(&adaptor->plugins_mutex);
+ adaptor->plugins = g_list_remove(adaptor->plugins, plugin);
+ g_mutex_unlock(&adaptor->plugins_mutex);
+
+ contact_adaptor_plugin_unref(plugin);
+
+ return CONTACT_ADAPTOR_ERROR_NONE;
+}
+
+/**
+* @brief Get plugin list of contact adaptor handle has
+*
+* @param[in] adaptor specifies contact adaptor handle
+* @return GList pointer on success, otherwise NULL value
+*/
+GList *contact_adaptor_get_plugins(contact_adaptor_h adaptor)
+{
+ contact_adaptor_warning("Get plugin list");
+
+ if (NULL == adaptor) {
+ contact_adaptor_error("Invalid argument");
+ return NULL;
+ }
+
+ GList *plugins = NULL;
+
+ g_mutex_lock(&adaptor->plugins_mutex);
+ int plugins_count = g_list_length(adaptor->plugins);
+ int i;
+ for (i = 0; i < plugins_count; i++) {
+ contact_adaptor_plugin_h plugin = g_list_nth_data(adaptor->plugins, i);
+ if (NULL != plugin) {
+ contact_adaptor_plugin_ref(plugin);
+ plugins = g_list_append(plugins, plugin);
+ }
+ }
+ g_mutex_unlock(&adaptor->plugins_mutex);
+
+ return plugins;
+}
+
+/**
+* @brief Refresh access token was issued from auth-adaptor
+*
+* @param[in] context specifies Contact Adaptor Plugin Context handle
+* @param[in] new_access_token specifies New access token
+* @return contact_adaptor_error_code_h on success, otherwise NULL value
+*/
+EXPORT_API
+contact_error_code_t contact_adaptor_refresh_access_token(contact_adaptor_plugin_context_h context,
+ const char *new_access_token)
+{
+ if ((NULL == context) || (NULL == new_access_token) || (0 >= strlen(new_access_token))) {
+ return CONTACT_ADAPTOR_ERROR_INVALID_ARGUMENT;
+ }
+ contact_adaptor_debug_secure("New access token : %s", new_access_token);
+
+ free(context->access_token);
+ context->access_token = NULL;
+ context->access_token = strdup(new_access_token);
+
+ return CONTACT_ADAPTOR_ERROR_NONE;
+}
+
+EXPORT_API
+contact_error_code_t contact_adaptor_refresh_uid(contact_adaptor_plugin_context_h context,
+ const char *new_uid)
+{
+ if ((NULL == context) || (NULL == new_uid) || (0 >= strlen(new_uid))) {
+ return CONTACT_ADAPTOR_ERROR_INVALID_ARGUMENT;
+ }
+ contact_adaptor_debug_secure("New uid : %s", new_uid);
+
+ free(context->duid);
+ context->duid = NULL;
+ context->duid = strdup(new_uid);
+
+ return CONTACT_ADAPTOR_ERROR_NONE;
+}
+
+
+/* //////////////////////////////////////////////////////
+ // Create / Destroy error code
+ ////////////////////////////////////////////////////// */
+
+/**
+* @brief Create error code
+*
+* @param[in] code specifies error code number
+* @param[in] msg specifies error message
+* @return contact_adaptor_error_code_h on success, otherwise NULL value
+*/
+contact_adaptor_error_code_h contact_adaptor_create_error_code(const int64_t code,
+ const char *msg)
+{
+ if (NULL == msg) {
+ return NULL;
+ }
+
+ contact_adaptor_error_code_h error_code = (contact_adaptor_error_code_h) malloc(sizeof(contact_adaptor_error_code_t));
+ if (NULL == error_code) {
+ return NULL;
+ }
+
+ error_code->code = code;
+ error_code->msg = strdup(msg);
+
+ return error_code;
+}
+
+/**
+* @brief Destroy error code
+*
+* @param[in] error_code specifies error code handle
+* @return void
+*/
+void contact_adaptor_destroy_error_code(contact_adaptor_error_code_h *error_code)
+{
+ if (NULL == *error_code) {
+ return;
+ }
+
+ if (NULL != (*error_code)->msg) {
+ free((*error_code)->msg);
+ (*error_code)->msg = NULL;
+ }
+
+ free(*error_code);
+ *error_code = NULL;
+}
+
+void __contact_adaptor_destroy_char_array(char **arr, unsigned int len)
+{
+ if ((NULL != arr) && (0U < len)) {
+ for (int i = 0; i < len; i++) {
+ free(arr[i]);
+ }
+ free(arr);
+ }
+}
+
+EXPORT_API
+void contact_adaptor_destroy_contact_req_s(contact_adaptor_contact_req_h req)
+{
+ if (NULL != req) {
+ if ((req->cts != NULL) && (0U < req->cts_len)) {
+ for (int i = 0; i < req->cts_len; i++) {
+ if (NULL != req->cts[i]) {
+ free(req->cts[i]->tp);
+ free(req->cts[i]->id);
+ free(req->cts[i]->pn);
+ free(req->cts[i]->nm);
+ free(req->cts[i]->cc);
+ }
+ free(req->cts[i]);
+ }
+ free(req->cts);
+ }
+ free(req);
+ }
+}
+
+EXPORT_API
+void contact_adaptor_destroy_contact_res_s(contact_adaptor_contact_res_h res)
+{
+ if (NULL == res) {
+ return;
+ } else if ((res->cts == NULL) || (0U == res->cts_len)) {
+ free(res);
+ return;
+ }
+
+ for (int i = 0; i < res->cts_len; i++) {
+ if (NULL != res->cts[i]) {
+ free(res->cts[i]->duid);
+ free(res->cts[i]->id);
+ free(res->cts[i]->msisdn);
+ free(res->cts[i]->ty);
+ free(res->cts[i]->cc);
+ free(res->cts[i]->pn);
+ free(res->cts[i]->nm);
+ /*
+ if ((NULL != res->cts[i]->evnt) && (0U > res->cts[i]->evnt_len)) {
+ for (int j = 0; j < res->cts[i]->evnt_len; j++) {
+ free(res->cts[i]->evnt[j]);
+ }
+ free(res->cts[i]->evnt);
+ }
+ */
+ __contact_adaptor_destroy_char_array(res->cts[i]->evnt, res->cts[i]->evnt_len);
+ /* free(res->cts[i]->img);*/
+
+ __contact_adaptor_destroy_char_array(res->cts[i]->adrs, res->cts[i]->adrs_len);
+ __contact_adaptor_destroy_char_array(res->cts[i]->mail, res->cts[i]->mail_len);
+ /*
+ if ((NULL != res->cts[i]->adrs) && (0U > res->cts[i]->adrs_len)) {
+ for (int j = 0; j < res->cts[i]->adrs_len; j++) {
+ free(res->cts[i]->adrs[j]);
+ }
+ free(res->cts[i]->adrs);
+ }
+ if ((NULL != res->cts[i]->mail) && (0U > res->cts[i]->mail_len)) {
+ for (int j = 0; j < res->cts[i]->mail_len; j++) {
+ free(res->cts[i]->mail[j]);
+ }
+ free(res->cts[i]->mail);
+ }
+ */
+ free(res->cts[i]->org);
+ free(res->cts[i]->prsc);
+ free(res->cts[i]->status);
+ }
+ free(res->cts[i]);
+ }
+ free(res->cts);
+ free(res);
+}
+
+EXPORT_API
+void contact_adaptor_destroy_profile_req_s(contact_adaptor_profile_req_h req)
+{
+ if (NULL == req) {
+ return;
+ }
+
+ free(req->cc);
+ free(req->pn);
+ free(req->nm);
+ __contact_adaptor_destroy_char_array(req->evnt, req->evnt_len);
+ free(req->img);
+ __contact_adaptor_destroy_char_array(req->adrs, req->adrs_len);
+ __contact_adaptor_destroy_char_array(req->mail, req->mail_len);
+ free(req->org);
+ free(req->prsc);
+ free(req->status);
+
+ free(req);
+}
+
+EXPORT_API
+void contact_adaptor_destroy_profile_res_s(contact_adaptor_profile_res_h res)
+{
+ if (NULL == res) {
+ return;
+ }
+
+ free(res->nm);
+ free(res->img);
+ free(res->prsc);
+ free(res->status);
+
+ free(res);
+}
+
+EXPORT_API
+void contact_adaptor_destroy_file_path_s(contact_adaptor_file_path_h path)
+{
+ if (NULL == path) {
+ return;
+ }
+
+ __contact_adaptor_destroy_char_array(path->file_paths, path->file_paths_len);
+
+ free(path);
+}
+
+EXPORT_API
+void contact_adaptor_destroy_privacy_req_s(contact_adaptor_privacy_req_h req)
+{
+ if (NULL == req) {
+ return;
+ }
+
+ if ((NULL != req->cts) && (0U < req->cts_len)) {
+ for (int i = 0; i < req->cts_len; i++) {
+ free(req->cts[i]->cc);
+ free(req->cts[i]->pn);
+ free(req->cts[i]);
+ }
+ free(req->cts);
+ }
+ free(req);
+}
+
+EXPORT_API
+void contact_adaptor_destroy_privacy_res_s(contact_adaptor_privacy_res_h res)
+{
+ free(res);
+}
+
+EXPORT_API
+void contact_adaptor_destroy_presence_info_s(contact_adaptor_presence_info_h info)
+{
+ if (NULL == info) {
+ return;
+ }
+
+ free(info->prsc);
+ free(info->status);
+ free(info);
+}
+
+/* //////////////////////////////////////////////////////
+ // Contact Adaptor External APIs
+ ////////////////////////////////////////////////////// */
+
+/**
+* @brief Set server information for Contact Plugin
+*
+* @param[in] plugin specifies Contact Adaptor Plugin handle
+* @param[in] context specifies Contact Adaptor Plugin Context handle
+* @param[in] server_info specifies server information for Contact Plugin
+* @param[in] request specifies optional parameter
+* @param[out] error specifies error code
+* @param[out] response specifies optional parameter
+* @return 0 on success, otherwise a positive error value
+* @retval error code defined in contact_error_code_t - CONTACT_ADAPTOR_ERROR_NONE if Successful
+*/
+EXPORT_API
+contact_error_code_t contact_adaptor_set_server_info(contact_adaptor_plugin_h plugin,
+ contact_adaptor_plugin_context_h context,
+ GHashTable *server_info,
+ void *user_data,
+ contact_adaptor_error_code_h *error,
+ void **server_data)
+{
+ if ((NULL == plugin) || (NULL == context)) {
+ contact_adaptor_error("Invalid argument");
+
+ *error = contact_adaptor_create_error_code((int64_t) CONTACT_ADAPTOR_ERROR_INVALID_ARGUMENT,
+ "Invalid argument (plugin or context)");
+
+ return CONTACT_ADAPTOR_ERROR_INVALID_ARGUMENT;
+ }
+
+ if (NULL == plugin->handle) {
+ contact_adaptor_error("Plugin handle is null");
+
+ *error = contact_adaptor_create_error_code((int64_t) CONTACT_ADAPTOR_ERROR_INVALID_HANDLE,
+ "Plugin handle is null");
+
+ return CONTACT_ADAPTOR_ERROR_INVALID_HANDLE;
+ }
+
+ contact_error_code_t ret;
+ plugin_req_enter();
+ ret = plugin->handle->set_server_info(context, server_info, user_data, error, server_data);
+ plugin_req_exit(ret, plugin, error);
+
+ return ret;
+}
+
+/**
+* @brief Resets contact information in Contact server and upload native contact information of device to
+* the server
+*
+* @param[in] plugin specifies contact adaptor plugin handle
+* @param[in] context specifies contact adaptor plugin context handle
+* @param[in] request specifies contact adaptor contact API request handle
+* @param[in] user_data specifies user side arbitrary data
+* @param[out] response specifies contact adaptor contact API response handle
+* @param[out] error specifies returned error code handle
+* @param[out] server_data specifies server side arbitrary data
+* @return 0 on success, otherwise a positive error value
+* @retval error code defined in contact_error_code_e - CONTACT_ADAPTOR_ERROR_NONE if successful
+*/
+contact_error_code_t contact_adaptor_new_contact_list(contact_adaptor_plugin_h plugin,
+ contact_adaptor_plugin_context_h context,
+ contact_adaptor_contact_req_h request,
+ void *user_data,
+ contact_adaptor_contact_res_h *response,
+ contact_adaptor_error_code_h *error,
+ void **server_data)
+{
+ contact_adaptor_warning("New contact list");
+
+ if ((NULL == plugin) || (NULL == context) || (NULL == request)) {
+ contact_adaptor_error("Invalid argument");
+
+ *error = contact_adaptor_create_error_code((int64_t) CONTACT_ADAPTOR_ERROR_INVALID_ARGUMENT,
+ "Invalid argument (plugin or context or request)");
+
+ return CONTACT_ADAPTOR_ERROR_INVALID_ARGUMENT;
+ }
+
+ if (NULL == plugin->handle) {
+ contact_adaptor_error("Plugin handle is null");
+
+ *error = contact_adaptor_create_error_code((int64_t) CONTACT_ADAPTOR_ERROR_INVALID_HANDLE,
+ "Plugin handle is null");
+
+ return CONTACT_ADAPTOR_ERROR_INVALID_HANDLE;
+ }
+
+ contact_error_code_t ret;
+ plugin_req_enter();
+ ret = plugin->handle->new_contact_list(context, request, user_data, response, error, server_data);
+ plugin_req_exit(ret, plugin, error);
+
+ return ret;
+}
+
+/**
+* @brief Synchronized native contact information of device with contact server according to type
+* "type" field of each contact
+*
+* @param[in] plugin specifies contact adaptor plugin handle
+* @param[in] context specifies contact adaptor plugin context handle
+* @param[in] request specifies contact adaptor contact API request handle
+* @param[in] user_data specifies user side arbitrary data
+* @param[out] response specifies contact adaptor contact API response handle
+* @param[out] error specifies returned error code handle
+* @param[out] server_data specifies server side arbitrary data
+* @return 0 on success, otherwise a positive error value
+* @retval error code defined in contact_error_code_e - CONTACT_ADAPTOR_ERROR_NONE if successful
+*/
+contact_error_code_t contact_adaptor_set_contact_list(contact_adaptor_plugin_h plugin,
+ contact_adaptor_plugin_context_h context,
+ contact_adaptor_contact_req_h request,
+ void *user_data,
+ contact_adaptor_contact_res_h *response,
+ contact_adaptor_error_code_h *error,
+ void **server_data)
+{
+ contact_adaptor_warning("Set contact list");
+
+ if ((NULL == plugin) || (NULL == context) || (NULL == request)) {
+ contact_adaptor_error("Invalid argument");
+
+ *error = contact_adaptor_create_error_code((int64_t) CONTACT_ADAPTOR_ERROR_INVALID_ARGUMENT,
+ "Invalid argument (plugin or context or request)");
+
+ return CONTACT_ADAPTOR_ERROR_INVALID_ARGUMENT;
+ }
+
+ if (NULL == plugin->handle) {
+ contact_adaptor_error("Plugin handle is null");
+
+ *error = contact_adaptor_create_error_code((int64_t) CONTACT_ADAPTOR_ERROR_INVALID_HANDLE,
+ "Plugin handle is null");
+
+ return CONTACT_ADAPTOR_ERROR_INVALID_HANDLE;
+ }
+
+ contact_error_code_t ret;
+ plugin_req_enter();
+ ret = plugin->handle->set_contact_list(context, request, user_data,
+ response, error, server_data);
+ plugin_req_exit(ret, plugin, error);
+
+ return ret;
+}
+
+/**
+* @brief Gets profile and service registration information of each contact
+*
+* @param[in] plugin specifies contact adaptor plugin handle
+* @param[in] context specifies contact adaptor plugin context handle
+* @param[in] request specifies contact adaptor contact API request handle
+* @param[in] user_data specifies user side arbitrary data
+* @param[out] response specifies contact adaptor contact API response handle
+* @param[out] error specifies returned error code handle
+* @param[out] server_data specifies server side arbitrary data
+* @return 0 on success, otherwise a positive error value
+* @retval error code defined in contact_error_code_e - CONTACT_ADAPTOR_ERROR_NONE if successful
+*/
+contact_error_code_t contact_adaptor_get_contact_infos_latest(contact_adaptor_plugin_h plugin,
+ contact_adaptor_plugin_context_h context,
+ contact_adaptor_contact_req_h request,
+ void *user_data,
+ contact_adaptor_contact_res_h *response,
+ contact_adaptor_error_code_h *error,
+ void **server_data)
+{
+ contact_adaptor_warning("Get contact infos latest");
+
+ if ((NULL == plugin) || (NULL == context)) {
+ contact_adaptor_error("Invalid argument");
+
+ *error = contact_adaptor_create_error_code((int64_t) CONTACT_ADAPTOR_ERROR_INVALID_ARGUMENT,
+ "Invalid argument (plugin or context)");
+
+ return CONTACT_ADAPTOR_ERROR_INVALID_ARGUMENT;
+ }
+
+ if (NULL == plugin->handle) {
+ contact_adaptor_error("Plugin handle is null");
+
+ *error = contact_adaptor_create_error_code((int64_t) CONTACT_ADAPTOR_ERROR_INVALID_HANDLE,
+ "Plugin handle is null");
+
+ return CONTACT_ADAPTOR_ERROR_INVALID_HANDLE;
+ }
+
+ contact_error_code_t ret;
+ plugin_req_enter();
+ ret = plugin->handle->get_contact_infos_latest(context, request, user_data,
+ response, error, server_data);
+ plugin_req_exit(ret, plugin, error);
+
+ return ret;
+}
+
+/**
+* @brief Gets profile and service registration information of contact that have been updated since
+* last update
+*
+* @param[in] plugin specifies contact adaptor plugin handle
+* @param[in] context specifies contact adaptor plugin context handle
+* @param[in] request specifies contact adaptor contact API request handle
+* @param[in] user_data specifies user side arbitrary data
+* @param[out] response specifies contact adaptor contact API response handle
+* @param[out] error specifies returned error code handle
+* @param[out] server_data specifies server side arbitrary data
+* @return 0 on success, otherwise a positive error value
+* @retval error code defined in contact_error_code_e - CONTACT_ADAPTOR_ERROR_NONE if successful
+*/
+contact_error_code_t contact_adaptor_get_contact_infos_polling(contact_adaptor_plugin_h plugin,
+ contact_adaptor_plugin_context_h context,
+ contact_adaptor_contact_req_h request,
+ void *user_data,
+ contact_adaptor_contact_res_h *response,
+ contact_adaptor_error_code_h *error,
+ void **server_data)
+{
+ contact_adaptor_warning("Get contact infos polling");
+
+ if ((NULL == plugin) || (NULL == context) || (NULL == request)) {
+ contact_adaptor_error("Invalid argument");
+
+ *error = contact_adaptor_create_error_code((int64_t) CONTACT_ADAPTOR_ERROR_INVALID_ARGUMENT,
+ "Invalid argument (plugin or context or request)");
+
+ return CONTACT_ADAPTOR_ERROR_INVALID_ARGUMENT;
+ }
+
+ if (NULL == plugin->handle) {
+ contact_adaptor_error("Plugin handle is null");
+
+ *error = contact_adaptor_create_error_code((int64_t) CONTACT_ADAPTOR_ERROR_INVALID_HANDLE,
+ "Plugin handle is null");
+
+ return CONTACT_ADAPTOR_ERROR_INVALID_HANDLE;
+ }
+
+ contact_error_code_t ret;
+ plugin_req_enter();
+ ret = plugin->handle->get_contact_infos_polling(context, request, user_data,
+ response, error, server_data);
+ plugin_req_exit(ret, plugin, error);
+
+ return ret;
+}
+
+/**
+* @brief Sets or updates device's profile to server
+*
+* @param[in] plugin specifies contact adaptor plugin handle
+* @param[in] context specifies contact adaptor plugin context handle
+* @param[in] request specifies contact adaptor profile API request handle
+* @param[in] user_data specifies user side arbitrary data
+* @param[out] response specifies contact adaptor profile API response handle
+* @param[out] error specifies returned error code handle
+* @param[out] server_data specifies server side arbitrary data
+* @return 0 on success, otherwise a positive error value
+* @retval error code defined in contact_error_code_e - CONTACT_ADAPTOR_ERROR_NONE if successful
+*/
+contact_error_code_t contact_adaptor_set_me_profile_with_push(contact_adaptor_plugin_h plugin,
+ contact_adaptor_plugin_context_h context,
+ contact_adaptor_profile_req_h request,
+ void *user_data,
+ contact_adaptor_profile_res_h *response,
+ contact_adaptor_error_code_h *error,
+ void **server_data)
+{
+ contact_adaptor_warning("Set me profile with push");
+
+ if ((NULL == plugin) || (NULL == context) || (NULL == request)) {
+ contact_adaptor_error("Invalid argument");
+
+ *error = contact_adaptor_create_error_code((int64_t) CONTACT_ADAPTOR_ERROR_INVALID_ARGUMENT,
+ "Invalid argument (plugin or context or request)");
+
+ return CONTACT_ADAPTOR_ERROR_INVALID_ARGUMENT;
+ }
+
+ if (NULL == plugin->handle) {
+ contact_adaptor_error("Plugin handle is null");
+
+ *error = contact_adaptor_create_error_code((int64_t) CONTACT_ADAPTOR_ERROR_INVALID_HANDLE,
+ "Plugin handle is null");
+
+ return CONTACT_ADAPTOR_ERROR_INVALID_HANDLE;
+ }
+
+ contact_error_code_t ret;
+ plugin_req_enter();
+ ret = plugin->handle->set_me_profile_with_push(context, request, user_data,
+ response, error, server_data);
+ plugin_req_exit(ret, plugin, error);
+
+ return ret;
+}
+
+/**
+* @brief Gets the profile information of a contact which is correspondent with country code and phone number
+*
+* @param[in] plugin specifies contact adaptor plugin handle
+* @param[in] context specifies contact adaptor plugin context handle
+* @param[in] request specifies contact adaptor profile API request handle
+* @param[in] user_data specifies user side arbitrary data
+* @param[out] response specifies contact adaptor profile API response handle
+* @param[out] error specifies returned error code handle
+* @param[out] server_data specifies server side arbitrary data
+* @return 0 on success, otherwise a positive error value
+* @retval error code defined in contact_error_code_e - CONTACT_ADAPTOR_ERROR_NONE if successful
+*/
+contact_error_code_t contact_adaptor_get_profile(contact_adaptor_plugin_h plugin,
+ contact_adaptor_plugin_context_h context,
+ contact_adaptor_profile_req_h request,
+ void *user_data,
+ contact_adaptor_profile_res_h *response,
+ contact_adaptor_error_code_h *error,
+ void **server_data)
+{
+ contact_adaptor_warning("Get profile");
+
+ if ((NULL == plugin) || (NULL == context) || (NULL == request)) {
+ contact_adaptor_error("Invalid argument");
+
+ *error = contact_adaptor_create_error_code((int64_t) CONTACT_ADAPTOR_ERROR_INVALID_ARGUMENT,
+ "Invalid argument (plugin or context or request)");
+
+ return CONTACT_ADAPTOR_ERROR_INVALID_ARGUMENT;
+ }
+
+ if (NULL == plugin->handle) {
+ contact_adaptor_error("Plugin handle is null");
+
+ *error = contact_adaptor_create_error_code((int64_t) CONTACT_ADAPTOR_ERROR_INVALID_HANDLE,
+ "Plugin handle is null");
+
+ return CONTACT_ADAPTOR_ERROR_INVALID_HANDLE;
+ }
+
+ contact_error_code_t ret;
+ plugin_req_enter();
+ ret = plugin->handle->get_profile(context, request, user_data, response, error, server_data);
+ plugin_req_exit(ret, plugin, error);
+
+ return ret;
+}
+
+/**
+* @brief Uploads profile image meta to file server
+*
+* @param[in] plugin specifies contact adaptor plugin handle
+* @param[in] context specifies contact adaptor plugin context handle
+* @param[in] request specifies contact adaptor profile API image file request handle
+* @param[in] user_data specifies user side arbitrary data
+* @param[out] response specifies contact adaptor profile API image file response handle
+* @param[out] error specifies returned error code handle
+* @param[out] server_data specifies server side arbitrary data
+* @return 0 on success, otherwise a positive error value
+* @retval error code defined in contact_error_code_e - CONTACT_ADAPTOR_ERROR_NONE if successful
+*/
+contact_error_code_t contact_adaptor_set_me_profile_image_meta_with_push(contact_adaptor_plugin_h plugin,
+ contact_adaptor_plugin_context_h context,
+ contact_adaptor_contact_image_h *imgs,
+ unsigned int imgs_len,
+ void *user_data,
+ contact_adaptor_error_code_h *error,
+ void **server_data)
+{
+ contact_adaptor_warning("Set me profile image meta with push");
+
+ if ((NULL == plugin) || (NULL == context) || (NULL == imgs) || (0U == imgs_len)) {
+ contact_adaptor_error("Invalid argument");
+
+ *error = contact_adaptor_create_error_code((int64_t) CONTACT_ADAPTOR_ERROR_INVALID_ARGUMENT,
+ "Invalid argument (plugin or context or request)");
+
+ return CONTACT_ADAPTOR_ERROR_INVALID_ARGUMENT;
+ }
+
+ if (NULL == plugin->handle) {
+ contact_adaptor_error("Plugin handle is null");
+
+ *error = contact_adaptor_create_error_code((int64_t) CONTACT_ADAPTOR_ERROR_INVALID_HANDLE,
+ "Plugin handle is null");
+
+ return CONTACT_ADAPTOR_ERROR_INVALID_HANDLE;
+ }
+
+ contact_error_code_t ret;
+ plugin_req_enter();
+ ret = plugin->handle->set_me_profile_image_meta_with_push(context, imgs, imgs_len, user_data,
+ error, server_data);
+ plugin_req_exit(ret, plugin, error);
+
+ return ret;
+}
+
+/**
+* @brief Deletes profile image meta from profile server
+*
+* @param[in] plugin specifies contact adaptor plugin handle
+* @param[in] context specifies contact adaptor plugin context handle
+* @param[in] request specifies contact adaptor profile API image file request handle
+* @param[in] user_data specifies user side arbitrary data
+* @param[out] response specifies contact adaptor profile API image file response handle
+* @param[out] error specifies returned error code handle
+* @param[out] server_data specifies server side arbitrary data
+* @return 0 on success, otherwise a positive error value
+* @retval error code defined in contact_error_code_e - CONTACT_ADAPTOR_ERROR_NONE if successful
+*/
+contact_error_code_t contact_adaptor_delete_me_profile_image_meta_with_push(contact_adaptor_plugin_h plugin,
+ contact_adaptor_plugin_context_h context,
+ void *user_data,
+ contact_adaptor_error_code_h *error,
+ void **server_data)
+{
+ contact_adaptor_warning("Delete me profile image meta with push");
+
+ if ((NULL == plugin) || (NULL == context)) {
+ contact_adaptor_error("Invalid argument");
+
+ *error = contact_adaptor_create_error_code((int64_t) CONTACT_ADAPTOR_ERROR_INVALID_ARGUMENT,
+ "Invalid argument (plugin or context or request)");
+
+ return CONTACT_ADAPTOR_ERROR_INVALID_ARGUMENT;
+ }
+
+ if (NULL == plugin->handle) {
+ contact_adaptor_error("Plugin handle is null");
+
+ *error = contact_adaptor_create_error_code((int64_t) CONTACT_ADAPTOR_ERROR_INVALID_HANDLE,
+ "Plugin handle is null");
+
+ return CONTACT_ADAPTOR_ERROR_INVALID_HANDLE;
+ }
+
+ contact_error_code_t ret;
+ plugin_req_enter();
+ ret = plugin->handle->delete_me_profile_image_meta_with_push(context, user_data,
+ error, server_data);
+ plugin_req_exit(ret, plugin, error);
+
+ return ret;
+}
+
+/**
+* @brief Sets the level of privacy
+*
+* @param[in] plugin specifies contact adaptor plugin handle
+* @param[in] context specifies contact adaptor plugin context handle
+* @param[in] request specifies contact adaptor privacy API request handle
+* @param[in] user_data specifies user side arbitrary data
+* @param[out] response specifies contact adaptor privacy API response handle
+* @param[out] error specifies returned error code handle
+* @param[out] server_data specifies server side arbitrary data
+* @return 0 on success, otherwise a positive error value
+* @retval error code defined in contact_error_code_e - CONTACT_ADAPTOR_ERROR_NONE if successful
+*/
+contact_error_code_t contact_adaptor_set_me_profile_privacy(contact_adaptor_plugin_h plugin,
+ contact_adaptor_plugin_context_h context,
+ contact_adaptor_privacy_req_h request,
+ void *user_data,
+ contact_adaptor_privacy_res_h *response,
+ contact_adaptor_error_code_h *error,
+ void **server_data)
+{
+ contact_adaptor_warning("Set me profile privacy");
+
+ if ((NULL == plugin) || (NULL == context) || (NULL == request)) {
+ contact_adaptor_error("Invalid argument");
+
+ *error = contact_adaptor_create_error_code((int64_t) CONTACT_ADAPTOR_ERROR_INVALID_ARGUMENT,
+ "Invalid argument (plugin or context or request)");
+
+ return CONTACT_ADAPTOR_ERROR_INVALID_ARGUMENT;
+ }
+
+ if (NULL == plugin->handle) {
+ contact_adaptor_error("Plugin handle is null");
+
+ *error = contact_adaptor_create_error_code((int64_t) CONTACT_ADAPTOR_ERROR_INVALID_HANDLE,
+ "Plugin handle is null");
+
+ return CONTACT_ADAPTOR_ERROR_INVALID_HANDLE;
+ }
+
+ contact_error_code_t ret;
+ plugin_req_enter();
+ ret = plugin->handle->set_me_profile_privacy(context, request, user_data,
+ response, error, server_data);
+ plugin_req_exit(ret, plugin, error);
+
+ return ret;
+}
+
+/**
+* @brief Gets my profile's privacy level
+*
+* @param[in] plugin specifies contact adaptor plugin handle
+* @param[in] context specifies contact adaptor plugin context handle
+* @param[in] request specifies contact adaptor privacy API request handle
+* @param[in] user_data specifies user side arbitrary data
+* @param[out] response specifies contact adaptor privacy API response handle
+* @param[out] error specifies returned error code handle
+* @param[out] server_data specifies server side arbitrary data
+* @return 0 on success, otherwise a positive error value
+* @retval error code defined in contact_error_code_e - CONTACT_ADAPTOR_ERROR_NONE if successful
+*/
+contact_error_code_t contact_adaptor_get_me_profile_privacy(contact_adaptor_plugin_h plugin,
+ contact_adaptor_plugin_context_h context,
+ contact_adaptor_privacy_req_h request,
+ void *user_data,
+ contact_adaptor_privacy_res_h *response,
+ contact_adaptor_error_code_h *error,
+ void **server_data)
+{
+ contact_adaptor_warning("Get me profile privacy");
+
+ if ((NULL == plugin) || (NULL == context)) {
+ contact_adaptor_error("Invalid argument");
+
+ *error = contact_adaptor_create_error_code((int64_t) CONTACT_ADAPTOR_ERROR_INVALID_ARGUMENT,
+ "Invalid argument (plugin or context or request)");
+
+ return CONTACT_ADAPTOR_ERROR_INVALID_ARGUMENT;
+ }
+
+ if (NULL == plugin->handle) {
+ contact_adaptor_error("Plugin handle is null");
+
+ *error = contact_adaptor_create_error_code((int64_t) CONTACT_ADAPTOR_ERROR_INVALID_HANDLE,
+ "Plugin handle is null");
+
+ return CONTACT_ADAPTOR_ERROR_INVALID_HANDLE;
+ }
+
+ contact_error_code_t ret;
+ plugin_req_enter();
+ ret = plugin->handle->get_me_profile_privacy(context, request, user_data,
+ response, error, server_data);
+ plugin_req_exit(ret, plugin, error);
+
+ return ret;
+}
+
+/**
+* @brief Sets my presence information
+*
+* @param[in] plugin specifies contact adaptor plugin handle
+* @param[in] context specifies contact adaptor plugin context handle
+* @param[in] request specifies contact adaptor presence API request handle
+* @param[in] user_data specifies user side arbitrary data
+* @param[out] response specifies contact adaptor presence API response handle
+* @param[out] error specifies returned error code handle
+* @param[out] server_data specifies server side arbitrary data
+* @return 0 on success, otherwise a positive error value
+* @retval error code defined in contact_error_code_e - CONTACT_ADAPTOR_ERROR_NONE if successful
+*/
+contact_error_code_t contact_adaptor_set_me_presence_with_push(contact_adaptor_plugin_h plugin,
+ contact_adaptor_plugin_context_h context,
+ contact_adaptor_presence_info_h request,
+ void *user_data,
+ contact_adaptor_presence_info_h *response,
+ contact_adaptor_error_code_h *error,
+ void **server_data)
+{
+ contact_adaptor_warning("Set me presence with push");
+
+ if ((NULL == plugin) || (NULL == context) || (NULL == request)) {
+ contact_adaptor_error("Invalid argument");
+
+ *error = contact_adaptor_create_error_code((int64_t) CONTACT_ADAPTOR_ERROR_INVALID_ARGUMENT,
+ "Invalid argument (plugin or context or request)");
+
+ return CONTACT_ADAPTOR_ERROR_INVALID_ARGUMENT;
+ }
+
+ if (NULL == plugin->handle) {
+ contact_adaptor_error("Plugin handle is null");
+
+ *error = contact_adaptor_create_error_code((int64_t) CONTACT_ADAPTOR_ERROR_INVALID_HANDLE,
+ "Plugin handle is null");
+
+ return CONTACT_ADAPTOR_ERROR_INVALID_HANDLE;
+ }
+
+ contact_error_code_t ret;
+ plugin_req_enter();
+ ret = plugin->handle->set_me_presence_with_push(context, request, user_data,
+ response, error, server_data);
+ plugin_req_exit(ret, plugin, error);
+
+ return ret;
+}
+
+/**
+* @brief Sets my presence on/off information
+*
+* @param[in] plugin specifies contact adaptor plugin handle
+* @param[in] context specifies contact adaptor plugin context handle
+* @param[in] request specifies contact adaptor presence API request handle
+* @param[in] user_data specifies user side arbitrary data
+* @param[out] response specifies contact adaptor presence API response handle
+* @param[out] error specifies returned error code handle
+* @param[out] server_data specifies server side arbitrary data
+* @return 0 on success, otherwise a positive error value
+* @retval error code defined in contact_error_code_e - CONTACT_ADAPTOR_ERROR_NONE if successful
+*/
+contact_error_code_t contact_adaptor_set_me_presence_on_off_with_push(contact_adaptor_plugin_h plugin,
+ contact_adaptor_plugin_context_h context,
+ contact_adaptor_presence_info_h request,
+ void *user_data,
+ contact_adaptor_presence_info_h *response,
+ contact_adaptor_error_code_h *error,
+ void **server_data)
+{
+ contact_adaptor_warning("Set me presence on off with push");
+
+ if ((NULL == plugin) || (NULL == context) || (NULL == request)) {
+ contact_adaptor_error("Invalid argument");
+
+ *error = contact_adaptor_create_error_code((int64_t) CONTACT_ADAPTOR_ERROR_INVALID_ARGUMENT,
+ "Invalid argument (plugin or context or request)");
+
+ return CONTACT_ADAPTOR_ERROR_INVALID_ARGUMENT;
+ }
+
+ if (NULL == plugin->handle) {
+ contact_adaptor_error("Plugin handle is null");
+
+ *error = contact_adaptor_create_error_code((int64_t) CONTACT_ADAPTOR_ERROR_INVALID_HANDLE,
+ "Plugin handle is null");
+
+ return CONTACT_ADAPTOR_ERROR_INVALID_HANDLE;
+ }
+
+ contact_error_code_t ret;
+ plugin_req_enter();
+ ret = plugin->handle->set_me_presence_on_off_with_push(context, request, user_data,
+ response, error, server_data);
+ plugin_req_exit(ret, plugin, error);
+
+ return ret;
+}
+
+EXPORT_API
+contact_error_code_t contact_adaptor_set_me_profile_type(contact_adaptor_plugin_h plugin,
+ contact_adaptor_plugin_context_h context,
+ int req_type,
+ void *user_data,
+ char **url,
+ contact_adaptor_error_code_h *error,
+ void **server_data)
+{
+ contact_adaptor_info("%s", __FUNCTION__);
+
+ if ((NULL == plugin) || (NULL == context)) {
+ contact_adaptor_error("Invalid argument");
+
+ *error = contact_adaptor_create_error_code((int64_t) CONTACT_ADAPTOR_ERROR_INVALID_ARGUMENT,
+ "Invalid argument (plugin or context or request)");
+
+ return CONTACT_ADAPTOR_ERROR_INVALID_ARGUMENT;
+ }
+
+ if (NULL == plugin->handle) {
+ contact_adaptor_error("Plugin handle is null");
+
+ *error = contact_adaptor_create_error_code((int64_t) CONTACT_ADAPTOR_ERROR_INVALID_HANDLE,
+ "Plugin handle is null");
+
+ return CONTACT_ADAPTOR_ERROR_INVALID_HANDLE;
+ }
+
+ char *_url = NULL;
+ contact_error_code_t ret;
+ plugin_req_enter();
+ ret = plugin->handle->set_me_profile_type(context, req_type, user_data,
+ &_url, error, server_data);
+ plugin_req_exit(ret, plugin, error);
+
+ contact_adaptor_debug("url : %s", _url);
+ if (NULL != url) {
+ *url = _url;
+ } else {
+ free(_url);
+ }
+
+ return ret;
+}
+
+