2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
24 #include "shop-adaptor.h"
25 #include "shop-adaptor-log.h"
30 typedef struct shop_adaptor_plugin_s {
31 shop_adaptor_h adaptor; /* Adaptor */
32 char *path; /* Plugin library path */
33 shop_adaptor_plugin_handle_h handle; /* Plugin handle */
34 void *dl_handle; /* Plugin library handle */
35 int ref_counter; /* Plugin reference counter */
36 GMutex ref_counter_mutex; /* Plugin reference counter mutex */
37 shop_adaptor_plugin_listener_h plugin_listener; /* Plugin callback listener */
38 GMutex plugin_listener_mutex; /* Plugin callback listener mutex */
39 } shop_adaptor_plugin_t;
44 typedef struct shop_adaptor_s {
45 GMutex shop_adaptor_mutex; /* Adaptor mutex */
46 int started; /* Started flag */
47 char *plugins_dir; /* Plugins directory path */
48 GList *plugins; /* List of loaded plugins */
49 GMutex plugins_mutex; /* Plugin list mutex */
50 GList *adaptor_listeners; /* List of vservice channel listener (for now not effective) */
51 GMutex adaptor_listeners_mutex; /* Listener list mutex */
57 static shop_adaptor_plugin_h shop_adaptor_create_plugin(const char *plugin_path);
60 * Destroys plugin and deletes all resources associated with it
62 static void shop_adaptor_destroy_plugin(shop_adaptor_plugin_h plugin);
65 * Loads plugins from selected directory
67 static int shop_adaptor_load_plugins_from_directory(shop_adaptor_h adaptor, const char *dir_path);
70 * Checks if plugin is loaded by selected plugin adaptor
72 static int shop_adaptor_has_plugin(shop_adaptor_h adaptor, shop_adaptor_plugin_h plugin);
75 * Increases adaptor's plugin references counter
77 static void shop_adaptor_plugin_ref(shop_adaptor_plugin_h);
80 * Decreases adaptor's plugin references counter
82 static void shop_adaptor_plugin_unref(shop_adaptor_plugin_h);
84 /* //------------------------------------------------------------------------
85 // Functions implementations
86 //------------------------------------------------------------------------ */
88 /* //////////////////////////////////////////////////////
89 // Mandatory: External adaptor management function
90 ////////////////////////////////////////////////////// */
93 shop_adaptor_h shop_adaptor_create(const char *plugins_dir)
95 shop_adaptor_h shop_adaptor = (shop_adaptor_h) malloc(sizeof(shop_adaptor_t));
96 if (NULL == shop_adaptor) {
100 shop_adaptor->started = 0;
101 shop_adaptor->plugins_dir = strdup(plugins_dir);
103 g_mutex_init(&shop_adaptor->shop_adaptor_mutex);
104 g_mutex_init(&shop_adaptor->plugins_mutex);
105 g_mutex_init(&shop_adaptor->adaptor_listeners_mutex);
107 g_mutex_lock(&shop_adaptor->adaptor_listeners_mutex);
108 shop_adaptor->adaptor_listeners = NULL;
109 g_mutex_unlock(&shop_adaptor->adaptor_listeners_mutex);
111 g_mutex_lock(&shop_adaptor->plugins_mutex);
112 shop_adaptor->plugins = NULL;
113 g_mutex_unlock(&shop_adaptor->plugins_mutex);
120 void shop_adaptor_destroy(shop_adaptor_h adaptor)
122 if (NULL == adaptor) {
123 shop_adaptor_error("Invalid argument");
127 g_mutex_lock(&adaptor->shop_adaptor_mutex);
128 if (adaptor->started) {
129 shop_adaptor_error("Shop adaptor is running. Forcing stop before destroy");
130 shop_adaptor_stop(adaptor);
133 g_mutex_lock(&adaptor->plugins_mutex);
134 if (NULL != adaptor->plugins) {
135 g_list_free_full(adaptor->plugins, (GDestroyNotify) shop_adaptor_plugin_unref);
136 adaptor->plugins = NULL;
138 g_mutex_unlock(&adaptor->plugins_mutex);
140 g_mutex_lock(&adaptor->adaptor_listeners_mutex);
141 if (NULL != adaptor->adaptor_listeners) {
142 g_list_free(adaptor->adaptor_listeners);
143 adaptor->adaptor_listeners = NULL;
145 g_mutex_unlock(&adaptor->adaptor_listeners_mutex);
148 /*please add destroying lisners if it needed, currently it is not needed */
150 free(adaptor->plugins_dir);
151 adaptor->plugins_dir = NULL;
153 g_mutex_unlock(&adaptor->shop_adaptor_mutex);
159 int shop_adaptor_start(shop_adaptor_h adaptor)
161 shop_adaptor_debug("Starting shop adaptor");
162 if (NULL == adaptor) {
163 shop_adaptor_error("Invalid argument");
164 return SHOP_ADAPTOR_ERROR_INVALID_ARGUMENT;
167 g_mutex_lock(&adaptor->shop_adaptor_mutex);
168 int result = SHOP_ADAPTOR_ERROR_NONE;
169 if (adaptor->started) {
170 shop_adaptor_error("Storage adaptor is already started");
171 result = SHOP_ADAPTOR_ERROR_START;
173 adaptor->started = 1;
174 result = shop_adaptor_load_plugins_from_directory(adaptor, adaptor->plugins_dir);
175 if (SHOP_ADAPTOR_ERROR_NONE != result) {
176 adaptor->started = 0;
177 shop_adaptor_error("Could not load plugins from directory");
179 shop_adaptor_debug("Storage adaptor started successfully");
182 g_mutex_unlock(&adaptor->shop_adaptor_mutex);
188 * Stops shop adaptor.
191 int shop_adaptor_stop(shop_adaptor_h adaptor)
193 if (NULL == adaptor) {
194 shop_adaptor_error("Invalid argument");
195 return SHOP_ADAPTOR_ERROR_INVALID_ARGUMENT;
198 g_mutex_lock(&adaptor->shop_adaptor_mutex);
199 int result = SHOP_ADAPTOR_ERROR_NONE;
200 if (!adaptor->started) {
201 result = SHOP_ADAPTOR_ERROR_START;
203 if (NULL != adaptor->plugins) {
204 g_mutex_lock(&adaptor->plugins_mutex);
205 g_list_free_full(adaptor->plugins, (GDestroyNotify) shop_adaptor_plugin_unref);
206 adaptor->plugins = NULL;
207 g_mutex_unlock(&adaptor->plugins_mutex);
209 adaptor->started = 0;
210 shop_adaptor_debug("Shop adaptor stopped");
213 g_mutex_unlock(&adaptor->shop_adaptor_mutex);
218 * Registers plugin state listener
221 int shop_adaptor_register_listener(shop_adaptor_h adaptor, shop_adaptor_listener_h listener)
223 if ((NULL == adaptor) || (NULL == listener)) {
224 shop_adaptor_error("Invalid argument");
225 return SHOP_ADAPTOR_ERROR_INVALID_ARGUMENT;
228 g_mutex_lock(&adaptor->adaptor_listeners_mutex);
230 adaptor->adaptor_listeners = g_list_append(adaptor->adaptor_listeners, listener);
232 g_mutex_unlock(&adaptor->adaptor_listeners_mutex);
234 return SHOP_ADAPTOR_ERROR_NONE;
238 * Unregisters plugin state listener
241 int shop_adaptor_unregister_listener(shop_adaptor_h adaptor, shop_adaptor_listener_h listener)
243 if ((NULL == adaptor) || (NULL == listener)) {
244 shop_adaptor_error("Invalid argument");
245 return SHOP_ADAPTOR_ERROR_INVALID_ARGUMENT;
248 g_mutex_lock(&adaptor->adaptor_listeners_mutex);
250 if (NULL == g_list_find(adaptor->adaptor_listeners, listener)) {
251 g_mutex_unlock(&adaptor->adaptor_listeners_mutex);
252 shop_adaptor_error("Could not find listener");
254 return SHOP_ADAPTOR_ERROR_NOT_FOUND;
257 adaptor->adaptor_listeners = g_list_remove(adaptor->adaptor_listeners, listener);
260 g_mutex_unlock(&adaptor->adaptor_listeners_mutex);
262 return SHOP_ADAPTOR_ERROR_NONE;
265 /* /////////////////////////////////////////////////////////////
266 // Plugin create / destroy / ref. count / get plugin name
267 ///////////////////////////////////////////////////////////// */
268 static shop_adaptor_plugin_h shop_adaptor_create_plugin(const char *plugin_path)
270 if (NULL == plugin_path) {
271 shop_adaptor_error("Invalid argument");
275 void *dl_handle = dlopen(plugin_path, RTLD_LAZY);
276 if (NULL == dl_handle) {
277 shop_adaptor_error("Could not load plugin %s: %s", plugin_path, dlerror());
281 shop_adaptor_plugin_handle_h (*get_adaptee_handle)(void) = NULL;
283 get_adaptee_handle = (shop_adaptor_plugin_handle_h (*)(void)) (dlsym(dl_handle, "create_plugin_handle"));
284 if (NULL == get_adaptee_handle) {
286 shop_adaptor_error("Could not get function pointer to create_plugin_handle");
291 shop_adaptor_plugin_handle_h handle = get_adaptee_handle();
292 plugin_req_exit_void();
294 if (NULL == handle) {
296 shop_adaptor_error("Could not get adaptee handle");
300 shop_adaptor_plugin_h plugin = (shop_adaptor_plugin_h) malloc(sizeof(shop_adaptor_plugin_t));
301 if (NULL == plugin) {
303 shop_adaptor_error("Could not create plugin object");
307 plugin->path = g_strdup(plugin_path);
308 plugin->handle = handle;
309 plugin->dl_handle = dl_handle;
310 plugin->ref_counter = 0;
312 g_mutex_init(&plugin->ref_counter_mutex);
313 g_mutex_init(&plugin->plugin_listener_mutex);
315 shop_adaptor_plugin_listener_h listener =
316 (shop_adaptor_plugin_listener_h) malloc(sizeof(shop_adaptor_plugin_listener_t));
319 plugin->handle->set_listener(listener);
320 plugin_req_exit_void();
321 g_mutex_lock(&plugin->plugin_listener_mutex);
322 plugin->plugin_listener = listener;
323 g_mutex_unlock(&plugin->plugin_listener_mutex);
328 static void shop_adaptor_destroy_plugin(shop_adaptor_plugin_h plugin)
330 if (NULL == plugin) {
331 shop_adaptor_error("Invalid argument");
335 if (NULL != plugin->handle) {
336 plugin->handle->destroy_handle(plugin->handle);
338 g_mutex_lock(&plugin->plugin_listener_mutex);
340 plugin->handle->unset_listener();
341 plugin_req_exit_void();
342 g_mutex_unlock(&plugin->plugin_listener_mutex);
344 plugin->handle = NULL;
347 if (NULL != plugin->dl_handle) {
348 dlclose(plugin->dl_handle);
349 plugin->dl_handle = NULL;
358 static int shop_adaptor_load_plugins_from_directory(shop_adaptor_h adaptor, const char *dir_path)
360 char *plugin_path = NULL;
362 struct dirent dir_entry, *result = NULL;
364 shop_adaptor_debug("Starting load plugins from directory");
366 if ((NULL == adaptor) || (NULL == dir_path)) {
367 shop_adaptor_error("Invalid argument");
368 return SHOP_ADAPTOR_ERROR_INVALID_ARGUMENT;
371 dir = opendir(dir_path);
373 shop_adaptor_error("Could not open dir path (%s)", dir_path);
374 return SHOP_ADAPTOR_ERROR_NOT_FOUND;
377 int ret = SHOP_ADAPTOR_ERROR_NONE;
378 while (0 == (readdir_r(dir, &dir_entry, &result))) {
380 if (NULL == result) {
381 shop_adaptor_error("Could not open directory %s", plugin_path);
385 if (dir_entry.d_type & DT_DIR) {
389 plugin_path = g_strconcat(dir_path, "/", dir_entry.d_name, NULL);
390 shop_adaptor_plugin_h plugin = shop_adaptor_create_plugin(plugin_path);
392 if (NULL != plugin) {
393 shop_adaptor_debug("Loaded plugin: %s", plugin_path);
394 plugin->adaptor = adaptor;
395 shop_adaptor_plugin_ref(plugin);
396 g_mutex_lock(&adaptor->plugins_mutex);
397 adaptor->plugins = g_list_append(adaptor->plugins, plugin);
398 g_mutex_unlock(&adaptor->plugins_mutex);
400 shop_adaptor_error("Could not load plugin %s", plugin_path);
407 shop_adaptor_debug("End load plugins from directory");
413 static int shop_adaptor_has_plugin(shop_adaptor_h adaptor, shop_adaptor_plugin_h plugin)
415 if ((NULL == adaptor) || (NULL == plugin)) {
416 shop_adaptor_error("Invalid argument");
422 g_mutex_lock(&adaptor->plugins_mutex);
423 if (NULL != g_list_find(adaptor->plugins, plugin)) {
426 g_mutex_unlock(&adaptor->plugins_mutex);
431 static void shop_adaptor_plugin_ref(shop_adaptor_plugin_h plugin)
433 if (NULL == plugin) {
434 shop_adaptor_error("Invalid argument");
438 g_mutex_lock(&plugin->ref_counter_mutex);
439 plugin->ref_counter = plugin->ref_counter + 1;
440 if (NULL != plugin->handle) {
441 shop_adaptor_info("plugin name : %s, ref_counter: %d", plugin->handle->plugin_uri, plugin->ref_counter);
443 shop_adaptor_info("ref_counter : %d", plugin->ref_counter);
445 g_mutex_unlock(&plugin->ref_counter_mutex);
448 static void shop_adaptor_plugin_unref(shop_adaptor_plugin_h plugin)
450 if (NULL == plugin) {
451 shop_adaptor_error("Invalid argument");
455 int should_destroy = 0;
457 g_mutex_lock(&plugin->ref_counter_mutex);
458 plugin->ref_counter = plugin->ref_counter - 1;
460 if (NULL != plugin->handle) {
461 shop_adaptor_info("plugin name : %s, ref_counter: %d", plugin->handle->plugin_uri, plugin->ref_counter);
463 shop_adaptor_info("ref_counter : %d", plugin->ref_counter);
466 if (0 >= plugin->ref_counter) {
469 g_mutex_unlock(&plugin->ref_counter_mutex);
471 if (should_destroy) {
472 shop_adaptor_debug("Plugin is being destroyed");
473 shop_adaptor_destroy_plugin(plugin);
478 * Refresh access token
481 shop_error_code_t shop_adaptor_refresh_access_token(shop_adaptor_plugin_context_h context,
482 const char *new_access_token)
484 if ((NULL == context) || (NULL == new_access_token) || (0 >= strlen(new_access_token))) {
485 return SHOP_ADAPTOR_ERROR_INVALID_ARGUMENT;
487 shop_adaptor_debug("New access token : %s", new_access_token);
489 free(context->access_token);
490 context->access_token = NULL;
491 context->access_token = strdup(new_access_token);
493 return SHOP_ADAPTOR_ERROR_NONE;
497 shop_error_code_t shop_adaptor_refresh_uid(shop_adaptor_plugin_context_h context,
500 if ((NULL == context) || (NULL == new_uid) || (0 >= strlen(new_uid))) {
501 return SHOP_ADAPTOR_ERROR_INVALID_ARGUMENT;
503 shop_adaptor_debug("New uid : %s", new_uid);
506 context->duid = NULL;
507 context->duid = strdup(new_uid);
509 return SHOP_ADAPTOR_ERROR_NONE;
512 /* //////////////////////////////////////////////////////
513 // Create / Destroy error code
514 ////////////////////////////////////////////////////// */
515 shop_adaptor_error_code_h shop_adaptor_create_error_code(const int64_t code, const char *msg)
521 shop_adaptor_error_code_h error_code =
522 (shop_adaptor_error_code_h) malloc(sizeof(shop_adaptor_error_code_t));
523 if (NULL == error_code) {
527 error_code->code = code;
528 error_code->msg = strdup(msg);
533 void shop_adaptor_destroy_error_code(shop_adaptor_error_code_h *error_code)
535 if ((NULL != error_code) && (NULL != (*error_code))) {
536 free((*error_code)->msg);
537 (*error_code)->msg = NULL;
544 /* //////////////////////////////////////////////////////
545 // Plugin context create / destroy
546 ////////////////////////////////////////////////////// */
547 shop_adaptor_plugin_context_h shop_adaptor_create_plugin_context(shop_adaptor_plugin_h plugin, char *plugin_uri, char *duid, char *access_token, char *app_id, char *apptype)
549 shop_adaptor_debug("Starting shop_adaptor_create_plugin_context");
551 if (NULL == plugin) {
552 shop_adaptor_error("Invalid argument");
556 if (NULL != plugin->handle) {
557 shop_adaptor_plugin_context_h plugin_context = NULL;
560 plugin->handle->create_context(&plugin_context, duid, access_token, app_id, apptype);
561 plugin_req_exit_void();
563 plugin_context->plugin_uri = strdup(plugin->handle->plugin_uri);
564 return plugin_context;
566 shop_adaptor_error("Plugin handle is null");
569 shop_adaptor_debug("End shop_adaptor_create_plugin_context");
573 void shop_adaptor_destroy_plugin_context(shop_adaptor_plugin_h plugin, shop_adaptor_plugin_context_h plugin_context)
575 shop_adaptor_warning("Starting shop_adaptor_get_plugin_by_name");
577 if ((NULL == plugin) || (NULL == plugin_context)) {
578 shop_adaptor_error("Invalid argument");
582 if (NULL != plugin->handle) {
584 plugin->handle->destroy_context(plugin_context);
585 plugin_req_exit_void();
587 shop_adaptor_error("Plugin handle is null");
591 /* //////////////////////////////////////////////////////
592 // Get plugin by plugin name
593 ////////////////////////////////////////////////////// */
594 shop_adaptor_plugin_h shop_adaptor_get_plugin_by_name(shop_adaptor_h adaptor, const char *plugin_name)
596 shop_adaptor_warning("Starting shop_adaptor_get_plugin_by_name");
598 if ((NULL == adaptor) || (NULL == plugin_name)) {
599 shop_adaptor_error("Invalid argument");
603 shop_adaptor_plugin_h plugin = NULL;
604 g_mutex_lock(&adaptor->plugins_mutex);
605 int count = g_list_length(adaptor->plugins);
607 for (i = 0; i < count; i++) {
608 shop_adaptor_plugin_h temp_plugin = (shop_adaptor_plugin_h)g_list_nth_data(adaptor->plugins, i);
609 if (NULL != temp_plugin) {
610 if (0 == strcmp(temp_plugin->handle->plugin_uri, plugin_name)) {
611 shop_adaptor_plugin_ref(temp_plugin);
612 plugin = temp_plugin;
613 g_mutex_unlock(&adaptor->plugins_mutex);
618 g_mutex_unlock(&adaptor->plugins_mutex);
620 if (NULL == plugin) {
621 shop_adaptor_debug("Plugin is not found by name");
627 /* //////////////////////////////////////////////////////
628 // Plugin load / unload / get plugin list
629 ////////////////////////////////////////////////////// */
630 int shop_adaptor_load_plugin(shop_adaptor_h adaptor, const char *plugin_path)
632 if ((NULL == adaptor) || (NULL == plugin_path)) {
633 shop_adaptor_error("Invalid argument");
634 return SHOP_ADAPTOR_ERROR_INVALID_ARGUMENT;
637 if (!adaptor->started) {
638 shop_adaptor_error("Storage adaptor is not started");
639 return SHOP_ADAPTOR_ERROR_START;
642 shop_adaptor_plugin_h plugin = shop_adaptor_create_plugin(plugin_path);
643 if (NULL == plugin) {
644 shop_adaptor_error("Could not load plugin %s", plugin_path);
645 return SHOP_ADAPTOR_ERROR_CREATE;
648 plugin->adaptor = adaptor;
649 shop_adaptor_plugin_ref(plugin);
651 g_mutex_lock(&adaptor->plugins_mutex);
652 adaptor->plugins = g_list_append(adaptor->plugins, plugin);
653 g_mutex_unlock(&adaptor->plugins_mutex);
655 return SHOP_ADAPTOR_ERROR_NONE;
658 int shop_adaptor_unload_plugin(shop_adaptor_h adaptor, shop_adaptor_plugin_h plugin)
660 if ((NULL == adaptor) || (NULL == plugin)) {
661 shop_adaptor_error("Invalid argument");
662 return SHOP_ADAPTOR_ERROR_INVALID_ARGUMENT;
665 if (!adaptor->started) {
666 shop_adaptor_error("Storage adaptor is not started");
667 return SHOP_ADAPTOR_ERROR_START;
670 if (!shop_adaptor_has_plugin(adaptor, plugin)) {
671 shop_adaptor_error("Storage adaptor has no plugin");
672 return SHOP_ADAPTOR_ERROR_NOT_FOUND;
675 plugin->adaptor = NULL;
677 g_mutex_lock(&adaptor->plugins_mutex);
678 adaptor->plugins = g_list_remove(adaptor->plugins, plugin);
679 g_mutex_unlock(&adaptor->plugins_mutex);
681 shop_adaptor_plugin_unref(plugin);
683 return SHOP_ADAPTOR_ERROR_NONE;
686 GList *shop_adaptor_get_plugins(shop_adaptor_h adaptor)
688 if (NULL == adaptor) {
689 shop_adaptor_error("Invalid argument");
693 GList *plugins = NULL;
695 g_mutex_lock(&adaptor->plugins_mutex);
696 int plugins_count = g_list_length(adaptor->plugins);
698 for (i = 0; i < plugins_count; i++) {
699 shop_adaptor_plugin_h plugin = (shop_adaptor_plugin_h)g_list_nth_data(adaptor->plugins, i);
700 if (NULL != plugin) {
701 shop_adaptor_plugin_ref(plugin);
702 plugins = g_list_append(plugins, plugin);
705 g_mutex_unlock(&adaptor->plugins_mutex);
712 shop_error_code_t shop_adaptor_set_server_info(shop_adaptor_plugin_h plugin,
713 shop_adaptor_plugin_context_h context,
714 GHashTable *server_info,
715 shop_adaptor_error_code_h *error_code)
717 if ((NULL == plugin) || (NULL == context)) {
718 shop_adaptor_error("Invalid argument");
720 *error_code = shop_adaptor_create_error_code((int64_t) SHOP_ADAPTOR_ERROR_INVALID_ARGUMENT,
721 "Invalid argument (plugin or context)");
723 return SHOP_ADAPTOR_ERROR_INVALID_ARGUMENT;
726 if (NULL == plugin->handle) {
727 shop_adaptor_error("Plugin handle is null");
729 *error_code = shop_adaptor_create_error_code((int64_t) SHOP_ADAPTOR_ERROR_INVALID_HANDLE,
730 "Plugin handle is null");
732 return SHOP_ADAPTOR_ERROR_INVALID_HANDLE;
735 shop_error_code_t ret;
737 ret = plugin->handle->set_server_info(context, server_info, error_code);
738 plugin_req_exit(ret, plugin, error_code);
743 /* ////////////////////////////////////////////////////////////
744 // Adaptor Plugin call Functions
745 //////////////////////////////////////////////////////////// */
747 shop_error_code_t shop_adaptor_get_item_list_v1(shop_adaptor_plugin_h plugin, shop_adaptor_plugin_context_h context, shop_adaptor_shop_info_s *info, void *user_data, shop_adaptor_shop_item_s ***items, unsigned int *items_len, shop_adaptor_error_code_h *error_code, void **server_data)
749 if ((NULL == plugin) || (NULL == context)) {
750 shop_adaptor_error("Invalid argument");
752 *error_code = shop_adaptor_create_error_code(
753 (int64_t) SHOP_ADAPTOR_ERROR_INVALID_ARGUMENT,
754 "Invalid argument (plugin or context)");
756 return SHOP_ADAPTOR_ERROR_INVALID_ARGUMENT;
759 if (NULL == plugin->handle) {
760 shop_adaptor_error("Plugin handle is null");
762 *error_code = shop_adaptor_create_error_code(
763 (int64_t) SHOP_ADAPTOR_ERROR_INVALID_HANDLE,
764 "Plugin handle is null");
766 return SHOP_ADAPTOR_ERROR_INVALID_HANDLE;
769 shop_error_code_t ret;
771 ret = plugin->handle->get_item_list_v1(context, info, user_data, items, items_len, error_code, server_data);
772 plugin_req_exit(ret, plugin, error_code);
778 shop_error_code_t shop_adaptor_download_item_package_v1(shop_adaptor_plugin_h plugin, shop_adaptor_plugin_context_h context, shop_adaptor_shop_info_s *info, void *user_data, shop_adaptor_shop_item_s **item, shop_adaptor_error_code_h *error_code, void **server_data)
780 if ((NULL == plugin) || (NULL == context)) {
781 shop_adaptor_error("Invalid argument");
783 *error_code = shop_adaptor_create_error_code(
784 (int64_t) SHOP_ADAPTOR_ERROR_INVALID_ARGUMENT,
785 "Invalid argument (plugin or context)");
787 return SHOP_ADAPTOR_ERROR_INVALID_ARGUMENT;
790 if (NULL == plugin->handle) {
791 shop_adaptor_error("Plugin handle is null");
793 *error_code = shop_adaptor_create_error_code(
794 (int64_t) SHOP_ADAPTOR_ERROR_INVALID_HANDLE,
795 "Plugin handle is null");
797 return SHOP_ADAPTOR_ERROR_INVALID_HANDLE;
800 shop_error_code_t ret;
802 ret = plugin->handle->download_item_package_v1(context, info, user_data, item, error_code, server_data);
803 plugin_req_exit(ret, plugin, error_code);
809 shop_error_code_t shop_adaptor_download_sticker_v1(shop_adaptor_plugin_h plugin, shop_adaptor_plugin_context_h context, shop_adaptor_shop_info_s *info, void *user_data, shop_adaptor_shop_item_s **item, shop_adaptor_error_code_h *error_code, void **server_data)
811 if ((NULL == plugin) || (NULL == context)) {
812 shop_adaptor_error("Invalid argument");
814 *error_code = shop_adaptor_create_error_code(
815 (int64_t) SHOP_ADAPTOR_ERROR_INVALID_ARGUMENT,
816 "Invalid argument (plugin or context)");
818 return SHOP_ADAPTOR_ERROR_INVALID_ARGUMENT;
821 if (NULL == plugin->handle) {
822 shop_adaptor_error("Plugin handle is null");
824 *error_code = shop_adaptor_create_error_code(
825 (int64_t) SHOP_ADAPTOR_ERROR_INVALID_HANDLE,
826 "Plugin handle is null");
828 return SHOP_ADAPTOR_ERROR_INVALID_HANDLE;
831 shop_error_code_t ret;
833 ret = plugin->handle->download_sticker_v1(context, info, user_data, item, error_code, server_data);
834 plugin_req_exit(ret, plugin, error_code);
840 shop_error_code_t shop_adaptor_get_panel_url_v1(shop_adaptor_plugin_h plugin, shop_adaptor_plugin_context_h context, shop_adaptor_shop_info_s *info, void *user_data, shop_adaptor_shop_item_s **item, shop_adaptor_error_code_h *error_code, void **server_data)
842 if ((NULL == plugin) || (NULL == context)) {
843 shop_adaptor_error("Invalid argument");
845 *error_code = shop_adaptor_create_error_code(
846 (int64_t) SHOP_ADAPTOR_ERROR_INVALID_ARGUMENT,
847 "Invalid argument (plugin or context)");
849 return SHOP_ADAPTOR_ERROR_INVALID_ARGUMENT;
852 if (NULL == plugin->handle) {
853 shop_adaptor_error("Plugin handle is null");
855 *error_code = shop_adaptor_create_error_code(
856 (int64_t) SHOP_ADAPTOR_ERROR_INVALID_HANDLE,
857 "Plugin handle is null");
859 return SHOP_ADAPTOR_ERROR_INVALID_HANDLE;
863 shop_adaptor_error("info handle is null");
865 *error_code = shop_adaptor_create_error_code(
866 (int64_t) SHOP_ADAPTOR_ERROR_INVALID_ARGUMENT,
867 "Info handle is null");
869 return SHOP_ADAPTOR_ERROR_INVALID_HANDLE;
872 shop_error_code_t ret;
874 ret = plugin->handle->get_panel_url_v1(context, info, user_data, item, error_code, server_data);
875 plugin_req_exit(ret, plugin, error_code);