| 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 |
|
| 21 |
#define _BSD_SOURCE |
| 22 |
#include <stdlib.h> |
| 23 |
#include <math.h> |
| 24 |
#include <unistd.h> |
| 25 |
#include <glib/gstdio.h> |
| 26 |
#include <string.h> |
| 27 |
|
| 28 |
#include "applet-struct.h" |
| 29 |
#include "applet-dnd2share.h" |
| 30 |
#include "applet-backend-free.h" |
| 31 |
|
| 32 |
#define NB_URLS 1 |
| 33 |
static const gchar *s_UrlLabels[NB_URLS] = {N_("Direct Link")}; |
| 34 |
|
| 35 |
static void upload (const gchar *cFilePath, gchar *cLocalDir, gboolean bAnonymous, gint iLimitRate, gchar **cResultUrls, GError **pError) |
| 36 |
{ |
| 37 |
// Upload the file |
| 38 |
gchar *cCommand = g_strdup_printf ("%s/%s \"%s\" \"%dk\"", MY_APPLET_SHARE_DATA_DIR, "upload2free.sh", cFilePath, iLimitRate); |
| 39 |
cd_debug ("%s", cCommand); |
| 40 |
gchar *cResult = cairo_dock_launch_command_sync (cCommand); |
| 41 |
g_free (cCommand); |
| 42 |
if (cResult == NULL || *cResult == '\0') |
| 43 |
{ |
| 44 |
DND2SHARE_SET_GENERIC_ERROR_WEBSITE ("Free.fr"); |
| 45 |
return; |
| 46 |
} |
| 47 |
|
| 48 |
if (cResult[strlen(cResult)-1] == '\r') |
| 49 |
cResult[strlen(cResult)-1] = '\0'; |
| 50 |
if (cResult[strlen(cResult)-1] == '\n') |
| 51 |
cResult[strlen(cResult)-1] = '\0'; |
| 52 |
|
| 53 |
cResultUrls[0] = cResult; |
| 54 |
} |
| 55 |
|
| 56 |
|
| 57 |
void cd_dnd2share_register_free_backend (void) |
| 58 |
{ |
| 59 |
cd_dnd2share_register_new_backend (CD_TYPE_FILE, |
| 60 |
"dl.free.fr", |
| 61 |
NB_URLS, |
| 62 |
s_UrlLabels, |
| 63 |
0, |
| 64 |
upload); |
| 65 |
} |