comparison src/curl/curl.c @ 717:c1ec0d8d9553 trunk

[svn] - store proxy info
author nenolod
date Sat, 24 Feb 2007 10:32:25 -0800
parents e758e9d4f861
children d252f02a9beb
comparison
equal deleted inserted replaced
716:1f6525272597 717:c1ec0d8d9553
73 73
74 VFSFile *download; // file to write to as we download 74 VFSFile *download; // file to write to as we download
75 75
76 gchar *name; 76 gchar *name;
77 gchar *title; 77 gchar *title;
78
79 struct {
80 gchar *proxy_host;
81 gchar *proxy_auth;
82 } proxy_info;
78 }; 83 };
79 84
80 VFSConstructor curl_const; 85 VFSConstructor curl_const;
81 86
82 /* TODO: 87 /* TODO:
555 db = bmp_cfg_db_open(); 560 db = bmp_cfg_db_open();
556 561
557 bmp_cfg_db_get_bool(db, NULL, "use_proxy", &tmp); 562 bmp_cfg_db_get_bool(db, NULL, "use_proxy", &tmp);
558 if (tmp == TRUE) 563 if (tmp == TRUE)
559 { 564 {
560 gchar *proxy_host = NULL;
561 gint proxy_port = 0; 565 gint proxy_port = 0;
562 566
563 bmp_cfg_db_get_string(db, NULL, "proxy_host", &proxy_host); 567 bmp_cfg_db_get_string(db, NULL, "proxy_host",
568 &handle->proxy_info.proxy_host);
564 bmp_cfg_db_get_int(db, NULL, "proxy_port", &proxy_port); 569 bmp_cfg_db_get_int(db, NULL, "proxy_port", &proxy_port);
565 570
566 curl_easy_setopt(handle->curl, CURLOPT_PROXY, proxy_host); 571 curl_easy_setopt(handle->curl, CURLOPT_PROXY, handle->proxy_info.proxy_host);
567 curl_easy_setopt(handle->curl, CURLOPT_PROXYPORT, proxy_port); 572 curl_easy_setopt(handle->curl, CURLOPT_PROXYPORT, proxy_port);
568 573
569 tmp = FALSE; 574 tmp = FALSE;
570 575
571 bmp_cfg_db_get_bool(db, NULL, "proxy_use_auth", &tmp); 576 bmp_cfg_db_get_bool(db, NULL, "proxy_use_auth", &tmp);
572 if (tmp == TRUE) 577 if (tmp == TRUE)
573 { 578 {
574 gchar *userbuf, *proxy_user = NULL, *proxy_pass = NULL; 579 gchar *proxy_user = NULL, *proxy_pass = NULL;
575 580
576 bmp_cfg_db_get_string(db, NULL, "proxy_user", &proxy_user); 581 bmp_cfg_db_get_string(db, NULL, "proxy_user", &proxy_user);
577 bmp_cfg_db_get_string(db, NULL, "proxy_pass", &proxy_pass); 582 bmp_cfg_db_get_string(db, NULL, "proxy_pass", &proxy_pass);
578 583
579 userbuf = g_strdup_printf("%s:%s", 584 handle->proxy_info.proxy_auth = g_strdup_printf("%s:%s",
580 proxy_user != NULL ? proxy_user : "", 585 proxy_user != NULL ? proxy_user : "",
581 proxy_pass != NULL ? proxy_pass : ""); 586 proxy_pass != NULL ? proxy_pass : "");
582 587
583 if (proxy_user != NULL) 588 curl_easy_setopt(handle->curl, CURLOPT_PROXYUSERPWD,
584 g_free(proxy_user); 589 handle->proxy_info.proxy_auth);
585
586 if (proxy_pass != NULL)
587 g_free(proxy_pass);
588
589 curl_easy_setopt(handle->curl, CURLOPT_PROXYUSERPWD, userbuf);
590 590
591 g_free(userbuf); 591 g_free(userbuf);
592 } 592 }
593
594 if (proxy_host != NULL)
595 g_free(proxy_host);
596 } 593 }
597 594
598 bmp_cfg_db_close(db); 595 bmp_cfg_db_close(db);
599 } 596 }
600 597
637 if (handle->name) 634 if (handle->name)
638 g_free(handle->name); 635 g_free(handle->name);
639 if (handle->stream_stack != NULL) 636 if (handle->stream_stack != NULL)
640 g_slist_free(handle->stream_stack); 637 g_slist_free(handle->stream_stack);
641 curl_easy_cleanup(handle->curl); 638 curl_easy_cleanup(handle->curl);
639
640 if (handle->proxy_info.proxy_host != NULL)
641 g_free(handle->proxy_info.proxy_host);
642
643 if (handle->proxy_info.proxy_auth != NULL)
644 g_free(handle->proxy_info.proxy_auth);
642 645
643 if (handle->download) 646 if (handle->download)
644 { 647 {
645 vfs_fclose(handle->download); 648 vfs_fclose(handle->download);
646 } 649 }