awesomium-raw (empty) → 0.1.0.0
raw patch · 8 files changed
+2942/−0 lines, 8 filesdep +basesetup-changed
Dependencies added: base
Files
- LICENSE +165/−0
- Setup.hs +2/−0
- awesomium-raw.cabal +46/−0
- cbits/keyb.c +10/−0
- include/Awesomium/PlatformUtils.h +29/−0
- include/awesomium_capi.h +2111/−0
- include/keyb.h +10/−0
- src/Graphics/UI/Awesomium/Raw.chs +569/−0
+ LICENSE view
@@ -0,0 +1,165 @@+ GNU LESSER GENERAL PUBLIC LICENSE+ Version 3, 29 June 2007++ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>+ Everyone is permitted to copy and distribute verbatim copies+ of this license document, but changing it is not allowed.+++ This version of the GNU Lesser General Public License incorporates+the terms and conditions of version 3 of the GNU General Public+License, supplemented by the additional permissions listed below.++ 0. Additional Definitions. ++ As used herein, "this License" refers to version 3 of the GNU Lesser+General Public License, and the "GNU GPL" refers to version 3 of the GNU+General Public License.++ "The Library" refers to a covered work governed by this License,+other than an Application or a Combined Work as defined below.++ An "Application" is any work that makes use of an interface provided+by the Library, but which is not otherwise based on the Library.+Defining a subclass of a class defined by the Library is deemed a mode+of using an interface provided by the Library.++ A "Combined Work" is a work produced by combining or linking an+Application with the Library. The particular version of the Library+with which the Combined Work was made is also called the "Linked+Version".++ The "Minimal Corresponding Source" for a Combined Work means the+Corresponding Source for the Combined Work, excluding any source code+for portions of the Combined Work that, considered in isolation, are+based on the Application, and not on the Linked Version.++ The "Corresponding Application Code" for a Combined Work means the+object code and/or source code for the Application, including any data+and utility programs needed for reproducing the Combined Work from the+Application, but excluding the System Libraries of the Combined Work.++ 1. Exception to Section 3 of the GNU GPL.++ You may convey a covered work under sections 3 and 4 of this License+without being bound by section 3 of the GNU GPL.++ 2. Conveying Modified Versions.++ If you modify a copy of the Library, and, in your modifications, a+facility refers to a function or data to be supplied by an Application+that uses the facility (other than as an argument passed when the+facility is invoked), then you may convey a copy of the modified+version:++ a) under this License, provided that you make a good faith effort to+ ensure that, in the event an Application does not supply the+ function or data, the facility still operates, and performs+ whatever part of its purpose remains meaningful, or++ b) under the GNU GPL, with none of the additional permissions of+ this License applicable to that copy.++ 3. Object Code Incorporating Material from Library Header Files.++ The object code form of an Application may incorporate material from+a header file that is part of the Library. You may convey such object+code under terms of your choice, provided that, if the incorporated+material is not limited to numerical parameters, data structure+layouts and accessors, or small macros, inline functions and templates+(ten or fewer lines in length), you do both of the following:++ a) Give prominent notice with each copy of the object code that the+ Library is used in it and that the Library and its use are+ covered by this License.++ b) Accompany the object code with a copy of the GNU GPL and this license+ document.++ 4. Combined Works.++ You may convey a Combined Work under terms of your choice that,+taken together, effectively do not restrict modification of the+portions of the Library contained in the Combined Work and reverse+engineering for debugging such modifications, if you also do each of+the following:++ a) Give prominent notice with each copy of the Combined Work that+ the Library is used in it and that the Library and its use are+ covered by this License.++ b) Accompany the Combined Work with a copy of the GNU GPL and this license+ document.++ c) For a Combined Work that displays copyright notices during+ execution, include the copyright notice for the Library among+ these notices, as well as a reference directing the user to the+ copies of the GNU GPL and this license document.++ d) Do one of the following:++ 0) Convey the Minimal Corresponding Source under the terms of this+ License, and the Corresponding Application Code in a form+ suitable for, and under terms that permit, the user to+ recombine or relink the Application with a modified version of+ the Linked Version to produce a modified Combined Work, in the+ manner specified by section 6 of the GNU GPL for conveying+ Corresponding Source.++ 1) Use a suitable shared library mechanism for linking with the+ Library. A suitable mechanism is one that (a) uses at run time+ a copy of the Library already present on the user's computer+ system, and (b) will operate properly with a modified version+ of the Library that is interface-compatible with the Linked+ Version. ++ e) Provide Installation Information, but only if you would otherwise+ be required to provide such information under section 6 of the+ GNU GPL, and only to the extent that such information is+ necessary to install and execute a modified version of the+ Combined Work produced by recombining or relinking the+ Application with a modified version of the Linked Version. (If+ you use option 4d0, the Installation Information must accompany+ the Minimal Corresponding Source and Corresponding Application+ Code. If you use option 4d1, you must provide the Installation+ Information in the manner specified by section 6 of the GNU GPL+ for conveying Corresponding Source.)++ 5. Combined Libraries.++ You may place library facilities that are a work based on the+Library side by side in a single library together with other library+facilities that are not Applications and are not covered by this+License, and convey such a combined library under terms of your+choice, if you do both of the following:++ a) Accompany the combined library with a copy of the same work based+ on the Library, uncombined with any other library facilities,+ conveyed under the terms of this License.++ b) Give prominent notice with the combined library that part of it+ is a work based on the Library, and explaining where to find the+ accompanying uncombined form of the same work.++ 6. Revised Versions of the GNU Lesser General Public License.++ The Free Software Foundation may publish revised and/or new versions+of the GNU Lesser General Public License from time to time. Such new+versions will be similar in spirit to the present version, but may+differ in detail to address new problems or concerns.++ Each version is given a distinguishing version number. If the+Library as you received it specifies that a certain numbered version+of the GNU Lesser General Public License "or any later version"+applies to it, you have the option of following the terms and+conditions either of that published version or of any later version+published by the Free Software Foundation. If the Library as you+received it does not specify a version number of the GNU Lesser+General Public License, you may choose any version of the GNU Lesser+General Public License ever published by the Free Software Foundation.++ If the Library as you received it specifies that a proxy can decide+whether future versions of the GNU Lesser General Public License shall+apply, that proxy's public statement of acceptance of any version is+permanent authorization for you to choose that version for the+Library.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ awesomium-raw.cabal view
@@ -0,0 +1,46 @@++Name: awesomium-raw+Version: 0.1.0.0+Synopsis: Low-level Awesomium bindings.+License: LGPL-3+License-File: LICENSE+Copyright: (c) 2012 Maksymilian Owsianny+Author: Maksymilian Owsianny+Maintainer: Maksymilian.Owsianny+AwesomiumRaw@gmail.com+Bug-Reports: https://github.com/MaxOw/awesomium-raw/issues+Category: Graphics, Web+Build-Type: Simple+Stability: Experimental+Cabal-Version: >=1.8++Extra-Source-Files: include/awesomium_capi.h+ , include/Awesomium/PlatformUtils.h+ , include/keyb.h+ , cbits/keyb.c++Description: This package contains raw bindings to Awesomium+ (<http://awesomium.com>).+ .+ For more user friendly, high-level bindings see+ here+ (<http://hackage.haskell.org/package/awesomium>).+ .+ Also, if you plan to integrate Awesomium with+ GLUT you can check out this package+ (<http://hackage.haskell.org/package/awesomium-glut>).++Source-Repository head+ Type: git+ Location: https://github.com/MaxOw/awesomium-raw.git++Library+ Exposed-Modules: Graphics.UI.Awesomium.Raw+ Build-Tools: c2hs+ Build-Depends: base >= 3 && < 5+ Hs-Source-Dirs: src+ Include-Dirs: include+ Includes: keyb.h+ C-Sources: cbits/keyb.c+ Extra-Libraries: awesomium-1.6.5+ Extra-Lib-Dirs: /usr/lib/awesomium-1.6.5+ Cc-Options: -ffast-math -std=gnu99
+ cbits/keyb.c view
@@ -0,0 +1,10 @@+#include <stdlib.h>+#include "keyb.h"++void awe_webview_get_dirty_bounds_wrapper(awe_webview* wv, awe_rect* r) {+ *r = awe_webview_get_dirty_bounds(wv);+}++void awe_webview_inject_keyboard_event_wrapper (awe_webview* wv, awe_webkeyboardevent* ev) {+ awe_webview_inject_keyboard_event(wv, *ev);+}
+ include/Awesomium/PlatformUtils.h view
@@ -0,0 +1,29 @@+/**+ * @file PlatformUtils.h+ *+ * @author+ *+ * This file is a part of Awesomium, a library that makes it easy for + * developers to embed the web in their applications.+ *+ * Website: <http://www.awesomium.com>+ * + * Copyright (C) 2011 Khrona. All rights reserved. Awesomium is a + * trademark of Khrona.+ */++#ifndef __PLATFORM_UTILS_H__+#define __PLATFORM_UTILS_H__++#if defined(__WIN32__) || defined(_WIN32)+# if defined(OSM_NONCLIENT_BUILD)+# define _OSMExport __declspec( dllexport )+# else+# define _OSMExport __declspec( dllimport )+# endif+#pragma warning (disable : 4251)+#else+# define _OSMExport __attribute__((visibility("default")))+#endif++#endif
+ include/awesomium_capi.h view
@@ -0,0 +1,2111 @@+/** + * @file awesomium_capi.h + * + * The main header for the Awesomium C API. + * + * @author + * + * This file is a part of Awesomium, a library that makes it easy for + * developers to embed the web in their applications. + * + * Website: <http://www.awesomium.com> + * + * Copyright (C) 2011 Khrona. All rights reserved. Awesomium is a + * trademark of Khrona. + */ + + +#ifndef __AWESOMIUM_CAPI_H__ +#define __AWESOMIUM_CAPI_H__ + +#include <Awesomium/PlatformUtils.h> +#include <stdlib.h> + +#ifdef _WIN32 +#include <windows.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _WIN32 + typedef wchar_t wchar16; +#else + typedef unsigned short wchar16; +#endif + +#if __LP64__ +typedef long int64; +#else +typedef long long int64; +#endif + + +/// WebView instance +typedef struct _awe_webview awe_webview; +/// JSValue instance +typedef struct _awe_jsvalue awe_jsvalue; +/// JSArray instance +typedef struct _awe_jsarray awe_jsarray; +/// JSObject instance +typedef struct _awe_jsobject awe_jsobject; +/// RenderBuffer instance, owned by the WebView +typedef struct _awe_renderbuffer awe_renderbuffer; +/// HeaderDefinition instance +typedef struct _awe_header_definition awe_header_definition; +/// ResourceResponse instance +typedef struct _awe_resource_response awe_resource_response; +/// ResourceRequest instance +typedef struct _awe_resource_request awe_resource_request; +/// UploadElement instance +typedef struct _awe_upload_element awe_upload_element; +/// String instance +typedef struct _awe_string awe_string; +/// HistoryQueryResult instance +typedef struct _awe_history_query_result awe_history_query_result; +/// HistoryEntry instance +typedef struct _awe_history_entry awe_history_entry; + +typedef enum _awe_loglevel +{ + AWE_LL_NONE, + AWE_LL_NORMAL, + AWE_LL_VERBOSE +} awe_loglevel; + +typedef enum _awe_mousebutton +{ + AWE_MB_LEFT, + AWE_MB_MIDDLE, + AWE_MB_RIGHT +} awe_mousebutton; + +typedef enum _awe_url_filtering_mode +{ + AWE_UFM_NONE, + AWE_UFM_BLACKLIST, + AWE_UFM_WHITELIST +} awe_url_filtering_mode; + +typedef enum _awe_webkey_type +{ + AWE_WKT_KEYDOWN, + AWE_WKT_KEYUP, + AWE_WKT_CHAR +} awe_webkey_type; + +typedef enum _awe_webkey_modifiers +{ + /// Whether or not a Shift key is down + AWE_WKM_SHIFT_KEY = 1 << 0, + /// Whether or not a Control key is down + AWE_WKM_CONTROL_KEY = 1 << 1, + /// Whether or not an ALT key is down + AWE_WKM_ALT_KEY = 1 << 2, + /// Whether or not a meta key (Command-key on Mac, Windows-key on Windows) is down + AWE_WKM_META_KEY = 1 << 3, + /// Whether or not the key pressed is on the keypad + AWE_WKM_IS_KEYPAD = 1 << 4, + /// Whether or not the character input is the result of an auto-repeat timer. + AWE_WKM_IS_AUTOREPEAT = 1 << 5, +} awe_webkey_modifiers; + +typedef enum _awe_cursor_type +{ + AWE_CUR_POINTER, + AWE_CUR_CROSS, + AWE_CUR_HAND, + AWE_CUR_IBEAM, + AWE_CUR_WAIT, + AWE_CUR_HELP, + AWE_CUR_EAST_RESIZE, + AWE_CUR_NORTH_RESIZE, + AWE_CUR_NORTHEAST_RESIZE, + AWE_CUR_NORTHWEST_RESIZE, + AWE_CUR_SOUTH_RESIZE, + AWE_CUR_SOUTHEAST_RESIZE, + AWE_CUR_SOUTHWEST_RESIZE, + AWE_CUR_WEST_RESIZE, + AWE_CUR_NORTHSOUTH_RESIZE, + AWE_CUR_EASTWEST_RESIZE, + AWE_CUR_NORTHEAST_SOUTHWEST_RESIZE, + AWE_CUR_NORTHWEST_SOUTHEAST_RESIZE, + AWE_CUR_COLUMN_RESIZE, + AWE_CUR_ROW_RESIZE, + AWE_CUR_MIDDLE_PANNING, + AWE_CUR_EAST_PANNING, + AWE_CUR_NORTH_PANNING, + AWE_CUR_NORTHEAST_PANNING, + AWE_CUR_NORTHWEST_PANNING, + AWE_CUR_SOUTH_PANNING, + AWE_CUR_SOUTHEAST_PANNING, + AWE_CUR_SOUTHWEST_PANNING, + AWE_CUR_WEST_PANNING, + AWE_CUR_MOVE, + AWE_CUR_VERTICAL_TEXT, + AWE_CUR_CELL, + AWE_CUR_CONTEXT_MENU, + AWE_CUR_ALIAS, + AWE_CUR_PROGRESS, + AWE_CUR_NO_DROP, + AWE_CUR_COPY, + AWE_CUR_NONE, + AWE_CUR_NOT_ALLOWED, + AWE_CUR_ZOOM_IN, + AWE_CUR_ZOOM_OUT, + AWE_CUR_CUSTOM +} awe_cursor_type; + +typedef enum _awe_ime_state +{ + AWE_IME_DISABLE = 0, + AWE_IME_MOVE_WINDOW = 1, + AWE_IME_COMPLETE_COMPOSITION = 2 +} awe_ime_state; + +typedef enum _awe_media_type +{ + AWE_MEDIA_TYPE_NONE, + AWE_MEDIA_TYPE_IMAGE, + AWE_MEDIA_TYPE_VIDEO, + AWE_MEDIA_TYPE_AUDIO +} awe_media_type; + +typedef enum _awe_media_state +{ + AWE_MEDIA_STATE_NONE = 0x0, + AWE_MEDIA_STATE_ERROR = 0x1, + AWE_MEDIA_STATE_PAUSED = 0x2, + AWE_MEDIA_STATE_MUTED = 0x4, + AWE_MEDIA_STATE_LOOP = 0x8, + AWE_MEDIA_STATE_CAN_SAVE = 0x10, + AWE_MEDIA_STATE_HAS_AUDIO = 0x20 +}; + +enum _awe_can_edit_flags +{ + AWE_CAN_EDIT_NOTHING = 0x0, + AWE_CAN_UNDO = 0x1, + AWE_CAN_REDO = 0x2, + AWE_CAN_CUT = 0x4, + AWE_CAN_COPY = 0x8, + AWE_CAN_PASTE = 0x10, + AWE_CAN_DELETE = 0x20, + AWE_CAN_SELECT_ALL = 0x40 +}; + +enum _awe_dialog_flags +{ + AWE_DIALOG_HAS_OK_BUTTON = 0x1, + AWE_DIALOG_HAS_CANCEL_BUTTON = 0x2, + AWE_DIALOG_HAS_PROMPT_FIELD = 0x4, + AWE_DIALOG_HAS_MESSAGE = 0x8 +}; + +typedef struct _awe_webkeyboardevent +{ + awe_webkey_type type; + int modifiers; + int virtual_key_code; + int native_key_code; + wchar16 text[4]; + wchar16 unmodified_text[4]; + bool is_system_key; +} awe_webkeyboardevent; + +typedef struct _awe_rect +{ + int x, y, width, height; +} awe_rect; + + +#ifdef _WIN32 +_OSMExport bool awe_is_child_process(HINSTANCE hInstance); + +_OSMExport int awe_child_process_main(HINSTANCE hInstance); +#else +_OSMExport bool awe_is_child_process(int argc, char** argv); + +_OSMExport int awe_child_process_main(int argc, char** argv); +#endif + + +/***************************** + * UTF-16 String Definitions * + *****************************/ + +/** + * Get an instance of an empty string. This is a convenience method to + * quickly pass an empty string to the C API-- you should not destroy + * this string yourself. + */ +_OSMExport const awe_string* awe_string_empty(); + +/** + * Create a string from an ASCII string. You must call awe_string_destroy + * with the returned instance once you're done using it. + * + * @param str An ASCII string to be copied from. + * + * @param len The length of the string + */ +_OSMExport awe_string* awe_string_create_from_ascii(const char* str, + size_t len); + +/** + * Create a string from a Wide string. You must call awe_string_destroy + * with the returned instance once you're done using it. + * + * @param str A Wide string to be copied from. + * + * @param len The length of the string + */ +_OSMExport awe_string* awe_string_create_from_wide(const wchar_t* str, + size_t len); + +/** + * Create a string from a UTF-8 string. You must call awe_string_destroy + * with the returned instance once you're done using it. + * + * @param str A UTF-8 string to be copied from. + * + * @param len The length of the string. + */ +_OSMExport awe_string* awe_string_create_from_utf8(const char* str, + size_t len); + +/** + * Create a string from a UTF-16 string. You must call awe_string_destroy + * with the returned instance once you're done using it. + * + * @param str A UTF-16 string to be copied from. + * + * @param len The length of the string. + */ +_OSMExport awe_string* awe_string_create_from_utf16(const wchar16* str, + size_t len); + +/** + * Destroys a string instance created with one of the above functions. + * + * @param str The instance to destroy. + */ +_OSMExport void awe_string_destroy(awe_string* str); + +/** + * Gets the length of a string. + * + * @param str The string to get the length of. + * + * @return The length of the string. + */ +_OSMExport size_t awe_string_get_length(const awe_string* str); + +/** + * Get a pointer to the actual internal UTF-16 bytes of a string. + * + * @param str The string to get the UTF-16 bytes of. + * + * @return A constant pointer to the UTF-16 buffer of the string. + */ +_OSMExport const wchar16* awe_string_get_utf16(const awe_string* str); + +/** + * Converts a string to a wide string by copying to the destination buffer. + * + * @param str The source string instance + * + * @param dest The destination buffer to copy to. + * + * @param len The size of the destination buffer. + * + * @return Returns the full size of the string-- you can use this for + * pre-allocation purposes: call this method once with a NULL + * destination and 0 length to get the size to allocate your + * destination buffer, and then call it again to actually + * convert the string. + */ +_OSMExport int awe_string_to_wide(const awe_string* str, + wchar_t* dest, + size_t len); + +/** + * Converts a string to a UTF-8 string by copying to the destination buffer. + * + * @param str The source string instance + * + * @param dest The destination buffer to copy to. + * + * @param len The size of the destination buffer. + * + * @return Returns the full size of the string-- you can use this for + * pre-allocation purposes: call this method once with a NULL + * destination and 0 length to get the size to allocate your + * destination buffer, and then call it again to actually + * convert the string. + */ +_OSMExport int awe_string_to_utf8(const awe_string* str, + char* dest, + size_t len); + +/*********************** + * Web Core Functions * + ***********************/ + +/** + * Instantiates the WebCore singleton with a set of configuration + * parameters. + * + * Here are recommendations for the default parameters: + * <pre> + * enable_plugins = false + * enable_javascript = true + * enable_databases = false + * package_path = awe_string_empty() + * locale_path = awe_string_empty() + * user_data_path = awe_string_empty() + * plugin_path = awe_string_empty() + * log_path = awe_string_empty() + * log_level = AWE_LL_NORMAL + * forceSingleProcess = false + * childProcessPath = (empty) + * enable_auto_detect_encoding = true + * accept_language_override = awe_string_empty() + * default_charset_override = awe_string_empty() + * user_agent_override = awe_string_empty() + * proxy_server = awe_string_empty() + * proxy_config_script = awe_string_empty() + * save_cache_and_cookies = true + * max_cache_size = 0 + * disable_same_origin_policy = false + * disable_win_message_pump = false + * custom_css = awe_string_empty() + * </pre> + */ +_OSMExport void awe_webcore_initialize(bool enable_plugins, + bool enable_javascript, + bool enable_databases, + const awe_string* package_path, + const awe_string* locale_path, + const awe_string* user_data_path, + const awe_string* plugin_path, + const awe_string* log_path, + awe_loglevel log_level, + bool force_single_process, + const awe_string* child_process_path, + bool enable_auto_detect_encoding, + const awe_string* accept_language_override, + const awe_string* default_charset_override, + const awe_string* user_agent_override, + const awe_string* proxy_server, + const awe_string* proxy_config_script, + const awe_string* auth_server_whitelist, + bool save_cache_and_cookies, + int max_cache_size, + bool disable_same_origin_policy, + bool disable_win_message_pump, + const awe_string* custom_css); + +/** + * Instantiates the WebCore singleton with the default parameters + * specified in the method above. + */ +_OSMExport void awe_webcore_initialize_default(); + +/** + * Destroys the WebCore singleton and destroys any remaining WebViews. + */ +_OSMExport void awe_webcore_shutdown(); + +/** + * Sets the base directory. + * + * @param base_dir_path The absolute path to your base directory. + * The base directory is a location that holds + * all of your local assets. It will be used + * for WebView::loadFile and WebView::loadHTML + * (to resolve relative URLs). + */ +_OSMExport void awe_webcore_set_base_directory(const awe_string* base_dir_path); + +/** + * Creates a new WebView. + * + * @param width The width of the WebView in pixels. + * @param height The height of the WebView in pixels. + * @param viewSource Enable this to view the HTML source of any web-page + * loaded into this WebView. Default is false. + * + * @return Returns a pointer to the created WebView instance. To call methods + * on the WebView, see awe_webview_load_url() and related functions. + */ +_OSMExport awe_webview* awe_webcore_create_webview(int width, int height, + bool view_source); + +/** + * Sets a custom response page to use when a WebView encounters a + * certain HTML status code from the server (like '404 - File not found'). + * + * @param status_code The status code this response page should be + * associated with. + * See <http://en.wikipedia.org/wiki/List_of_HTTP_status_codes> + * + * @param file_path The local page to load as a response, should be + * a path relative to the base directory. + */ +_OSMExport void awe_webcore_set_custom_response_page(int status_code, + const awe_string* file_path); + +/** + * Updates the WebCore and allows it to conduct various operations such + * as updating the render buffer of each WebView, destroying any + * WebViews that are queued for destruction, and invoking any queued + * callback events. + */ +_OSMExport void awe_webcore_update(); + +/** + * Retrieves the base directory. + * + * @return Returns a string instance representing the current + * base directory. (You do not need to destroy this instance) + */ +_OSMExport const awe_string* awe_webcore_get_base_directory(); + +/** + * Returns whether or not plugins are enabled. + */ +_OSMExport bool awe_webcore_are_plugins_enabled(); + +/** + * Clear the disk cache and media cache. + */ +_OSMExport void awe_webcore_clear_cache(); + +/** + * Clear all cookies. + */ +_OSMExport void awe_webcore_clear_cookies(); + +/** + * Sets a cookie for a certain URL. + * + * @param url The URL to set the cookie on. + * + * @param cookie_string The cookie string, for example: + * <pre> "key1=value1; key2=value2" </pre> + * + * @param is_http_only Whether or not this cookie is HTTP-only. + * + * @param force_session_cookie Whether or not to force this as a + * session cookie. + * + */ +_OSMExport void awe_webcore_set_cookie(const awe_string* url, + const awe_string* cookie_string, + bool is_http_only, + bool force_session_cookie); + +/** + * Gets all cookies for a certain URL. + * + * @param url The URL whose cookies will be retrieved. + * + * @param exclude_http_only Whether or not to exclude HTTP-only + * cookies from the result. + * + * @return Returns the cookie string. (You do not need to destroy this string) + */ +_OSMExport const awe_string* awe_webcore_get_cookies(const awe_string* url, + bool exclude_http_only); + +/** + * Deletes a certain cookie on a certain URL. + * + * @param url The URL that we will be deleting cookies on. + * + * @param cookie_name The name of the cookie that will be deleted. + */ +_OSMExport void awe_webcore_delete_cookie(const awe_string* url, + const awe_string* cookie_name); + + +/** + * Set whether or not the printer dialog should be suppressed or not. + * Set this to "true" to hide printer dialogs and print immediately + * using the OS's default printer when WebView::print is called. + * Default is "false" if you never call this. + * + * @param suppress Whether or not the printer dialog should be + * suppressed. + */ +_OSMExport void awe_webcore_set_suppress_printer_dialog(bool suppress); + +/** + * Query the on-disk history database. + * + * @param full_text_query All results returned should match the + * specified text (either in the page title or + * in the actual text of the page itself). + * Specify an empty string to match anything. + * + * @param num_days_ago Limit results to a specified number of days ago. + * + * @param max_count Limit results to a maximum count. Specify 0 to + * use no limit. + * + * @note You must enable "SaveCacheAndCookies" (see awe_webcore_initialize) for + * this method to work (otherwise no results will be returned). + * + * @return Returns an instance of awe_history_query_result containing the results + * of the query. You must call awe_history_query_result_destroy once + * you are finished using the instance. + */ +_OSMExport awe_history_query_result* awe_webcore_query_history(const awe_string* full_text_query, + int num_days_ago, int max_count); + + +/*********************** + * Web View Functions * + ***********************/ + +/** + * Queue a WebView for destruction by the WebCore. + * + * @param webview The WebView instance. + * + */ +_OSMExport void awe_webview_destroy(awe_webview* webview); + +/** + * Loads a URL into the WebView asynchronously. + * + * @param webview The WebView instance. + * + * @param url The URL to load. + * + * @param frame_name The name of the frame to load the URL + * in; leave this blank to load in the main frame. + * + * @param username If the URL requires authentication, the username + * to authorize as, otherwise just pass an empty string. + * + * @param password If the URL requires authentication, the password + * to use, otherwise just pass an empty string. + */ +_OSMExport void awe_webview_load_url(awe_webview* webview, + const awe_string* url, + const awe_string* frame_name, + const awe_string* username, + const awe_string* password); + +/** + * Loads a string of HTML into the WebView asynchronously. + * + * @param webview The WebView instance. + * + * @param html The HTML string (ASCII) to load. + * + * @param frame_name The name of the frame to load the HTML + * in; leave this blank to load in the main frame. + */ +_OSMExport void awe_webview_load_html(awe_webview* webview, + const awe_string* html, + const awe_string* frame_name); + +/** + * Loads a local file into the WebView asynchronously. + * + * @param webview The WebView instance. + * + * @param file The file to load. + * + * @param frame_name The name of the frame to load the file + * in; leave this blank to load in the main frame. + * + * @note The file should exist within the base directory. + */ +_OSMExport void awe_webview_load_file(awe_webview* webview, + const awe_string* file, + const awe_string* frame_name); + +_OSMExport awe_string* awe_webview_get_url(awe_webview* webview); + +/** + * Navigates back/forward in history via a relative offset. + * + * @param webview The WebView instance. + * + * @param offset The relative offset in history to navigate to. + */ +_OSMExport void awe_webview_go_to_history_offset(awe_webview* webview, + int offset); + +/// Get the number of steps back in history we can go. +_OSMExport int awe_webview_get_history_back_count(awe_webview* webview); + +/// Get the number of steps forward in history we can go. +_OSMExport int awe_webview_get_history_forward_count(awe_webview* webview); + +/** + * Stops the current navigation. + */ +_OSMExport void awe_webview_stop(awe_webview* webview); + +/** + * Reloads the current page. + */ +_OSMExport void awe_webview_reload(awe_webview* webview); + +/** + * Executes a string of Javascript in the context of the current page + * asynchronously. + * + * @param javascript The string of Javascript to execute. + * + * @param frame_name The name of the frame to execute in; + * pass an empty string to execute in the main frame. + */ +_OSMExport void awe_webview_execute_javascript(awe_webview* webview, + const awe_string* javascript, + const awe_string* frame_name); + +/** + * Executes a string of Javascript in the context of the current page + * asynchronously with a result. + * + * @param javascript The string of Javascript to execute. + * + * @param frame_name The name of the frame to execute in; + * pass an empty string to execute in the main frame. + * + * @param timeout_ms The maximum amount of time (in milliseconds) to wait + * for a result. Pass 0 to use no timeout. (If no result + * is obtained, or the timeout is reached, this function + * will return a jsvalue with type "null") + * + * @return Returns an awe_jsvalue instance. You must call awe_jsvalue_destroy + * on this instance when you're done using it. + */ +_OSMExport awe_jsvalue* awe_webview_execute_javascript_with_result( + awe_webview* webview, + const awe_string* javascript, + const awe_string* frame_name, + int timeout_ms); +/** + * Call a certain function defined in Javascript directly. + * + * @param object The name of the object that contains the function, + * pass an empty string if the function is defined in + * the global scope. + * + * @param function The name of the function. + * + * @param args The arguments to pass to the function. + * + * @param frame_name The name of the frame to execute in; + * leave this blank to execute in the main frame. + */ +_OSMExport void awe_webview_call_javascript_function(awe_webview* webview, + const awe_string* object, + const awe_string* function, + const awe_jsarray* arguments, + const awe_string* frame_name); + +/** + * Creates a new global Javascript object that will persist throughout + * the lifetime of this WebView. This object is managed directly by + * Awesomium and so you can modify its properties and bind callback + * functions via awe_webview_set_object_property() and + * awe_webview_set_object_callback(), respectively. + * + * @param objectName The name of the object. + */ +_OSMExport void awe_webview_create_object(awe_webview* webview, + const awe_string* object_name); + +/** + * Destroys a Javascript object previously created by + * awe_webview_create_object + * + * @param object_name The name of the object to destroy. + */ +_OSMExport void awe_webview_destroy_object(awe_webview* webview, + const awe_string* object_name); + +/** + * Sets a property of a Javascript object previously created by + * awe_webview_create_object(). + * + * @param object_name The name of the Javascript object. + * + * @param property_name The name of the property. + * + * @param value The javascript-value of the property. + */ +_OSMExport void awe_webview_set_object_property(awe_webview* webview, + const awe_string* object_name, + const awe_string* property_name, + const awe_jsvalue* value); + +/** + * Sets a callback function of a Javascript object previously created + * by awe_webview_create_object(). This is very useful for passing events + * from Javascript to C. To receive notification of the callback, please + * see awe_webview_set_callback_js_callback(). + * + * @param object_name The name of the Javascript object. + * + * @param callback_name The name of the callback function. + */ +_OSMExport void awe_webview_set_object_callback(awe_webview* webview, + const awe_string* object_name, + const awe_string* callback_name); + +/** + * Returns whether or not a page is currently loading in the WebView. + * + * @return If a page is loading, returns true, otherwise returns false. + */ +_OSMExport bool awe_webview_is_loading_page(awe_webview* webview); + +/** + * Returns whether or not the WebView is dirty and needs to be + * re-rendered via awe_webview_render. + * + * @return If the WebView is dirty, returns true, otherwise returns + * false. + */ +_OSMExport bool awe_webview_is_dirty(awe_webview* webview); + +/** + * Returns the bounds of the area that has changed since the last call + * to awe_webview_render. + * + * @return The bounds of the dirty area. + */ +_OSMExport awe_rect awe_webview_get_dirty_bounds(awe_webview* webview); + +/** + * Renders this WebView into an offscreen render buffer and clears the + * dirty state. + * + * @return A pointer to the internal render buffer instance that was used to + * render this WebView. This value may change between renders and + * may return NULL if the WebView has crashed. + */ +_OSMExport const awe_renderbuffer* awe_webview_render(awe_webview* webview); + +/** + * All rendering is actually done asynchronously in a separate process + * and so the page is usually continuously rendering even if you never + * call awe_webview_render. Call this to temporarily pause rendering. + */ +_OSMExport void awe_webview_pause_rendering(awe_webview* webview); + +/** + * Resume rendering after all call to awe_webview_pause_rendering. + */ +_OSMExport void awe_webview_resume_rendering(awe_webview* webview); + +/** + * Injects a mouse-move event in local coordinates. + * + * @param x The absolute x-coordinate of the mouse (localized to + * the WebView). + * + * @param y The absolute y-coordinate of the mouse (localized to + * the WebView). + */ +_OSMExport void awe_webview_inject_mouse_move(awe_webview* webview, + int x, + int y); + +/** + * Injects a mouse-down event. + * + * @param button The button that was pressed. + */ +_OSMExport void awe_webview_inject_mouse_down(awe_webview* webview, + awe_mousebutton button); + +/** + * Injects a mouse-up event. + * + * @param button The button that was released. + */ +_OSMExport void awe_webview_inject_mouse_up(awe_webview* webview, + awe_mousebutton button); + +/** + * Injects a mouse-wheel event. + * + * @param scrollAmountVert The relative amount of pixels to scroll vertically. + * + * @param scrollAmountHorz The relative amount of pixels to scroll horizontally. + */ +_OSMExport void awe_webview_inject_mouse_wheel(awe_webview* webview, + int scroll_amount_vert, + int scroll_amount_horz); + +/** + * Injects a keyboard event. You'll need to initialize the members of + * awe_webkeyboardevent yourself. + * + * @param keyboardEvent The keyboard event to inject. + */ +_OSMExport void awe_webview_inject_keyboard_event(awe_webview* webview, + awe_webkeyboardevent key_event); + +#ifdef _WIN32 +/** + * Injects a native Windows keyboard event. + * + * @param msg The msg parameter. + * @param wparam The wparam parameter. + * @param lparam The lparam parameter. + */ +_OSMExport void awe_webview_inject_keyboard_event_win(awe_webview* webview, + UINT msg, + WPARAM wparam, + LPARAM lparam); +#endif + +/** + * Invokes a 'cut' action using the system clipboard. + */ +_OSMExport void awe_webview_cut(awe_webview* webview); + +/** + * Invokes a 'copy' action using the system clipboard. + */ +_OSMExport void awe_webview_copy(awe_webview* webview); + +/** + * Invokes a 'paste' action using the system clipboard. + */ +_OSMExport void awe_webview_paste(awe_webview* webview); + +/** + * Selects all items on the current page. + */ +_OSMExport void awe_webview_select_all(awe_webview* webview); + +/// Copies an image on the page to the system clipboard. +_OSMExport void awe_webview_copy_image_at(awe_webview* webview, + int x, + int y); + +/** + * Zooms the page a specified percent. + * + * @param zoom_percent The percent of the page to zoom to. Valid range + * is from 10% to 500%. + */ +_OSMExport void awe_webview_set_zoom(awe_webview* webview, + int zoom_percent); + +/** + * Resets the zoom level. + */ +_OSMExport void awe_webview_reset_zoom(awe_webview* webview); + +/// Gets the current zoom level. +_OSMExport int awe_webview_get_zoom(awe_webview* webview); + +/// Gets the zoom level for a specific hostname. +_OSMExport int awe_webview_get_zoom_for_host(awe_webview* webview, + const awe_string* host); + +/** + * Resizes this WebView to certain dimensions. + * + * @param width The width in pixels to resize to. + * + * @param height The height in pixels to resize to. + * + * @param wait_for_repaint Whether or not to wait for the WebView + * to finish repainting. + * + * @param repaint_timeout_ms The maximum amount of time to wait + * for a repaint, in milliseconds. + * + * @return Returns true if the resize was successful. This operation + * can fail if there is another resize already pending (see + * awe_webview_is_resizing) or if the repaint timeout was exceeded. + */ +_OSMExport bool awe_webview_resize(awe_webview* webview, + int width, + int height, + bool wait_for_repaint, + int repaint_timeout_ms); + +/** +* Checks whether or not there is a resize operation pending. +* +* @return Returns true if we are waiting for the WebView process to +* return acknowledgement of a pending resize operation. +*/ +_OSMExport bool awe_webview_is_resizing(awe_webview* webview); + +/** + * Notifies the current page that it has lost focus. + */ +_OSMExport void awe_webview_unfocus(awe_webview* webview); + +/** + * Notifies the current page that is has gained focus. You will need + * to call this to gain textbox focus, among other things. (If you + * fail to ever see a blinking caret when typing text, this is why). + */ +_OSMExport void awe_webview_focus(awe_webview* webview); + +/** + * Sets whether or not pages should be rendered with transparency + * preserved. (ex, for pages with style="background-color:transparent") + * + * @param is_transparent Whether or not this WebView is transparent. + */ +_OSMExport void awe_webview_set_transparent(awe_webview* webview, + bool is_transparent); + +_OSMExport bool awe_webview_is_transparent(awe_webview* webview); + +/** + * Sets the current URL Filtering Mode (default is AWE_UFM_NONE). + * See awe_url_filtering_mode for more information on the modes. + * + * @param mode The URL filtering mode to use. + */ +_OSMExport void awe_webview_set_url_filtering_mode(awe_webview* webview, + awe_url_filtering_mode mode); + +/** + * Adds a new URL Filter rule. + * + * @param filter A string with optional wildcards that describes a + * certain URL. + * + * @note For example, to match all URLs from the domain + * "google.com", your filter string might be: + * http://google.com/* + * + * @note You may also use the "local://" scheme prefix to + * describe the URL to the base directory (set via + * awe_webcore_set_base_directory). + */ +_OSMExport void awe_webview_add_url_filter(awe_webview* webview, + const awe_string* filter); + +/** + * Clears all URL Filter rules. + */ +_OSMExport void awe_webview_clear_all_url_filters(awe_webview* webview); + +/** + * Defines a new Header Definition or updates it if it already exists. + * + * @param name The unique name of the Header Definition; this is + * used to refer to it later in + * awe_webview_add_header_rewrite_rule and + * related methods. + * + * @param num_fields The number of fields in the header. + * + * @param field_names An array of strings representing the field names + * + * @param field_vales An array of strings representing the field values + */ +_OSMExport void awe_webview_set_header_definition(awe_webview* webview, + const awe_string* name, + size_t num_fields, + const awe_string** field_names, + const awe_string** field_values); + +/** + * Adds a new a header re-write rule. All requests whose URL matches the + * specified rule will have its HTTP headers re-written with the + * specified header definition before sending it to the server. + * + * @param rule A string with optional wildcards (*, ?) that + * matches the URL(s) that will have its headers + * re-written with the specified header definition. + * + * @param name The name of the header definition (specified in + * awe_webview_set_header_definition). + * + * @note The case where a URL is matched by multiple rules is + * unsupported, only the first match will be used. + */ +_OSMExport void awe_webview_add_header_rewrite_rule(awe_webview* webview, + const awe_string* rule, + const awe_string* name); + +/** + * Removes a header re-write rule from this WebView. + * + * @param rule The rule to remove (should match the string + * specified in awe_webview_add_header_rewrite_rule exactly). + */ +_OSMExport void awe_webview_remove_header_rewrite_rule(awe_webview* webview, + const awe_string* rule); + +/** + * Removes all header re-write rules that are using a certain header + * definition. + * + * @param name The name of the header definition (specified in + * awe_webview_set_header_definition). If you specify an + * empty string, this will remove ALL header re-write rules. + */ +_OSMExport void awe_webview_remove_header_rewrite_rules_by_definition_name( + awe_webview* webview, + const awe_string* name); + +/** + * This should be called as a response to the request file chooser callback. + * + * @param file_path The full path to the file that was chosen. + */ +_OSMExport void awe_webview_choose_file(awe_webview* webview, + const awe_string* file_path); + +/** + * Print the current page. To suppress the printer selection dialog and + * print immediately using the operating system's defaults, see + * awe_webcore_set_suppress_printer_dialog. + */ +_OSMExport void awe_webview_print(awe_webview* webview); + +/** + * Request the page dimensions and scroll position of the page. You can + * retrieve the response via the get scroll data callback. + * + * @param frame_name The frame's scroll data to retrieve. Leave blank + * to get the main frame's scroll data. + */ +_OSMExport void awe_webview_request_scroll_data(awe_webview* webview, + const awe_string* frame_name); + +/** + * Start finding a certain string on the current web-page. All matches + * of the string will be highlighted on the page and you can jump + * to different instances of the string by using the 'findNext' + * parameter. To get actual stats about a certain query, please see + * awe_webview_set_callback_get_find_results. + * + * @param request_id A unique numeric ID for each search. You will + * need to generate one yourself for each unique + * search-- please note that you should use the + * same request_id if you wish to iterate through + * all the search results using the 'findNext' + * parameter. + * + * @param search_string The string to search for. + * + * @param forward Whether or not we should search forward, down + * the page. + * + * @param case_sensitive Whether or not this search is case-sensitive. + * + * @param find_next Whether or not we should jump to the next + * instance of a search string (you should use + * the same request_id as a previously-successful + * search). + */ +_OSMExport void awe_webview_find(awe_webview* webview, + int request_id, + const awe_string* search_string, + bool forward, + bool case_sensitive, + bool find_next); + + +/** + * Stop finding. This will un-highlight all matches of a previous + * call to awe_webview_find. + * + * @param clear_selection Whether or not we should also deselect + * the currently-selected string instance. + */ +_OSMExport void awe_webview_stop_find(awe_webview* webview, + bool clear_selection); + +/** + * Attempt automatic translation of the current page via Google + * Translate. All language codes are ISO 639-2. + * + * @param source_language The language to translate from + * (for ex. "en" for English) + * + * @param target_language The language to translate to + * (for ex. "fr" for French) + */ +_OSMExport void awe_webview_translate_page(awe_webview* webview, + const awe_string* source_language, + const awe_string* target_language); + +/** + * Call this method to let the WebView know you will be passing + * text input via IME and will need to be notified of any + * IME-related events (caret position, user unfocusing textbox, etc.) + * Please see awe_webview_set_callback_update_ime + */ +_OSMExport void awe_webview_activate_ime(awe_webview* webview, + bool activate); + +/** + * Update the current IME text composition. + * + * @param inputString The string generated by your IME. + * @param cursorPos The current cursor position in your IME composition. + * @param targetStart The position of the beginning of the selection. + * @param targetEnd The position of the end of the selection. + */ +_OSMExport void awe_webview_set_ime_composition(awe_webview* webview, + const awe_string* input_string, + int cursor_pos, + int target_start, + int target_end); + +/** + * Confirm a current IME text composition. + * + * @param inputString The string generated by your IME. + */ +_OSMExport void awe_webview_confirm_ime_composition(awe_webview* webview, + const awe_string* input_string); + +/** + * Cancel a current IME text composition. + */ +_OSMExport void awe_webview_cancel_ime_composition(awe_webview* webview); + +/** + * Respond to the "request login" callback with some user-supplied + * credentials. + * + * @param request_id The unique ID of the request. + * + * @param username The username supplied by the user. + * + * @param password The password supplied by the user. + */ +_OSMExport void awe_webview_login(awe_webview* webview, + int request_id, + const awe_string* username, + const awe_string* password); + +/** + * Respond to the "request login" callback by telling the + * server that the user cancelled the authentication request. + * + * @param request_id The unique ID of the request. + */ +_OSMExport void awe_webview_cancel_login(awe_webview* webview, + int request_id); + +/** + * Respond to the "show javascript dialog" callback. + * + * @param request_id The unique ID of the dialog request. + * + * @param was_cancelled Whether or not the dialog was cancelled/ignored. + * + * @param prompt_text If the dialog had a prompt, you should pass whatever + * text the user entered into the textbox via this parameter. + */ +_OSMExport void awe_webview_close_javascript_dialog(awe_webview* webview, + int request_id, + bool was_cancelled, + const awe_string* prompt_text); + +/** + * Assign a callback function to be notified when a WebView begins navigation + * to a certain URL. + * + * @param webview The WebView instance. + * + * @param callback A function pointer to the callback. + */ +_OSMExport void awe_webview_set_callback_begin_navigation( + awe_webview* webview, + void (*callback)(awe_webview* caller, + const awe_string* url, + const awe_string* frame_name)); + +/** + * Assign a callback function to be notified when a WebView begins to actually + * receive data from a server. + * + * @param webview The WebView instance. + * + * @param callback A function pointer to the callback. + */ +_OSMExport void awe_webview_set_callback_begin_loading( + awe_webview* webview, + void (*callback)(awe_webview* caller, + const awe_string* url, + const awe_string* frame_name, + int status_code, + const awe_string* mime_type)); + +/** + * Assign a callback function to be notified when a WebView has finished + * all loads. + * + * @param webview The WebView instance. + * + * @param callback A function pointer to the callback. + */ +_OSMExport void awe_webview_set_callback_finish_loading( + awe_webview* webview, + void (*callback)(awe_webview* caller)); + +/** + * Assign a callback function to be notified when a Javascript object callback + * has been invoked on a page. + * + * @param webview The WebView instance. + * + * @param callback A function pointer to the callback. + */ +_OSMExport void awe_webview_set_callback_js_callback( + awe_webview* webview, + void (*callback)(awe_webview* caller, + const awe_string* object_name, + const awe_string* callback_name, + const awe_jsarray* arguments)); + +/** + * Assign a callback function to be notified when a page title is received. + * + * @param webview The WebView instance. + * + * @param callback A function pointer to the callback. + */ +_OSMExport void awe_webview_set_callback_receive_title( + awe_webview* webview, + void (*callback)(awe_webview* caller, + const awe_string* title, + const awe_string* frame_name)); + +/** + * Assign a callback function to be notified when a tooltip has changed state. + * + * @param webview The WebView instance. + * + * @param callback A function pointer to the callback. + */ +_OSMExport void awe_webview_set_callback_change_tooltip( + awe_webview* webview, + void (*callback)(awe_webview* caller, + const awe_string* tooltip)); + +/** + * Assign a callback function to be notified when a cursor has changed state. + * + * @param webview The WebView instance. + * + * @param callback A function pointer to the callback. + */ +_OSMExport void awe_webview_set_callback_change_cursor( + awe_webview* webview, + void (*callback)(awe_webview* caller, + awe_cursor_type cursor)); + +/** + * Assign a callback function to be notified when keyboard focus has changed. + * + * @param webview The WebView instance. + * + * @param callback A function pointer to the callback. + */ +_OSMExport void awe_webview_set_callback_change_keyboard_focus( + awe_webview* webview, + void (*callback)(awe_webview* caller, + bool is_focused)); + +/** + * Assign a callback function to be notified when the target URL has changed. + * This is usually the result of hovering over a link on the page. + * + * @param webview The WebView instance. + * + * @param callback A function pointer to the callback. + */ +_OSMExport void awe_webview_set_callback_change_target_url( + awe_webview* webview, + void (*callback)(awe_webview* caller, + const awe_string* url)); + +/** + * Assign a callback function to be notified when an external link is attempted + * to be opened. An external link is any link that normally opens in a new + * window in a standard browser (for example, links with target="_blank", + * calls to window.open(url), and URL open events from Flash plugins). + * + * @param webview The WebView instance. + * + * @param callback A function pointer to the callback. + */ +_OSMExport void awe_webview_set_callback_open_external_link( + awe_webview* webview, + void (*callback)(awe_webview* caller, + const awe_string* url, + const awe_string* source)); + +/** + * Assign a callback function to be notified when a page requests for a certain + * URL to be downloaded by the user. + * + * @param webview The WebView instance. + * + * @param callback A function pointer to the callback. + */ +_OSMExport void awe_webview_set_callback_request_download( + awe_webview* webview, + void (*callback)(awe_webview* caller, + const awe_string* download)); + +/** + * Assign a callback function to be notified when the renderer for a certain + * WebView (which is isolated in a separate process) crashes unexpectedly. + * + * @param webview The WebView instance. + * + * @param callback A function pointer to the callback. + */ +_OSMExport void awe_webview_set_callback_web_view_crashed( + awe_webview* webview, + void (*callback)(awe_webview* caller)); + +/** + * Assign a callback function to be notified when when the renderer for a + * certain plugin (usually Flash, which is isolated in a separate process) + * crashes unexpectedly. + * + * @param webview The WebView instance. + * + * @param callback A function pointer to the callback. + */ +_OSMExport void awe_webview_set_callback_plugin_crashed( + awe_webview* webview, + void (*callback)(awe_webview* caller, + const awe_string* plugin_name)); + +/** + * Assign a callback function to be notified when the page requests for the + * containing window to be moved to a certain location on the screen. + * + * @param webview The WebView instance. + * + * @param callback A function pointer to the callback. + */ +_OSMExport void awe_webview_set_callback_request_move( + awe_webview* webview, + void (*callback)(awe_webview* caller, + int x, + int y)); + +/** + * Assign a callback function to be notified when the contents of the page has finished + * loading. This occurs at the end of most page loads. + * + * @param webview The WebView instance. + * + * @param callback A function pointer to the callback. + */ +_OSMExport void awe_webview_set_callback_get_page_contents( + awe_webview* webview, + void (*callback)(awe_webview* caller, + const awe_string* url, + const awe_string* contents)); + +/** + * Assign a callback function to be notified once the DOM (Document Object + * Model) for a page is ready. This is very useful for executing Javascript + * on a page before its content has finished loading. + * + * @param webview The WebView instance. + * + * @param callback A function pointer to the callback. + */ +_OSMExport void awe_webview_set_callback_dom_ready( + awe_webview* webview, + void (*callback)(awe_webview* caller)); + +/** + * Assign a callback function to be notified whenever a page requests a file + * chooser dialog to be displayed (usually the result of an "input" element + * with type "file" being clicked by a user). You will need to display your + * own dialog (it does not have to be modal, this request does not block). + * Once a file has been chosen by the user, awe_webview_choose_file or + * awe_webview_choose_multiple_files should be called. + * + * @param webview The WebView instance. + * + * @param callback A function pointer to the callback. + */ +_OSMExport void awe_webview_set_callback_request_file_chooser( + awe_webview* webview, + void (*callback)(awe_webview* caller, + bool select_multiple_files, + const awe_string* title, + const awe_string* default_path)); + +/** + * Assign a callback function to be notified of a response to + * awe_webview_request_scroll_data. + * + * @param webview The WebView instance. + * + * @param callback A function pointer to the callback. + */ +_OSMExport void awe_webview_set_callback_get_scroll_data( + awe_webview* webview, + void (*callback)(awe_webview* caller, + int contentWidth, + int contentHeight, + int preferredWidth, + int scrollX, + int scrollY)); + +/** + * Assign a callback function to be notified of any Javascript + * console messages. (Usually Javascript errors encountered in scripts) + * + * @param webview The WebView instance + * + * @param callback A function pointer to the callback. + */ +_OSMExport void awe_webview_set_callback_js_console_message( + awe_webview* webview, + void (*callback)(awe_webview* caller, + const awe_string* message, + int line_number, + const awe_string* source)); + +/** + * Assign a callback function to be notified whenever we receive + * results back from an in-page find operation (awe_webview_find). + * + * @param webview The WebView instance + * + * @param callback A function pointer to the callback. + */ +_OSMExport void awe_webview_set_callback_get_find_results( + awe_webview* webview, + void (*callback)(awe_webview* caller, + int request_id, + int num_matches, + awe_rect selection, + int cur_match, + bool finalUpdate)); + +/** + * Assign a callback function to be notified whenever the user does + * something that may change the position or visiblity of the IME Widget. + * This callback is only active when IME is activated (please + * see awe_webview_activate_ime). + * + * @param webview The WebView instance + * + * @param callback A function pointer to the callback. + */ +_OSMExport void awe_webview_set_callback_update_ime( + awe_webview* webview, + void (*callback)(awe_webview* caller, + awe_ime_state state, + awe_rect caret_rect)); + +/** + * Assign a callback function to be notified whenever the page requests + * a context menu to be shown (usually the result of a user right-clicking + * somewhere on the page). It is your responsiblity to display a menu for + * the user to select an appropriate action. + * + * @param webview The WebView instance + * + * @param callback A function pointer to the callback. + */ +_OSMExport void awe_webview_set_callback_show_context_menu( + awe_webview* webview, + void (*callback)(awe_webview* caller, + int mouse_x, + int mouse_y, + awe_media_type type, + int media_state, + const awe_string* link_url, + const awe_string* src_url, + const awe_string* page_url, + const awe_string* frame_url, + const awe_string* selection_text, + bool is_editable, + int edit_flags)); + +/** + * Assign a callback function to be notified whenever a page requests + * authentication from the user (ex, Basic HTTP Auth, NTLM Auth, etc.). + * See awe_webview_login and awe_webview_cancel_login + * + * @param webview The WebView instance + * + * @param callback A function pointer to the callback. + */ +_OSMExport void awe_webview_set_callback_request_login( + awe_webview* webview, + void (*callback)(awe_webview* caller, + int request_id, + const awe_string* request_url, + bool is_proxy, + const awe_string* host_and_port, + const awe_string* scheme, + const awe_string* realm)); + +/** + * Assign a callback function to be notified whenever the history state + * has changed. (eg, the state of thie back/forward buttons should be + * updated) + * + * @param webview The WebView instance + * + * @param callback A function pointer to the callback. + */ +_OSMExport void awe_webview_set_callback_change_history( + awe_webview* webview, + void (*callback)(awe_webview* caller, + int back_count, + int forward_count)); + +/** + * Assign a callback function to be notified whenever a WebView has + * finished resizing to a certain size (and has finished repainting + * the RenderBuffer). + * + * @param webview The WebView instance + * + * @param callback A function pointer to the callback. + */ +_OSMExport void awe_webview_set_callback_finish_resize( + awe_webview* webview, + void (*callback)(awe_webview* caller, + int width, + int height)); + +/** + * Assign a callback function to be notified whenever a WebView + * requests that a certain Javascript dialog be shown (eg, alert, + * confirm, prompt). See awe_webview_close_javascript_dialog for + * more information. + * + * @param webview The WebView instance + * + * @param callback A function pointer to the callback. + */ +_OSMExport void awe_webview_set_callback_show_javascript_dialog( + awe_webview* webview, + void (*callback)(awe_webview* caller, + int request_id, + int dialog_flags, + const awe_string* message, + const awe_string* default_prompt, + const awe_string* frame_url)); + +/*********************** + * JS Value Functions * + ***********************/ + +typedef enum _awe_jsvalue_type +{ + JSVALUE_TYPE_NULL, + JSVALUE_TYPE_BOOLEAN, + JSVALUE_TYPE_INTEGER, + JSVALUE_TYPE_DOUBLE, + JSVALUE_TYPE_STRING, + JSVALUE_TYPE_OBJECT, + JSVALUE_TYPE_ARRAY +} awe_jsvalue_type; + +/** + * Create a JSValue instance initialized as a null type. You must call + * awe_jsvalue_destroy with the returned instance once you're done using it. + */ +_OSMExport awe_jsvalue* awe_jsvalue_create_null_value(); + +/** + * Create a JSValue instance initialized with a boolean type. You must call + * awe_jsvalue_destroy with the returned instance once you're done using it. + * + * @param value The initial value + */ +_OSMExport awe_jsvalue* awe_jsvalue_create_bool_value(bool value); + +/** + * Create a JSValue instance initialized with an integer type. You must call + * awe_jsvalue_destroy with the returned instance once you're done using it. + * + * @param value The initial value + */ +_OSMExport awe_jsvalue* awe_jsvalue_create_integer_value(int value); + +/** + * Create a JSValue instance initialized with a double type. You must call + * awe_jsvalue_destroy with the returned instance once you're done using it. + * + * @param value The initial value + */ +_OSMExport awe_jsvalue* awe_jsvalue_create_double_value(double value); + +/** + * Create a JSValue instance initialized with a string type. You must call + * awe_jsvalue_destroy with the returned instance once you're done using it. + * + * @param value The initial value + */ +_OSMExport awe_jsvalue* awe_jsvalue_create_string_value(const awe_string* value); + +/** + * Create a JSValue instance initialized with an object type. You must call + * awe_jsvalue_destroy with the returned instance once you're done using it. + * + * @param value The initial value + */ +_OSMExport awe_jsvalue* awe_jsvalue_create_object_value(const awe_jsobject* value); + +/** + * Create a JSValue instance initialized with an array type. You must call + * awe_jsvalue_destroy with the returned instance once you're done using it. + * + * @param value The initial value + */ +_OSMExport awe_jsvalue* awe_jsvalue_create_array_value(const awe_jsarray* value); + +/** + * Destroys a JSValue instance. + * + * @param jsvalue The JSValue instance. + */ +_OSMExport void awe_jsvalue_destroy(awe_jsvalue* jsvalue); + +/** + * Get the type of a JSValue. + * + * @param jsvalue The JSValue instance. + * + * @return Returns the type of the JSValue (see enum awe_jsvalue_type) + */ +_OSMExport awe_jsvalue_type awe_jsvalue_get_type(const awe_jsvalue* jsvalue); + +/** + * Get the value as a string. + * + * @param jsvalue The JSValue instance. + * + * @return Returns a string instance. You'll need to call awe_string_destroy + * with this instance when you're done using it. + */ +_OSMExport awe_string* awe_jsvalue_to_string(const awe_jsvalue* jsvalue); + +/// Returns this value as an integer. +_OSMExport int awe_jsvalue_to_integer(const awe_jsvalue* jsvalue); + +/// Returns this value as an double. +_OSMExport double awe_jsvalue_to_double(const awe_jsvalue* jsvalue); + +/// Returns this value as an boolean. +_OSMExport bool awe_jsvalue_to_boolean(const awe_jsvalue* jsvalue); + +/// Returns this value as an array. Will throw an exception if not an array. +_OSMExport const awe_jsarray* awe_jsvalue_get_array(const awe_jsvalue* jsvalue); + +/// Returns this value as an object. Will throw an exception if not an object. +_OSMExport const awe_jsobject* awe_jsvalue_get_object(const awe_jsvalue* jsvalue); + +/**************************** + * JS Value Array Functions * + ****************************/ + +/** + * Create a JSValue Array. + * + * @param jsvalue_array An array of JSValue instances to be copied from. + * @param length Length of the array. + */ +_OSMExport awe_jsarray* awe_jsarray_create(const awe_jsvalue** jsvalue_array, + size_t length); + +/** + * Destroys a JSValue Array created with awe_jsarray_create. + */ +_OSMExport void awe_jsarray_destroy(awe_jsarray* jsarray); + +/** + * Get the size of a JSValue Array. + */ +_OSMExport size_t awe_jsarray_get_size(const awe_jsarray* jsarray); + +/** + * Get a specific element of a JSValue Array. The Array retains ownership + * of the returned JSValue instance (you do not need to destroy it). + */ +_OSMExport const awe_jsvalue* awe_jsarray_get_element(const awe_jsarray* jsarray, + size_t index); + +/***************************** + * JS Value Object Functions * + *****************************/ + +/** + * Creates a JSValue Object. + */ +_OSMExport awe_jsobject* awe_jsobject_create(); + +/** + * Destroys a JSValue Object created with awe_jsobject_create + */ +_OSMExport void awe_jsobject_destroy(awe_jsobject* jsobject); + +/** + * Returns whether or not a JSValue Object has a certained named property. + */ +_OSMExport bool awe_jsobject_has_property(const awe_jsobject* jsobject, + const awe_string* property_name); + +/** + * Gets the value of a certain named property of a JSValue Object. You do not + * need to destroy the returned jsvalue instance, it is owned by the object. + */ +_OSMExport const awe_jsvalue* awe_jsobject_get_property(const awe_jsobject* jsobject, + const awe_string* property_name); + +/** + * Sets the value of a certained named property of a JSValue Object. + */ +_OSMExport void awe_jsobject_set_property(awe_jsobject* jsobject, + const awe_string* property_name, + const awe_jsvalue* value); + +/** + * Get the number of key/value pairs in a JSValue object. + */ +_OSMExport size_t awe_jsobject_get_size(awe_jsobject* jsobject); + +/** + * Get a list of all key names as a JSValue Array, you need to call + * awe_jsarray_destroy on the returned value after you're done using it. + */ +_OSMExport awe_jsarray* awe_jsobject_get_keys(awe_jsobject* jsobject); + +/*************************** + * Render Buffer Functions * + ***************************/ + +/** + * Get the width (in pixels) of a RenderBuffer. + */ +_OSMExport int awe_renderbuffer_get_width(const awe_renderbuffer* renderbuffer); + +/** + * Get the height (in pixels) of a RenderBuffer. + */ +_OSMExport int awe_renderbuffer_get_height(const awe_renderbuffer* renderbuffer); + +/** + * Get the rowspan (number of bytes per row) of a RenderBuffer. + */ +_OSMExport int awe_renderbuffer_get_rowspan(const awe_renderbuffer* renderbuffer); + +/** + * Get a pointer to the actual pixel buffer within a RenderBuffer. + */ +_OSMExport const unsigned char* awe_renderbuffer_get_buffer( + const awe_renderbuffer* renderbuffer); + +/** + * Copy a RenderBuffer to a specific destination with the same dimensions. + */ +_OSMExport void awe_renderbuffer_copy_to(const awe_renderbuffer* renderbuffer, + unsigned char* dest_buffer, + int dest_rowspan, + int dest_depth, + bool convert_to_rgba, + bool flip_y); + +/** + * Copy a RenderBuffer to a pixel buffer with a floating-point pixel format + * for use with game engines like Unity3D. + */ +_OSMExport void awe_renderbuffer_copy_to_float(const awe_renderbuffer* renderbuffer, + float* dest_buffer); + +/** + * Save a copy of this RenderBuffer to a PNG image file. + */ +_OSMExport bool awe_renderbuffer_save_to_png(const awe_renderbuffer* renderbuffer, + const awe_string* file_path, + bool preserve_transparency); + +/** + * Save a copy of this RenderBuffer to a JPEG image file with quality 1 to 100. + */ +_OSMExport bool awe_renderbuffer_save_to_jpeg(const awe_renderbuffer* renderbuffer, + const awe_string* file_path, + int quality); + +/** + * Get the alpha value at a certain point (origin is top-left). This is + * useful for alpha-picking. + * + * @param x The x-value of the point. + * @param y The y-value of the point. + * + * @return Returns the alpha value at a certain point (255 is comppletely + * opaque, 0 is completely transparent). + */ +_OSMExport unsigned char awe_renderbuffer_get_alpha_at_point(const awe_renderbuffer* renderbuffer, + int x, + int y); + +/** + * Sets the alpha channel to completely opaque values. + */ +_OSMExport void awe_renderbuffer_flush_alpha(const awe_renderbuffer* renderbuffer); + +/************************ + * Resource Interceptor * + ************************/ + +/** + * Assign a callback function to intercept requests for resources. You can use + * this to modify requests before they are sent, respond to requests using + * your own custom resource-loading back-end, or to monitor requests for + * tracking purposes. + * + * @param webview The WebView instance. + * + * @param callback A function pointer to the callback. + */ +_OSMExport void awe_webview_set_callback_resource_request( + awe_webview* webview, + awe_resource_response* (*callback)( + awe_webview* caller, + awe_resource_request* request)); + +/** + * Assign a callback function to intercept responses to requests. You can use + * this for tracking/statistic purposes. + */ +_OSMExport void awe_webview_set_callback_resource_response( + awe_webview* webview, + void (*callback)( + awe_webview* caller, + const awe_string* url, + int status_code, + bool was_cached, + int64 request_time_ms, + int64 response_time_ms, + int64 expected_content_size, + const awe_string* mime_type)); + +/** + * Create a ResourceResponse from a raw block of data. (Buffer is copied) + */ +_OSMExport awe_resource_response* awe_resource_response_create( + size_t num_bytes, + unsigned char* buffer, + const awe_string* mime_type); + +/** + * Create a ResourceResponse from a file on disk. + */ +_OSMExport awe_resource_response* awe_resource_response_create_from_file( + const awe_string* file_path); + +/************************ + * Resource Request * + ************************/ + +/// Cancel the request (this is useful for blocking a resource load). +_OSMExport void awe_resource_request_cancel(awe_resource_request* request); + +/// Get the URL associated with this request. (You must destroy returned string) +_OSMExport awe_string* awe_resource_request_get_url(awe_resource_request* request); + +/// Get the HTTP method (usually "GET" or "POST") (You must destroy returned string) +_OSMExport awe_string* awe_resource_request_get_method(awe_resource_request* request); + +/// Set the HTTP method +_OSMExport void awe_resource_request_set_method(awe_resource_request* request, + const awe_string* method); + +/// Get the referrer (You must destroy returned string) +_OSMExport awe_string* awe_resource_request_get_referrer(awe_resource_request* request); + +/// Set the referrer +_OSMExport void awe_resource_request_set_referrer(awe_resource_request* request, + const awe_string* referrer); + +/// Get extra headers for the request (You must destroy returned string) +_OSMExport awe_string* awe_resource_request_get_extra_headers(awe_resource_request* request); + +/** + * Override extra headers for the request, delimited by /r/n (CRLF). + * + * Format should be: + * Name: Value/r/nName: Value/r/nName: Value + * + * Headers should NOT end in /r/n (CRLF) + */ +_OSMExport void awe_resource_request_set_extra_headers(awe_resource_request* request, + const awe_string* headers); + +/** + * Append an extra header to the request. + * + * @param name Name of the header + * @param value Value of the header + */ +_OSMExport void awe_resource_request_append_extra_header(awe_resource_request* request, + const awe_string* name, + const awe_string* value); + +/// Get the number of upload elements (essentially, batches of POST data). +_OSMExport size_t awe_resource_request_get_num_upload_elements(awe_resource_request* request); + +/// Get a certain upload element (returned instance is owned by this class) +_OSMExport const awe_upload_element* awe_resource_request_get_upload_element(awe_resource_request* request, + size_t idx); + +/// Clear all upload elements +_OSMExport void awe_resource_request_clear_upload_elements(awe_resource_request* request); + +/// Append a file for POST data (adds a new UploadElement) +_OSMExport void awe_resource_request_append_upload_file_path(awe_resource_request* request, + const awe_string* file_path); + +/// Append a string of bytes for POST data (adds a new UploadElement) +_OSMExport void awe_resource_request_append_upload_bytes(awe_resource_request* request, + const awe_string* bytes); + +/************************ + * Upload Element * + ************************/ + +/// Whether or not this UploadElement is a file +_OSMExport bool awe_upload_element_is_file_path(const awe_upload_element* ele); + +/// Whether or not this UploadElement is a string of bytes +_OSMExport bool awe_upload_element_is_bytes(const awe_upload_element* ele); + +/// Get the string of bytes associated with this UploadElement (You must destroy returned string) +_OSMExport awe_string* awe_upload_element_get_bytes(const awe_upload_element* ele); + +/// Get the file path associated with this UploadElement (You must destroy returned string) +_OSMExport awe_string* awe_upload_element_get_file_path(const awe_upload_element* ele); + + +/************************ + * History Query Result * + ************************/ + +/// Destroy the instance (you must call this once you're done using the instance) +_OSMExport void awe_history_query_result_destroy(awe_history_query_result* res); + +/// Get the total number of entries +_OSMExport size_t awe_history_query_result_get_size(awe_history_query_result* res); + +/// Get a certain entry (you must destroy any returned entry using awe_history_entry_destroy). +/// May return NULL if the index is out of bounds. +_OSMExport awe_history_entry* awe_history_query_result_get_entry_at_index(awe_history_query_result* res, + size_t idx); + +/************************ + * History Entry * + ************************/ + +/// Destroy the instance +_OSMExport void awe_history_entry_destroy(awe_history_entry* entry); + +/// Get the URL of the page +_OSMExport awe_string* awe_history_entry_get_url(awe_history_entry* entry); + +/// Get the title of the page +_OSMExport awe_string* awe_history_entry_get_title(awe_history_entry* entry); + +/// Get the last time this page was visited (in seconds since epoch) +_OSMExport double awe_history_entry_get_visit_time(awe_history_entry* entry); + +/// Get the number of times this page was visited. +_OSMExport int awe_history_entry_get_visit_count(awe_history_entry* entry); + + +#ifdef __cplusplus +} +#endif + +/** + * @mainpage Awesomium C API + * + * @section intro_sec Introduction + * + * Hi there, welcome to the Awesomium C API docs! Awesomium is a software + * library that makes it easy to put the web in your applications. Whether + * that means embedded web browsing, rendering pages as images, streaming + * pages over the net, or manipulating web content live for some other + * purpose, Awesomium does it all. + * + * Our C API provides much more compatibility than our C++ API at the cost + * of some extra convenience. + * + * To start off, we'd recommend looking at some of the following functions: + * <pre> + * awe_webcore_initialize() + * awe_webcore_initialize_default() + * awe_webcore_shutdown() + * awe_webcore_create_webview() + * awe_webview_load_url() + * awe_webview_render() + * awe_webview_destroy() + * </pre> + * + * To avoid memory leaks, there is one major rule that you must follow in + * our C API regarding ownership of returned objects: if a function returns + * a regular pointer to an instance, you must destroy the instance using the + * relevant method. Otherwise, if a function returns a const pointer to an + * instance, you should not destroy it (ownership is retained by Awesomium). + * + * For example, you must destroy all strings you create in Awesomium: + * + * <pre> + * awe_string* str = awe_string_create_from_ascii("Hello", strlen("Hello")); + * + * // Use the string somewhere... then destroy it when we are done: + * + * awe_string_destroy(str); + * </pre> + * + * But you should not destroy certain strings returned from certain methods: + * + * <pre> + * const awe_string* str = awe_webcore_get_base_directory(); + * + * // We do not need to destroy this string: when a function returns + * // a const pointer in Awesomium, it means ownership is retained by + * // Awesomium and the instance will be destroyed automatically later. + * </pre> + * + * For more help and tips with the API, please visit our Knowledge Base + * <http://support.awesomium.com/faqs> + * + * @section usefullinks_sec Useful Links + * - Awesomium Main: <http://www.awesomium.com> + * - Support Home: <http://support.awesomium.com> + * + * @section copyright_sec Copyright + * This documentation is copyright (C) 2011 Khrona. All rights reserved. + * Awesomium is a trademark of Khrona. + */ + +#endif
+ include/keyb.h view
@@ -0,0 +1,10 @@+#ifndef KEYB_H+#define KEYB_H+#define bool uint+#include <stdlib.h>+#include "awesomium_capi.h"++void awe_webview_get_dirty_bounds_wrapper(awe_webview*, awe_rect*);+void awe_webview_inject_keyboard_event_wrapper(awe_webview*, awe_webkeyboardevent*);++#endif
+ src/Graphics/UI/Awesomium/Raw.chs view
@@ -0,0 +1,569 @@+---------------------------------------------------------------------- +-- | +-- Module : Graphics.UI.Awesomium.Raw +-- Copyright : (c) 2012 Maksymilian Owsianny +-- License : LGPL-3 (see the file LICENSE) +-- +-- Maintainer : Maksymilian.Owsianny+AwesomiumRaw@gmail.com +-- Stability : Experimental +-- Portability : Portable? (needs FFI) +-- +-- This module contains raw bindings to Awesomium +-- (<http://awesomium.com>). For more user friendly, high-level +-- bindings see here (<http://hackage.haskell.org/package/awesomium>). +-- Also, if you plan to integrate Awesomium with GLUT you can +-- check out this package +-- (<http://hackage.haskell.org/package/awesomium-glut>). +---------------------------------------------------------------------- + +{-# LANGUAGE ForeignFunctionInterface, EmptyDataDecls #-} +module Graphics.UI.Awesomium.Raw where + +import Data.Char (chr, ord) +import Foreign.C.Types +import Foreign.C.String +import Foreign.Marshal +import Foreign.Ptr +import Foreign.Storable +import Control.Monad ((<=<)) +import Control.Applicative +import Control.Exception (bracket) + +---------------------------------------------------------------------- +-- Some marshalling functions originaly from C2HS + +-- Strings with explicit length +withCStringLenIntConv :: Num n => String -> ((CString, n) -> IO a) -> IO a +withCStringLenIntConv s f = withCStringLen s $ \(p, n) -> f (p, fromIntegral n) + +-- Integral conversion +cIntConv :: (Integral a, Integral b) => a -> b +cIntConv = fromIntegral + +-- Convert a C enumeration to Haskell. +cToEnum :: (Integral i, Enum e) => i -> e +cToEnum = toEnum . fromIntegral + +-- Convert a Haskell enumeration to C. +cFromEnum :: (Enum e, Integral i) => e -> i +cFromEnum = fromIntegral . fromEnum + +---------------------------------------------------------------------- + +{#context prefix = "awe"#} +#include "keyb.h" + +type WChar16 = {#type wchar16#} +type Int64 = {#type int64#} + +-- WebView instance +data DWebView +{#pointer *webview as WebView -> DWebView #} +-- JSValue instance +data DJSValue +{#pointer *jsvalue as JSValue -> DJSValue #} +-- JSArray instance +data DJSArray +{#pointer *jsarray as JSArray -> DJSArray #} +-- JSObject instance +data DJSObject +{#pointer *jsobject as JSObject -> DJSObject #} +-- RenderBuffer instance, owned by the WebView +data DRenderBuffer +{#pointer *renderbuffer as RenderBuffer -> DRenderBuffer #} +-- HeaderDefinition instance +data DHeaderDefinition +{#pointer *header_definition as HeaderDefinition -> DHeaderDefinition #} +-- ResourceResponse instance +data DResourceResponse +{#pointer *resource_response as ResourceResponse -> DResourceResponse #} +-- ResourceRequest instance +data DResourceRequest +{#pointer *resource_request as ResourceRequest -> DResourceRequest #} +-- UploadElement instance +data DUploadElement +{#pointer *upload_element as UploadElement -> DUploadElement #} +-- String instance +data DAweString +{#pointer *awe_string as AweString -> DAweString #} +-- HistoryQueryResult instance +data DHistoryQueryResult +{#pointer *history_query_result as HistoryQueryResult -> DHistoryQueryResult #} +-- HistoryEntry instance +data DHistoryEntry +{#pointer *history_entry as HistoryEntry -> DHistoryEntry #} + +{#enum loglevel as LogLevel {underscoreToCase} with prefix = "AWE_LL_" deriving (Show, Read, Eq)#} +{#enum mousebutton as MouseButton {underscoreToCase}#} +{#enum url_filtering_mode as UrlFilteringMode {underscoreToCase}#} +{#enum webkey_type as WebkeyType {underscoreToCase}#} +{#enum webkey_modifiers as WebkeyModifiers {underscoreToCase}#} +{#enum cursor_type as CursorType {underscoreToCase}#} +{#enum ime_state as ImeState {underscoreToCase}#} +{#enum media_type as MediaType {underscoreToCase}#} +{#enum _awe_media_state as MediaState {underscoreToCase} with prefix = "AWE_" #} +{#enum _awe_can_edit_flags as CanEditFlags {underscoreToCase} with prefix = "AWE_" #} +{#enum _awe_dialog_flags as DialogFlags {underscoreToCase} with prefix = "AWE_" #} + +{- +These are flags, remember! + * WebkeyModifiers + * MediaState + * CanEditFlags + * DialogFlags +-} + +data WebkeyboardEvent = WebkeyboardEvent + { wkeType :: WebkeyType + , wkeModifiers :: Int + , wkeVirtualKeyCode :: Int + , wkeNativeKeyCode :: Int + , wkeText :: Char + , wkeUnmodifiedText :: Char + , wkeIsSystemKey :: Bool } + +instance Storable WebkeyboardEvent where + alignment _ = {#alignof awe_webkeyboardevent#} + sizeOf _ = {#sizeof awe_webkeyboardevent#} + peek p = + let {fromWkeText = return . chr . fromIntegral . head <=< peekArray 4} in + WebkeyboardEvent + <$> fmap cToEnum ({#get awe_webkeyboardevent.type #} p) + <*> fmap fromIntegral ({#get awe_webkeyboardevent.modifiers #} p) + <*> fmap fromIntegral ({#get awe_webkeyboardevent.virtual_key_code #} p) + <*> fmap fromIntegral ({#get awe_webkeyboardevent.native_key_code #} p) + <*> (fromWkeText =<< ({#get awe_webkeyboardevent.text #} p)) + <*> (fromWkeText =<< ({#get awe_webkeyboardevent.unmodified_text #} p)) + <*> fmap toBool ({#get awe_webkeyboardevent.is_system_key #} p) + poke p r = do + ({#set awe_webkeyboardevent.type #}) p (cFromEnum $ wkeType r) + ({#set awe_webkeyboardevent.modifiers #}) p (fromIntegral $ wkeModifiers r) + ({#set awe_webkeyboardevent.virtual_key_code #}) p (fromIntegral $ wkeVirtualKeyCode r) + ({#set awe_webkeyboardevent.native_key_code #}) p (fromIntegral $ wkeNativeKeyCode r) + +{- It would be nice if c2hs supported the offsetof hook as + proposed here: http://hackage.haskell.org/trac/c2hs/ticket/22 + then I could simply write this as: + + pokeArray (plusPtr p {#offsetof awe_webkeyboardevent.text #}) $ toWkeText (wkeText r) + pokeArray (plusPtr p {#offsetof awe_webkeyboardevent.unmodified_text#}) $ toWkeText (wkeUnmodifiedText r) + +-} + pokeArray (plusPtr p (4*{#alignof awe_webkeyboardevent#} + 0)) $ toWkeText (wkeText r) + pokeArray (plusPtr p (4*{#alignof awe_webkeyboardevent#} + 8)) $ toWkeText (wkeUnmodifiedText r) + + ({#set awe_webkeyboardevent.is_system_key #}) p (fromBool $ wkeIsSystemKey r) + where + toWkeText :: Char -> [WChar16] + toWkeText l = [cFromEnum l, 0, 0, 0] + +data Rect = Rect + { rectX :: Int + , rectY :: Int + , rectWidth :: Int + , rectHeight :: Int } + deriving (Eq, Show) + +instance Storable Rect where + alignment _ = {#alignof awe_rect#} + sizeOf _ = {#sizeof awe_rect#} + peek p = let f = fmap fromIntegral in Rect + <$> f ({#get awe_rect.x #} p) + <*> f ({#get awe_rect.y #} p) + <*> f ({#get awe_rect.width #} p) + <*> f ({#get awe_rect.height #} p) + poke p r = do + ({#set awe_rect.x #}) p (fromIntegral $ rectX r) + ({#set awe_rect.y #}) p (fromIntegral $ rectY r) + ({#set awe_rect.width #}) p (fromIntegral $ rectWidth r) + ({#set awe_rect.height #}) p (fromIntegral $ rectHeight r) + +{- +#ifdef _WIN32 +{#fun awe_is_child_process { HINSTANCE hInstance } -> `Bool' #} +{#fun awe_child_process_main { HINSTANCE hInstance } -> `Int' #} +#else +{#fun awe_is_child_process { `Int', char** argv } -> `Bool' #} +{#fun awe_child_process_main { `Int', char** argv } -> `Int' #} +#endif +-} + +{----------------------- + - AweString Functions - + -----------------------} + +{#fun awe_string_empty { } -> `AweString' id #} +-- {#fun awe_string_create_orom_ascii { `String'& } -> `AweString' id #} +-- {#fun awe_string_create_from_wide { `String'& } -> `AweString' id #} +{#fun awe_string_create_from_utf8 { `String'& } -> `AweString' id #} +-- {#fun awe_string_create_from_utf16 { `String'& } -> `AweString' id #} +{#fun awe_string_destroy { id `AweString' } -> `()' #} +{#fun awe_string_get_length { id `AweString' } -> `Int' fromIntegral #} +-- {#fun awe_string_get_utf16 { id `AweString' } -> `String' #} +-- {#fun awe_string_to_wide { id `AweString' , `String'& } -> `Int' #} + +foreign import ccall "Graphics/UI/Awesomium/Raw.chs.h awe_string_to_utf8" + awe_string_to_utf8'_ :: AweString -> Ptr CChar -> CULong -> IO CInt + +awe_string_to_utf8 :: AweString -> IO (String) +awe_string_to_utf8 a1 = do + len <- awe_string_get_length a1 + allocaBytes len $ \buf -> do + awe_string_to_utf8'_ a1 buf (cIntConv len) + peekCStringLen (buf, (cIntConv len)) + +-- | Use with c functions that return const awe_string* +fromAweString :: AweString -> IO (String) +fromAweString = awe_string_to_utf8 + +-- | Use with c functions that return awe_string* that should be destroyed afterwards. +fromAweStringDestroy :: AweString -> IO (String) +fromAweStringDestroy as = do + res <- awe_string_to_utf8 as + awe_string_destroy as + return res + +withAweString :: String -> (AweString -> IO b) -> IO b +withAweString str = + bracket (awe_string_create_from_utf8 str) awe_string_destroy + +{----------------------- + - Web Core Functions - + -----------------------} + +{#fun awe_webcore_initialize { `Bool', `Bool', `Bool', withAweString* `String', withAweString* `String', withAweString* `String', withAweString* `String', withAweString* `String', cFromEnum `LogLevel', `Bool', withAweString* `String', `Bool', withAweString* `String', withAweString* `String', withAweString* `String', withAweString* `String', withAweString* `String', withAweString* `String', `Bool', `Int', `Bool', `Bool', withAweString* `String' } -> `()' #} +{#fun awe_webcore_initialize_default { } -> `()' #} +{#fun awe_webcore_shutdown { } -> `()' #} +{#fun awe_webcore_set_base_directory { withAweString* `String' } -> `()' #} +{#fun awe_webcore_create_webview { `Int', `Int', `Bool' } -> `WebView' id #} +{#fun awe_webcore_set_custom_response_page { `Int', withAweString* `String' } -> `()' #} +{#fun awe_webcore_update { } -> `()' #} +{#fun awe_webcore_get_base_directory { } -> `String' fromAweString* #} +{#fun awe_webcore_are_plugins_enabled { } -> `Bool' #} +{#fun awe_webcore_clear_cache { } -> `()' #} +{#fun awe_webcore_clear_cookies { } -> `()' #} +{#fun awe_webcore_set_cookie { withAweString* `String', withAweString* `String', `Bool', `Bool' } -> `()' #} +{#fun awe_webcore_get_cookies { withAweString* `String', `Bool' } -> `String' fromAweString* #} +{#fun awe_webcore_delete_cookie { withAweString* `String', withAweString* `String' } -> `()' #} +{#fun awe_webcore_set_suppress_printer_dialog { `Bool' } -> `()' #} +{#fun awe_webcore_query_history { withAweString* `String', `Int', `Int' } -> `HistoryQueryResult' id #} + +{----------------------- + - Web View Functions - + -----------------------} + +{#fun awe_webview_destroy { id `WebView' } -> `()' #} +{#fun awe_webview_load_url { id `WebView', withAweString* `String', withAweString* `String', withAweString* `String', withAweString* `String' } -> `()' #} +{#fun awe_webview_load_html { id `WebView', withAweString* `String', withAweString* `String' } -> `()' #} +{#fun awe_webview_load_file { id `WebView', withAweString* `String', withAweString* `String' } -> `()' #} +{#fun awe_webview_get_url { id `WebView' } -> `String' fromAweStringDestroy* #} +{#fun awe_webview_go_to_history_offset { id `WebView', `Int' } -> `()' #} +{#fun awe_webview_get_history_back_count { id `WebView' } -> `Int' #} +{#fun awe_webview_get_history_forward_count { id `WebView' } -> `Int' #} +{#fun awe_webview_stop { id `WebView' } -> `()' #} +{#fun awe_webview_reload { id `WebView' } -> `()' #} +{#fun awe_webview_execute_javascript { id `WebView', withAweString* `String', withAweString* `String' } -> `()' #} +{#fun awe_webview_execute_javascript_with_result { id `WebView', withAweString* `String', withAweString* `String', `Int' } -> `JSValue' id #} +{#fun awe_webview_call_javascript_function { id `WebView', withAweString* `String', withAweString* `String', id `JSArray', withAweString* `String' } -> `()' #} +{#fun awe_webview_create_object { id `WebView', withAweString* `String' } -> `()' #} +{#fun awe_webview_destroy_object { id `WebView', withAweString* `String' } -> `()' #} +{#fun awe_webview_set_object_property { id `WebView', withAweString* `String', withAweString* `String', id `JSValue' } -> `()' #} +{#fun awe_webview_set_object_callback { id `WebView', withAweString* `String', withAweString* `String' } -> `()' #} +{#fun awe_webview_is_loading_page { id `WebView' } -> `Bool' #} +{#fun awe_webview_is_dirty { id `WebView' } -> `Bool' #} + +foreign import ccall safe "keyb.h awe_webview_get_dirty_bounds_wrapper" + awe_webview_get_dirty_bounds'_ :: WebView -> Ptr Rect -> IO () +awe_webview_get_dirty_bounds :: WebView -> IO (Rect) +awe_webview_get_dirty_bounds wv = alloca $ \p -> + awe_webview_get_dirty_bounds'_ wv p >> peek p + +{#fun awe_webview_render { id `WebView' } -> `RenderBuffer' id #} +{#fun awe_webview_pause_rendering { id `WebView' } -> `()' #} +{#fun awe_webview_resume_rendering { id `WebView' } -> `()' #} +{#fun awe_webview_inject_mouse_move { id `WebView', `Int', `Int' } -> `()' #} +{#fun awe_webview_inject_mouse_down { id `WebView', cFromEnum `MouseButton' } -> `()' #} +{#fun awe_webview_inject_mouse_up { id `WebView', cFromEnum `MouseButton' } -> `()' #} +{#fun awe_webview_inject_mouse_wheel { id `WebView', `Int', `Int' } -> `()' #} + +foreign import ccall safe "keyb.h awe_webview_inject_keyboard_event_wrapper" + awe_webview_inject_keyboard_event'_ :: WebView -> Ptr WebkeyboardEvent -> IO () +awe_webview_inject_keyboard_event :: WebView -> WebkeyboardEvent -> IO () +awe_webview_inject_keyboard_event wv e = with e $ \e' -> + awe_webview_inject_keyboard_event'_ wv e' + +#ifdef _WIN32 +-- {#fun awe_webview_inject_keyboard_event_win { id `WebView', UINT msg, WPARAM wparam, LPARAM lparam } -> `()' #} +#endif + +{#fun awe_webview_cut { id `WebView' } -> `()' #} +{#fun awe_webview_copy { id `WebView' } -> `()' #} +{#fun awe_webview_paste { id `WebView' } -> `()' #} +{#fun awe_webview_select_all { id `WebView' } -> `()' #} +{#fun awe_webview_copy_image_at { id `WebView', `Int', `Int' } -> `()' #} +{#fun awe_webview_set_zoom { id `WebView', `Int' } -> `()' #} +{#fun awe_webview_reset_zoom { id `WebView' } -> `()' #} +{#fun awe_webview_get_zoom { id `WebView' } -> `Int' #} +{#fun awe_webview_get_zoom_for_host { id `WebView', withAweString* `String' } -> `Int' #} +{#fun awe_webview_resize { id `WebView', `Int', `Int', `Bool', `Int' } -> `Bool' #} +{#fun awe_webview_is_resizing { id `WebView' } -> `Bool' #} +{#fun awe_webview_unfocus { id `WebView' } -> `()' #} +{#fun awe_webview_focus { id `WebView' } -> `()' #} +{#fun awe_webview_set_transparent { id `WebView', `Bool' } -> `()' #} +{#fun awe_webview_is_transparent { id `WebView' } -> `Bool' #} +{#fun awe_webview_set_url_filtering_mode { id `WebView', cFromEnum `UrlFilteringMode' } -> `()' #} +{#fun awe_webview_add_url_filter { id `WebView', withAweString* `String' } -> `()' #} +{#fun awe_webview_clear_all_url_filters { id `WebView' } -> `()' #} + +foreign import ccall safe "Graphics/UI/Awesomium/Raw.chs.h awe_webview_set_header_definition" + awe_webview_set_header_definition'_ :: ((WebView) -> ((AweString) -> (CULong -> ((Ptr (AweString)) -> ((Ptr (AweString)) -> (IO ())))))) +awe_webview_set_header_definition :: WebView -> String -> [(String, String)] -> IO () +awe_webview_set_header_definition wv n l = + withAweString n $ \n' -> + let (fns, fvs) = unzip l in + withMany withAweString fns $ \ns -> + withArray ns $ \ns' -> + withMany withAweString fvs $ \vs -> + withArray vs $ \vs' -> + let len' = fromIntegral . length $ l in + awe_webview_set_header_definition'_ wv n' len' ns' vs' + +{#fun awe_webview_add_header_rewrite_rule { id `WebView', withAweString* `String', withAweString* `String' } -> `()' #} +{#fun awe_webview_remove_header_rewrite_rule { id `WebView', withAweString* `String' } -> `()' #} +{#fun awe_webview_remove_header_rewrite_rules_by_definition_name { id `WebView', withAweString* `String' } -> `()' #} +{#fun awe_webview_choose_file { id `WebView', withAweString* `String' } -> `()' #} +{#fun awe_webview_print { id `WebView' } -> `()' #} +{#fun awe_webview_request_scroll_data { id `WebView', withAweString* `String' } -> `()' #} +{#fun awe_webview_find { id `WebView', `Int', withAweString* `String', `Bool', `Bool', `Bool' } -> `()' #} +{#fun awe_webview_stop_find { id `WebView', `Bool' } -> `()' #} +{#fun awe_webview_translate_page { id `WebView', withAweString* `String', withAweString* `String' } -> `()' #} +{#fun awe_webview_activate_ime { id `WebView', `Bool' } -> `()' #} +{#fun awe_webview_set_ime_composition { id `WebView', withAweString* `String', `Int', `Int', `Int' } -> `()' #} +{#fun awe_webview_confirm_ime_composition { id `WebView', withAweString* `String' } -> `()' #} +{#fun awe_webview_cancel_ime_composition { id `WebView' } -> `()' #} +{#fun awe_webview_login { id `WebView', `Int', withAweString* `String', withAweString* `String' } -> `()' #} +{#fun awe_webview_cancel_login { id `WebView', `Int' } -> `()' #} +{#fun awe_webview_close_javascript_dialog { id `WebView', `Int', `Bool', withAweString* `String' } -> `()' #} + +type BeginNavigationCallback = WebView -> AweString -> AweString -> IO() +foreign import ccall "wrapper" mkBeginNavigationCallback :: BeginNavigationCallback -> IO (FunPtr BeginNavigationCallback) +{#fun awe_webview_set_callback_begin_navigation { id `WebView', id `FunPtr BeginNavigationCallback' } -> `()' #} + +type BeginLoadingCallback = WebView -> AweString -> AweString -> CInt -> AweString -> IO() +foreign import ccall "wrapper" mkBeginLoadingCallback :: BeginLoadingCallback -> IO (FunPtr BeginLoadingCallback) +{#fun awe_webview_set_callback_begin_loading { id `WebView', id `FunPtr BeginLoadingCallback' } -> `()' #} + +type FinishLoadingCallback = WebView -> IO() +foreign import ccall "wrapper" mkFinishLoadingCallback :: FinishLoadingCallback -> IO (FunPtr FinishLoadingCallback) +{#fun awe_webview_set_callback_finish_loading { id `WebView', id `FunPtr FinishLoadingCallback' } -> `()' #} + +type JSCallback = WebView -> AweString -> AweString -> JSArray -> IO() +foreign import ccall "wrapper" mkJSCallback :: JSCallback -> IO (FunPtr JSCallback) +{#fun awe_webview_set_callback_js_callback { id `WebView', id `FunPtr JSCallback' } -> `()' #} + +type ReceiveTitleCallback = WebView -> AweString -> AweString -> IO() +foreign import ccall "wrapper" mkReceiveTitleCallback :: ReceiveTitleCallback -> IO (FunPtr ReceiveTitleCallback) +{#fun awe_webview_set_callback_receive_title { id `WebView', id `FunPtr ReceiveTitleCallback' } -> `()' #} + +type ChangeTooltipCallback = WebView -> AweString -> IO() +foreign import ccall "wrapper" mkChangeTooltipCallback :: ChangeTooltipCallback -> IO (FunPtr ChangeTooltipCallback) +{#fun awe_webview_set_callback_change_tooltip { id `WebView', id `FunPtr ChangeTooltipCallback' } -> `()' #} + +type ChangeCursorCallback = WebView -> CInt {-CursorType-} -> IO() +foreign import ccall "wrapper" mkChangeCursorCallback :: ChangeCursorCallback -> IO (FunPtr ChangeCursorCallback) +{#fun awe_webview_set_callback_change_cursor { id `WebView', id `FunPtr ChangeCursorCallback' } -> `()' #} + +type ChangeKeyboardFocusCallback = WebView -> CUInt {-Bool-} -> IO() +foreign import ccall "wrapper" mkChangeKeyboardFocusCallback :: ChangeKeyboardFocusCallback -> IO (FunPtr ChangeKeyboardFocusCallback) +{#fun awe_webview_set_callback_change_keyboard_focus { id `WebView', id `FunPtr ChangeKeyboardFocusCallback' } -> `()' #} + +type ChangeTargetUrlCallback = WebView -> AweString -> IO() +foreign import ccall "wrapper" mkChangeTargetUrlCallback :: ChangeTargetUrlCallback -> IO (FunPtr ChangeTargetUrlCallback) +{#fun awe_webview_set_callback_change_target_url { id `WebView', id `FunPtr ChangeTargetUrlCallback' } -> `()' #} + +type OpenExternalLinkCallback = WebView -> AweString -> AweString -> IO() +foreign import ccall "wrapper" mkOpenExternalLinkCallback :: OpenExternalLinkCallback -> IO (FunPtr OpenExternalLinkCallback) +{#fun awe_webview_set_callback_open_external_link { id `WebView', id `FunPtr OpenExternalLinkCallback' } -> `()' #} + +type RequestDownloadCallback = WebView -> AweString -> IO() +foreign import ccall "wrapper" mkRequestDownloadCallback :: RequestDownloadCallback -> IO (FunPtr RequestDownloadCallback) +{#fun awe_webview_set_callback_request_download { id `WebView', id `FunPtr RequestDownloadCallback' } -> `()' #} + +type WebViewCrashedCallback = WebView -> IO() +foreign import ccall "wrapper" mkWebViewCrashedCallback :: WebViewCrashedCallback -> IO (FunPtr WebViewCrashedCallback) +{#fun awe_webview_set_callback_web_view_crashed { id `WebView', id `FunPtr WebViewCrashedCallback' } -> `()' #} + +type PluginCrashedCallback = WebView -> AweString -> IO() +foreign import ccall "wrapper" mkPluginCrashedCallback :: PluginCrashedCallback -> IO (FunPtr PluginCrashedCallback) +{#fun awe_webview_set_callback_plugin_crashed { id `WebView', id `FunPtr PluginCrashedCallback' } -> `()' #} + +type RequestMoveCallback = WebView -> CInt -> CInt -> IO() +foreign import ccall "wrapper" mkRequestMoveCallback :: RequestMoveCallback -> IO (FunPtr RequestMoveCallback) +{#fun awe_webview_set_callback_request_move { id `WebView', id `FunPtr RequestMoveCallback' } -> `()' #} + +type GetPageContentsCallback = WebView -> AweString -> AweString -> IO() +foreign import ccall "wrapper" mkGetPageContentsCallback :: GetPageContentsCallback -> IO (FunPtr GetPageContentsCallback) +{#fun awe_webview_set_callback_get_page_contents { id `WebView', id `FunPtr GetPageContentsCallback' } -> `()' #} + +type DomReadyCallback = WebView -> IO() +foreign import ccall "wrapper" mkDomReadyCallback :: DomReadyCallback -> IO (FunPtr DomReadyCallback) +{#fun awe_webview_set_callback_dom_ready { id `WebView', id `FunPtr DomReadyCallback' } -> `()' #} + +type RequestFileChooserCallback = WebView -> CUInt {-Bool-} -> AweString -> AweString -> IO() +foreign import ccall "wrapper" mkRequestFileChooserCallback :: RequestFileChooserCallback -> IO (FunPtr RequestFileChooserCallback) +{#fun awe_webview_set_callback_request_file_chooser { id `WebView', id `FunPtr RequestFileChooserCallback' } -> `()' #} + +type GetScrollDataCallback = WebView -> CInt -> CInt -> CInt -> CInt -> CInt -> IO() +foreign import ccall "wrapper" mkGetScrollDataCallback :: GetScrollDataCallback -> IO (FunPtr GetScrollDataCallback) +{#fun awe_webview_set_callback_get_scroll_data { id `WebView', id `FunPtr GetScrollDataCallback' } -> `()' #} + +type JsConsoleMessageCallback = WebView -> AweString -> CInt -> AweString -> IO() +foreign import ccall "wrapper" mkJsConsoleMessageCallback :: JsConsoleMessageCallback -> IO (FunPtr JsConsoleMessageCallback) +{#fun awe_webview_set_callback_js_console_message { id `WebView', id `FunPtr JsConsoleMessageCallback' } -> `()' #} + +type GetFindResultsCallback = WebView -> CInt -> CInt -> Ptr Rect -> CInt -> CUInt {-Bool-} -> IO() +foreign import ccall "wrapper" mkGetFindResultsCallback :: GetFindResultsCallback -> IO (FunPtr GetFindResultsCallback) +foreign import ccall safe "Graphics/UI/Awesomium/Raw.chs.h awe_webview_set_callback_get_find_results" + awe_webview_set_callback_get_find_results :: WebView -> FunPtr GetFindResultsCallback -> IO () + +type UpdateImeCallback = WebView -> CInt {-ImeState-} -> Ptr Rect -> IO() +foreign import ccall "wrapper" mkUpdateImeCallback :: UpdateImeCallback -> IO (FunPtr UpdateImeCallback) +foreign import ccall safe "Graphics/UI/Awesomium/Raw.chs.h awe_webview_set_callback_get_find_results" + awe_webview_set_callback_update_ime :: WebView -> FunPtr UpdateImeCallback -> IO () + +type ShowContextMenuCallback = WebView -> CInt -> CInt -> CInt {-MediaType-} -> CInt -> AweString -> AweString -> AweString -> AweString -> AweString -> CUInt {-Bool-} -> CInt -> IO() +foreign import ccall "wrapper" mkShowContextMenuCallback :: ShowContextMenuCallback -> IO (FunPtr ShowContextMenuCallback) +{#fun awe_webview_set_callback_show_context_menu { id `WebView', id `FunPtr ShowContextMenuCallback' } -> `()' #} + +type RequestLoginCallback = WebView -> CInt -> AweString -> CUInt {-Bool-} -> AweString -> AweString -> AweString -> IO() +foreign import ccall "wrapper" mkRequestLoginCallback :: RequestLoginCallback -> IO (FunPtr RequestLoginCallback) +{#fun awe_webview_set_callback_request_login { id `WebView', id `FunPtr RequestLoginCallback' } -> `()' #} + +type ChangeHistoryCallback = WebView -> CInt -> CInt -> IO() +foreign import ccall "wrapper" mkChangeHistoryCallback :: ChangeHistoryCallback -> IO (FunPtr ChangeHistoryCallback) +{#fun awe_webview_set_callback_change_history { id `WebView', id `FunPtr ChangeHistoryCallback' } -> `()' #} + +type FinishResizeCallback = WebView -> CInt -> CInt -> IO() +foreign import ccall "wrapper" mkFinishResizeCallback :: FinishResizeCallback -> IO (FunPtr FinishResizeCallback) +{#fun awe_webview_set_callback_finish_resize { id `WebView', id `FunPtr FinishResizeCallback' } -> `()' #} + +type ShowJavascriptDialogCallback = WebView -> CInt -> CInt -> AweString -> AweString -> AweString -> IO() +foreign import ccall "wrapper" mkShowJavascriptDialogCallback :: ShowJavascriptDialogCallback -> IO (FunPtr ShowJavascriptDialogCallback) +{#fun awe_webview_set_callback_show_javascript_dialog { id `WebView', id `FunPtr ShowJavascriptDialogCallback' } -> `()' #} + +{----------------------- + - JS Value Functions - + -----------------------} + +data JSValueType + = JSValueTypeNull + | JSValueTypeBoolean + | JSValueTypeInteger + | JSValueTypeDouble + | JSValueTypeString + | JSValueTypeObject + | JSValueTypeArray + deriving (Eq, Enum) + +{#fun awe_jsvalue_create_null_value { } -> `JSValue' id #} +{#fun awe_jsvalue_create_bool_value { `Bool' } -> `JSValue' id #} +{#fun awe_jsvalue_create_integer_value { `Int' } -> `JSValue' id #} +{#fun awe_jsvalue_create_double_value { `Double' } -> `JSValue' id #} +{#fun awe_jsvalue_create_string_value { withAweString* `String' } -> `JSValue' id #} +{#fun awe_jsvalue_create_object_value { id `JSObject' } -> `JSValue' id #} +{#fun awe_jsvalue_create_array_value { id `JSArray' } -> `JSValue' id #} +{#fun awe_jsvalue_destroy { id `JSValue' } -> `()' #} +{#fun awe_jsvalue_get_type { id `JSValue' } -> `JSValueType' cToEnum #} +{#fun awe_jsvalue_to_string { id `JSValue' } -> `String' fromAweStringDestroy* #} +{#fun awe_jsvalue_to_integer { id `JSValue' } -> `Int' #} +{#fun awe_jsvalue_to_double { id `JSValue' } -> `Double' #} +{#fun awe_jsvalue_to_boolean { id `JSValue' } -> `Bool' #} +{#fun awe_jsvalue_get_array { id `JSValue' } -> `JSArray' id #} +{#fun awe_jsvalue_get_object { id `JSValue' } -> `JSObject' id #} +{#fun awe_jsarray_create { id `Ptr JSValue', fromIntegral `Int' } -> `JSArray' id #} +{#fun awe_jsarray_destroy { id `JSArray' } -> `()' #} +{#fun awe_jsarray_get_size { id `JSArray' } -> `Int' fromIntegral #} +{#fun awe_jsarray_get_element { id `JSArray', fromIntegral `Int' } -> `JSValue' id #} + +{----------------------------- + - JS Value Object Functions - + -----------------------------} + +{#fun awe_jsobject_create { } -> `JSObject' id #} +{#fun awe_jsobject_destroy { id `JSObject' } -> `()' #} +{#fun awe_jsobject_has_property { id `JSObject', withAweString* `String' } -> `Bool' #} +{#fun awe_jsobject_get_property { id `JSObject', withAweString* `String' } -> `JSValue' id #} +{#fun awe_jsobject_set_property { id `JSObject', withAweString* `String', id `JSValue' } -> `()' #} +{#fun awe_jsobject_get_size { id `JSObject' } -> `Int' fromIntegral #} +{#fun awe_jsobject_get_keys { id `JSObject' } -> `JSArray' id #} + +{--------------------------- + - Render Buffer Functions - + ---------------------------} + +{#fun awe_renderbuffer_get_width { id `RenderBuffer' } -> `Int' #} +{#fun awe_renderbuffer_get_height { id `RenderBuffer' } -> `Int' #} +{#fun awe_renderbuffer_get_rowspan { id `RenderBuffer' } -> `Int' #} +{#fun awe_renderbuffer_get_buffer { id `RenderBuffer' } -> `Ptr CUChar' id #} +-- {#fun awe_renderbuffer_copy_to { id `RenderBuffer', unsigned char* dest_buffer, `Int', `Int', `Bool', `Bool' } -> `()' #} +-- {#fun awe_renderbuffer_copy_to_float { id `RenderBuffer', float* dest_buffer } -> `()' #} +{#fun awe_renderbuffer_save_to_png { id `RenderBuffer', withAweString* `String', `Bool' } -> `Bool' #} +{#fun awe_renderbuffer_save_to_jpeg { id `RenderBuffer', withAweString* `String', `Int' } -> `Bool' #} +{#fun awe_renderbuffer_get_alpha_at_point { id `RenderBuffer', `Int', `Int' } -> `Int' #} +{#fun awe_renderbuffer_flush_alpha { id `RenderBuffer' } -> `()' #} + +{------------------------ + - Resource Interceptor - + ------------------------} + +-- {#fun awe_webview_set_callback_resource_request { id `WebView', resource_response* (*callback } -> `()' #} +-- {#fun awe_webview_set_callback_resource_response { id `WebView', void (*callback } -> `()' #} +-- {#fun awe_resource_response_create { size_t num_bytes, unsigned char* buffer, withAweString* `String' } -> `ResourceResponse' id #} +{#fun awe_resource_response_create_from_file { withAweString* `String' } -> `ResourceResponse' id #} + +{------------------------ + - Resource Request - + ------------------------} + +{#fun awe_resource_request_cancel { id `ResourceRequest' } -> `()' #} +{#fun awe_resource_request_get_url { id `ResourceRequest' } -> `String' fromAweStringDestroy* #} +{#fun awe_resource_request_get_method { id `ResourceRequest' } -> `String' fromAweStringDestroy* #} +{#fun awe_resource_request_set_method { id `ResourceRequest', withAweString* `String' } -> `()' #} +{#fun awe_resource_request_get_referrer { id `ResourceRequest' } -> `String' fromAweStringDestroy* #} +{#fun awe_resource_request_set_referrer { id `ResourceRequest', withAweString* `String' } -> `()' #} +{#fun awe_resource_request_get_extra_headers { id `ResourceRequest' } -> `String' fromAweStringDestroy* #} +{#fun awe_resource_request_set_extra_headers { id `ResourceRequest', withAweString* `String' } -> `()' #} +{#fun awe_resource_request_append_extra_header { id `ResourceRequest', withAweString* `String', withAweString* `String' } -> `()' #} +{#fun awe_resource_request_get_num_upload_elements { id `ResourceRequest' } -> `Int' fromIntegral #} +{#fun awe_resource_request_get_upload_element { id `ResourceRequest', fromIntegral `Int' } -> `UploadElement' id #} +{#fun awe_resource_request_clear_upload_elements { id `ResourceRequest' } -> `()' #} +{#fun awe_resource_request_append_upload_file_path { id `ResourceRequest', withAweString* `String' } -> `()' #} +{#fun awe_resource_request_append_upload_bytes { id `ResourceRequest', withAweString* `String' } -> `()' #} + +{------------------------ + - Upload Element - + ------------------------} + +{#fun awe_upload_element_is_file_path { id `UploadElement' } -> `Bool' #} +{#fun awe_upload_element_is_bytes { id `UploadElement' } -> `Bool' #} +{#fun awe_upload_element_get_bytes { id `UploadElement' } -> `String' fromAweStringDestroy* #} +{#fun awe_upload_element_get_file_path { id `UploadElement' } -> `String' fromAweStringDestroy* #} + +{------------------------ + - History Query Result - + ------------------------} + +{#fun awe_history_query_result_destroy { id `HistoryQueryResult' } -> `()' #} +{#fun awe_history_query_result_get_size { id `HistoryQueryResult' } -> `Int' fromIntegral #} +{#fun awe_history_query_result_get_entry_at_index { id `HistoryQueryResult', fromIntegral `Int' } -> `HistoryEntry' id #} + +{------------------------ + - History Entry - + ------------------------} + +{#fun awe_history_entry_destroy { id `HistoryEntry' } -> `()' #} +{#fun awe_history_entry_get_url { id `HistoryEntry' } -> `String' fromAweStringDestroy* #} +{#fun awe_history_entry_get_title { id `HistoryEntry' } -> `String' fromAweStringDestroy* #} +{#fun awe_history_entry_get_visit_time { id `HistoryEntry' } -> `Double' #} +{#fun awe_history_entry_get_visit_count { id `HistoryEntry' } -> `Int' #} +