| 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 |
#ifndef __CD_APPLET_STRUCT__ |
| 22 |
#define __CD_APPLET_STRUCT__ |
| 23 |
|
| 24 |
#include <cairo-dock.h> |
| 25 |
|
| 26 |
|
| 27 |
typedef enum _CDFileType { |
| 28 |
CD_UNKNOWN_TYPE=0, |
| 29 |
CD_TYPE_TEXT, |
| 30 |
CD_TYPE_IMAGE, |
| 31 |
CD_TYPE_VIDEO, |
| 32 |
CD_TYPE_FILE, |
| 33 |
CD_NB_FILE_TYPES |
| 34 |
} CDFileType; |
| 35 |
|
| 36 |
#define CD_NB_SITES_MAX 5 // max number here above |
| 37 |
// number of sites for the each type in the config file |
| 38 |
#define CD_NB_SITES_TEXT 5 |
| 39 |
#define CD_NB_SITES_IMG 4 |
| 40 |
#define CD_NB_SITES_VID 2 |
| 41 |
#define CD_NB_SITES_FILE 3 |
| 42 |
|
| 43 |
|
| 44 |
typedef struct _CDUploadedItem { |
| 45 |
gchar *cItemName; // name of the item (also the group name in the history file and the local copy if needed -> looks like "item-$timestamp"). |
| 46 |
gint iSiteID; // to link it with the right backend. |
| 47 |
gchar **cDistantUrls; // can have several url (with different size, etc) => check backend. |
| 48 |
time_t iDate; // date of the upload, to sort items and it's unique. |
| 49 |
gchar *cLocalPath; // Path of the file when the user has uploaded it. |
| 50 |
gchar *cFileName; // name of the file (which will be displayed to the user). |
| 51 |
CDFileType iFileType; |
| 52 |
} CDUploadedItem; |
| 53 |
|
| 54 |
typedef void (* CDUploadFunc) (const gchar *cFilePath, gchar *cLocalDir, gboolean bAnonymous, gint iLimitRate, gchar **cResultUrls, GError **pError); |
| 55 |
|
| 56 |
typedef struct _CDSiteBackend { |
| 57 |
const gchar *cSiteName; // name of the website (display) |
| 58 |
gint iNbUrls; // number of URL returned. |
| 59 |
gchar **cUrlLabels; // description of each URL. |
| 60 |
gint iPreferedUrlType; // the most 'useful' URL |
| 61 |
CDUploadFunc upload; // the upload function (launched in a separated thread). |
| 62 |
} CDSiteBackend; |
| 63 |
|
| 64 |
|
| 65 |
//\___________ structure containing the applet's configuration parameters. |
| 66 |
struct _AppletConfig { |
| 67 |
gboolean bEnableDialogs; |
| 68 |
gdouble dTimeDialogs; |
| 69 |
guint iNbItems; |
| 70 |
gint iLimitRate; |
| 71 |
gboolean bkeepCopy; |
| 72 |
gboolean bUseOnlyFileType; |
| 73 |
gboolean bDisplayLastImage; |
| 74 |
gint iPreferedSite[CD_NB_FILE_TYPES]; |
| 75 |
gchar *cIconAnimation; |
| 76 |
gchar *cCustomScripts[CD_NB_FILE_TYPES]; |
| 77 |
gchar *cLocalDir; |
| 78 |
gboolean bAnonymous; |
| 79 |
gint iTinyURLService; |
| 80 |
gboolean bUseTinyAsDefault; |
| 81 |
} ; |
| 82 |
|
| 83 |
typedef struct _CDSharedMemory { |
| 84 |
gchar *cCurrentFilePath; |
| 85 |
CDFileType iCurrentFileType; |
| 86 |
gboolean bTempFile; |
| 87 |
CDUploadFunc upload; // we don't keep a pointer to the current backend in the shard memory, because it can be destroyed meanwhile. so we just copy the part that is useful. |
| 88 |
gint iNbUrls; |
| 89 |
gint iTinyURLService; |
| 90 |
gchar *cLocalDir; |
| 91 |
gboolean bAnonymous; |
| 92 |
gint iLimitRate; |
| 93 |
gchar **cResultUrls; |
| 94 |
GError *pError; |
| 95 |
} CDSharedMemory; |
| 96 |
|
| 97 |
|
| 98 |
//\___________ structure containing the applet's data, like surfaces, dialogs, results of calculus, etc. |
| 99 |
struct _AppletData { |
| 100 |
gchar *cWorkingDirPath; |
| 101 |
CDSiteBackend backends[CD_NB_FILE_TYPES][CD_NB_SITES_MAX]; |
| 102 |
CDSiteBackend *pCurrentBackend[CD_NB_FILE_TYPES]; |
| 103 |
int iNbSitesForType[CD_NB_FILE_TYPES]; |
| 104 |
|
| 105 |
GldiTask *pTask; // current upload task. |
| 106 |
|
| 107 |
GList *pUpoadedItems; // list of CDUploadedItem* |
| 108 |
gchar *cLastURL; // the last copied URL -> for the left click |
| 109 |
gint iCurrentItemNum; // the number of the current item in the list (safer than using a pointer in the list if this list is modified) |
| 110 |
gchar *cTmpFilePath; |
| 111 |
} ; |
| 112 |
|
| 113 |
|
| 114 |
#endif |