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

Automated RISC OS message routing (implementation). More...

#include <assert.h>
#include <stdbool.h>
#include <stdlib.h>
#include "oslib/os.h"
#include "oslib/wimp.h"
#include "utils/log.h"
#include "riscos/message.h"
#include "riscos/gui.h"
Include dependency graph for message.c:

Go to the source code of this file.

Data Structures

struct  active_message
 

Functions

static struct active_messagero_message_add (unsigned int message_code, void(*callback)(wimp_message *message))
 
static void ro_message_free (int ref)
 
bool ro_message_send_message (wimp_event_no event, wimp_message *message, wimp_t task, void(*callback)(wimp_message *message))
 Sends a message and registers a return route for a bounce. More...
 
bool ro_message_send_message_to_window (wimp_event_no event, wimp_message *message, wimp_w to_w, wimp_i to_i, void(*callback)(wimp_message *message), wimp_t *to_t)
 Sends a message and registers a return route for a bounce. More...
 
bool ro_message_register_handler (wimp_message *message, unsigned int message_code, void(*callback)(wimp_message *message))
 Registers a return route for a message. More...
 
bool ro_message_register_route (unsigned int message_code, void(*callback)(wimp_message *message))
 Registers a route for a message code. More...
 
bool ro_message_handle_message (wimp_event_no event, wimp_message *message)
 Attempts to route a message. More...
 

Variables

struct active_messagecurrent_messages = NULL
 

Detailed Description

Automated RISC OS message routing (implementation).

Definition in file message.c.

Function Documentation

◆ ro_message_add()

struct active_message * ro_message_add ( unsigned int  message_code,
void(*)(wimp_message *message)  callback 
)
static

Definition at line 165 of file message.c.

References active_message::callback, current_messages, active_message::id, active_message::message_code, active_message::next, and active_message::previous.

Referenced by ro_message_register_handler(), and ro_message_register_route().

Here is the caller graph for this function:

◆ ro_message_free()

void ro_message_free ( int  ref)
static

Definition at line 234 of file message.c.

References current_messages, active_message::id, active_message::next, and active_message::previous.

Referenced by ro_message_handle_message().

Here is the caller graph for this function:

◆ ro_message_handle_message()

bool ro_message_handle_message ( wimp_event_no  event,
wimp_message *  message 
)

Attempts to route a message.

Parameters
eventwimp event
messagethe message to attempt to route
Returns
true if message was routed, false otherwise

Definition at line 192 of file message.c.

References active_message::callback, current_messages, active_message::id, active_message::message_code, active_message::next, and ro_message_free().

Referenced by ro_gui_user_message().

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

◆ ro_message_register_handler()

bool ro_message_register_handler ( wimp_message *  message,
unsigned int  message_code,
void(*)(wimp_message *message)  callback 
)

Registers a return route for a message.

This function must be called after wimp_send_message so that a valid value is present in the my_ref field.

Parameters
messagethe message to register a route back for
message_codethe message action code to route
callbackthe code to call for a matched action
Returns
true on success, false on memory exhaustion

Definition at line 134 of file message.c.

References active_message::callback, active_message::id, active_message::message_code, and ro_message_add().

Referenced by ro_message_send_message(), and ro_message_send_message_to_window().

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

◆ ro_message_register_route()

bool ro_message_register_route ( unsigned int  message_code,
void(*)(wimp_message *message)  callback 
)

Registers a route for a message code.

Parameters
message_codethe message action code to route
callbackthe code to call for a matched action
Returns
true on success, false on memory exhaustion

Definition at line 157 of file message.c.

References active_message::callback, active_message::message_code, and ro_message_add().

Referenced by gui_init().

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

◆ ro_message_send_message()

bool ro_message_send_message ( wimp_event_no  event,
wimp_message *  message,
wimp_t  task,
void(*)(wimp_message *message)  callback 
)

Sends a message and registers a return route for a bounce.

Parameters
eventthe message event type
messagethe message to register a route back for
taskthe task to send a message to, or 0 for broadcast
callbackthe code to call on a bounce
Returns
true on success, false otherwise

Definition at line 57 of file message.c.

References active_message::callback, NSLOG, ro_message_register_handler(), and ro_warn_user().

Referenced by ro_gui_hotlist_add_page(), ro_gui_selection_prepare_paste(), ro_gui_selection_prepare_paste_dataload(), ro_gui_selection_prepare_paste_datasave(), ro_gui_selection_send_dragging(), ro_gui_send_datasave(), and ro_gui_view_source().

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

◆ ro_message_send_message_to_window()

bool ro_message_send_message_to_window ( wimp_event_no  event,
wimp_message *  message,
wimp_w  to_w,
wimp_i  to_i,
void(*)(wimp_message *message)  callback,
wimp_t *  to_t 
)

Sends a message and registers a return route for a bounce.

Parameters
eventthe message event type
messagethe message to register a route back for
to_wthe window to send the message to
to_ithe icon
callbackthe code to call on a bounce
to_treceives the task handle of the window's creator
Returns
true on success, false otherwise

Definition at line 94 of file message.c.

References active_message::callback, NSLOG, ro_message_register_handler(), and ro_warn_user().

Referenced by ro_gui_save_drag_end(), and ro_gui_selection_send_dragging().

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

Variable Documentation

◆ current_messages

struct active_message* current_messages = NULL

Definition at line 41 of file message.c.

Referenced by ro_message_add(), ro_message_free(), and ro_message_handle_message().