Initialize the configuration value using argument.
authorSung-jae Park <nicesj.park@samsung.com>
Tue, 24 Sep 2013 12:46:42 +0000 (21:46 +0900)
committerSung-jae Park <nicesj.park@samsung.com>
Tue, 24 Sep 2013 12:46:42 +0000 (21:46 +0900)
Change-Id: Id0f2a382dead9e171d282713f4516fe6d3723431

include/provider.h
packaging/libprovider.spec
src/provider.c

index 72b1713..363c5b2 100644 (file)
@@ -263,10 +263,33 @@ struct event_handler {
  * \pre N/A
  * \post N/A
  * \see provider_fini
+ * \see provider_init_with_options
  */
 extern int provider_init(void *disp, const char *name, struct event_handler *table, void *data);
 
 /*!
+ * \brief Initialize the provider service
+ * \details Some provider doesn't want to access environment value.
+ *          This API will get some configuration info via argument instead of environment value.
+ * \remarks N/A
+ * \param[in] disp XDisplay object, if you don't know what this is, set NULL
+ * \param[in] name Slave name which is given by the master provider.
+ * \param[in] table Event handler table
+ * \param[in] data callback data
+ * \return int
+ * \retval LB_STATUS_SUCCESS
+ * \retval LB_STATUS_ERROR_INVALID
+ * \retval LB_STATUS_ERROR_MEMORY
+ * \retval LB_STATUS_ERROR_ALREADY
+ * \retval LB_STATUS_ERROR_FAULT
+ * \pre N/A
+ * \post N/A
+ * \see provider_fini
+ * \see provider_init
+ */
+extern int provider_init_with_options(void *disp, const char *name, struct event_handler *table, void *data, int prevent_overwrite, int com_core_use_thread);
+
+/*!
  * \brief Finalize the provider service
  * \details N/A
  * \remarks N/A
index cc5fcc7..eeeb6ed 100644 (file)
@@ -1,6 +1,6 @@
 Name: libprovider
 Summary: Library for developing the livebox service provider.
-Version: 0.9.10
+Version: 0.9.11
 Release: 1
 Group: HomeTF/Livebox
 License: Flora License
index e580449..443d509 100644 (file)
@@ -878,30 +878,9 @@ static int disconnected_cb(int handle, void *data)
        return 0;
 }
 
-EAPI int provider_init(void *disp, const char *name, struct event_handler *table, void *data)
+static int initialize_provider(void *disp, const char *name, struct event_handler *table, void *data)
 {
        int ret;
-       const char *option;
-
-       option = getenv("PROVIDER_DISABLE_PREVENT_OVERWRITE");
-       if (option && !strcasecmp(option, "true")) {
-               s_info.prevent_overwrite = 1;
-       }
-
-       option = getenv("PROVIDER_COM_CORE_THREAD");
-       if (option && !strcasecmp(option, "true")) {
-               com_core_packet_use_thread(1);
-       }
-
-       if (!name || !table) {
-               ErrPrint("Invalid argument\n");
-               return LB_STATUS_ERROR_INVALID;
-       }
-
-       if (s_info.name) {
-               ErrPrint("Provider is already initialized\n");
-               return LB_STATUS_ERROR_ALREADY;
-       }
 
        s_info.name = strdup(name);
        if (!s_info.name) {
@@ -927,6 +906,51 @@ EAPI int provider_init(void *disp, const char *name, struct event_handler *table
        return LB_STATUS_SUCCESS;
 }
 
+EAPI int provider_init_with_options(void *disp, const char *name, struct event_handler *table, void *data, int prevent_overwrite, int com_core_use_thread)
+{
+       if (!name || !table) {
+               ErrPrint("Invalid argument\n");
+               return LB_STATUS_ERROR_INVALID;
+       }
+
+       if (s_info.name) {
+               ErrPrint("Provider is already initialized\n");
+               return LB_STATUS_ERROR_ALREADY;
+       }
+
+       s_info.prevent_overwrite = prevent_overwrite;
+       com_core_packet_use_thread(com_core_use_thread);
+
+       return initialize_provider(disp, name, table, data);
+}
+
+EAPI int provider_init(void *disp, const char *name, struct event_handler *table, void *data)
+{
+       const char *option;
+
+       if (!name || !table) {
+               ErrPrint("Invalid argument\n");
+               return LB_STATUS_ERROR_INVALID;
+       }
+
+       if (s_info.name) {
+               ErrPrint("Provider is already initialized\n");
+               return LB_STATUS_ERROR_ALREADY;
+       }
+
+       option = getenv("PROVIDER_DISABLE_PREVENT_OVERWRITE");
+       if (option && !strcasecmp(option, "true")) {
+               s_info.prevent_overwrite = 1;
+       }
+
+       option = getenv("PROVIDER_COM_CORE_THREAD");
+       if (option && !strcasecmp(option, "true")) {
+               com_core_packet_use_thread(1);
+       }
+
+       return initialize_provider(disp, name, table, data);
+}
+
 EAPI void *provider_fini(void)
 {
        void *ret;