Create string tightly when retrive string from cbhm callback event
[framework/web/webkit-efl.git] / Source / WebKit2 / UIProcess / API / efl / ewk_favicon_database.h
1 /*
2  * Copyright (C) 2012 Intel Corporation. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25
26 /**
27  * @file    ewk_favicon_database.h
28  * @brief   Describes the Ewk Favicon Database API.
29  */
30
31 #ifndef ewk_favicon_database_h
32 #define ewk_favicon_database_h
33
34 #include <Evas.h>
35
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39
40 /** Creates a type name for @a Ewk_Favicon_Database. */
41 typedef struct Ewk_Favicon_Database Ewk_Favicon_Database;
42
43 /**
44  * @typedef Ewk_Favicon_Database_Icon_Change_Cb Ewk_Favicon_Database_Icon_Change_Cb
45  * @brief Callback type for use with ewk_favicon_database_icon_change_callback_add and ewk_favicon_database_icon_change_callback_del
46  */
47 typedef void (*Ewk_Favicon_Database_Icon_Change_Cb)(const char *page_url, void *event_info);
48
49 /**
50  * @typedef Ewk_Favicon_Database_Async_Icon_Get_Cb Ewk_Favicon_Database_Async_Icon_Get_Cb
51  * @brief Callback type for use with ewk_favicon_database_async_icon_get
52  *
53  * The @a icon may be NULL if there is no favicon associated to the given @a page_url.
54  *
55  * You need to call evas_object_ref() on the @a icon if you wish to keep it after the
56  * callback is executed.
57  */
58 typedef void (*Ewk_Favicon_Database_Async_Icon_Get_Cb)(const char *page_url, Evas_Object *icon, void *event_info);
59
60 /**
61  * Retrieves from the database the favicon URL for the given @a page_url
62  *
63  * @param database database object to query
64  * @param page_url URL of the page to get the favicon URL for
65  *
66  * @return a newly allocated string guaranteed to be eina_stringshare
67  *         or @c NULL in case of error or if the key does not exist.
68  *         You need to call eina_stringshare_del() after use.
69  */
70 EAPI const char *ewk_favicon_database_icon_url_get(Ewk_Favicon_Database *database, const char *page_url);
71
72 /**
73  * Retrieves asynchronously from the database the favicon for the given @a page_url
74  *
75  * @param database database object to query
76  * @param page_url URL of the page to get the favicon for
77  * @param evas The canvas to add the favicon to
78  * @param callback callback function to be called when the icon is retrieved
79  * @param data the data pointer that was to be passed to the callback
80  *
81  * @return @c EINA_TRUE if the icon was successfuly requested, @c EINA_FALSE otherwise
82  */
83 EAPI Eina_Bool ewk_favicon_database_async_icon_get(Ewk_Favicon_Database *database, const char *page_url, Evas *evas, Ewk_Favicon_Database_Async_Icon_Get_Cb callback, void *data);
84
85 /**
86  * Add (register) a callback function to a icon change event
87  *
88  * @param database database object to register the callback
89  * @param callback callback function to be called when an icon changes
90  * @param data the data pointer that was to be passed to the callback
91  */
92 EAPI void ewk_favicon_database_icon_change_callback_add(Ewk_Favicon_Database *database, Ewk_Favicon_Database_Icon_Change_Cb callback, void *data);
93
94 /**
95  * Delete (unregister) a callback function registered to a icon change event
96  *
97  * @param database database object to unregister the callback.
98  * @param callback callback function to unregister
99  */
100 EAPI void ewk_favicon_database_icon_change_callback_del(Ewk_Favicon_Database *database, Ewk_Favicon_Database_Icon_Change_Cb callback);
101
102 #ifdef __cplusplus
103 }
104 #endif
105
106 #endif // ewk_favicon_database_h