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

Implementation of RISC OS hotlist manager. More...

#include <stdint.h>
#include <stdlib.h>
#include <oslib/osmodule.h>
#include <oslib/wimp.h>
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/nsoption.h"
#include "utils/nsurl.h"
#include "netsurf/url_db.h"
#include "netsurf/window.h"
#include "netsurf/plotters.h"
#include "netsurf/keypress.h"
#include "desktop/hotlist.h"
#include "riscos/gui.h"
#include "riscos/dialog.h"
#include "riscos/message.h"
#include "riscos/save.h"
#include "riscos/toolbar.h"
#include "riscos/wimp.h"
#include "riscos/wimp_event.h"
#include "riscos/query.h"
#include "riscos/menus.h"
#include "riscos/corewindow.h"
#include "riscos/hotlist.h"
Include dependency graph for hotlist.c:

Go to the source code of this file.

Data Structures

struct  ro_hotlist_window
 Hotlist window container for RISC OS. More...
 
struct  ro_hotlist_message_hotlist_addurl
 URL adding hotlist protocol message block. More...
 
struct  ro_hotlist_message_hotlist_changed
 change hotlist protocol message block. More...
 

Functions

static nserror hotlist_draw (struct ro_corewindow *ro_cw, int originx, int originy, struct rect *r)
 callback to draw on drawable area of ro hotlist window More...
 
static nserror hotlist_key (struct ro_corewindow *ro_cw, uint32_t nskey)
 callback for keypress on ro hotlist window More...
 
static nserror hotlist_mouse (struct ro_corewindow *ro_cw, browser_mouse_state mouse_state, int x, int y)
 callback for mouse event on ro hotlist window More...
 
static nserror hotlist_toolbar_click (struct ro_corewindow *ro_cw, button_bar_action action)
 handle clicks in ro hotlist window toolbar. More...
 
static nserror hotlist_toolbar_update (struct ro_corewindow *ro_cw)
 Handle updating state of buttons in ro core window toolbar. More...
 
static nserror hotlist_toolbar_save (struct ro_corewindow *ro_cw, char *config)
 callback for saving of toolbar state in ro hotlist window More...
 
static bool hotlist_menu_prepare (wimp_w w, wimp_i i, wimp_menu *menu, wimp_pointer *pointer)
 Prepare the hotlist menu for display. More...
 
static void hotlist_menu_warning (wimp_w w, wimp_i i, wimp_menu *menu, wimp_selection *selection, menu_action action)
 Handle submenu warnings for the hotlist menu. More...
 
static bool hotlist_menu_select (wimp_w w, wimp_i i, wimp_menu *menu, wimp_selection *selection, menu_action action)
 Handle selections from the hotlist menu. More...
 
static nserror ro_hotlist_init (void)
 Creates the window for the hotlist tree. More...
 
nserror ro_gui_hotlist_present (void)
 make the cookie window visible. More...
 
void ro_gui_hotlist_initialise (void)
 initialise the hotlist window template ready for subsequent use. More...
 
nserror ro_gui_hotlist_finalise (void)
 Free any resources allocated for the cookie window. More...
 
bool ro_gui_hotlist_check_window (wimp_w wh)
 
bool ro_gui_hotlist_check_menu (wimp_menu *menu)
 
static void ro_gui_hotlist_scheduled_callback (void *p)
 Callback to schedule for the next available Null poll, by which point a hotlist client will have claimed the Message_HotlistAddURL and any details in RMA can safely be discarded. More...
 
static void ro_gui_hotlist_addurl_bounce (wimp_message *message)
 Handle bounced Message_HotlistAddURL, so that RMA storage can be freed. More...
 
void ro_gui_hotlist_add_page (nsurl *url)
 Add a URL to the hotlist. More...
 
void ro_gui_hotlist_add_cleanup (void)
 Clean up RMA storage used by the Message_HotlistAddURL protocol. More...
 
static void ro_gui_hotlist_remove_confirmed (query_id id, enum query_response res, void *p)
 Callback confirming a URL delete query. More...
 
static void ro_gui_hotlist_remove_cancelled (query_id id, enum query_response res, void *p)
 Callback cancelling a URL delete query. More...
 
void ro_gui_hotlist_remove_page (nsurl *url)
 Remove a URL from the hotlist. More...
 
bool ro_gui_hotlist_has_page (nsurl *url)
 Report whether the hotlist contains a given URL. More...
 

Variables

static struct ro_hotlist_windowhotlist_window = NULL
 hotlist window singleton More...
 
static wimp_window * dialog_hotlist_template
 riscos template for hotlist window More...
 
static query_id hotlist_query = QUERY_INVALID
 Hotlist Query Handler. More...
 
