Remmina - The GTK+ Remote Desktop Client  v1.4.25
Remmina is a remote desktop client written in GTK+, aiming to be useful for system administrators and travellers, who need to work with lots of remote computers in front of either large monitors or tiny netbooks. Remmina supports multiple network protocols in an integrated and consistent user interface. Currently RDP, VNC, NX, XDMCP and SSH are supported.
remmina_plugin_python_common.c File Reference

Go to the source code of this file.

Functions

PyObject * remmina_plugin_python_last_result (void)
 Gets the result of the last python method call. More...
 
PyObject * remmina_plugin_python_last_result_set (PyObject *last_result)
 Sets the result of the last python method call. More...
 
gboolean remmina_plugin_python_check_error (void)
 Checks if an error has occurred and prints it. More...
 
void remmina_plugin_python_log_method_call (PyObject *instance, const char *method)
 Prints a log message to inform the user a python message has been called. More...
 
long remmina_plugin_python_get_attribute_long (PyObject *instance, const char *attr_name, long def)
 Gets the attribute as long value. More...
 
gboolean remmina_plugin_python_check_attribute (PyObject *instance, const char *attr_name)
 Checks if a given attribute exists. More...
 
void * remmina_plugin_python_malloc (int bytes)
 Allocates memory and checks for errors before returning. More...
 
char * remmina_plugin_python_copy_string_from_python (PyObject *string, Py_ssize_t len)
 Copies a string from a Python object to a new point in memory. More...
 
void remmina_plugin_python_set_service (RemminaPluginService *service)
 Sets the pointer to the plugin service of Remmina. More...
 
RemminaPluginServiceremmina_plugin_python_get_service (void)
 
void remmina_plugin_python_add_plugin (PyPlugin *plugin)
 Registers the given plugin if no other plugin with the same name has been already registered. More...
 
RemminaTypeHint remmina_plugin_python_to_generic (PyObject *field, gpointer *target)
 Extracts data from a PyObject instance to a generic pointer and returns a type hint if it could be determined. More...
 
PyPluginremmina_plugin_python_get_plugin (const char *name)
 Tries to find the Python plugin matching to the given instance of RemminaPlugin. More...
 
void init_pygobject ()
 Initializes the pygobject library. More...
 
GtkWidget * new_pywidget (GObject *obj)
 Creates a new GtkWidget. More...
 
GtkWidget * get_pywidget (PyObject *obj)
 Extracts a GtkWidget from a PyObject instance. More...
 

Variables

