1 /* 2 * Remmina - The GTK+ Remote Desktop Client 3 * Copyright (C) 2010-2011 Vic Lee 4 * Copyright (C) 2014-2015 Antenore Gatta, Fabio Castelli, Giovanni Panozzo 5 * Copyright (C) 2016-2021 Antenore Gatta, Giovanni Panozzo 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, 20 * Boston, MA 02110-1301, USA. 21 * 22 * In addition, as a special exception, the copyright holders give 23 * permission to link the code of portions of this program with the 24 * OpenSSL library under certain conditions as described in each 25 * individual source file, and distribute linked combinations 26 * including the two. 27 * You must obey the GNU General Public License in all respects 28 * for all of the code used other than OpenSSL. * If you modify 29 * file(s) with this exception, you may extend this exception to your 30 * version of the file(s), but you are not obligated to do so. * If you 31 * do not wish to do so, delete this exception statement from your 32 * version. * If you delete this exception statement from all source 33 * files in the program, then also delete it here. 34 * 35 */ 36 37 #pragma once 38 39 #include <stdarg.h> 40 #include <remmina/types.h> 41 #include "remmina/remmina_trace_calls.h" 42 43 G_BEGIN_DECLS 44 45 typedef enum { 46 REMMINA_PLUGIN_TYPE_PROTOCOL = 0, 47 REMMINA_PLUGIN_TYPE_ENTRY = 1, 48 REMMINA_PLUGIN_TYPE_FILE = 2, 49 REMMINA_PLUGIN_TYPE_TOOL = 3, 50 REMMINA_PLUGIN_TYPE_PREF = 4, 51 REMMINA_PLUGIN_TYPE_SECRET = 5 52 } RemminaPluginType; 53 54 typedef struct _RemminaPlugin { 55 RemminaPluginType type; 56 const gchar * name; 57 const gchar * description; 58 const gchar * domain; 59 const gchar * version; 60 } RemminaPlugin; 61 62 typedef struct _RemminaProtocolPlugin _RemminaProtocolPlugin; 63 typedef struct _RemminaProtocolPlugin { 64 RemminaPluginType type; 65 const gchar * name; 66 const gchar * description; 67 const gchar * domain; 68 const gchar * version; 69 70 const gchar * icon_name; 71 const gchar * icon_name_ssh; 72 const RemminaProtocolSetting * basic_settings; 73 const RemminaProtocolSetting * advanced_settings; 74 RemminaProtocolSSHSetting ssh_setting; 75 const RemminaProtocolFeature * features; 76 77 void (*init)(RemminaProtocolWidget *gp); 78 gboolean (*open_connection)(RemminaProtocolWidget *gp); 79 gboolean (*close_connection)(RemminaProtocolWidget *gp); 80 gboolean (*query_feature)(RemminaProtocolWidget *gp, const RemminaProtocolFeature *feature); 81 void (*call_feature)(RemminaProtocolWidget *gp, const RemminaProtocolFeature *feature); 82 void (*send_keystrokes)(RemminaProtocolWidget *gp, const guint keystrokes[], const gint keylen); 83 gboolean (*get_plugin_screenshot)(RemminaProtocolWidget *gp, RemminaPluginScreenshotData *rpsd); 84 gboolean (*map_event)(RemminaProtocolWidget *gp); 85 gboolean (*unmap_event)(RemminaProtocolWidget *gp); 86 } RemminaProtocolPlugin; 87 88 typedef struct _RemminaEntryPlugin { 89 RemminaPluginType type; 90 const gchar * name; 91 const gchar * description; 92 const gchar * domain; 93 const gchar * version; 94 95 void (*entry_func)(void); 96 } RemminaEntryPlugin; 97 98 typedef struct _RemminaFilePlugin { 99 RemminaPluginType type; 100 const gchar * name; 101 const gchar * description; 102 const gchar * domain; 103 const gchar * version; 104 105 gboolean (*import_test_func)(const gchar *from_file); 106 RemminaFile * (*import_func)(const gchar * from_file); 107 gboolean (*export_test_func)(RemminaFile *file); 108 gboolean (*export_func)(RemminaFile *file, const gchar *to_file); 109 const gchar * export_hints; 110 } RemminaFilePlugin; 111 112 typedef struct _RemminaToolPlugin { 113 RemminaPluginType type; 114 const gchar * name; 115 const gchar * description; 116 const gchar * domain; 117 const gchar * version; 118 119 void (*exec_func)(void); 120 } RemminaToolPlugin; 121 122 typedef struct _RemminaPrefPlugin { 123 RemminaPluginType type; 124 const gchar * name; 125 const gchar * description; 126 const gchar * domain; 127 const gchar * version; 128 129 const gchar * pref_label; 130 GtkWidget * (*get_pref_body)(void); 131 } RemminaPrefPlugin; 132 133 typedef struct _RemminaSecretPlugin { 134 RemminaPluginType type; 135 const gchar * name; 136 const gchar * description; 137 const gchar * domain; 138 const gchar * version; 139 int init_order; 140 141 gboolean (*init)(void); 142 gboolean (*is_service_available)(void); 143 void (*store_password)(RemminaFile *remminafile, const gchar *key, const gchar *password); 144 gchar * (*get_password)(RemminaFile * remminafile, const gchar *key); 145 void (*delete_password)(RemminaFile *remminafile, const gchar *key); 146 } RemminaSecretPlugin; 147 148 /* Plugin Service is a struct containing a list of function pointers, 149 * which is passed from Remmina main program to the plugin module 150 * through the plugin entry function remmina_plugin_entry() */ 151 typedef struct _RemminaPluginService { 152 gboolean (*register_plugin)(RemminaPlugin *plugin); 153 154 gint (*protocol_plugin_get_width)(RemminaProtocolWidget *gp); 155 void (*protocol_plugin_set_width)(RemminaProtocolWidget *gp, gint width); 156 gint (*protocol_plugin_get_height)(RemminaProtocolWidget *gp); 157 void (*protocol_plugin_set_height)(RemminaProtocolWidget *gp, gint height); 158 RemminaScaleMode (*remmina_protocol_widget_get_current_scale_mode)(RemminaProtocolWidget *gp); 159 gboolean (*protocol_plugin_get_expand)(RemminaProtocolWidget *gp); 160 void (*protocol_plugin_set_expand)(RemminaProtocolWidget *gp, gboolean expand); 161 gboolean (*protocol_plugin_has_error)(RemminaProtocolWidget *gp); 162 void (*protocol_plugin_set_error)(RemminaProtocolWidget *gp, const gchar *fmt, ...); 163 gboolean (*protocol_plugin_is_closed)(RemminaProtocolWidget *gp); 164 RemminaFile * (*protocol_plugin_get_file)(RemminaProtocolWidget * gp); 165 void (*protocol_plugin_emit_signal)(RemminaProtocolWidget *gp, const gchar *signal_name); 166 void (*protocol_plugin_register_hostkey)(RemminaProtocolWidget *gp, GtkWidget *widget); 167 gchar * (*protocol_plugin_start_direct_tunnel)(RemminaProtocolWidget * gp, gint default_port, gboolean port_plus); 168 gboolean (*protocol_plugin_start_reverse_tunnel)(RemminaProtocolWidget *gp, gint local_port); 169 gboolean (*protocol_plugin_start_xport_tunnel)(RemminaProtocolWidget *gp, RemminaXPortTunnelInitFunc init_func); 170 void (*protocol_plugin_set_display)(RemminaProtocolWidget *gp, gint display); 171 void (*protocol_plugin_signal_connection_closed)(RemminaProtocolWidget *gp); 172 void (*protocol_plugin_signal_connection_opened)(RemminaProtocolWidget *gp); 173 void (*protocol_plugin_update_align)(RemminaProtocolWidget *gp); 174 void (*protocol_plugin_lock_dynres)(RemminaProtocolWidget *gp); 175 void (*protocol_plugin_unlock_dynres)(RemminaProtocolWidget *gp); 176 void (*protocol_plugin_desktop_resize)(RemminaProtocolWidget *gp); 177 gint (*protocol_plugin_init_auth)(RemminaProtocolWidget *gp, RemminaMessagePanelFlags pflags, const gchar *title, const gchar *default_username, const gchar *default_password, const gchar *default_domain, const gchar *password_prompt); 178 gint (*protocol_plugin_init_certificate)(RemminaProtocolWidget *gp, const gchar *subject, const gchar *issuer, const gchar *fingerprint); 179 gint (*protocol_plugin_changed_certificate)(RemminaProtocolWidget *gp, const gchar *subject, const gchar *issuer, const gchar *new_fingerprint, const gchar *old_fingerprint); 180 gchar * (*protocol_plugin_init_get_username)(RemminaProtocolWidget * gp); 181 gchar * (*protocol_plugin_init_get_password)(RemminaProtocolWidget * gp); 182 gchar * (*protocol_plugin_init_get_domain)(RemminaProtocolWidget * gp); 183 gboolean (*protocol_plugin_init_get_savepassword)(RemminaProtocolWidget *gp); 184 gint (*protocol_plugin_init_authx509)(RemminaProtocolWidget *gp); 185 gchar * (*protocol_plugin_init_get_cacert)(RemminaProtocolWidget * gp); 186 gchar * (*protocol_plugin_init_get_cacrl)(RemminaProtocolWidget * gp); 187 gchar * (*protocol_plugin_init_get_clientcert)(RemminaProtocolWidget * gp); 188 gchar * (*protocol_plugin_init_get_clientkey)(RemminaProtocolWidget * gp); 189 void (*protocol_plugin_init_save_cred)(RemminaProtocolWidget *gp); 190 void (*protocol_plugin_init_show_listen)(RemminaProtocolWidget *gp, gint port); 191 void (*protocol_plugin_init_show_retry)(RemminaProtocolWidget *gp); 192 void (*protocol_plugin_init_show)(RemminaProtocolWidget *gp); 193 void (*protocol_plugin_init_hide)(RemminaProtocolWidget *gp); 194 gboolean (*protocol_plugin_ssh_exec)(RemminaProtocolWidget *gp, gboolean wait, const gchar *fmt, ...); 195 void (*protocol_plugin_chat_open)(RemminaProtocolWidget *gp, const gchar *name, void (*on_send)(RemminaProtocolWidget *gp, const gchar *text), void (*on_destroy)(RemminaProtocolWidget *gp)); 196 void (*protocol_plugin_chat_close)(RemminaProtocolWidget *gp); 197 void (*protocol_plugin_chat_receive)(RemminaProtocolWidget *gp, const gchar *text); 198 void (*protocol_plugin_send_keys_signals)(GtkWidget *widget, const guint *keyvals, int length, GdkEventType action); 199 200 gchar * (*file_get_user_datadir)(void); 201 202 RemminaFile * (*file_new)(void); 203 const gchar * (*file_get_path)(RemminaFile * remminafile); 204 void (*file_set_string)(RemminaFile *remminafile, const gchar *setting, const gchar *value); 205 const gchar * (*file_get_string)(RemminaFile * remminafile, const gchar *setting); 206 gchar * (*file_get_secret)(RemminaFile * remminafile, const gchar *setting); 207 void (*file_set_int)(RemminaFile *remminafile, const gchar *setting, gint value); 208 gint (*file_get_int)(RemminaFile *remminafile, const gchar *setting, gint default_value); 209 void (*file_unsave_passwords)(RemminaFile *remminafile); 210 211 void (*pref_set_value)(const gchar *key, const gchar *value); 212 gchar * (*pref_get_value)(const gchar * key); 213 gint (*pref_get_scale_quality)(void); 214 gint (*pref_get_sshtunnel_port)(void); 215 gint (*pref_get_ssh_loglevel)(void); 216 gboolean (*pref_get_ssh_parseconfig)(void); 217 guint (*pref_keymap_get_keyval)(const gchar *keymap, guint keyval); 218 219 void (*_remmina_debug)(const gchar *func, const gchar *fmt, ...); 220 void (*log_print)(const gchar *text); 221 void (*log_printf)(const gchar *fmt, ...); 222 223 void (*ui_register)(GtkWidget *widget); 224 225 GtkWidget * (*open_connection)(RemminaFile * remminafile, GCallback disconnect_cb, gpointer data, guint *handler); 226 gint (*open_unix_sock)(const char *unixsock); 227 void (*get_server_port)(const gchar *server, gint defaultport, gchar **host, gint *port); 228 gboolean (*is_main_thread)(void); 229 gboolean (*gtksocket_available)(void); 230 gint (*get_profile_remote_width)(RemminaProtocolWidget *gp); 231 gint (*get_profile_remote_height)(RemminaProtocolWidget *gp); 232 } RemminaPluginService; 233 234 /* "Prototype" of the plugin entry function */ 235 typedef gboolean (*RemminaPluginEntryFunc) (RemminaPluginService *service); 236 237 G_END_DECLS 238