static nsurlhotlist_delete_url = NULL
 
static char * hotlist_url = NULL
 URL area claimed from RMA. More...
 
static char * hotlist_title = NULL
 Title area claimed from RMA. More...
 
static const query_callback remove_funcs
 removal query dialog callbacks. More...
 

Detailed Description

Implementation of RISC OS hotlist manager.

Definition in file hotlist.c.

Function Documentation

◆ hotlist_draw()

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

callback to draw on drawable area of ro hotlist 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 107 of file hotlist.c.

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

Referenced by ro_hotlist_init().

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

◆ hotlist_key()

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

callback for keypress on ro hotlist 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 137 of file hotlist.c.

References hotlist_keypress(), NSERROR_NOT_IMPLEMENTED, and NSERROR_OK.

Referenced by ro_hotlist_init().

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

◆ hotlist_menu_prepare()

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

Prepare the hotlist menu 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 264 of file hotlist.c.

References ro_hotlist_window::core, GUI_SAVE_HOTLIST_EXPORT_HTML, hotlist_has_selection(), ro_hotlist_window::menu, ro_gui_menu_set_entry_shaded(), ro_gui_menu_set_entry_ticked(), ro_gui_save_prepare(), 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_hotlist_init().

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

◆ hotlist_menu_select()

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

Handle selections from the hotlist 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 329 of file hotlist.c.

References ro_hotlist_window::core, dialog_saveas, hotlist_add_entry(), hotlist_add_folder(), hotlist_contract(), hotlist_edit_selection(), hotlist_expand(), HOTLIST_EXPORT, hotlist_keypress(), ro_hotlist_window::menu, NS_KEY_CLEAR_SELECTION, NS_KEY_CR, NS_KEY_DELETE_LEFT, NS_KEY_SELECT_ALL, ro_gui_dialog_open_persistent(), ro_gui_wimp_event_get_user_data(), ro_toolbar_get_display_buttons(), ro_toolbar_set_display_buttons(), ro_toolbar_toggle_edit(), ro_toolbar_update_all_hotlists(), 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_NEW_FOLDER, TREE_NEW_LINK, TREE_SELECT_ALL, TREE_SELECTION_DELETE, TREE_SELECTION_EDIT, and TREE_SELECTION_LAUNCH.

Referenced by ro_hotlist_init().

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

◆ hotlist_menu_warning()

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

Handle submenu warnings for the hotlist 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 308 of file hotlist.c.

Referenced by ro_hotlist_init().

Here is the caller graph for this function:

◆ hotlist_mouse()

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

callback for mouse event on ro hotlist 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 156 of file hotlist.c.

References hotlist_mouse_action(), and NSERROR_OK.

Referenced by ro_hotlist_init().

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

◆ hotlist_toolbar_click()

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

handle clicks in ro hotlist 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 174 of file hotlist.c.

References hotlist_add_folder(), hotlist_contract(), hotlist_expand(), hotlist_keypress(), NS_KEY_CR, NS_KEY_DELETE_LEFT, NSERROR_OK, ro_toolbar_update_all_hotlists(), TOOLBAR_BUTTON_CLOSE, TOOLBAR_BUTTON_COLLAPSE, TOOLBAR_BUTTON_CREATE, TOOLBAR_BUTTON_DELETE, TOOLBAR_BUTTON_EXPAND, TOOLBAR_BUTTON_LAUNCH, and TOOLBAR_BUTTON_OPEN.

Referenced by ro_hotlist_init().

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

◆ hotlist_toolbar_save()

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

callback for saving of toolbar state in ro hotlist 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 245 of file hotlist.c.

References NSERROR_OK, nsoption_set_charp, and ro_gui_save_options().

Referenced by ro_hotlist_init().

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

◆ hotlist_toolbar_update()

static nserror hotlist_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 220 of file hotlist.c.

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

Referenced by ro_hotlist_init().

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

◆ ro_gui_hotlist_add_cleanup()

void ro_gui_hotlist_add_cleanup ( void  )

Clean up RMA storage used by the Message_HotlistAddURL protocol.

Definition at line 730 of file hotlist.c.

References hotlist_title, and hotlist_url.

Referenced by ro_gui_hotlist_add_page(), ro_gui_hotlist_addurl_bounce(), ro_gui_hotlist_scheduled_callback(), and ro_gui_user_message().

Here is the caller graph for this function:

◆ ro_gui_hotlist_add_page()

void ro_gui_hotlist_add_page ( struct nsurl url)

Add a URL to the hotlist.

This will be passed on to the core hotlist, then Message_HotlistAddURL will broadcast to any bookmark applications via the Hotlist Protocol.

Parameters
*urlThe URL to be added.

