15
15
* GNU General Public License for more details.
16
16
* You should have received a copy of the GNU General Public License
17
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
21
#include <cairo-dock.h>
23
#include "applet-struct.h"
24
#include "applet-config.h"
25
#include "applet-dnd2share.h"
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");
21
#include <cairo-dock.h>
23
#include "applet-struct.h"
24
#include "applet-config.h"
25
#include "applet-dnd2share.h"
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
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.iPreferedSite[CD_TYPE_TEXT] = CD_CONFIG_GET_INTEGER ("Configuration", "text site");
38
myConfig.iPreferedSite[CD_TYPE_IMAGE] = CD_CONFIG_GET_INTEGER ("Configuration", "image site");
39
myConfig.iPreferedSite[CD_TYPE_VIDEO] = CD_CONFIG_GET_INTEGER ("Configuration", "video site");
40
myConfig.iPreferedSite[CD_TYPE_FILE] = CD_CONFIG_GET_INTEGER ("Configuration", "file site");
42
myConfig.cCustomScripts[CD_TYPE_TEXT] = CD_CONFIG_GET_STRING ("Configuration", "text script");
43
myConfig.cCustomScripts[CD_TYPE_IMAGE] = CD_CONFIG_GET_STRING ("Configuration", "image script");
44
myConfig.cCustomScripts[CD_TYPE_VIDEO] = CD_CONFIG_GET_STRING ("Configuration", "video script");
45
myConfig.cCustomScripts[CD_TYPE_FILE] = CD_CONFIG_GET_STRING ("Configuration", "file script");
47
for (i = 0; i < CD_NB_FILE_TYPES; i ++) // on empeche de choisir le backend custom si aucun script n'est fourni.
49
if (myConfig.cCustomScripts[i] == NULL && myConfig.iPreferedSite[i] == 0)
50
myConfig.iPreferedSite[i] = 1;
52
myConfig.cDropboxDir = CD_CONFIG_GET_STRING ("Configuration", "dropbox dir");
53
if (myConfig.cDropboxDir && myConfig.cDropboxDir[strlen(myConfig.cDropboxDir)-1] == '/')
54
myConfig.cDropboxDir[strlen(myConfig.cDropboxDir)-1] = '\0';
55
CD_APPLET_GET_CONFIG_END
58
//\_________________ 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.
59
CD_APPLET_RESET_CONFIG_BEGIN
60
g_free (myConfig.cIconAnimation);
62
for (i = 0; i < CD_NB_FILE_TYPES; i ++)
63
g_free (myConfig.cCustomScripts[i]);
64
g_free (myConfig.cDropboxDir);
65
CD_APPLET_RESET_CONFIG_END
68
//\_________________ 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.
69
CD_APPLET_RESET_DATA_BEGIN
70
cairo_dock_free_task (myData.pTask); // stoppe la tache.
72
g_free (myData.cCurrentFilePath); // on libere la memoire partagee apres.
73
g_strfreev (myData.cResultUrls);
75
cd_dnd2share_clear_history ();
77
g_free (myData.cLastURL);
78
g_free (myData.cWorkingDirPath);
79
CD_APPLET_RESET_DATA_END
35
myConfig.iLimitRate = CD_CONFIG_GET_INTEGER ("Configuration", "limit rate");
36
myConfig.cIconAnimation = CD_CONFIG_GET_STRING ("Configuration", "animation");
37
myConfig.iPreferedSite[CD_TYPE_TEXT] = CD_CONFIG_GET_INTEGER ("Configuration", "text site");
38
myConfig.iPreferedSite[CD_TYPE_IMAGE] = CD_CONFIG_GET_INTEGER ("Configuration", "image site");
39
myConfig.iPreferedSite[CD_TYPE_VIDEO] = CD_CONFIG_GET_INTEGER ("Configuration", "video site");
40
myConfig.iPreferedSite[CD_TYPE_FILE] = CD_CONFIG_GET_INTEGER ("Configuration", "file site");
42
myConfig.cCustomScripts[CD_TYPE_TEXT] = CD_CONFIG_GET_STRING ("Configuration", "text script");
43
myConfig.cCustomScripts[CD_TYPE_IMAGE] = CD_CONFIG_GET_STRING ("Configuration", "image script");
44
myConfig.cCustomScripts[CD_TYPE_VIDEO] = CD_CONFIG_GET_STRING ("Configuration", "video script");
45
myConfig.cCustomScripts[CD_TYPE_FILE] = CD_CONFIG_GET_STRING ("Configuration", "file script");
47
for (i = 0; i < CD_NB_FILE_TYPES; i ++) // on empeche de choisir le backend custom si aucun script n'est fourni.
49
if (myConfig.cCustomScripts[i] == NULL && myConfig.iPreferedSite[i] == 0)
50
myConfig.iPreferedSite[i] = 1;
52
myConfig.cDropboxDir = CD_CONFIG_GET_STRING ("Configuration", "dropbox dir");
53
if (myConfig.cDropboxDir && myConfig.cDropboxDir[strlen(myConfig.cDropboxDir)-1] == '/')
54
myConfig.cDropboxDir[strlen(myConfig.cDropboxDir)-1] = '\0';
55
myConfig.bAnonymous = CD_CONFIG_GET_BOOLEAN ("Configuration", "anonymous");
56
myConfig.iTinyURLService = CD_CONFIG_GET_INTEGER_WITH_DEFAULT ("Configuration", "tiny url", 1);
57
if (myConfig.iTinyURLService != 0)
58
myConfig.bUseTinyAsDefault = CD_CONFIG_GET_BOOLEAN_WITH_DEFAULT ("Configuration", "use tiny", FALSE);
59
CD_APPLET_GET_CONFIG_END
62
//\_________________ 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.
63
CD_APPLET_RESET_CONFIG_BEGIN
64
g_free (myConfig.cIconAnimation);
66
for (i = 0; i < CD_NB_FILE_TYPES; i ++)
67
g_free (myConfig.cCustomScripts[i]);
68
g_free (myConfig.cDropboxDir);
69
CD_APPLET_RESET_CONFIG_END
72
//\_________________ 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.
73
CD_APPLET_RESET_DATA_BEGIN
74
cairo_dock_free_task (myData.pTask); // stoppe la tache.
76
g_free (myData.cCurrentFilePath); // on libere la memoire partagee apres.
77
g_strfreev (myData.cResultUrls);
79
cd_dnd2share_clear_history ();
81
g_free (myData.cLastURL);
82
g_free (myData.cWorkingDirPath);
83
CD_APPLET_RESET_DATA_END