File: gwget_data.h

package info (click to toggle)
gwget2 0.94-2sarge1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 3,032 kB
  • ctags: 584
  • sloc: sh: 8,393; ansic: 4,446; makefile: 184
file content (123 lines) | stat: -rw-r--r-- 4,882 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Library General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */
 

#ifndef _GWGET_DATA_H
#define _GWGET_DATA_H

/* Global Preferences */
typedef struct
{
	gchar *download_dir; /* Default download directory */
	gboolean ask_save_each_dl; 
	gint num_retries;    /* Number of Retries */
	gchar *http_proxy; /* HTTP Proxy */
	gint http_proxy_port; /* HTTP Proxy Port */
	gchar *gnome_http_proxy; /* GNOME HTTP Proxy */
	gint gnome_http_proxy_port; /* GNOME HTTP Proxy Port */
	gboolean gnome_use_proxy;
	gchar *network_mode;
	gboolean resume_at_start;
	gboolean open_after_dl; /* Open the file after Download */
	gboolean no_create_directories;
	gboolean follow_relative;	/* Follow relative links only */
	gboolean convert_links;		/* Converts to relative links */
	gboolean dl_page_requisites;	/* Download page requisites */
	gint max_depth;
	gboolean view_actual_size;
	gboolean view_total_size;
	gboolean view_percentage;
	gboolean view_elapse_time;
	gboolean view_rem_time;
	gboolean view_down_speed;
	gboolean view_toolbar;
	gboolean view_file_type;
	gboolean docked;
	gboolean limit_speed;
	gboolean limit_simultaneousdownloads;
	gint max_speed;
	gint max_simultaneousdownloads;
	gboolean trayonly;
} Preferences;

extern Preferences gwget_pref;

typedef enum
{
	DL_NOT_STARTED,		/* We have not started the download of the file */
	DL_NOT_RUNNING,		/* Wget is not running */
	DL_NOT_CONNECTED,	/* Wget is trying to connect with remote host */
	DL_CONNECTED,		/* Wget is connected with remote host */
	DL_RETRIEVING,		/* Wget is retrieving the file */
	DL_COMPLETED,         	/* The downloaded is completed */
	DL_ERROR,		/* Error in the download */
	DL_WAITING		/* Waiting for another try */
} DlState;


/* Struct of the gwget data */
typedef struct 
{
    pid_t wget_pid;             /* Pid of the process running wget */
    gint log_fd;                /* File descriptor of the wget log file */
    gint log_tag;               /* Tag to the function monitoring the log */
    gchar *url;                 /* URL to the file to download */
    gchar *dir;                 /* Directory where the file will be saved */
    gchar *filename;            /* Name of the file being downloaded */
    gchar *local_filename;      /* Used to get the status of the download */
    gboolean use_proxy;         /* Used to use proxy */
    gboolean use_auto_dl;       /* Used to use auto download */
    gchar *line;                /* Used to process the wget output */
    guint32 total_size;         /* Total file size in bytes */
    guint32 total_time;         /* Total time spent in seconds */
    time_t session_start_time;  /* Time at start of this download session */
    guint32 session_start_size; /* Size at start of this download session */
    guint32 session_elapsed;    /* Time spent in seconds on this session */
    guint32 cur_size;           /* Current downloaded file size */
    DlState state;              /* State of the download */
    GtkTreeIter file_list;       /* GtkTreeIter where this file is inserted */
    guint id;                   /* File data id */
    gboolean error;		/* Error in download */
    gchar *error_msg;		/* Error Message */
    gboolean recursive;		/* Recursive download */
	gboolean multimedia;	/* Only download multimedia files in recursive mode */
	gboolean mirror;		/* Mirror the site in recursive mode */
	gchar *state_str;
    
} GwgetData;



gint num_of_download;

#define gwget_data_run(gwgetdata) ((gwgetdata->log_tag != -1) ? TRUE : FALSE)

GwgetData * gwget_data_create(gchar *url, gchar *dir);
void gwget_data_set_filename(GwgetData* gwgetdata,gchar *str);
void gwget_data_start_download(GwgetData *gwgetdata);
void gwget_data_set_state (GwgetData *gwgetdata, DlState state);
void gwget_data_update_statistics (GwgetData *gwgetdata);
void gwget_data_set_total_size (GwgetData *gwgetdata,guint32 total_size);
GwgetData* gwget_data_get_selected(void);
void gwget_data_free(gpointer data);
void gwget_data_stop_download(GwgetData *data);
void gwget_data_set_filename_from_url(GwgetData *gwgetdata, gchar *url);
void gwget_data_add_download(GwgetData *gwgetdata);
void gwget_data_exec(GwgetData *gwgetdata);

void gwget_init_pref(Preferences *pref);

#endif