Revision 1854 trunk/base/nzbcreator.c

nzbcreator.c (revision 1854)
49 49
    SoupSession *session;
50 50
    SoupMessage *msg;
51 51
    GError *err = NULL;
52
    NGList *list;
53 52

                
54 53
    g_return_val_if_fail(api_okay != NULL, FALSE);
55 54

                
56
    session = soup_session_sync_new();
55
    session = soup_session_sync_new_with_options("timeout", 30, NULL);
57 56

                
58 57
#ifdef HAVE_SOUP_GNOME
59 58
    /* Enable proxy support when using GNOME 2.26.0 or higher */
... ...
134 133
        *errmsg = g_strdup(_("Support for the Online Search hasn't been enabled in this build. Please rebuild NNTPGrab to enable this feature"));
135 134
    }
136 135
#else
137
    SoupSession *session = soup_session_sync_new();
136
    SoupSession *session = soup_session_sync_new_with_options("timeout", 30, NULL);
138 137
    SoupMessage *msg = soup_xmlrpc_request_new(URI, "getListOfAvailableGroups", G_TYPE_INVALID);
139 138
    GError *err = NULL;
140 139
    int i;
... ...
156 155
    soup_session_send_message(session, msg);
157 156
    if (!SOUP_STATUS_IS_SUCCESSFUL (msg->status_code)) {
158 157
        if (errmsg) {
159
            *errmsg = g_strdup_printf("Server returned unknown error: %s (%i)", msg->reason_phrase, msg->status_code);
158
            *errmsg = g_strdup_printf(_("Server returned unknown error: %s (%i)"), msg->reason_phrase, msg->status_code);
160 159
        }
161 160
        g_object_unref(msg);
162 161
        g_object_unref(session);
... ...
166 165
    if (!soup_xmlrpc_extract_method_response(msg->response_body->data, msg->response_body->length, &err, G_TYPE_VALUE_ARRAY, &result)) {
167 166
        if (errmsg) {
168 167
            if (err) {
169
                *errmsg = g_strdup_printf("Unable to parse reply: %s", err->message);
168
                *errmsg = g_strdup_printf(_("An error occured while retrieving the list of Online Search groups:\n%s"), err->message);
170 169
            } else {
171
                *errmsg = g_strdup_printf(__FILE__ ":%i Unable to parse reply from server. See the console for more details", __LINE__);
170
                *errmsg = g_strdup_printf(_("%s:%i Unable to parse reply from server. See the console for more details"), __FILE__, __LINE__);
172 171
            }
173 172
        }
174 173

                
... ...
188 187
        int group_id = -1;
189 188

                
190 189
        if (!soup_value_array_get_nth(result, i, G_TYPE_HASH_TABLE, &group_arr)) {
191
            g_warning(__FILE__ ":%i Unable to parse values", __LINE__);
190
            g_warning(_("%s:%i Unable to parse values"), __FILE__, __LINE__);
192 191
            continue;
193 192
        }
194 193

                
195 194
        if (!soup_value_hash_lookup_vals(group_arr, "group_id", G_TYPE_INT, &group_id, "newsgroup", G_TYPE_STRING, &groupname, NULL)) {
196
            g_warning(__FILE__ ":%i Unable to parse values", __LINE__);
195
            g_warning(_("%s:%i Unable to parse values"), __FILE__, __LINE__);
197 196
            g_hash_table_destroy(group_arr);
198 197
            continue;
199 198
        }
... ...
251 250
    g_return_val_if_fail(opts.max_age <= 150, FALSE);
252 251
    g_return_val_if_fail(opts.percentage_complete <= 100, FALSE);
253 252

                
254
    session = soup_session_sync_new();
253
    session = soup_session_sync_new_with_options("timeout", 30, NULL);
255 254

                
256 255
#ifdef SOUP_TYPE_GNOME_FEATURES_2_26
257 256
    /* Enable proxy support when using GNOME 2.26.0 or higher */
... ...
305 304

                
306 305
    if (!SOUP_STATUS_IS_SUCCESSFUL (msg->status_code)) {
307 306
        if (errmsg) {
308
            *errmsg = g_strdup_printf("Server returned unknown error: %s (%i)", msg->reason_phrase, msg->status_code);
307
            *errmsg = g_strdup_printf(_("Server returned unknown error: %s (%i)"), msg->reason_phrase, msg->status_code);
309 308
        }
310 309
        g_object_unref(msg);
311 310
        g_object_unref(session);
... ...
315 314
    if (!soup_xmlrpc_extract_method_response(msg->response_body->data, msg->response_body->length, &err, G_TYPE_HASH_TABLE, &rpc_result)) {
316 315
        if (errmsg) {
317 316
            if (err) {
318
                *errmsg = g_strdup_printf("Unable to parse reply: %s", err->message);
317
                *errmsg = g_strdup_printf(_("An error occured while performing the search:\n%s"), err->message);
319 318
            } else {
320
                *errmsg = g_strdup_printf(__FILE__ ":%i Unable to parse reply from server. See the console for more details", __LINE__);
319
                *errmsg = g_strdup_printf(_("%s:%i Unable to parse reply from server. See the console for more details"), __FILE__, __LINE__);
321 320
            }
322 321
        }
323 322

                
... ...
338 337
                                                    "offset", G_TYPE_INT, &result->offset,
339 338
                                                    "matches", G_TYPE_VALUE_ARRAY, &matches,
340 339
                                                    NULL)) {
341
        g_warning(__FILE__ ":%i Unable to parse values", __LINE__);
340
        g_warning(_("%s:%i Unable to parse values"), __FILE__, __LINE__);
342 341
        g_slice_free(NZBCreatorSearchResult, result);
343 342
        g_hash_table_destroy(rpc_result);
344 343
        g_object_unref(msg);
... ...
382 381
                                                            "num_par2_files", G_TYPE_INT, &num_par2_files,
383 382
                                                            "first_file_id", G_TYPE_INT, &first_file_id,
384 383
                                                            NULL)) {
385
            g_warning(__FILE__ ":%i Unable to parse values", __LINE__);
384
            g_warning(_("%s:%i Unable to parse values"), __FILE__, __LINE__);
386 385
            g_hash_table_destroy(hash_collection);
387 386
            continue;
388 387
        }
... ...
427 426
    SoupMessage *msg;
428 427
    GHashTable *args;
429 428
    GError *err = NULL;
430
    GHashTable *rpc_result = NULL;
431 429
    GValueArray *matches = NULL;
432 430
    int i;
433 431

                
434 432
    g_return_val_if_fail(collection_id > 0, FALSE);
435 433

                
436
    session = soup_session_sync_new();
434
    session = soup_session_sync_new_with_options("timeout", 30, NULL);
437 435

                
438 436
#ifdef SOUP_TYPE_GNOME_FEATURES_2_26
439 437
    /* Enable proxy support when using GNOME 2.26.0 or higher */
... ...
458 456

                
459 457
    if (!SOUP_STATUS_IS_SUCCESSFUL (msg->status_code)) {
460 458
        if (errmsg) {
461
            *errmsg = g_strdup_printf("Server returned unknown error: %s (%i)", msg->reason_phrase, msg->status_code);
459
            *errmsg = g_strdup_printf(_("Server returned unknown error: %s (%i)"), msg->reason_phrase, msg->status_code);
462 460
        }
463 461
        g_object_unref(msg);
464 462
        g_object_unref(session);
... ...
468 466
    if (!soup_xmlrpc_extract_method_response(msg->response_body->data, msg->response_body->length, &err, G_TYPE_VALUE_ARRAY, &matches)) {
469 467
        if (errmsg) {
470 468
            if (err) {
471
                *errmsg = g_strdup_printf("Unable to parse reply: %s", err->message);
469
                *errmsg = g_strdup_printf(_("An error occured while retrieving the collection details:\n%s"), err->message);
472 470
            } else {
473
                *errmsg = g_strdup_printf(__FILE__ ":%i Unable to parse reply from server:\n%s", __LINE__, msg->response_body->data);
471
                *errmsg = g_strdup_printf(_("%s:%i Unable to parse reply from server:\n%s"), __FILE__, __LINE__, msg->response_body->data);
474 472
            }
475 473
        }
476 474

                
... ...
498 496
        int stamp;
499 497

                
500 498
        if (!soup_value_array_get_nth(matches, i, G_TYPE_HASH_TABLE, &hash_file)) {
501
            g_warning(__FILE__ ":%i Unable to parse values", __LINE__);
499
            g_warning(_("%s:%i Unable to parse values"), __FILE__, __LINE__);
502 500
            continue;
503 501
        }
504 502

                
... ...
512 510
                                                    "stamp", G_TYPE_INT, &stamp,
513 511
                                                    "complete_percentage", G_TYPE_INT, &complete_percentage,
514 512
                                                    NULL)) {
515
            g_warning(__FILE__ ":%i Unable to parse values", __LINE__);
513
            g_warning(_("%s:%i Unable to parse values"), __FILE__, __LINE__);
516 514
            continue;
517 515
        }
518 516

                
... ...
574 572
        list = ng_list_next(list);
575 573
    }
