~cairo-dock-team/ubuntu/quantal/cairo-dock-plug-ins/3.0.2

« back to all changes in this revision

Viewing changes to dnd2share/src/applet-dnd2share.c

Tags: upstream-2.2.0~0beta4
ImportĀ upstreamĀ versionĀ 2.2.0~0beta4

Show diffs side-by-side

added added

removed removed

Lines of Context:
92
92
                for (j = 0; j < myData.backends[iFileType][iSiteID].iNbUrls; j ++)
93
93
                {
94
94
                        g_string_printf (sUrlKey, "url%d", j);
95
 
                        pItem->cDistantUrls[j] = g_key_file_get_string (pKeyFile, cItemName, sUrlKey->str, NULL);
 
95
                        pItem->cDistantUrls[j] = g_key_file_get_string (pKeyFile, cItemName, sUrlKey->str, NULL);  // NULL si cette URL n'avait pas ete sauvegardee avant.
96
96
                }
97
97
                pItem->iDate = g_key_file_get_integer (pKeyFile, cItemName, "date", NULL);  /// un 'int' est-ce que ca suffit ?...
98
98
                
119
119
{
120
120
        CDSiteBackend *pCurrentBackend = myData.pCurrentBackend[myData.iCurrentFileType];
121
121
        g_return_if_fail (pCurrentBackend != NULL);
 
122
        
 
123
        myData.cResultUrls = g_new0 (gchar *, pCurrentBackend->iNbUrls+1);  // NULL-terminated
122
124
        pCurrentBackend->upload (cFilePath);
 
125
        
 
126
        if (myData.cResultUrls[0] && myConfig.iTinyURLService != 0)  // on en fait une tiny-url.
 
127
        {
 
128
                gchar *Command = NULL;
 
129
                switch (myConfig.iTinyURLService)
 
130
                {
 
131
                        case 1:
 
132
                        default:
 
133
                                Command = g_strdup_printf ("http://tinyurl.com/api-create.php?url=%s", myData.cResultUrls[0]);
 
134
                        break;
 
135
                        case 2:
 
136
                                Command = g_strdup_printf ("http://shorterlink.org/createlink.php?url=%s", myData.cResultUrls[0]);
 
137
                        break;
 
138
                        /*http://soso.bz/
 
139
                        http://notlong.com/links/
 
140
                        http://www.minu.me/
 
141
                        http://cuturl.biz/
 
142
                        http://tiny.cc/
 
143
                        http://o-x.fr/create.php
 
144
                        http://petitlien.fr/create.php
 
145
                        http://bit.ly
 
146
                        http://is.gd/create.php*/
 
147
                }
 
148
                myData.cResultUrls[pCurrentBackend->iNbUrls-1] = cairo_dock_get_url_data (Command, NULL);
 
149
                g_free (Command);
 
150
        }
123
151
}
124
152
static gboolean _cd_dnd2share_update_from_result (gchar *cFilePath)
125
153
{
218
246
                }
219
247
                
220
248
                // On copie l'URL dans le clipboard.
221
 
                gchar *cURL = myData.cResultUrls[pCurrentBackend->iPreferedUrlType];
 
249
                gchar *cURL = NULL;
 
250
                if (myConfig.bUseTinyAsDefault)
 
251
                        cURL = myData.cResultUrls[pCurrentBackend->iNbUrls-1];
 
252
                if (cURL == NULL)
 
253
                        cURL = myData.cResultUrls[pCurrentBackend->iPreferedUrlType];
222
254
                if (cURL == NULL)
223
255
                {
224
256
                        int i;
283
315
        {
284
316
                cd_warning ("Please wait the current upload is finished before starting a new one.");
285
317
                cairo_dock_remove_dialog_if_any (myIcon);
286
 
                cairo_dock_show_temporary_dialog_with_icon (D_("Please wait the current upload is finished before starting a new one."),
 
318
                cairo_dock_show_temporary_dialog_with_icon (D_("Please wait for the current upload to finish before starting a new one."),
287
319
                        myIcon,
288
320
                        myContainer,
289
321
                        myConfig.dTimeDialogs,
310
342
        cairo_dock_launch_task (myData.pTask);
311
343
        
312
344
        // On lance une animation.
313
 
        cairo_dock_request_icon_animation (myIcon, myContainer, myConfig.cIconAnimation, 1e6);  // on l'interrompra nous-memes a la fin de l'upload.
 
345
        CD_APPLET_ANIMATE_MY_ICON (myConfig.cIconAnimation, 1e6);  // on l'interrompra nous-memes a la fin de l'upload.
314
346
        cairo_dock_mark_icon_as_clicked (myIcon);  // pour ne pas se faire interrompre par un survol.
315
347
        cairo_dock_launch_animation (myContainer);
316
348
}
343
375
        g_free (cCommand);
344
376
}
345
377
 
346
 
void cd_dnd2share_set_working_directory_size (int iNbItems)
 
378
void cd_dnd2share_set_working_directory_size (guint iNbItems)
347
379
{
348
380
        gchar *cConfFilePath = g_strdup_printf ("%s/%s", myData.cWorkingDirPath, "history.conf");
349
381
        GKeyFile *pKeyFile = cairo_dock_open_key_file (cConfFilePath);
359
391
        {
360
392
                gchar *cItemName;
361
393
                GString *sPreviewPath = g_string_new ("");
362
 
                int i;
 
394
                guint i;
363
395
                for (i = 0; pGroupList[i] != NULL && i < length - iNbItems; i ++)  // on supprime les n premiers groupes en trop, ainsi que leurs eventuelles prevues.
364
396
                {
365
397
                        cItemName = pGroupList[i];
412
444
{
413
445
        CDSiteBackend *pBackend = &myData.backends[pItem->iFileType][pItem->iSiteID];
414
446
        //g_print ("%s (type:%d; site:%d)\n", __func__, pItem->iFileType, pItem->iSiteID);
415
 
        gchar *cURL = pItem->cDistantUrls[pBackend->iPreferedUrlType];
 
447
        gchar *cURL = NULL;
 
448
        if (myConfig.bUseTinyAsDefault)
 
449
                cURL = pItem->cDistantUrls[pBackend->iNbUrls-1];
 
450
        if (cURL == NULL)
 
451
                cURL = pItem->cDistantUrls[pBackend->iPreferedUrlType];
416
452
        if (cURL == NULL)
417
453
        {
418
454
                int i;
495
531
        myData.iNbSitesForType[iFileType] ++;
496
532
        
497
533
        pNewBackend->cSiteName = cSiteName;
498
 
        pNewBackend->iNbUrls = iNbUrls;
499
 
        pNewBackend->cUrlLabels = cUrlLabels;
 
534
        pNewBackend->iNbUrls = iNbUrls + 1;  // +1 pour la tiny-url.
 
535
        pNewBackend->cUrlLabels = g_new0 (gchar *, pNewBackend->iNbUrls+1);  // +1 pour le NULL final.
 
536
        memcpy (pNewBackend->cUrlLabels, cUrlLabels, iNbUrls * sizeof (gchar*));  // on prend les N labels fournis par le backend.
 
537
        pNewBackend->cUrlLabels[iNbUrls] = D_("Tiny URL");  // on rajoute le tiny-url.
500
538
        pNewBackend->iPreferedUrlType = iPreferedUrlType;
501
539
        pNewBackend->upload = pUploadFunc;
502
540
}