static PyObject * __last_result
 A cache to store the last result that has been returned by the Python code using CallPythonMethod (. More...
 
static GPtrArray * plugin_map = NULL
 
static RemminaPluginServiceremmina_plugin_service
 
const char * ATTR_NAME = "name"
 
const char * ATTR_ICON_NAME = "icon_name"
 
const char * ATTR_DESCRIPTION = "description"
 
const char * ATTR_VERSION = "version"
 
const char * ATTR_ICON_NAME_SSH = "icon_name_ssh"
 
const char * ATTR_FEATURES = "features"
 
const char * ATTR_BASIC_SETTINGS = "basic_settings"
 
const char * ATTR_ADVANCED_SETTINGS = "advanced_settings"
 
const char * ATTR_SSH_SETTING = "ssh_setting"
 
const char * ATTR_EXPORT_HINTS = "export_hints"
 
const char * ATTR_PREF_LABEL = "pref_label"
 
const char * ATTR_INIT_ORDER = "init_order"
 
static const int REASONABLE_LIMIT_FOR_MALLOC = 1024 * 1024
 To prevent some memory related attacks or accidental allocation of an excessive amount of byes, this limit should always be used to check for a sane amount of bytes to allocate. More...
 

Detailed Description

Author
Mathias Winterhalter
Date
07.04.2021

Definition in file remmina_plugin_python_common.c.

Function Documentation

◆ get_pywidget()

GtkWidget* get_pywidget ( PyObject *  obj)

Extracts a GtkWidget from a PyObject instance.

Parameters
obj
Returns

Definition at line 309 of file remmina_plugin_python_common.c.

◆ init_pygobject()

void init_pygobject ( void  )

Initializes the pygobject library.

This needs to be called before any Python plugin is being initialized.

Definition at line 299 of file remmina_plugin_python_common.c.

◆ new_pywidget()

GtkWidget* new_pywidget ( GObject *  obj)

Creates a new GtkWidget.

Parameters
obj
Returns

Definition at line 304 of file remmina_plugin_python_common.c.

◆ remmina_plugin_python_add_plugin()

void remmina_plugin_python_add_plugin ( PyPlugin plugin)

Registers the given plugin if no other plugin with the same name has been already registered.

Definition at line 204 of file remmina_plugin_python_common.c.

◆ remmina_plugin_python_check_attribute()

gboolean remmina_plugin_python_check_attribute ( PyObject *  instance,
const char *  attr_name 
)

Checks if a given attribute exists.

Parameters
instanceThe object to check for the attribute.
attr_nameThe name of the attribute to check.
Returns
Returns TRUE if the attribute exists.

Definition at line 139 of file remmina_plugin_python_common.c.

◆ remmina_plugin_python_check_error()

gboolean remmina_plugin_python_check_error ( void  )

Checks if an error has occurred and prints it.

Returns
Returns TRUE if an error has occurred.

Definition at line 98 of file remmina_plugin_python_common.c.

◆ remmina_plugin_python_copy_string_from_python()

char* remmina_plugin_python_copy_string_from_python ( PyObject *  string,
Py_ssize_t  len 
)

Copies a string from a Python object to a new point in memory.

Parameters
stringThe python object, containing the string to copy.
lenThe length of the string to copy.
Returns
A char pointer to the new copy of the string.

Definition at line 172 of file remmina_plugin_python_common.c.

◆ remmina_plugin_python_get_attribute_long()

long remmina_plugin_python_get_attribute_long ( PyObject *  instance,
const char *  attr_name,
long  def 
)

Gets the attribute as long value.

Parameters
instanceThe instance of the object to get the attribute.
constant_nameThe name of the attribute to get.
defThe value to return if the attribute doesn't exist or is not set.
Returns
The value attribute as long.

Definition at line 124 of file remmina_plugin_python_common.c.

◆ remmina_plugin_python_get_plugin()

PyPlugin* remmina_plugin_python_get_plugin ( const char *  name)

Tries to find the Python plugin matching to the given instance of RemminaPlugin.

Parameters
plugin_mapAn array of PyPlugin pointers to search.
instanceThe RemminaPlugin instance to find the correct PyPlugin instance for.
Returns
A pointer to a PyPlugin instance if successful. Otherwise NULL is returned.

Definition at line 280 of file remmina_plugin_python_common.c.

◆ remmina_plugin_python_get_service()

RemminaPluginService* remmina_plugin_python_get_service ( void  )

Definition at line 199 of file remmina_plugin_python_common.c.

◆ remmina_plugin_python_last_result()

PyObject* remmina_plugin_python_last_result ( void  )

Gets the result of the last python method call.

Definition at line 84 of file remmina_plugin_python_common.c.

◆ remmina_plugin_python_last_result_set()

PyObject* remmina_plugin_python_last_result_set ( PyObject *  result)

Sets the result of the last python method call.

Returns
Returns the passed result (it's done to be compatible with the CallPythonMethod macro).

Definition at line 91 of file remmina_plugin_python_common.c.

◆ remmina_plugin_python_log_method_call()

void remmina_plugin_python_log_method_call ( PyObject *  instance,
const char *  method 
)

Prints a log message to inform the user a python message has been called.

This method is called from the CALL_PYTHON macro if WITH_PYTHON_TRACE_CALLS is defined.

Parameters
instanceThe instance that contains the called method.
methodThe name of the method called.

Definition at line 111 of file remmina_plugin_python_common.c.

◆ remmina_plugin_python_malloc()

void* remmina_plugin_python_malloc ( int  bytes)

Allocates memory and checks for errors before returning.

Parameters
bytesAmount of bytes to allocate.
Returns
Address to the allocated memory.

Definition at line 154 of file remmina_plugin_python_common.c.

◆ remmina_plugin_python_set_service()

void remmina_plugin_python_set_service ( RemminaPluginService service)

Sets the pointer to the plugin service of Remmina.

Definition at line 194 of file remmina_plugin_python_common.c.

◆ remmina_plugin_python_to_generic()

RemminaTypeHint remmina_plugin_python_to_generic ( PyObject *  field,
gpointer *  target 
)

Extracts data from a PyObject instance to a generic pointer and returns a type hint if it could be determined.

Definition at line 224 of file remmina_plugin_python_common.c.

Variable Documentation

◆ __last_result

PyObject* __last_result
static

A cache to store the last result that has been returned by the Python code using CallPythonMethod (.

See also
remmina_plugin_python_common.h)

Definition at line 56 of file remmina_plugin_python_common.c.

◆ ATTR_ADVANCED_SETTINGS

const char* ATTR_ADVANCED_SETTINGS = "advanced_settings"

Definition at line 68 of file remmina_plugin_python_common.c.

◆ ATTR_BASIC_SETTINGS

const char* ATTR_BASIC_SETTINGS = "basic_settings"

Definition at line 67 of file remmina_plugin_python_common.c.

◆ ATTR_DESCRIPTION

const char* ATTR_DESCRIPTION = "description"

Definition at line 63 of file remmina_plugin_python_common.c.

◆ ATTR_EXPORT_HINTS

const char* ATTR_EXPORT_HINTS = "export_hints"

Definition at line 70 of file remmina_plugin_python_common.c.

◆ ATTR_FEATURES

const char* ATTR_FEATURES = "features"

Definition at line 66 of file remmina_plugin_python_common.c.

◆ ATTR_ICON_NAME

const char* ATTR_ICON_NAME = "icon_name"

Definition at line 62 of file remmina_plugin_python_common.c.

◆ ATTR_ICON_NAME_SSH

const char* ATTR_ICON_NAME_SSH = "icon_name_ssh"

Definition at line 65 of file remmina_plugin_python_common.c.

◆ ATTR_INIT_ORDER

const char* ATTR_INIT_ORDER = "init_order"

Definition at line 72 of file remmina_plugin_python_common.c.

◆ ATTR_NAME

const char* ATTR_NAME = "name"

Definition at line 61 of file remmina_plugin_python_common.c.

◆ ATTR_PREF_LABEL

const char* ATTR_PREF_LABEL = "pref_label"

Definition at line 71 of file remmina_plugin_python_common.c.

◆ ATTR_SSH_SETTING

const char* ATTR_SSH_SETTING = "ssh_setting"

Definition at line 69 of file remmina_plugin_python_common.c.

◆ ATTR_VERSION

const char* ATTR_VERSION = "version"

Definition at line 64 of file remmina_plugin_python_common.c.

◆ plugin_map

GPtrArray* plugin_map = NULL
static

Definition at line 57 of file remmina_plugin_python_common.c.

◆ REASONABLE_LIMIT_FOR_MALLOC

const int REASONABLE_LIMIT_FOR_MALLOC = 1024 * 1024
static

To prevent some memory related attacks or accidental allocation of an excessive amount of byes, this limit should always be used to check for a sane amount of bytes to allocate.

Definition at line 78 of file remmina_plugin_python_common.c.

◆ remmina_plugin_service

RemminaPluginService* remmina_plugin_service
static

Definition at line 59 of file remmina_plugin_python_common.c.