Definition at line 667 of file hotlist.c.

References ro_hotlist_message_hotlist_addurl::appname, hotlist_add_url(), hotlist_title, hotlist_url, message_HOTLIST_ADD_URL, nsoption_bool, nsurl_access(), nsurl_length(), riscos_schedule(), ro_gui_hotlist_add_cleanup(), ro_gui_hotlist_addurl_bounce(), ro_gui_hotlist_scheduled_callback(), ro_message_send_message(), ro_hotlist_message_hotlist_addurl::title, url_data::title, ro_hotlist_message_hotlist_addurl::url, and urldb_get_url_data().

Referenced by ro_gui_window_action_add_bookmark().

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

◆ ro_gui_hotlist_addurl_bounce()

static void ro_gui_hotlist_addurl_bounce ( wimp_message *  message)
static

Handle bounced Message_HotlistAddURL, so that RMA storage can be freed.

Parameters
messageThe bounced message content.

Definition at line 646 of file hotlist.c.

References hotlist_add_url(), hotlist_url, NSERROR_OK, nsurl_create(), nsurl_unref(), riscos_schedule(), ro_gui_hotlist_add_cleanup(), and ro_gui_hotlist_scheduled_callback().

Referenced by ro_gui_hotlist_add_page().

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

◆ ro_gui_hotlist_check_menu()

bool ro_gui_hotlist_check_menu ( wimp_menu *  menu)

Definition at line 618 of file hotlist.c.

References hotlist_window, and ro_hotlist_window::menu.

Referenced by ro_gui_interactive_help_request().

Here is the caller graph for this function:

◆ ro_gui_hotlist_check_window()

bool ro_gui_hotlist_check_window ( wimp_w  wh)

Definition at line 607 of file hotlist.c.

References ro_hotlist_window::core, hotlist_window, and ro_corewindow::wh.

Referenced by ro_gui_interactive_help_request().

Here is the caller graph for this function:

◆ ro_gui_hotlist_finalise()

nserror ro_gui_hotlist_finalise ( void  )

Free any resources allocated for the cookie window.

Returns
NSERROR_OK on success else appropriate error code on faliure.

Definition at line 586 of file hotlist.c.

References ro_hotlist_window::core, hotlist_fini(), hotlist_window, 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_hotlist_has_page()

bool ro_gui_hotlist_has_page ( struct nsurl url)

Report whether the hotlist contains a given URL.

This will be passed on to the core hotlist, unless we're configured to use an external hotlist in which case we always report false.

Parameters
urlThe URL to be tested.
Returns
true if the hotlist contains the URL; else false.

Definition at line 826 of file hotlist.c.

References hotlist_has_url(), nsoption_bool, and ro_hotlist_message_hotlist_addurl::url.

Referenced by ro_gui_url_bar_set_url(), ro_gui_url_bar_test_for_text_field_keypress(), and ro_gui_url_bar_update_hotlist().

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

◆ ro_gui_hotlist_initialise()

void ro_gui_hotlist_initialise ( void  )

initialise the hotlist window template ready for subsequent use.

Definition at line 579 of file hotlist.c.

References dialog_hotlist_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_hotlist_present()

nserror ro_gui_hotlist_present ( void  )

make the cookie window visible.

Returns
NSERROR_OK on success else appropriate error code on faliure.

Definition at line 539 of file hotlist.c.

References ro_hotlist_window::core, hotlist_window, NSERROR_OK, NSLOG, nsoption_bool, nsoption_charp, ro_gui_dialog_open_top(), ro_hotlist_init(), ro_warn_user(), ro_corewindow::toolbar, and ro_corewindow::wh.

Referenced by ro_gui_iconbar_click(), ro_gui_iconbar_menu_select(), ro_gui_window_handle_local_keypress(), ro_gui_window_menu_select(), and ro_gui_window_toolbar_click().

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

◆ ro_gui_hotlist_remove_cancelled()

static void ro_gui_hotlist_remove_cancelled ( query_id  id,
enum query_response  res,
void *  p 
)
static

Callback cancelling a URL delete query.

Parameters
idThe ID of the query calling us.
resThe user's response to the query.
pCallback data (always NULL).

Definition at line 771 of file hotlist.c.

References hotlist_delete_url, hotlist_query, nsurl_unref(), and QUERY_INVALID.

Here is the call graph for this function:

◆ ro_gui_hotlist_remove_confirmed()

static void ro_gui_hotlist_remove_confirmed ( query_id  id,
enum query_response  res,
void *  p 
)
static

Callback confirming a URL delete query.

Parameters
idThe ID of the query calling us.
resThe user's response to the query.
pCallback data (always NULL).

Definition at line 752 of file hotlist.c.

