NetSurf
Data Structures | Functions | Variables
cookies.c File Reference

Implementation of RISC OS cookie manager. More...

#include <stdint.h>
#include <stdlib.h>
#include <oslib/wimp.h>
#include "utils/log.h"
#include "utils/nsoption.h"
#include "utils/messages.h"
#include "netsurf/plotters.h"
#include "netsurf/keypress.h"
#include "desktop/cookie_manager.h"
#include "riscos/gui.h"
#include "riscos/wimp.h"
#include "riscos/wimp_event.h"
#include "riscos/dialog.h"
#include "riscos/toolbar.h"
#include "riscos/corewindow.h"
#include "riscos/cookies.h"
Include dependency graph for cookies.c:

Go to the source code of this file.

Data Structures

struct  ro_cookie_window
 

Functions

static nserror cookie_draw (struct ro_corewindow *ro_cw, int originx, int originy, struct rect *r)
 callback to draw on drawable area of ro cookie window More...
 
static nserror cookie_key (struct ro_corewindow *ro_cw, uint32_t nskey)
 callback for keypress on ro cookie window More...
 
static nserror cookie_mouse (struct ro_corewindow *ro_cw, browser_mouse_state mouse_state, int x, int y)
 callback for mouse event on ro cookie window More...
 
static nserror cookie_toolbar_click (struct ro_corewindow *ro_cw, button_bar_action action)
 handle clicks in ro core window toolbar. More...
 
static nserror cookie_toolbar_update (struct ro_corewindow *ro_cw)
 Handle updating state of buttons in ro core window toolbar. More...
 
static nserror cookie_toolbar_save (struct ro_corewindow *ro_cw, char *config)
 callback for saving of toolbar state in ro cookie window More...
 
static bool cookie_menu_prepare (wimp_w w, wimp_i i, wimp_menu *menu, wimp_pointer *pointer)
 Prepare the cookie meu for display. More...
 
static void cookie_menu_warning (wimp_w w, wimp_i i, wimp_menu *menu, wimp_selection *selection, menu_action action)
 Handle submenu warnings for the cookies menu. More...
 
static bool cookie_menu_select (wimp_w w, wimp_i i, wimp_menu *menu, wimp_selection *selection, menu_action action)
 Handle selections from the cookies menu. More...
 
static nserror ro_cookie_init (void)
 Creates the window for the cookie tree. More...
 
nserror ro_gui_cookies_present (const char *search_term)
 make the cookie window visible. More...
 
void ro_gui_cookies_initialise (void)
 initialise the cookies window template ready for subsequent use. More...
 
nserror ro_gui_cookies_finalise (void)
 Free any resources allocated for the cookie window. More...
 
bool ro_gui_cookies_check_window (wimp_w wh)
 check if window handle is for the cookies window More...
 
bool ro_gui_cookies_check_menu (wimp_menu *menu)
 check if menu handle is for the cookies menu More...
 

Variables

static struct ro_cookie_windowcookie_window = NULL
 cookie window is a singleton More...
 
static wimp_window * dialog_cookie_template
 riscos template for cookie window More...
 

Detailed Description

Implementation of RISC OS cookie manager.

Definition in file cookies.c.

Function Documentation

◆ cookie_draw()

static nserror cookie_draw ( struct ro_corewindow ro_cw,
int  originx,
int  originy,
struct rect r 
)
static

callback to draw on drawable area of ro cookie window

Parameters
ro_cwThe riscos core window structure.
rThe rectangle of the window that needs updating.
originxThe risc os plotter x origin.
originyThe risc os plotter y origin.
Returns
NSERROR_OK on success otherwise apropriate error code

Definition at line 65 of file cookies.c.

References cookie_manager_redraw(), redraw_context::interactive, no_font_blending, NSERROR_OK, ro_plot_origin_x, ro_plot_origin_y, and ro_plotters.

Referenced by ro_cookie_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cookie_key()

static nserror cookie_key ( struct ro_corewindow ro_cw,
uint32_t  nskey 
)
static

callback for keypress on ro cookie window

Parameters
ro_cwThe ro core window structure.
nskeyThe netsurf key code.
Returns
NSERROR_OK if key processed, NSERROR_NOT_IMPLEMENTED if key not processed otherwise apropriate error code

Definition at line 95 of file cookies.c.

References cookie_manager_keypress(), NSERROR_NOT_IMPLEMENTED, and NSERROR_OK.

Referenced by ro_cookie_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cookie_menu_prepare()

static bool cookie_menu_prepare ( wimp_w  w,
wimp_i  i,
wimp_menu *  menu,
wimp_pointer *  pointer 
)
static

Prepare the cookie meu for display.

Parameters
wThe window owning the menu.
iThe icon owning the menu.
menuThe menu from which the selection was made.
pointerThe pointer shape
Returns
true if action accepted; else false.

