Revision 1853
| trunk/nntpgrab_core/download_queue.c (revision 1853) | ||
|---|---|---|
| 258 | 258 |
|
| 259 | 259 |
file->now_decoding = TRUE; |
| 260 | 260 |
|
| 261 |
nntpgrab_core_emit_file_state_changed(FALSE, collection->collection_name, file->subject, NULL, file->status, TASK_STATE_WAITING_FOR_DECODE); |
|
| 261 |
nntpgrab_core_emit_file_state_changed(FALSE, collection->collection_name, file->subject, NULL, file->status, TASK_STATE_WAITING_FOR_DECODE, file->file_size_remaining, collection->total_size, collection->total_size_remaining); |
|
| 262 | 262 |
|
| 263 | 263 |
file->status = TASK_STATE_WAITING_FOR_DECODE; |
| 264 | 264 |
|
| ... | ... | |
| 645 | 645 |
|
| 646 | 646 |
g_static_mutex_lock(&collection->mutex); |
| 647 | 647 |
|
| 648 |
/* Did the file just changed state? */ |
|
| 649 |
if (file->status == TASK_STATE_SKIPPED) {
|
|
| 650 |
/* Ignore the event */ |
|
| 651 |
g_static_mutex_unlock(&collection->mutex); |
|
| 652 |
return; |
|
| 653 |
} |
|
| 654 |
|
|
| 648 | 655 |
part->now_downloading = FALSE; |
| 649 | 656 |
part->downloaded = success; |
| 650 | 657 |
file->file_is_downloading = FALSE; |
| ... | ... | |
| 767 | 774 |
g_return_if_fail(collection != NULL); |
| 768 | 775 |
g_return_if_fail(file != NULL); |
| 769 | 776 |
|
| 770 |
nntpgrab_core_emit_file_state_changed(FALSE, collection->collection_name, file->subject, NULL, file->status, TASK_STATE_DECODING); |
|
| 777 |
nntpgrab_core_emit_file_state_changed(FALSE, collection->collection_name, file->subject, NULL, file->status, TASK_STATE_DECODING, file->file_size_remaining, collection->total_size, collection->total_size_remaining); |
|
| 771 | 778 |
|
| 772 | 779 |
g_static_mutex_lock(&collection->mutex); |
| 773 | 780 |
file->status = TASK_STATE_DECODING; |
| ... | ... | |
| 806 | 813 |
|
| 807 | 814 |
} |
| 808 | 815 |
|
| 809 |
nntpgrab_core_emit_file_state_changed(FALSE, collection->collection_name, file->subject, file->real_filename, file->status, status); |
|
| 816 |
nntpgrab_core_emit_file_state_changed(FALSE, collection->collection_name, file->subject, file->real_filename, file->status, status, file->file_size_remaining, collection->total_size, collection->total_size_remaining); |
|
| 810 | 817 |
file->status = status; |
| 811 | 818 |
|
| 812 | 819 |
file->now_decoding = FALSE; |
| ... | ... | |
| 1398 | 1405 |
collection->total_size_remaining += file->file_size - file->file_size_remaining - filesize_remaining_active; |
| 1399 | 1406 |
file->file_size_remaining = file->file_size - filesize_remaining_active; |
| 1400 | 1407 |
|
| 1401 |
nntpgrab_core_emit_file_state_changed(FALSE, collection_name_copy, file->subject, NULL, file->status, TASK_STATE_WAITING_FOR_DOWNLOAD); |
|
| 1408 |
nntpgrab_core_emit_file_state_changed(FALSE, collection_name_copy, file->subject, NULL, file->status, TASK_STATE_WAITING_FOR_DOWNLOAD, file->file_size_remaining, collection->total_size, collection->total_size_remaining); |
|
| 1402 | 1409 |
file->status = TASK_STATE_WAITING_FOR_DOWNLOAD; |
| 1403 | 1410 |
|
| 1404 | 1411 |
if (!restart_flag) {
|
| ... | ... | |
| 1764 | 1771 |
|
| 1765 | 1772 |
file->file_size_remaining = file->file_size; |
| 1766 | 1773 |
|
| 1767 |
nntpgrab_core_emit_file_state_changed(FALSE, collection_name, subject, file->real_filename, TASK_STATE_WAITING_FOR_DOWNLOAD, TASK_STATE_SKIPPED); |
|
| 1774 |
nntpgrab_core_emit_file_state_changed(FALSE, collection_name, subject, file->real_filename, TASK_STATE_WAITING_FOR_DOWNLOAD, TASK_STATE_SKIPPED, file->file_size_remaining, collection->total_size, collection->total_size_remaining); |
|
| 1768 | 1775 |
|
| 1769 | 1776 |
ng_plugin_emit_log_msg(NULL, NG_LOG_LEVEL_DEBUG, _("File '%s' of collection '%s' was marked optional"), collection_name, subject);
|
| 1770 | 1777 |
|
| ... | ... | |
| 1776 | 1783 |
collection->total_size_remaining += file->file_size; |
| 1777 | 1784 |
file->file_size_remaining = file->file_size; |
| 1778 | 1785 |
|
| 1779 |
nntpgrab_core_emit_file_state_changed(FALSE, collection_name, subject, file->real_filename, TASK_STATE_SKIPPED, TASK_STATE_WAITING_FOR_DOWNLOAD); |
|
| 1786 |
nntpgrab_core_emit_file_state_changed(FALSE, collection_name, subject, file->real_filename, TASK_STATE_SKIPPED, TASK_STATE_WAITING_FOR_DOWNLOAD, file->file_size_remaining, collection->total_size, collection->total_size_remaining); |
|
| 1780 | 1787 |
|
| 1781 | 1788 |
ng_plugin_emit_log_msg(NULL, NG_LOG_LEVEL_DEBUG, _("File '%s' of collection '%s' was marked non-optional"), collection_name, subject);
|
| 1782 | 1789 |
|
| trunk/nntpgrab_core/nntpgrab_core.c (revision 1853) | ||
|---|---|---|
| 396 | 396 |
G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, |
| 397 | 397 |
0, |
| 398 | 398 |
NULL, NULL, |
| 399 |
nntpgrab_marshal_VOID__STRING_STRING_STRING_INT_INT, |
|
| 400 |
G_TYPE_NONE, 5, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT, G_TYPE_INT); |
|
| 399 |
nntpgrab_marshal_VOID__STRING_STRING_STRING_INT_INT_UINT64_UINT64_UINT64, |
|
| 400 |
G_TYPE_NONE, 8, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT, G_TYPE_INT, G_TYPE_UINT64, G_TYPE_UINT64, G_TYPE_UINT64); |
|
| 401 | 401 |
|
| 402 | 402 |
/** |
| 403 | 403 |
* NntpgrabCore::connection-connecting: |
| trunk/nntpgrab_core/nntpgrab_plugin.h (revision 1853) | ||
|---|---|---|
| 27 | 27 |
|
| 28 | 28 |
G_BEGIN_DECLS |
| 29 | 29 |
|
| 30 |
#define NNTPGRAB_PLUGIN_API_VERSION 20110710 |
|
| 30 |
#define NNTPGRAB_PLUGIN_API_VERSION 20110712 |
|
| 31 | 31 |
|
| 32 | 32 |
typedef enum {
|
| 33 | 33 |
NNTP_ERROR_NONE, |
| trunk/nntpgrab_core/core_signals.c (revision 1853) | ||
|---|---|---|
| 124 | 124 |
char real_filename[256]; |
| 125 | 125 |
NGTaskState old_state; |
| 126 | 126 |
NGTaskState new_state; |
| 127 |
guint64 file_size_remaining; |
|
| 128 |
guint64 total_size; |
|
| 129 |
guint64 total_size_remaining; |
|
| 127 | 130 |
}; |
| 128 | 131 |
|
| 129 | 132 |
struct _schedular_data {
|
| ... | ... | |
| 953 | 956 |
signal_data->file_state_data.subject, |
| 954 | 957 |
real_filename, |
| 955 | 958 |
signal_data->file_state_data.old_state, |
| 956 |
signal_data->file_state_data.new_state); |
|
| 959 |
signal_data->file_state_data.new_state, |
|
| 960 |
signal_data->file_state_data.file_size_remaining, |
|
| 961 |
signal_data->file_state_data.total_size, |
|
| 962 |
signal_data->file_state_data.total_size_remaining); |
|
| 957 | 963 |
|
| 958 | 964 |
push_signal_data(signal_data); |
| 959 | 965 |
|
| ... | ... | |
| 961 | 967 |
} |
| 962 | 968 |
|
| 963 | 969 |
void |
| 964 |
nntpgrab_core_emit_file_state_changed(gboolean direct, const char *collection_name, const char *subject, const char *real_filename, NGTaskState old_state, NGTaskState new_state) |
|
| 970 |
nntpgrab_core_emit_file_state_changed(gboolean direct, const char *collection_name, const char *subject, const char *real_filename, NGTaskState old_state, NGTaskState new_state, guint64 file_size_remaining, guint64 total_size, guint64 total_size_remaining) |
|
| 965 | 971 |
{
|
| 966 | 972 |
SignalData *data; |
| 967 | 973 |
|
| ... | ... | |
| 977 | 983 |
} |
| 978 | 984 |
data->file_state_data.old_state = old_state; |
| 979 | 985 |
data->file_state_data.new_state = new_state; |
| 986 |
data->file_state_data.file_size_remaining = file_size_remaining; |
|
| 987 |
data->file_state_data.total_size = total_size; |
|
| 988 |
data->file_state_data.total_size_remaining = total_size_remaining; |
|
| 980 | 989 |
|
| 981 | 990 |
if (direct) {
|
| 982 | 991 |
do_emit_file_state_changed(data); |
| trunk/nntpgrab_core/nntpgrab_internal.h (revision 1853) | ||
|---|---|---|
| 40 | 40 |
void nntpgrab_core_emit_collection_modified(gboolean direct, const char *collection_name, const char *poster); |
| 41 | 41 |
void nntpgrab_core_emit_file_added(gboolean direct, const char *collection_name, const char *subject, const char *poster, guint64 stamp, guint64 file_size, guint64 total_size, guint64 total_size_remaining, NGTaskState status, int num_parts, GList *groups); |
| 42 | 42 |
void nntpgrab_core_emit_file_removed(gboolean direct, const char *collection_name, const char *subject, guint64 total_file_size, guint64 total_file_size_remaining); |
| 43 |
void nntpgrab_core_emit_file_download_state_update(gboolean direct, const char *collection_name, const char *subject, int num_parts_total, int num_parts_done, int num_parts_failed, guint64 file_size, guint64 file_size_remaining, guint64 total_file_size, guint64 total_file_size_remaining); |
|
| 44 |
void nntpgrab_core_emit_file_state_changed(gboolean direct, const char *collection_name, const char *subject, const char *real_filename, NGTaskState old_state, NGTaskState new_state); |
|
| 43 |
void nntpgrab_core_emit_file_download_state_update(gboolean direct, const char *collection_name, const char *subject, int num_parts_total, int num_parts_done, int num_parts_failed, guint64 file_size, guint64 file_size_remaining, guint64 total_size, guint64 total_size_remaining); |
|
| 44 |
void nntpgrab_core_emit_file_state_changed(gboolean direct, const char *collection_name, const char *subject, const char *real_filename, NGTaskState old_state, NGTaskState new_state, guint64 file_size_remaining, guint64 total_size, guint64 total_size_remaining); |
|
| 45 | 45 |
void nntpgrab_core_emit_schedular_state_changed(gboolean direct, NGSchedularState state, const char *reason); |
| 46 | 46 |
void nntpgrab_core_emit_file_moved(gboolean direct, const char *orig_collection_name, const char *subject, const char *new_collection_name, int old_position, int new_position); |
| 47 | 47 |
void nntpgrab_core_emit_collection_moved(gboolean direct, const char *collection_name, int old_position, int new_position); |
| trunk/nntpgrab_core/nntpgrab.h (revision 1853) | ||
|---|---|---|
| 25 | 25 |
extern "C" {
|
| 26 | 26 |
#endif |
| 27 | 27 |
|
| 28 |
#define NNTPGRAB_API_VERSION 20110710 |
|
| 28 |
#define NNTPGRAB_API_VERSION 20110712 |
|
| 29 | 29 |
|
| 30 | 30 |
#define NNTPGRAB_TYPE_CORE (nntpgrab_core_get_type ()) |
| 31 | 31 |
#define NNTPGRAB_CORE(object) (NG_TYPE_CHECK_INSTANCE_CAST ((object), NNTPGRAB_TYPE_CORE, NntpgrabCore)) |
| trunk/nntpgrab_core/marshall.list (revision 1853) | ||
|---|---|---|
| 22 | 22 |
VOID:STRING,STRING,UINT64,UINT64 |
| 23 | 23 |
# void (*file_download_state_update) (NNTPGrabCore *core, const char *collection_name, const char *subject, int num_parts_total, int num_parts_done, int num_parts_failed, guint64 file_size, guint64 file_size_remaining, guint64 total_file_size, guint64 total_file_size_remaining); |
| 24 | 24 |
VOID:STRING,STRING,INT,INT,INT,UINT64,UINT64,UINT64,UINT64 |
| 25 |
# void (*file_state_changed) (NNTPGrabCore *core, const char *collection_name, const char *subject, const char *real_filename, NGTaskState old_state, NGTaskState new_state); |
|
| 26 |
VOID:STRING,STRING,STRING,INT,INT |
|
| 25 |
# void (*file_state_changed) (NNTPGrabCore *core, const char *collection_name, const char *subject, const char *real_filename, NGTaskState old_state, NGTaskState new_state, guint64 file_size_remaining, guint64 total_size, guint64 total_size_remaining); |
|
| 26 |
VOID:STRING,STRING,STRING,INT,INT,UINT64,UINT64,UINT64 |
|
| 27 | 27 |
# void (*connection_connecting) (NNTPGrabCore *core, const char *servername, int conn_id); |
| 28 | 28 |
VOID:STRING,INT |
| 29 | 29 |
# void (*connection_connected) (NNTPGrabCore *core, const char *servername, int conn_id, const char *welcome_msg); |
| trunk/plugins/jsonrpc/jsonrpc_events.c (revision 1853) | ||
|---|---|---|
| 302 | 302 |
} |
| 303 | 303 |
|
| 304 | 304 |
static void |
| 305 |
file_state_changed (NGPlugin *plugin_data, const char *collection_name, const char *subject, const char *real_filename, NGTaskState old_state, NGTaskState new_state, gpointer data) |
|
| 305 |
file_state_changed (NGPlugin *plugin_data, const char *collection_name, const char *subject, const char *real_filename, NGTaskState old_state, NGTaskState new_state, guint64 file_size_remaining, guint64 total_size, guint64 total_size_remaining, gpointer data) |
|
| 306 | 306 |
{
|
| 307 | 307 |
struct json_object *event = json_object_new_object(); |
| 308 |
int i_file_size_remaining = 0; |
|
| 309 |
int i_total_size = 0; |
|
| 310 |
int i_total_size_remaining = 0; |
|
| 308 | 311 |
|
| 312 |
if (file_size_remaining) {
|
|
| 313 |
i_file_size_remaining = max(1, file_size_remaining / 1024); |
|
| 314 |
} |
|
| 315 |
if (total_size != 0) {
|
|
| 316 |
i_total_size = max(1, total_size / 1024); |
|
| 317 |
} |
|
| 318 |
if (total_size_remaining != 0) {
|
|
| 319 |
i_total_size_remaining = max(1, total_size_remaining / 1024); |
|
| 320 |
} |
|
| 321 |
|
|
| 309 | 322 |
json_object_object_add(event, "collection_name", json_object_new_string((char*) collection_name)); |
| 310 | 323 |
json_object_object_add(event, "subject", json_object_new_string((char*) subject)); |
| 311 | 324 |
json_object_object_add(event, "real_filename", json_object_new_string((char*) (real_filename ? real_filename : ""))); |
| 312 | 325 |
json_object_object_add(event, "old_state", json_object_new_int(old_state)); |
| 313 | 326 |
json_object_object_add(event, "new_state", json_object_new_int(new_state)); |
| 327 |
json_object_object_add(event, "file_size_remaining", json_object_new_int(i_file_size_remaining)); |
|
| 328 |
json_object_object_add(event, "total_size", json_object_new_int(i_total_size)); |
|
| 329 |
json_object_object_add(event, "total_size_remaining", json_object_new_int(i_total_size_remaining)); |
|
| 314 | 330 |
|
| 315 | 331 |
emit_event("file_state_changed", event);
|
| 316 | 332 |
|
| trunk/glue/glue_json.c (revision 1853) | ||
|---|---|---|
| 308 | 308 |
char *real_filename; |
| 309 | 309 |
int old_state; |
| 310 | 310 |
int new_state; |
| 311 |
guint64 file_size_remaining; |
|
| 312 |
guint64 total_size; |
|
| 313 |
guint64 total_size_remaining; |
|
| 311 | 314 |
|
| 312 | 315 |
get_param(msg, params, "collection_name", "file_state_changed", string, collection_name); |
| 313 | 316 |
get_param(msg, params, "subject", "file_state_changed", string, subject); |
| 314 | 317 |
get_param(msg, params, "real_filename", "file_state_changed", string, real_filename); |
| 315 | 318 |
get_param(msg, params, "old_state", "file_state_changed", int, old_state); |
| 316 | 319 |
get_param(msg, params, "new_state", "file_state_changed", int, new_state); |
| 320 |
get_param(msg, params, "file_size_remaining", "file_state_changed", int, file_size_remaining); |
|
| 321 |
get_param(msg, params, "total_size", "file_state_changed", int, total_size); |
|
| 322 |
get_param(msg, params, "total_size_remaining", "file_state_changed", int, total_size_remaining); |
|
| 317 | 323 |
|
| 318 |
nntpgrab_core_emit_file_state_changed(FALSE, collection_name, subject, real_filename, old_state, new_state); |
|
| 324 |
nntpgrab_core_emit_file_state_changed(FALSE, collection_name, subject, real_filename, old_state, new_state, file_size_remaining * 1024, total_size * 1024, total_size_remaining * 1024); |
|
| 319 | 325 |
} |
| 320 | 326 |
|
| 321 | 327 |
static void |
| trunk/glue/glue.c (revision 1853) | ||
|---|---|---|
| 372 | 372 |
G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, |
| 373 | 373 |
0, |
| 374 | 374 |
NULL, NULL, |
| 375 |
nntpgrab_marshal_VOID__STRING_STRING_STRING_INT_INT, |
|
| 376 |
G_TYPE_NONE, 5, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT, G_TYPE_INT); |
|
| 375 |
nntpgrab_marshal_VOID__STRING_STRING_STRING_INT_INT_UINT64_UINT64_UINT64, |
|
| 376 |
G_TYPE_NONE, 8, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT, G_TYPE_INT, G_TYPE_UINT64, G_TYPE_UINT64, G_TYPE_UINT64); |
|
| 377 | 377 |
|
| 378 | 378 |
/** |
| 379 | 379 |
* NntpgrabGlue::connection-connecting: |
| trunk/glue/nntpgrab_glue.h (revision 1853) | ||
|---|---|---|
| 25 | 25 |
extern "C" {
|
| 26 | 26 |
#endif |
| 27 | 27 |
|
| 28 |
#define NNTPGRAB_GLUE_VERSION 20110710 |
|
| 28 |
#define NNTPGRAB_GLUE_VERSION 20110712 |
|
| 29 | 29 |
|
| 30 | 30 |
#define NNTPGRAB_TYPE_GLUE (nntpgrab_glue_get_type ()) |
| 31 | 31 |
#define NNTPGRAB_GLUE(object) (NG_TYPE_CHECK_INSTANCE_CAST ((object), NNTPGRAB_TYPE_GLUE, NntpgrabGlue)) |
| trunk/NNTPGrab.files (revision 1853) | ||
|---|---|---|
| 96 | 96 |
nntpgrab_core/download_queue.h |
| 97 | 97 |
nntpgrab_core/download_thread.c |
| 98 | 98 |
nntpgrab_core/download_thread.h |
| 99 |
nntpgrab_core/marshall.list |
|
| 99 | 100 |
nntpgrab_core/marshalers.c |
| 100 | 101 |
nntpgrab_core/marshalers.h |
| 101 | 102 |
nntpgrab_core/nntpconnection.c |
| trunk/client/gui/notify.c (revision 1853) | ||
|---|---|---|
| 24 | 24 |
#include |
| 25 | 25 |
|
| 26 | 26 |
static void |
| 27 |
file_state_changed (NntpgrabGlue *obj, const char *collection_name, const char *subject, const char *real_filename, NGTaskState old_state, NGTaskState new_state, gpointer data) |
|
| 27 |
file_state_changed (NntpgrabGlue *obj, const char *collection_name, const char *subject, const char *real_filename, NGTaskState old_state, NGTaskState new_state, guint64 file_size_remaining, guint64 total_size, guint64 total_size_remaining, gpointer data) |
|
| 28 | 28 |
{
|
| 29 | 29 |
char *msg; |
| 30 | 30 |
NotifyNotification *notification; |
| trunk/client/gui/queue.c (revision 1853) | ||
|---|---|---|
| 1219 | 1219 |
} |
| 1220 | 1220 |
|
| 1221 | 1221 |
static void |
| 1222 |
file_state_changed (NntpgrabGlue *obj, const char *collection_name, const char *subject, const char *real_filename, NGTaskState old_state, NGTaskState new_state) |
|
| 1222 |
file_state_changed (NntpgrabGlue *obj, const char *collection_name, const char *subject, const char *real_filename, NGTaskState old_state, NGTaskState new_state, guint64 file_size_remaining, guint64 total_size, guint64 total_size_remaining) |
|
| 1223 | 1223 |
{
|
| 1224 | 1224 |
GtkWidget *treeDownloadQueue; |
| 1225 | 1225 |
GtkTreeModel *store; |
| 1226 | 1226 |
GtkTreeIter iter, parent; |
| 1227 | 1227 |
int progress; |
| 1228 |
guint64 file_size; |
|
| 1229 |
guint64 file_size_remaining; |
|
| 1230 |
guint64 total_size; |
|
| 1231 |
guint64 total_size_remaining; |
|
| 1232 | 1228 |
char size[64]; |
| 1233 | 1229 |
char size_remaining[64]; |
| 1234 | 1230 |
|
| ... | ... | |
| 1241 | 1237 |
switch(new_state) {
|
| 1242 | 1238 |
case TASK_STATE_WAITING_FOR_DOWNLOAD: // The file was restarted |
| 1243 | 1239 |
// Update the row itself |
| 1244 |
gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, FIELD_FILESIZE, &file_size, |
|
| 1245 |
FIELD_FILESIZE_REMAINING, &file_size_remaining, -1); |
|
| 1246 |
|
|
| 1247 | 1240 |
memset(size_remaining, 0, sizeof(size_remaining)); |
| 1248 |
nntpgrab_utils_calculate_file_size(file_size, size_remaining, sizeof(size_remaining) - 1); |
|
| 1241 |
nntpgrab_utils_calculate_file_size(file_size_remaining, size_remaining, sizeof(size_remaining) - 1); |
|
| 1249 | 1242 |
|
| 1250 | 1243 |
gtk_tree_store_set(GTK_TREE_STORE(store), &iter, FIELD_PARTS_DONE, (int) 0, |
| 1251 | 1244 |
FIELD_PARTS_FAILED, (int) 0, |
| 1252 | 1245 |
FIELD_PROGRESS, (int) 0, |
| 1253 | 1246 |
FIELD_STATE_STR, NULL, |
| 1254 |
FIELD_FILESIZE_REMAINING, file_size, |
|
| 1247 |
FIELD_FILESIZE_REMAINING, file_size_remaining, |
|
| 1255 | 1248 |
FIELD_FILESIZE_REMAINING_STR, size_remaining, -1); |
| 1256 | 1249 |
|
| 1257 | 1250 |
// Update the parent |
| 1258 |
gtk_tree_model_get(GTK_TREE_MODEL(store), &parent, FIELD_FILESIZE, &total_size, |
|
| 1259 |
FIELD_FILESIZE_REMAINING, &total_size_remaining, -1); |
|
| 1260 |
|
|
| 1261 |
if (old_state == TASK_STATE_SKIPPED) {
|
|
| 1262 |
total_size += file_size - file_size_remaining; |
|
| 1263 |
} |
|
| 1264 |
|
|
| 1265 |
total_size_remaining += file_size - file_size_remaining; |
|
| 1266 | 1251 |
progress = calculate_progress(total_size, total_size_remaining); |
| 1267 | 1252 |
|
| 1268 | 1253 |
memset(size, 0, sizeof(size)); |
| 1269 |
nntpgrab_utils_calculate_file_size(total_size_remaining, size, sizeof(size) - 1); |
|
| 1254 |
nntpgrab_utils_calculate_file_size(total_size, size, sizeof(size) - 1); |
|
| 1270 | 1255 |
|
| 1271 | 1256 |
memset(size_remaining, 0, sizeof(size_remaining)); |
| 1272 | 1257 |
nntpgrab_utils_calculate_file_size(total_size_remaining, size_remaining, sizeof(size_remaining) - 1); |
| ... | ... | |
| 1316 | 1301 |
break; |
| 1317 | 1302 |
|
| 1318 | 1303 |
case TASK_STATE_SKIPPED: |
| 1319 |
gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, FIELD_FILESIZE, &file_size, |
|
| 1320 |
FIELD_FILESIZE_REMAINING, &file_size_remaining, -1); |
|
| 1321 |
|
|
| 1322 | 1304 |
gtk_tree_store_set(GTK_TREE_STORE(store), &iter, FIELD_STATE_STR, _("Skipped"),
|
| 1323 | 1305 |
FIELD_FILESIZE_REMAINING, (guint64) 0, |
| 1324 | 1306 |
FIELD_FILESIZE_REMAINING_STR, NULL, -1); |
| 1325 | 1307 |
|
| 1326 | 1308 |
// Update the parent |
| 1327 |
gtk_tree_model_get(GTK_TREE_MODEL(store), &parent, FIELD_FILESIZE, &total_size, |
|
| 1328 |
FIELD_FILESIZE_REMAINING, &total_size_remaining, -1); |
|
| 1329 |
|
|
| 1330 |
total_size -= file_size_remaining; |
|
| 1331 |
total_size_remaining -= file_size_remaining; |
|
| 1332 | 1309 |
progress = calculate_progress(total_size, total_size_remaining); |
| 1310 |
|
|
| 1311 |
memset(size, 0, sizeof(size)); |
|
| 1312 |
nntpgrab_utils_calculate_file_size(total_size, size, sizeof(size) - 1); |
|
| 1313 |
|
|
| 1333 | 1314 |
memset(size_remaining, 0, sizeof(size_remaining)); |
| 1334 | 1315 |
nntpgrab_utils_calculate_file_size(total_size_remaining, size_remaining, sizeof(size_remaining) - 1); |
| 1335 | 1316 |
|
| 1336 | 1317 |
gtk_tree_store_set(GTK_TREE_STORE(store), &parent, FIELD_PROGRESS, progress, |
| 1318 |
FIELD_FILESIZE, total_size, |
|
| 1319 |
FIELD_FILESIZE_REMAINING, size, |
|
| 1337 | 1320 |
FIELD_FILESIZE_REMAINING, total_size_remaining, |
| 1338 | 1321 |
FIELD_FILESIZE_REMAINING_STR, size_remaining, -1); |
| 1339 | 1322 |
|
| trunk/client/gui_qt/QNNTPGrabGlue_p.h (revision 1853) | ||
|---|---|---|
| 48 | 48 |
static void fileAddedWrapper(NntpgrabGlue *glue, const char *collection_name, const char *subject, const char *poster, nguint64 stamp, nguint64 file_size, nguint64 total_size, nguint64 total_size_remaining, NGTaskState state, int num_parts, NGList *groups, void *data); |
| 49 | 49 |
static void fileRemovedWrapper(NntpgrabGlue *glue, const char *collection_name, const char *subject, nguint64 total_size, nguint64 total_size_remaining, void *data); |
| 50 | 50 |
static void fileDownloadStateUpdateWrapper(NntpgrabGlue *glue, const char *collection_name, const char *subject, int num_parts_total, int num_parts_done, int num_parts_failed, nguint64 file_size, nguint64 file_size_remaining, nguint64 total_size, nguint64 total_size_remaining, void *data); |
| 51 |
static void fileStateChangedWrapper(NntpgrabGlue *glue, const char *collection_name, const char *subject, const char *real_filename, NGTaskState old_state, NGTaskState new_state, void *data); |
|
| 51 |
static void fileStateChangedWrapper(NntpgrabGlue *glue, const char *collection_name, const char *subject, const char *real_filename, NGTaskState old_state, NGTaskState new_state, nguint64 file_size_remaining, nguint64 total_file_size, nguint64 total_file_size_remaining, void *data); |
|
| 52 | 52 |
static void connectionConnectingWrapper(NntpgrabGlue *glue, const char *servername, int conn_id, void *data); |
| 53 | 53 |
static void connectionConnectedWrapper(NntpgrabGlue *glue, const char *servername, int conn_id, const char *welcome_msg, void *data); |
| 54 | 54 |
static void connectionDisconnectWrapper(NntpgrabGlue *glue, const char *servername, int conn_id, NNTPDisconnectType disconnect_type, const char *reason, void *data); |
| trunk/client/gui_qt/DownloadQueueModel.h (revision 1853) | ||
|---|---|---|
| 32 | 32 |
|
| 33 | 33 |
private slots: |
| 34 | 34 |
void onFileDownloadStateUpdate(QString collection_name, QString subject, int num_parts_total, int num_parts_done, int num_parts_failed, quint64 file_size, quint64 file_size_remaining, quint64 total_size, quint64 total_size_remaining); |
| 35 |
void onFileStateChanged(QString collection_name, QString subject, QString real_filename, QNNTPGrabGlue::TaskState old_state, QNNTPGrabGlue::TaskState new_state); |
|
| 35 |
void onFileStateChanged(QString collection_name, QString subject, QString real_filename, QNNTPGrabGlue::TaskState old_state, QNNTPGrabGlue::TaskState new_state, quint64 file_size_remaining, quint64 total_size, quint64 total_size_remaining); |
|
| 36 | 36 |
|
| 37 | 37 |
void onFileAdded(QString collection_name, QString subject, QString poster, QDateTime stamp, quint64 file_size, quint64 total_size, quint64 total_size_remaining, QNNTPGrabGlue::TaskState state, int num_parts, QList |
| 38 | 38 |
void onFileRemoved(QString collection_name, QString subject, quint64 total_size, quint64 total_size_remaining); |
| trunk/client/gui_qt/mainwindow.cpp (revision 1853) | ||
|---|---|---|
| 91 | 91 |
connect(ui->actionShowDebugWindow, SIGNAL(triggered(void)), |
| 92 | 92 |
SLOT(actionShowDebugWindow_activated(void))); |
| 93 | 93 |
|
| 94 |
connect(glue, SIGNAL(fileStateChanged(QString,QString,QString,QNNTPGrabGlue::TaskState,QNNTPGrabGlue::TaskState)), |
|
| 95 |
SLOT(onFileStateChanged(QString,QString,QString,QNNTPGrabGlue::TaskState,QNNTPGrabGlue::TaskState))); |
|
| 94 |
connect(glue, SIGNAL(fileStateChanged(QString,QString,QString,QNNTPGrabGlue::TaskState,QNNTPGrabGlue::TaskState,quint64,quint64,quint64)), |
|
| 95 |
SLOT(onFileStateChanged(QString,QString,QString,QNNTPGrabGlue::TaskState,QNNTPGrabGlue::TaskState,quint64,quint64,quint64))); |
|
| 96 | 96 |
connect(glue, SIGNAL(schedularStateChanged(QNNTPGrabGlue::SchedularState,QString)), |
| 97 | 97 |
SLOT(onSchedularStateChanged(QNNTPGrabGlue::SchedularState,QString))); |
| 98 | 98 |
if (!glue->getIsStandalone()) {
|
| ... | ... | |
| 252 | 252 |
} |
| 253 | 253 |
} |
| 254 | 254 |
|
| 255 |
void MainWindow::onFileStateChanged(QString collection_name, QString subject, QString real_filename, QNNTPGrabGlue::TaskState old_state, QNNTPGrabGlue::TaskState new_state) |
|
| 255 |
void MainWindow::onFileStateChanged(QString collection_name, QString subject, QString real_filename, QNNTPGrabGlue::TaskState old_state, QNNTPGrabGlue::TaskState new_state, quint64 file_size_remaining, quint64 total_size, quint64 total_size_remaining) |
|
| 256 | 256 |
{
|
| 257 | 257 |
Q_UNUSED(collection_name); |
| 258 | 258 |
Q_UNUSED(real_filename); |
| trunk/client/gui_qt/QNNTPGrabGlue.h (revision 1853) | ||
|---|---|---|
| 48 | 48 |
LOG_LEVEL_WARNING, |
| 49 | 49 |
LOG_LEVEL_ERROR, |
| 50 | 50 |
LOG_LEVEL_FATAL, |
| 51 |
LOG_LEVEL_DEBUG, |
|
| 51 |
LOG_LEVEL_DEBUG |
|
| 52 | 52 |
}; |
| 53 | 53 |
|
| 54 | 54 |
enum SchedularState {
|
| ... | ... | |
| 220 | 220 |
void fileAdded(QString collection_name, QString subject, QString poster, QDateTime stamp, quint64 file_size, quint64 total_size, quint64 total_size_remaining, QNNTPGrabGlue::TaskState state, int num_parts, QList |
| 221 | 221 |
void fileRemoved(QString collection_name, QString subject, quint64 total_size, quint64 total_size_remaining); |
| 222 | 222 |
void fileDownloadStateUpdate(QString collection_name, QString subject, int num_parts_total, int num_parts_done, int num_parts_failed, quint64 file_size, quint64 file_size_remaining, quint64 total_size, quint64 total_size_remaining); |
| 223 |
void fileStateChanged(QString collection_name, QString subject, QString real_filename, QNNTPGrabGlue::TaskState old_state, QNNTPGrabGlue::TaskState new_state); |
|
| 223 |
void fileStateChanged(QString collection_name, QString subject, QString real_filename, QNNTPGrabGlue::TaskState old_state, QNNTPGrabGlue::TaskState new_state, quint64 file_size_remaining, quint64 total_size, quint64 total_size_remaining); |
|
| 224 | 224 |
void connectionConnecting(QString servername, int conn_id); |
| 225 | 225 |
void connectionConnected(QString servername, int conn_id, QString welcome_msg); |
| 226 | 226 |
void connectionDisconnect(QString servername, int conn_id, QNNTPGrabGlue::NNTPDisconnectType disconnect_type, QString reason); |
| ... | ... | |
| 234 | 234 |
void pluginEvent(QString plugin_name, QString event_name, QList |
| 235 | 235 |
|
| 236 | 236 |
private: |
| 237 |
Q_DECLARE_PRIVATE(QNNTPGrabGlue); |
|
| 237 |
Q_DECLARE_PRIVATE(QNNTPGrabGlue) |
|
| 238 | 238 |
QNNTPGrabGluePrivate * const d_ptr; |
| 239 | 239 |
}; |
| 240 | 240 |
|
| trunk/client/gui_qt/DownloadQueueModel.cpp (revision 1853) | ||
|---|---|---|
| 8 | 8 |
loadDownloadQueue(glue); |
| 9 | 9 |
|
| 10 | 10 |
connect(glue, SIGNAL(fileDownloadStateUpdate(QString,QString,int,int,int,quint64,quint64,quint64,quint64)), SLOT(onFileDownloadStateUpdate(QString,QString,int,int,int,quint64,quint64,quint64,quint64)), Qt::QueuedConnection); |
| 11 |
connect(glue, SIGNAL(fileStateChanged(QString,QString,QString,QNNTPGrabGlue::TaskState,QNNTPGrabGlue::TaskState)), SLOT(onFileStateChanged(QString,QString,QString,QNNTPGrabGlue::TaskState,QNNTPGrabGlue::TaskState)), Qt::QueuedConnection); |
|
| 11 |
connect(glue, SIGNAL(fileStateChanged(QString,QString,QString,QNNTPGrabGlue::TaskState,QNNTPGrabGlue::TaskState,quint64,quint64,quint64)), SLOT(onFileStateChanged(QString,QString,QString,QNNTPGrabGlue::TaskState,QNNTPGrabGlue::TaskState,quint64,quint64,quint64)), Qt::QueuedConnection); |
|
| 12 | 12 |
|
| 13 | 13 |
connect(glue, SIGNAL(fileAdded(QString,QString,QString,QDateTime,quint64,quint64,quint64,QNNTPGrabGlue::TaskState,int,QList |
| 14 | 14 |
connect(glue, SIGNAL(fileRemoved(QString,QString,quint64,quint64)), SLOT(onFileRemoved(QString,QString,quint64,quint64)), Qt::QueuedConnection); |
| ... | ... | |
| 254 | 254 |
|
| 255 | 255 |
if (ret < 0 || ret > 100) {
|
| 256 | 256 |
qDebug("Invalid progress detected, size = %lli, size_remaining = %lli", size, sizeRemaining);
|
| 257 |
if (ret < 0) {
|
|
| 258 |
ret = 0; |
|
| 259 |
} |
|
| 257 | 260 |
} |
| 258 | 261 |
|
| 259 | 262 |
return qMin(100, ret); |
| ... | ... | |
| 323 | 326 |
emit dataChanged(idx, idx); |
| 324 | 327 |
} |
| 325 | 328 |
|
| 326 |
void DownloadQueueModel::onFileStateChanged(QString collection_name, QString subject, QString real_filename, QNNTPGrabGlue::TaskState old_state, QNNTPGrabGlue::TaskState new_state) |
|
| 329 |
void DownloadQueueModel::onFileStateChanged(QString collection_name, QString subject, QString real_filename, QNNTPGrabGlue::TaskState old_state, QNNTPGrabGlue::TaskState new_state, quint64 file_size_remaining, quint64 total_size, quint64 total_size_remaining) |
|
| 327 | 330 |
{
|
| 328 | 331 |
Q_UNUSED(old_state); |
| 329 | 332 |
|
| 333 |
QModelIndex idx; |
|
| 330 | 334 |
DownloadQueueItem *collection_node; |
| 331 | 335 |
DownloadQueueItem *subject_node; |
| 332 | 336 |
|
| ... | ... | |
| 338 | 342 |
return; |
| 339 | 343 |
} |
| 340 | 344 |
|
| 341 |
quint64 file_size; |
|
| 342 |
quint64 file_size_remaining; |
|
| 343 |
QString size_remaining; |
|
| 344 |
quint64 total_size; |
|
| 345 |
quint64 total_size_remaining; |
|
| 346 |
QModelIndex idx; |
|
| 347 |
|
|
| 348 | 345 |
switch(new_state) {
|
| 349 | 346 |
case QNNTPGrabGlue::TASK_STATE_WAITING_FOR_DOWNLOAD: |
| 350 | 347 |
/* The task was restarted */ |
| 351 | 348 |
|
| 352 | 349 |
/* Update the row itself */ |
| 353 |
file_size = subject_node->size; |
|
| 354 |
file_size_remaining = subject_node->sizeRemaining; |
|
| 355 |
|
|
| 356 | 350 |
subject_node->progress = 0; |
| 357 | 351 |
subject_node->stateStr = ""; |
| 358 |
subject_node->sizeRemaining = file_size; |
|
| 359 |
subject_node->sizeRemainingStr = QNNTPGrabGlue::utilsCalculateFileSize(file_size); |
|
| 352 |
subject_node->sizeRemaining = file_size_remaining; |
|
| 353 |
subject_node->sizeRemainingStr = QNNTPGrabGlue::utilsCalculateFileSize(file_size_remaining); |
|
| 360 | 354 |
|
| 361 | 355 |
/* Update the parent */ |
| 362 |
total_size = collection_node->size; |
|
| 363 |
total_size_remaining = collection_node->sizeRemaining; |
|
| 364 |
|
|
| 365 |
total_size_remaining += file_size - file_size_remaining; |
|
| 366 |
|
|
| 367 | 356 |
collection_node->progress = calculateProgress(total_size, total_size_remaining); |
| 357 |
collection_node->size = total_size; |
|
| 358 |
collection_node->sizeStr = QNNTPGrabGlue::utilsCalculateFileSize(total_size); |
|
| 368 | 359 |
collection_node->sizeRemaining = total_size_remaining; |
| 369 | 360 |
collection_node->sizeRemainingStr = QNNTPGrabGlue::utilsCalculateFileSize(total_size_remaining); |
| 370 | 361 |
|
| ... | ... | |
| 380 | 371 |
subject_node->stateStr = ""; /* The state message should be empty. In that case the value of the progress bar will be shown */ |
| 381 | 372 |
break; |
| 382 | 373 |
case QNNTPGrabGlue::TASK_STATE_WAITING_FOR_DECODE: |
| 383 |
size_remaining = QNNTPGrabGlue::utilsCalculateFileSize(0); |
|
| 384 | 374 |
subject_node->progress = 100; |
| 385 | 375 |
subject_node->sizeRemaining = 0; |
| 386 |
subject_node->sizeRemainingStr = size_remaining; |
|
| 376 |
subject_node->sizeRemainingStr = QNNTPGrabGlue::utilsCalculateFileSize(0); |
|
| 387 | 377 |
subject_node->stateStr = tr("Waiting");
|
| 388 | 378 |
break; |
| 389 | 379 |
case QNNTPGrabGlue::TASK_STATE_DECODING: |
| ... | ... | |
| 406 | 396 |
subject_node->stateStr = tr("Not available");
|
| 407 | 397 |
break; |
| 408 | 398 |
case QNNTPGrabGlue::TASK_STATE_SKIPPED: |
| 409 |
size_remaining = QNNTPGrabGlue::utilsCalculateFileSize(0); |
|
| 410 | 399 |
subject_node->stateStr = tr("Skipped");
|
| 411 | 400 |
subject_node->sizeRemaining = 0; |
| 412 |
subject_node->sizeRemainingStr = size_remaining; |
|
| 401 |
subject_node->sizeRemainingStr = ""; |
|
| 402 |
|
|
| 403 |
/* Update the parent */ |
|
| 404 |
collection_node->progress = calculateProgress(total_size, total_size_remaining); |
|
| 405 |
collection_node->size = total_size; |
|
| 406 |
collection_node->sizeStr = QNNTPGrabGlue::utilsCalculateFileSize(total_size); |
|
| 407 |
collection_node->sizeRemaining = total_size_remaining; |
|
| 408 |
collection_node->sizeRemainingStr = QNNTPGrabGlue::utilsCalculateFileSize(total_size_remaining); |
|
| 409 |
|
|
| 410 |
idx = createIndex(collection_node->row(), (int) DownloadQueueItem::FIELD_STATE_STR, collection_node); |
|
| 411 |
emit dataChanged(idx, idx); |
|
| 412 |
|
|
| 413 |
idx = createIndex(collection_node->row(), (int) DownloadQueueItem::FIELD_FILE_SIZE_REMAINING_STR, collection_node); |
|
| 414 |
emit dataChanged(idx, idx); |
|
| 415 |
|
|
| 413 | 416 |
break; |
| 414 | 417 |
} |
| 415 | 418 |
|
| trunk/client/gui_qt/QNNTPGrabGlue.cpp (revision 1853) | ||
|---|---|---|
| 170 | 170 |
emit ((QNNTPGrabGlue*) data)->fileDownloadStateUpdate(QString::fromUtf8(collection_name), QString::fromUtf8(subject), num_parts_total, num_parts_done, num_parts_failed, file_size, file_size_remaining, total_size, total_size_remaining); |
| 171 | 171 |
} |
| 172 | 172 |
|
| 173 |
void QNNTPGrabGluePrivate::fileStateChangedWrapper(NntpgrabGlue *glue, const char *collection_name, const char *subject, const char *real_filename, NGTaskState old_state, NGTaskState new_state, void *data) |
|
| 173 |
void QNNTPGrabGluePrivate::fileStateChangedWrapper(NntpgrabGlue *glue, const char *collection_name, const char *subject, const char *real_filename, NGTaskState old_state, NGTaskState new_state, nguint64 file_size_remaining, nguint64 total_size, nguint64 total_size_remaining, void *data) |
|
| 174 | 174 |
{
|
| 175 | 175 |
Q_UNUSED(glue); |
| 176 | 176 |
|
| 177 |
emit ((QNNTPGrabGlue*) data)->fileStateChanged(QString::fromUtf8(collection_name), QString::fromUtf8(subject), QString::fromUtf8(real_filename), (QNNTPGrabGlue::TaskState) old_state, (QNNTPGrabGlue::TaskState) new_state); |
|
| 177 |
emit ((QNNTPGrabGlue*) data)->fileStateChanged(QString::fromUtf8(collection_name), QString::fromUtf8(subject), QString::fromUtf8(real_filename), (QNNTPGrabGlue::TaskState) old_state, (QNNTPGrabGlue::TaskState) new_state, file_size_remaining, total_size, total_size_remaining); |
|
| 178 | 178 |
} |
| 179 | 179 |
|
| 180 | 180 |
void QNNTPGrabGluePrivate::connectionConnectingWrapper(NntpgrabGlue *glue, const char *servername, int conn_id, void *data) |
| trunk/client/gui_qt/mainwindow.h (revision 1853) | ||
|---|---|---|
| 73 | 73 |
void actionShowDebugWindow_activated(void); |
| 74 | 74 |
void actionPauseDownloadQueue_activated(void); |
| 75 | 75 |
|
| 76 |
void onFileStateChanged(QString collection_name, QString subject, QString real_filename, QNNTPGrabGlue::TaskState old_state, QNNTPGrabGlue::TaskState new_state); |
|
| 76 |
void onFileStateChanged(QString collection_name, QString subject, QString real_filename, QNNTPGrabGlue::TaskState old_state, QNNTPGrabGlue::TaskState new_state, quint64 file_size_remaining, quint64 total_size, quint64 total_size_remaining); |
|
| 77 | 77 |
void onSchedularStateChanged(QNNTPGrabGlue::SchedularState state, QString reason); |
| 78 | 78 |
void onConnectionLost(QString errmsg); |
| 79 | 79 |
void onAllDownloadsCompleted(void); |
Also available in: Unified diff
NNTPGrab