References hotlist_delete_url, hotlist_query, hotlist_remove_url(), nsurl_unref(), QUERY_INVALID, and ro_toolbar_update_all_hotlists().

Here is the call graph for this function:

◆ ro_gui_hotlist_remove_page()

void ro_gui_hotlist_remove_page ( struct nsurl url)

Remove a URL from the hotlist.

This will be passed on to the core hotlist, unless we're configured to use external hotlists in which case we ignore it.

Parameters
*urlThe URL to be removed.

Definition at line 789 of file hotlist.c.

References hotlist_delete_url, hotlist_has_url(), hotlist_query, hotlist_remove_url(), messages_get(), nsoption_bool, nsurl_ref(), nsurl_unref(), query_close(), QUERY_INVALID, query_user(), remove_funcs, ro_toolbar_update_all_hotlists(), and ro_hotlist_message_hotlist_addurl::url.

Referenced by ro_gui_window_action_remove_bookmark().

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

◆ ro_gui_hotlist_scheduled_callback()

static void ro_gui_hotlist_scheduled_callback ( void *  p)
static

Callback to schedule for the next available Null poll, by which point a hotlist client will have claimed the Message_HotlistAddURL and any details in RMA can safely be discarded.

Parameters
pUnused data pointer.

Definition at line 635 of file hotlist.c.

References ro_gui_hotlist_add_cleanup().

Referenced by ro_gui_hotlist_add_page(), and ro_gui_hotlist_addurl_bounce().

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

◆ ro_hotlist_init()

static nserror ro_hotlist_init ( void  )
static

Creates the window for the hotlist tree.

Returns
NSERROR_OK on success else appropriate error code on faliure.

Definition at line 424 of file hotlist.c.

References ro_hotlist_window::core, dialog_hotlist_template, dialog_saveas, ro_corewindow::draw, hotlist_draw(), HOTLIST_EXPORT, hotlist_key(), hotlist_manager_init(), hotlist_menu_prepare(), hotlist_menu_select(), hotlist_menu_warning(), hotlist_mouse(), hotlist_toolbar_click(), hotlist_toolbar_save(), hotlist_toolbar_update(), hotlist_window, ro_corewindow::key, ro_hotlist_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_HOTLIST_TOOLBAR, TOOLBAR_BUTTON_CLOSE, TOOLBAR_BUTTON_COLLAPSE, TOOLBAR_BUTTON_CREATE, TOOLBAR_BUTTON_DELETE, TOOLBAR_BUTTON_EXPAND, TOOLBAR_BUTTON_LAUNCH, 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_NEW_FOLDER, TREE_NEW_LINK, TREE_SELECT_ALL, TREE_SELECTION, TREE_SELECTION_DELETE, TREE_SELECTION_EDIT, TREE_SELECTION_LAUNCH, and ro_corewindow::wh.

Referenced by ro_gui_hotlist_present().

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

Variable Documentation

◆ dialog_hotlist_template

wimp_window* dialog_hotlist_template
static

riscos template for hotlist window

Definition at line 64 of file hotlist.c.

Referenced by ro_gui_hotlist_initialise(), and ro_hotlist_init().

◆ hotlist_delete_url

nsurl* hotlist_delete_url = NULL
static

◆ hotlist_query

query_id hotlist_query = QUERY_INVALID
static

Hotlist Query Handler.

Definition at line 67 of file hotlist.c.

Referenced by ro_gui_hotlist_remove_cancelled(), ro_gui_hotlist_remove_confirmed(), and ro_gui_hotlist_remove_page().

◆ hotlist_title

char* hotlist_title = NULL
static

Title area claimed from RMA.

Definition at line 94 of file hotlist.c.

Referenced by ro_gui_hotlist_add_cleanup(), and ro_gui_hotlist_add_page().

◆ hotlist_url

char* hotlist_url = NULL
static

URL area claimed from RMA.

Definition at line 92 of file hotlist.c.

Referenced by ro_gui_hotlist_add_cleanup(), ro_gui_hotlist_add_page(), and ro_gui_hotlist_addurl_bounce().

◆ hotlist_window

struct ro_hotlist_window* hotlist_window = NULL
static

◆ remove_funcs

const query_callback remove_funcs
static
Initial value:
= {
}
static void ro_gui_hotlist_remove_cancelled(query_id id, enum query_response res, void *p)
Callback cancelling a URL delete query.
Definition: hotlist.c:771
static void ro_gui_hotlist_remove_confirmed(query_id id, enum query_response res, void *p)
Callback confirming a URL delete query.
Definition: hotlist.c:752

removal query dialog callbacks.

Definition at line 782 of file hotlist.c.

Referenced by ro_gui_hotlist_remove_page().