Definition at line 204 of file cookies.c.

References cookie_manager_has_selection(), ro_cookie_window::core, ro_cookie_window::menu, ro_gui_menu_set_entry_shaded(), ro_gui_menu_set_entry_ticked(), ro_gui_wimp_event_get_user_data(), ro_toolbar_menu_buttons_tick, ro_toolbar_menu_edit_shade, ro_toolbar_menu_edit_tick, ro_toolbar_menu_option_shade, ro_corewindow::toolbar, TOOLBAR_BUTTONS, TOOLBAR_EDIT, TREE_CLEAR_SELECTION, and TREE_SELECTION.

Referenced by ro_cookie_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cookie_menu_select()

static bool cookie_menu_select ( wimp_w  w,
wimp_i  i,
wimp_menu *  menu,
wimp_selection *  selection,
menu_action  action 
)
static

Handle selections from the cookies menu.

Parameters
wThe window owning the menu.
iThe icon owning the menu.
menuThe menu from which the selection was made.
selectionThe wimp menu selection data.
actionThe selected menu action.
Returns
true if action accepted; else false.

Definition at line 269 of file cookies.c.

References cookie_manager_contract(), cookie_manager_expand(), cookie_manager_keypress(), ro_cookie_window::core, ro_cookie_window::menu, NS_KEY_CLEAR_SELECTION, NS_KEY_DELETE_LEFT, NS_KEY_SELECT_ALL, ro_gui_wimp_event_get_user_data(), ro_toolbar_get_display_buttons(), ro_toolbar_set_display_buttons(), ro_toolbar_toggle_edit(), ro_corewindow::toolbar, TOOLBAR_BUTTONS, TOOLBAR_EDIT, TREE_CLEAR_SELECTION, TREE_COLLAPSE_ALL, TREE_COLLAPSE_FOLDERS, TREE_COLLAPSE_LINKS, TREE_EXPAND_ALL, TREE_EXPAND_FOLDERS, TREE_EXPAND_LINKS, TREE_SELECT_ALL, and TREE_SELECTION_DELETE.

Referenced by ro_cookie_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cookie_menu_warning()

static void cookie_menu_warning ( wimp_w  w,
wimp_i  i,
wimp_menu *  menu,
wimp_selection *  selection,
menu_action  action 
)
static

Handle submenu warnings for the cookies menu.

Parameters
wThe window owning the menu.
iThe icon owning the menu.
menuThe menu to which the warning applies.
selectionThe wimp menu selection data.
actionThe selected menu action.

Definition at line 248 of file cookies.c.

Referenced by ro_cookie_init().

Here is the caller graph for this function:

◆ cookie_mouse()

static nserror cookie_mouse ( struct ro_corewindow ro_cw,
browser_mouse_state  mouse_state,
int  x,
int  y 
)
static

callback for mouse event on ro cookie window

Parameters
ro_cwThe ro core window structure.
mouse_statemouse state
xlocation of event
ylocation of event
Returns
NSERROR_OK on sucess otherwise apropriate error code.

Definition at line 114 of file cookies.c.

References cookie_manager_mouse_action(), and NSERROR_OK.

Referenced by ro_cookie_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cookie_toolbar_click()

static nserror cookie_toolbar_click ( struct ro_corewindow ro_cw,
button_bar_action  action 
)
static

handle clicks in ro core window toolbar.

Parameters
ro_cwThe ro core window structure.
actionThe button bar action.
Returns
NSERROR_OK if config saved, otherwise apropriate error code

Definition at line 132 of file cookies.c.

References cookie_manager_contract(), cookie_manager_expand(), cookie_manager_keypress(), NS_KEY_DELETE_LEFT, NSERROR_OK, TOOLBAR_BUTTON_CLOSE, TOOLBAR_BUTTON_COLLAPSE, TOOLBAR_BUTTON_DELETE, TOOLBAR_BUTTON_EXPAND, and TOOLBAR_BUTTON_OPEN.

Referenced by ro_cookie_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cookie_toolbar_save()

static nserror cookie_toolbar_save ( struct ro_corewindow ro_cw,
char *  config 
)
static

callback for saving of toolbar state in ro cookie window

Parameters
ro_cwThe ro core window structure.
configThe new toolbar configuration.
Returns
NSERROR_OK if config saved, otherwise apropriate error code

Definition at line 185 of file cookies.c.

References NSERROR_OK, nsoption_set_charp, and ro_gui_save_options().

Referenced by ro_cookie_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cookie_toolbar_update()

static nserror cookie_toolbar_update ( struct ro_corewindow ro_cw)
static

Handle updating state of buttons in ro core window toolbar.

Parameters
ro_cwThe ro core window structure.
Returns
NSERROR_OK if config saved, otherwise apropriate error code

Definition at line 169 of file cookies.c.

