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>
27
#include "applet-struct.h"
28
#include "applet-dnd2share.h"
29
#include "applet-backend-ubuntuone.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)
37
// On lance la commande d'upload.
38
gchar *cFileName = g_path_get_basename (cFilePath);
39
gchar *cLocalFilePath;
41
cLocalFilePath = g_strdup_printf ("%s/%s", cDropboxDir, cFileName);
43
cLocalFilePath = g_strdup_printf ("/home/%s/Ubuntu One/%s", g_getenv ("USER"), cFileName);
46
gchar *cCommand = g_strdup_printf ("cp \"%s\" \"%s\"", cFilePath, cLocalFilePath);
47
cd_debug ("commande u1 : %s", cCommand);
48
int r = system (cCommand);
52
cd_warning ("couldn't copy the file to %s", cLocalFilePath);
53
g_free (cLocalFilePath);
57
// On recupere l'URL (dispo tout de suite, sinon il faudra boucler en testant 'dropbox status' jusqu'a avoir 'Idle').
58
cCommand= g_strdup_printf ("u1sdtool --publish-file \"%s\"", cLocalFilePath);
59
cd_debug ("commande u2 : %s", cCommand);
60
gchar *cResult = cairo_dock_launch_command_sync (cCommand);
62
g_free (cLocalFilePath);
63
if (cResult == NULL || *cResult == '\0')
65
cd_warning ("is u1sdtool installed?");
69
if (cResult[strlen(cResult)-1] == '\r')
70
cResult[strlen(cResult)-1] = '\0';
71
if (cResult[strlen(cResult)-1] == '\n')
72
cResult[strlen(cResult)-1] = '\0';
74
// Enfin on remplit la memoire partagee avec nos URLs.
75
gchar *str = strstr (cResult, "http"); // File is published at http://ubuntuone.com/x/y
78
cd_warning ("couldn't publish this file: %s", cResult);
82
cResultUrls[0] = g_strdup (str);
87
void cd_dnd2share_register_ubuntuone_backend (void)
89
cd_dnd2share_register_new_backend (CD_TYPE_FILE,