29
29
#include "applet-backend-imagebin.h"
32
static const gchar *s_UrlLabels[NB_URLS] = {"DirectLink"};
35
static void upload (const gchar *cFilePath, gchar *cDropboxDir, gboolean bAnonymous, gint iLimitRate, gchar **cResultUrls)
32
static const gchar *s_UrlLabels[NB_URLS] = {N_("Direct Link")};
35
static void upload (const gchar *cFilePath, gchar *cLocalDir, gboolean bAnonymous, gint iLimitRate, gchar **cResultUrls, GError **pError)
37
// On cree un fichier de log temporaire.
38
gchar *cLogFile = g_strdup ("/tmp/dnd2share-log.XXXXXX");
39
int fds = mkstemp (cLogFile);
47
// On lance la commande d'upload.
48
gchar *cCommand = g_strdup_printf ("curl -L --connect-timeout 5 --retry 2 --limit-rate %dk http://imagebin.ca/upload.php -F f=@\"%s\" -F t=file -o \"%s\"", iLimitRate, cFilePath, cLogFile);
38
gchar *cCommand = g_strdup_printf ("curl -L --connect-timeout 5 --retry 2 --limit-rate %dk http://imagebin.ca/upload.php -F f=@\"%s\" -F t=file", iLimitRate, cFilePath);
49
39
cd_debug ("%s", cCommand);
50
int r = system (cCommand);
52
cd_warning ("Not able to launch this command: %s", cCommand);
40
gchar *cContent = cairo_dock_launch_command_sync (cCommand);
55
// On récupère l'URL dans le log :
45
DND2SHARE_SET_GENERIC_ERROR_WEBSITE ("ImageBin");
49
// We have the content, now we can extract data
56
50
gchar *cURL = NULL;
57
gchar *cContent = NULL;
59
g_file_get_contents (cLogFile, &cContent, &length, NULL);
60
gchar *str = g_strstr_len (cContent, -1, "href='");
51
gchar *str = strstr (cContent, "href='");