1 /* 2 * plugins.h 3 * vim: expandtab:ts=4:sts=4:sw=4 4 * 5 * Copyright (C) 2012 - 2019 James Booth <boothj5@gmail.com> 6 * 7 * This file is part of Profanity. 8 * 9 * Profanity is free software: you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by 11 * the Free Software Foundation, either version 3 of the License, or 12 * (at your option) any later version. 13 * 14 * Profanity is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with Profanity. If not, see <https://www.gnu.org/licenses/>. 21 * 22 * In addition, as a special exception, the copyright holders give permission to 23 * link the code of portions of this program with the OpenSSL library under 24 * certain conditions as described in each individual source file, and 25 * distribute linked combinations including the two. 26 * 27 * You must obey the GNU General Public License in all respects for all of the 28 * code used other than OpenSSL. If you modify file(s) with this exception, you 29 * may extend this exception to your version of the file(s), but you are not 30 * obligated to do so. If you do not wish to do so, delete this exception 31 * statement from your version. If you delete this exception statement from all 32 * source files in the program, then also delete it here. 33 * 34 */ 35 36 #ifndef PLUGINS_PLUGINS_H 37 #define PLUGINS_PLUGINS_H 38 39 #include "command/cmd_defs.h" 40 41 typedef enum { 42 LANG_PYTHON, 43 LANG_C 44 } lang_t; 45 46 typedef struct prof_plugins_install_t 47 { 48 GSList* installed; 49 GSList* failed; 50 } PluginsInstallResult; 51 52 typedef struct prof_plugin_t 53 { 54 char* name; 55 lang_t lang; 56 void* module; 57 void (*init_func)(struct prof_plugin_t* plugin, const char* const version, 58 const char* const status, const char* const account_name, const char* const fulljid); 59 60 gboolean (*contains_hook)(struct prof_plugin_t* plugin, const char* const hook); 61 62 void (*on_start_func)(struct prof_plugin_t* plugin); 63 void (*on_shutdown_func)(struct prof_plugin_t* plugin); 64 void (*on_unload_func)(struct prof_plugin_t* plugin); 65 66 void (*on_connect_func)(struct prof_plugin_t* plugin, const char* const account_name, const char* const fulljid); 67 void (*on_disconnect_func)(struct prof_plugin_t* plugin, const char* const account_name, 68 const char* const fulljid); 69 70 char* (*pre_chat_message_display)(struct prof_plugin_t* plugin, const char* const barejid, const char* const resource, const char* message); 71 void (*post_chat_message_display)(struct prof_plugin_t* plugin, const char* const barejid, const char* const resource, const char* message); 72 char* (*pre_chat_message_send)(struct prof_plugin_t* plugin, const char* const barejid, const char* message); 73 void (*post_chat_message_send)(struct prof_plugin_t* plugin, const char* const barejid, const char* message); 74 75 char* (*pre_room_message_display)(struct prof_plugin_t* plugin, const char* const barejid, const char* const nick, 76 const char* message); 77 void (*post_room_message_display)(struct prof_plugin_t* plugin, const char* const barejid, const char* const nick, 78 const char* message); 79 char* (*pre_room_message_send)(struct prof_plugin_t* plugin, const char* const barejid, const char* message); 80 void (*post_room_message_send)(struct prof_plugin_t* plugin, const char* const barejid, const char* message); 81 void (*on_room_history_message)(struct prof_plugin_t* plugin, const char* const barejid, const char* const nick, const char* const message, 82 const char* const timestamp); 83 84 char* (*pre_priv_message_display)(struct prof_plugin_t* plugin, const char* const barejid, const char* const nick, 85 const char* message); 86 void (*post_priv_message_display)(struct prof_plugin_t* plugin, const char* const barejid, const char* const nick, 87 const char* message); 88 char* (*pre_priv_message_send)(struct prof_plugin_t* plugin, const char* const barejid, const char* const nick, 89 const char* const message); 90 void (*post_priv_message_send)(struct prof_plugin_t* plugin, const char* const barejid, const char* const nick, 91 const char* const message); 92 93 char* (*on_message_stanza_send)(struct prof_plugin_t* plugin, const char* const text); 94 gboolean (*on_message_stanza_receive)(struct prof_plugin_t* plugin, const char* const text); 95 96 char* (*on_presence_stanza_send)(struct prof_plugin_t* plugin, const char* const text); 97 gboolean (*on_presence_stanza_receive)(struct prof_plugin_t* plugin, const char* const text); 98 99 char* (*on_iq_stanza_send)(struct prof_plugin_t* plugin, const char* const text); 100 gboolean (*on_iq_stanza_receive)(struct prof_plugin_t* plugin, const char* const text); 101 102 void (*on_contact_offline)(struct prof_plugin_t* plugin, const char* const barejid, const char* const resource, 103 const char* const status); 104 void (*on_contact_presence)(struct prof_plugin_t* plugin, const char* const barejid, const char* const resource, 105 const char* const presence, const char* const status, const int priority); 106 107 void (*on_chat_win_focus)(struct prof_plugin_t* plugin, const char* const barejid); 108 void (*on_room_win_focus)(struct prof_plugin_t* plugin, const char* const barejid); 109 } ProfPlugin; 110 111 void plugins_init(void); 112 GSList* plugins_unloaded_list(void); 113 GList* plugins_loaded_list(void); 114 char* plugins_autocomplete(const char* const input, gboolean previous); 115 void plugins_reset_autocomplete(void); 116 void plugins_shutdown(void); 117 118 void plugins_free_install_result(PluginsInstallResult* result); 119 120 gboolean plugins_install(const char* const plugin_name, const char* const filename, GString* error_message); 121 gboolean plugins_uninstall(const char* const plugin_name); 122 gboolean plugins_update(const char* const plugin_name, const char* const filename, GString* error_message); 123 PluginsInstallResult* plugins_install_all(const char* const path); 124 gboolean plugins_load(const char* const name, GString* error_message); 125 GSList* plugins_load_all(void); 126 gboolean plugins_unload(const char* const name); 127 gboolean plugins_unload_all(void); 128 gboolean plugins_reload(const char* const name, GString* error_message); 129 void plugins_reload_all(void); 130 131 void plugins_on_start(void); 132 void plugins_on_shutdown(void); 133 134 void plugins_on_connect(const char* const account_name, const char* const fulljid); 135 void plugins_on_disconnect(const char* const account_name, const char* const fulljid); 136 137 char* plugins_pre_chat_message_display(const char* const barejid, const char* const resource, const char* message); 138 void plugins_post_chat_message_display(const char* const barejid, const char* const resource, const char* message); 139 char* plugins_pre_chat_message_send(const char* const barejid, const char* message); 140 void plugins_post_chat_message_send(const char* const barejid, const char* message); 141 142 char* plugins_pre_room_message_display(const char* const barejid, const char* const nick, const char* message); 143 void plugins_post_room_message_display(const char* const barejid, const char* const nick, const char* message); 144 char* plugins_pre_room_message_send(const char* const barejid, const char* message); 145 void plugins_post_room_message_send(const char* const barejid, const char* message); 146 void plugins_on_room_history_message(const char* const barejid, const char* const nick, const char* const message, 147 GDateTime* timestamp); 148 149 char* plugins_pre_priv_message_display(const char* const fulljid, const char* message); 150 void plugins_post_priv_message_display(const char* const fulljid, const char* message); 151 char* plugins_pre_priv_message_send(const char* const fulljid, const char* const message); 152 void plugins_post_priv_message_send(const char* const fulljid, const char* const message); 153 154 void plugins_win_process_line(char* win, const char* const line); 155 void plugins_close_win(const char* const plugin_name, const char* const tag); 156 157 char* plugins_on_message_stanza_send(const char* const text); 158 gboolean plugins_on_message_stanza_receive(const char* const text); 159 160 char* plugins_on_presence_stanza_send(const char* const text); 161 gboolean plugins_on_presence_stanza_receive(const char* const text); 162 163 char* plugins_on_iq_stanza_send(const char* const text); 164 gboolean plugins_on_iq_stanza_receive(const char* const text); 165 166 void plugins_on_contact_offline(const char* const barejid, const char* const resource, const char* const status); 167 void plugins_on_contact_presence(const char* const barejid, const char* const resource, const char* const presence, 168 const char* const status, const int priority); 169 170 void plugins_on_chat_win_focus(const char* const barejid); 171 void plugins_on_room_win_focus(const char* const barejid); 172 173 gboolean plugins_run_command(const char* const cmd); 174 void plugins_run_timed(void); 175 GList* plugins_get_command_names(void); 176 gchar* plugins_get_dir(void); 177 CommandHelp* plugins_get_help(const char* const cmd); 178 179 GList* plugins_get_disco_features(void); 180 181 #endif 182