| 1 |
/** |
| 2 |
* This file is a part of the Cairo-Dock project |
| 3 |
* |
| 4 |
* Copyright : (C) see the 'copyright' file. |
| 5 |
* E-mail : see the 'copyright' file. |
| 6 |
* |
| 7 |
* This program is free software; you can redistribute it and/or |
| 8 |
* modify it under the terms of the GNU General Public License |
| 9 |
* as published by the Free Software Foundation; either version 3 |
| 10 |
* of the License, or (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 |
* You should have received a copy of the GNU General Public License |
| 17 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 |
*/ |
| 19 |
|
| 20 |
#include <string.h> |
| 21 |
#include <cairo-dock.h> |
| 22 |
|
| 23 |
#include "applet-struct.h" |
| 24 |
#include "applet-config.h" |
| 25 |
#include "applet-dnd2share.h" |
| 26 |
|
| 27 |
|
| 28 |
//\_________________ Here you have to get all your parameters from the conf file. Use the macros CD_CONFIG_GET_BOOLEAN, CD_CONFIG_GET_INTEGER, CD_CONFIG_GET_STRING, etc. myConfig has been reseted to 0 at this point. This function is called at the beginning of init and reload. |
| 29 |
CD_APPLET_GET_CONFIG_BEGIN |
| 30 |
myConfig.bEnableDialogs = CD_CONFIG_GET_BOOLEAN ("Configuration", "enable_dialogs"); |
| 31 |
myConfig.dTimeDialogs = 1000. * CD_CONFIG_GET_INTEGER_WITH_DEFAULT ("Configuration", "dialogs_duration", 5); |
| 32 |
myConfig.iNbItems = CD_CONFIG_GET_INTEGER ("Configuration", "nb_items"); |
| 33 |
myConfig.bkeepCopy = CD_CONFIG_GET_BOOLEAN ("Configuration", "keep copy"); |
| 34 |
myConfig.bDisplayLastImage = myConfig.bkeepCopy && CD_CONFIG_GET_BOOLEAN ("Configuration", "display last image"); |
| 35 |
myConfig.iLimitRate = CD_CONFIG_GET_INTEGER ("Configuration", "limit rate"); |
| 36 |
myConfig.cIconAnimation = CD_CONFIG_GET_STRING ("Configuration", "animation"); |
| 37 |
myConfig.bUseOnlyFileType = CD_CONFIG_GET_BOOLEAN_WITH_DEFAULT ("Configuration", "only file type", FALSE); |
| 38 |
|
| 39 |
int iSite = CD_CONFIG_GET_INTEGER ("Configuration", "text site"); |
| 40 |
myConfig.iPreferedSite[CD_TYPE_TEXT] = iSite < CD_NB_SITES_TEXT ? iSite : 1; |
| 41 |
iSite = CD_CONFIG_GET_INTEGER ("Configuration", "image site"); |
| 42 |
myConfig.iPreferedSite[CD_TYPE_IMAGE] = iSite < CD_NB_SITES_IMG ? iSite : 1; |
| 43 |
iSite = CD_CONFIG_GET_INTEGER ("Configuration", "video site"); |
| 44 |
myConfig.iPreferedSite[CD_TYPE_VIDEO] = iSite < CD_NB_SITES_VID ? iSite : 1; |
| 45 |
iSite = CD_CONFIG_GET_INTEGER ("Configuration", "file site"); |
| 46 |
myConfig.iPreferedSite[CD_TYPE_FILE] = iSite < CD_NB_SITES_FILE ? iSite : 1; |
| 47 |
|
| 48 |
myConfig.cCustomScripts[CD_TYPE_TEXT] = CD_CONFIG_GET_STRING ("Configuration", "text script"); |
| 49 |
myConfig.cCustomScripts[CD_TYPE_IMAGE] = CD_CONFIG_GET_STRING ("Configuration", "image script"); |
| 50 |
myConfig.cCustomScripts[CD_TYPE_VIDEO] = CD_CONFIG_GET_STRING ("Configuration", "video script"); |
| 51 |
myConfig.cCustomScripts[CD_TYPE_FILE] = CD_CONFIG_GET_STRING ("Configuration", "file script"); |
| 52 |
int i; |
| 53 |
for (i = 0; i < CD_NB_FILE_TYPES; i ++) // avoid using custom backend if no script is set for this type |
| 54 |
{ |
| 55 |
if (myConfig.cCustomScripts[i] == NULL && myConfig.iPreferedSite[i] == 0) |
| 56 |
myConfig.iPreferedSite[i] = 1; |
| 57 |
} |
| 58 |
myConfig.cLocalDir = CD_CONFIG_GET_STRING ("Configuration", "dropbox dir"); |
| 59 |
if (myConfig.cLocalDir && myConfig.cLocalDir[strlen(myConfig.cLocalDir)-1] == '/') |
| 60 |
myConfig.cLocalDir[strlen(myConfig.cLocalDir)-1] = '\0'; |
| 61 |
myConfig.bAnonymous = CD_CONFIG_GET_BOOLEAN ("Configuration", "anonymous"); |
| 62 |
myConfig.iTinyURLService = CD_CONFIG_GET_INTEGER_WITH_DEFAULT ("Configuration", "tiny url", 1); |
| 63 |
if (myConfig.iTinyURLService != 0) |
| 64 |
myConfig.bUseTinyAsDefault = CD_CONFIG_GET_BOOLEAN_WITH_DEFAULT ("Configuration", "use tiny", FALSE); |
| 65 |
CD_APPLET_GET_CONFIG_END |
| 66 |
|
| 67 |
|
| 68 |
//\_________________ Here you have to free all ressources allocated for myConfig. This one will be reseted to 0 at the end of this function. This function is called right before you get the applet's config, and when your applet is stopped, in the end. |
| 69 |
CD_APPLET_RESET_CONFIG_BEGIN |
| 70 |
g_free (myConfig.cIconAnimation); |
| 71 |
int i; |
| 72 |
for (i = 0; i < CD_NB_FILE_TYPES; i ++) |
| 73 |
g_free (myConfig.cCustomScripts[i]); |
| 74 |
g_free (myConfig.cLocalDir); |
| 75 |
CD_APPLET_RESET_CONFIG_END |
| 76 |
|
| 77 |
|
| 78 |
//\_________________ Here you have to free all ressources allocated for myData. This one will be reseted to 0 at the end of this function. This function is called when your applet is stopped, in the very end. |
| 79 |
CD_APPLET_RESET_DATA_BEGIN |
| 80 |
gldi_task_discard (myData.pTask); |
| 81 |
|
| 82 |
cd_dnd2share_clear_history (); |
| 83 |
|
| 84 |
g_free (myData.cLastURL); |
| 85 |
g_free (myData.cWorkingDirPath); |
| 86 |
CD_APPLET_RESET_DATA_END |