1 /*************************************************************************** 2 * Copyright (C) 2010~2010 by CSSlayer * 3 * wengxt@gmail.com * 4 * * 5 * This program is free software; you can redistribute it and/or modify * 6 * it under the terms of the GNU General Public License as published by * 7 * the Free Software Foundation; either version 2 of the License, or * 8 * (at your option) any later version. * 9 * * 10 * This program is distributed in the hope that it will be useful, * 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 13 * GNU General Public License for more details. * 14 * * 15 * You should have received a copy of the GNU General Public License * 16 * along with this program; if not, write to the * 17 * Free Software Foundation, Inc., * 18 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * 19 ***************************************************************************/ 20 21 /** 22 * @addtogroup Fcitx 23 * @{ 24 */ 25 26 /** 27 * @file addon.h 28 * Header Addon Support for fcitx 29 * @author CSSlayer wengxt@gmail.com 30 */ 31 32 #ifndef _FCITX_ADDON_H_ 33 #define _FCITX_ADDON_H_ 34 35 #include <fcitx-utils/utarray.h> 36 #include <fcitx-config/fcitx-config.h> 37 38 #ifdef __cplusplus 39 extern "C" { 40 #endif 41 42 struct _FcitxInstance; 43 struct _FcitxModule; 44 45 /** 46 * Addon Category Definition 47 **/ 48 typedef enum _FcitxAddonCategory { 49 /** 50 * Input method 51 **/ 52 AC_INPUTMETHOD = 0, 53 /** 54 * Input frontend, like xim 55 **/ 56 AC_FRONTEND, 57 /** 58 * General module, can be implemented in a quite extensive way 59 **/ 60 AC_MODULE, 61 /** 62 * User Interface, only one of it can be enabled currently. 63 **/ 64 AC_UI 65 } FcitxAddonCategory; 66 67 /** 68 * Supported Addon Type, Currently only sharedlibrary 69 **/ 70 typedef enum _FcitxAddonType { 71 AT_SHAREDLIBRARY = 0 72 } FcitxAddonType; 73 74 /** 75 * How addon get input method list 76 **/ 77 typedef enum _IMRegisterMethod { 78 IMRM_SELF, 79 IMRM_EXEC, 80 IMRM_CONFIGFILE 81 } IMRegisterMethod; 82 83 /** 84 * Addon Instance in Fcitx 85 **/ 86 typedef struct _FcitxAddon { 87 FcitxGenericConfig config; /**< config file */ 88 char *name; /**< addon name, used as a identifier */ 89 char *generalname; /**< addon name, translatable user visible string */ 90 char *comment; /**< longer desc translatable user visible string */ 91 boolean bEnabled; /**< enabled or not*/ 92 FcitxAddonCategory category; /**< addon category */ 93 FcitxAddonType type; /**< addon type */ 94 char *library; /**< library string */ 95 char *depend; /**< dependency string */ 96 int priority; /**< priority */ 97 char *subconfig; /**< used by ui for subconfig */ 98 union { 99 struct _FcitxFrontend *frontend; 100 struct _FcitxModule *module; 101 struct _FcitxIMClass* imclass; 102 struct _FcitxIMClass2* imclass2; 103 struct _FcitxUI* ui; 104 }; 105 void *addonInstance; /**< addon private pointer */ 106 UT_array functionList; /**< addon exposed function */ 107 108 IMRegisterMethod registerMethod; /**< the input method register method */ 109 char* registerArgument; /**< extra argument for register, unused for now */ 110 char* uifallback; /**< if's a user interface addon, the fallback UI addon name */ 111 struct _FcitxInstance* owner; /**< upper pointer to instance */ 112 union { 113 boolean advance; /**< a hint for GUI */ 114 void* dummy; 115 }; 116 117 union { 118 boolean isIMClass2; 119 void* dummy2; 120 }; 121 122 union { 123 boolean loadLocal; 124 void* dummy3; 125 }; 126 127 void* padding[7]; /**< padding */ 128 } FcitxAddon; 129 130 /** 131 * Init utarray for addon 132 * 133 * @return void 134 **/ 135 void FcitxAddonsInit(UT_array* addons); 136 137 /** 138 * Free one addon info 139 * 140 * @param v addon info 141 */ 142 void FcitxAddonFree(void *v); 143 144 /** 145 * Load all addon of fcitx during initialize 146 * 147 * @return void 148 **/ 149 void FcitxAddonsLoad(UT_array* addons); 150 151 /** 152 * Resolve addon dependency, in order to make every addon works 153 * 154 * @return void 155 **/ 156 void FcitxInstanceResolveAddonDependency(struct _FcitxInstance* instance); 157 158 /** 159 * Check whether an addon is enabled or not by addon name 160 * 161 * @param addons addon array 162 * @param name addon name 163 * @return boolean 164 **/ 165 boolean FcitxAddonsIsAddonAvailable(UT_array* addons, const char* name); 166 167 /** 168 * Get addon instance by addon name 169 * 170 * @param addons addon array 171 * @param name addon name 172 * @return FcitxAddon* 173 **/ 174 FcitxAddon* FcitxAddonsGetAddonByName(UT_array* addons, const char* name); 175 176 /** 177 * Load addon.desc file 178 * 179 * @return FcitxConfigFileDesc* 180 **/ 181 FcitxConfigFileDesc* FcitxAddonGetConfigDesc(); 182 183 #ifdef __cplusplus 184 } 185 #endif 186 187 #endif 188 189 /** 190 * @} 191 */ 192 // kate: indent-mode cstyle; space-indent on; indent-width 0; 193