576 574

                
577
    session = soup_session_sync_new();
575
    session = soup_session_sync_new_with_options("timeout", 30, NULL);
578 576

                
579 577
#ifdef HAVE_SOUP_GNOME
580 578
    /* Enable proxy support when using GNOME 2.26.0 or higher */
... ...
599 597

                
600 598
    if (!SOUP_STATUS_IS_SUCCESSFUL (msg->status_code)) {
601 599
        if (errmsg) {
602
            *errmsg = g_strdup_printf("Server returned unknown error: %s (%i)", msg->reason_phrase, msg->status_code);
600
            *errmsg = g_strdup_printf(_("Server returned unknown error: %s (%i)"), msg->reason_phrase, msg->status_code);
603 601
        }
604 602
        g_object_unref(msg);
605 603
        g_object_unref(session);
... ...
609 607
    if (!soup_xmlrpc_extract_method_response(msg->response_body->data, msg->response_body->length, &err, G_TYPE_STRING, &result)) {
610 608
        if (errmsg) {
611 609
            if (err) {
612
                *errmsg = g_strdup_printf("Unable to parse reply: %s", err->message);
610
                *errmsg = g_strdup_printf(_("An error occured while retrieving the NZB from the server:\n%s"), err->message);
613 611
            } else {
614
                *errmsg = g_strdup_printf(__FILE__ ":%i Unable to parse reply from server. See the console for more details", __LINE__);
612
                *errmsg = g_strdup_printf(_("%s:%i Unable to parse reply from server. See the console for more details"), __FILE__, __LINE__);
615 613
            }
616 614
        }
617 615

                

Also available in: Unified diff