1 /* 2 * 3 * Copyright (C) 2012-2018 by C.H. Huang 4 * plushuang.tw@gmail.com 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 2.1 of the License, or (at your option) any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with this library; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 * 20 * --- 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 Lesser 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 #ifndef UGTK_SETTING_H 38 #define UGTK_SETTING_H 39 40 #ifdef HAVE_CONFIG_H 41 #include <config.h> 42 #endif 43 44 #include <UgArray.h> 45 #include <UgList.h> 46 #include <UgEntry.h> 47 48 #ifdef __cplusplus 49 extern "C" { 50 #endif 51 52 typedef struct UgtkSetting UgtkSetting; 53 54 typedef enum 55 { 56 UGTK_SCHEDULE_TURN_OFF, 57 UGTK_SCHEDULE_UPLOAD_ONLY, // reserve 58 UGTK_SCHEDULE_LIMITED_SPEED, 59 UGTK_SCHEDULE_NORMAL, 60 61 UGTK_SCHEDULE_N_STATE, 62 } UgtkScheduleState; 63 64 typedef enum 65 { 66 UGTK_PLUGIN_ORDER_CURL, 67 UGTK_PLUGIN_ORDER_ARIA2, 68 UGTK_PLUGIN_ORDER_CURL_ARIA2, 69 UGTK_PLUGIN_ORDER_ARIA2_CURL, 70 71 UGTK_PLUGIN_N_ORDER, 72 } UgtkPluginOrder; 73 74 struct UgtkSetting 75 { 76 // "WindowSetting" 77 struct UgtkWindowSetting 78 { 79 // visible: boolean 80 int toolbar; 81 int statusbar; 82 int category; 83 int summary; 84 int banner; 85 86 // window position: int 87 int x; 88 int y; 89 int width; 90 int height; 91 // window ststus: boolean 92 int maximized; 93 94 // user action 95 int nth_category; 96 int nth_state; 97 int paned_position_h; 98 int paned_position_v; 99 } window; 100 101 // "SummarySetting" 102 struct UgtkSummarySetting 103 { 104 // visible: boolean 105 int name; 106 int folder; 107 int category; 108 int uri; 109 int message; 110 } summary; 111 112 // "DownloadColumn" 113 struct UgtkDownloadColumnSetting 114 { 115 // visible: boolean 116 int complete; 117 int total; 118 int percent; 119 int elapsed; // consuming time 120 int left; // remaining time 121 int speed; 122 int upload_speed; 123 int uploaded; 124 int ratio; 125 int retry; 126 int category; 127 int uri; 128 int added_on; 129 int completed_on; 130 131 // width: integer 132 struct UgtkDownloadColumnWidth 133 { 134 int state; // state icon 135 int name; 136 int complete; 137 int total; 138 int percent; 139 int elapsed; // consuming time 140 int left; // remaining time 141 int speed; 142 int upload_speed; 143 int uploaded; 144 int ratio; 145 int retry; 146 int category; 147 int uri; 148 int added_on; 149 int completed_on; 150 } width; 151 152 struct 153 { 154 int type; // GtkSortType 155 int nth; // UgtkNodeColumn 156 } sort; 157 } download_column; 158 159 // "UserInterface" 160 struct UgtkUserInterfaceSetting 161 { 162 // boolean 163 int exit_confirmation; 164 int delete_confirmation; 165 int show_trayicon; 166 int start_in_tray; 167 int close_to_tray; 168 int start_in_offline_mode; 169 int start_notification; 170 int sound_notification; 171 int apply_recent; 172 int skip_existing; 173 int large_icon; 174 #ifdef HAVE_APP_INDICATOR 175 int app_indicator; 176 #endif 177 } ui; 178 179 // "ClipboardSetting" 180 struct UgtkClipboardSetting 181 { 182 char* pattern; 183 int monitor; 184 int quiet; 185 int nth_category; 186 int website; 187 } clipboard; 188 189 // "BandwidthSetting" - global speed limits 190 struct UgtkBandwidthSetting 191 { 192 struct { 193 int upload; // KiB / second 194 int download; // KiB / second 195 } normal, scheduler; 196 } bandwidth; 197 198 // "SchedulerSetting" 199 struct UgtkSchedulerSetting 200 { 201 int enable; 202 UgArrayInt state; // [7][24] 1 week, 7 days, 24 hours 203 } scheduler; 204 205 // "CommandlineSetting" 206 struct UgtkCommandlineSetting 207 { 208 int quiet; // --quiet 209 int nth_category; // --category-index 210 } commandline; 211 212 // "PluginOrder" 213 int plugin_order; // UgtkPluginOrder: matching order 214 215 // UgetPluginAria2 option 216 struct UgtkPluginAria2Setting { 217 // aria2 speed limit 218 struct { 219 int download; // KiB / second 220 int upload; // KiB / second 221 } limit; 222 // aria2 options 223 int launch; 224 int shutdown; 225 char* token; 226 char* path; 227 char* args; 228 char* uri; 229 } aria2; 230 231 // UgetPluginMedia option 232 struct UgtkPluginMediaSetting { 233 int match_mode; 234 int quality; 235 int type; 236 } media; 237 238 // Completion Auto-Actions 239 struct UgtkCompletionSetting { 240 int remember; 241 int action; 242 char* command; 243 char* on_error; 244 } completion; 245 246 struct UgtkAutoSaveSetting 247 { 248 int enable; 249 int interval; 250 } auto_save; 251 252 // "FolderHistory" 253 UgList folder_history; 254 255 int offline_mode; 256 }; 257 258 void ugtk_setting_init (UgtkSetting* setting); 259 int ugtk_setting_save (UgtkSetting* setting, const char* file); 260 int ugtk_setting_load (UgtkSetting* setting, const char* file); 261 void ugtk_setting_reset (UgtkSetting* setting); 262 263 void ugtk_setting_add_folder (UgtkSetting* setting, const char* folder); 264 void ugtk_setting_fix_data (UgtkSetting* setting); 265 266 #ifdef __cplusplus 267 } 268 #endif 269 270 #endif // UGTK_SETTING_H 271