2
* This file is a part of the Cairo-Dock project
4
* Copyright : (C) see the 'copyright' file.
5
* E-mail : see the 'copyright' file.
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.
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/>.
24
#include <glib/gstdio.h>
26
#include "applet-struct.h"
27
#include "applet-dnd2share.h"
28
#include "applet-backend-uppix.h"
31
static const gchar *s_UrlLabels[NB_URLS] = {"DirectLink", "Thumbnail"};
34
static void upload (const gchar *cFilePath)
36
// On cree un fichier de log temporaire.
37
gchar *cLogFile = g_strdup ("/tmp/dnd2share-log.XXXXXX");
38
int fds = mkstemp (cLogFile);
46
// On lance la commande d'upload.
47
gchar *cCommand = NULL;
48
cCommand = g_strdup_printf ("curl --connect-timeout 5 --retry 2 --limit-rate %dk http://imageshack.us -F xml=yes -F tags=Cairo-Dock -F fileupload=@'%s' -o '%s'", myConfig.iLimitRate, cFilePath, cLogFile);
49
g_print ("%s\n", cCommand);
50
int r = system (cCommand);
53
// On récupère l'URL dans le log :
54
gchar *cURL = NULL, *cThumbnail = NULL;
55
gchar *cContent = NULL;
57
g_file_get_contents (cLogFile, &cContent, &length, NULL);
59
gchar *str = g_strstr_len (cContent, -1, "<image_link>");
62
str += 12; // <image_link>http://bla/bla/bla.png</image_link>
63
gchar *end = g_strstr_len (str, -1, "</image_link>");
66
cURL = g_strndup (str, end - str);
70
str = g_strstr_len (cContent, -1, "<thumb_link>");
73
str += 12; // <thumb_link>http://bla/bla/bla.png</thumb_link>
74
gchar *end = g_strstr_len (str, -1, "</thumb_link>");
77
cThumbnail = g_strndup (str, end - str);
90
// Enfin on remplit la memoire partagee avec nos URLs.
91
myData.cResultUrls = g_new0 (gchar *, NB_URLS+1);
92
myData.cResultUrls[0] = cURL;
93
myData.cResultUrls[1] = cThumbnail;
97
void cd_dnd2share_register_imageshack_backend (void)
99
cd_dnd2share_register_new_backend (CD_TYPE_IMAGE,