References cookie_manager_has_selection(), NSERROR_OK, ro_toolbar_set_button_shaded_state(), ro_corewindow::toolbar, and TOOLBAR_BUTTON_DELETE.

Referenced by ro_cookie_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ro_cookie_init()

static nserror ro_cookie_init ( void  )
static

Creates the window for the cookie tree.

Returns
NSERROR_OK on success else appropriate error code on faliure.

Definition at line 343 of file cookies.c.

References ro_corewindow::cb_table, cookie_draw(), cookie_key(), cookie_manager_init(), cookie_menu_prepare(), cookie_menu_select(), cookie_menu_warning(), cookie_mouse(), cookie_toolbar_click(), cookie_toolbar_save(), cookie_toolbar_update(), cookie_window, ro_cookie_window::core, dialog_cookie_template, ro_corewindow::draw, ro_corewindow::key, ro_cookie_window::menu, messages_get(), ro_corewindow::mouse, NO_ACTION, NSERROR_NOMEM, NSERROR_OK, NSLOG, nsoption_charp, ro_corewindow_init(), ro_gui_menu_define_menu(), ro_gui_set_window_title(), ro_gui_wimp_event_register_menu(), ro_gui_wimp_event_register_menu_prepare(), ro_gui_wimp_event_register_menu_selection(), ro_gui_wimp_event_register_menu_warning(), ro_warn_user(), THEME_STYLE_COOKIES_TOOLBAR, TOOLBAR_BUTTON_CLOSE, TOOLBAR_BUTTON_COLLAPSE, TOOLBAR_BUTTON_DELETE, TOOLBAR_BUTTON_EXPAND, TOOLBAR_BUTTON_NONE, TOOLBAR_BUTTON_OPEN, TOOLBAR_BUTTONS, ro_corewindow::toolbar_click, TOOLBAR_EDIT, ro_corewindow::toolbar_save, ro_corewindow::toolbar_update, TREE_CLEAR_SELECTION, TREE_COLLAPSE_ALL, TREE_COLLAPSE_FOLDERS, TREE_COLLAPSE_LINKS, TREE_EXPAND_ALL, TREE_EXPAND_FOLDERS, TREE_EXPAND_LINKS, TREE_SELECT_ALL, TREE_SELECTION, TREE_SELECTION_DELETE, and ro_corewindow::wh.

Referenced by ro_gui_cookies_present().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ro_gui_cookies_check_menu()

bool ro_gui_cookies_check_menu ( wimp_menu *  menu)

check if menu handle is for the cookies menu

Definition at line 511 of file cookies.c.

References cookie_window, and ro_cookie_window::menu.

Referenced by ro_gui_interactive_help_request().

Here is the caller graph for this function:

◆ ro_gui_cookies_check_window()

bool ro_gui_cookies_check_window ( wimp_w  wh)

check if window handle is for the cookies window

Definition at line 500 of file cookies.c.

References cookie_window, ro_cookie_window::core, and ro_corewindow::wh.

Referenced by ro_gui_interactive_help_request().

Here is the caller graph for this function:

◆ ro_gui_cookies_finalise()

nserror ro_gui_cookies_finalise ( void  )

Free any resources allocated for the cookie window.

Returns
NSERROR_OK on success else appropriate error code on faliure.

Definition at line 479 of file cookies.c.

References cookie_manager_fini(), cookie_window, ro_cookie_window::core, NSERROR_OK, and ro_corewindow_fini().

Referenced by gui_quit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ro_gui_cookies_initialise()

void ro_gui_cookies_initialise ( void  )

initialise the cookies window template ready for subsequent use.

Definition at line 472 of file cookies.c.

References dialog_cookie_template, and ro_gui_dialog_load_template().

Referenced by ro_gui_dialog_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ro_gui_cookies_present()

nserror ro_gui_cookies_present ( const char *  search_term)

make the cookie window visible.

Returns
NSERROR_OK on success else appropriate error code on faliure.

Definition at line 450 of file cookies.c.

References cookie_manager_set_search_string(), cookie_window, ro_cookie_window::core, NSERROR_OK, NSLOG, ro_cookie_init(), ro_gui_dialog_open_top(), ro_corewindow::toolbar, and ro_corewindow::wh.

Referenced by ro_gui_iconbar_menu_select(), and ro_gui_window_menu_select().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ cookie_window

struct ro_cookie_window* cookie_window = NULL
static

cookie window is a singleton

Definition at line 49 of file cookies.c.

Referenced by ro_cookie_init(), ro_gui_cookies_check_menu(), ro_gui_cookies_check_window(), ro_gui_cookies_finalise(), and ro_gui_cookies_present().

◆ dialog_cookie_template

wimp_window* dialog_cookie_template
static

riscos template for cookie window

Definition at line 52 of file cookies.c.

Referenced by ro_cookie_init(), and ro_gui_cookies_initialise().