]>
git.saurik.com Git - apt.git/blob - apt-pkg/acquire.cc
1 // -*- mode: cpp; mode: fold -*-
3 // $Id: acquire.cc,v 1.2 1998/10/20 02:39:15 jgg Exp $
4 /* ######################################################################
6 Acquire - File Acquiration
8 ##################################################################### */
10 // Include Files /*{{{*/
12 #pragma implementation "apt-pkg/acquire.h"
14 #include <apt-pkg/acquire.h>
15 #include <apt-pkg/acquire-item.h>
16 #include <apt-pkg/acquire-worker.h>
20 // Acquire::pkgAcquire - Constructor /*{{{*/
21 // ---------------------------------------------------------------------
23 pkgAcquire::pkgAcquire()
29 // Acquire::~pkgAcquire - Destructor /*{{{*/
30 // ---------------------------------------------------------------------
32 pkgAcquire::~pkgAcquire()
34 while (Items
.size() != 0)
39 MethodConfig
*Jnk
= Configs
;
40 Configs
= Configs
->Next
;
45 // Acquire::Add - Add a new item /*{{{*/
46 // ---------------------------------------------------------------------
48 void pkgAcquire::Add(Item
*Itm
)
53 // Acquire::Remove - Remove a item /*{{{*/
54 // ---------------------------------------------------------------------
56 void pkgAcquire::Remove(Item
*Itm
)
58 for (vector
<Item
*>::iterator I
= Items
.begin(); I
< Items
.end(); I
++)
65 // Acquire::Enqueue - Queue an URI for fetching /*{{{*/
66 // ---------------------------------------------------------------------
68 void pkgAcquire::Enqueue(Item
*Item
,string URI
)
70 cout
<< "Fetching " << URI
<< endl
;
71 cout
<< " to " << Item
->ToFile() << endl
;
72 cout
<< " Queue is: " << QueueName(URI
) << endl
;
75 // Acquire::QueueName - Return the name of the queue for this URI /*{{{*/
76 // ---------------------------------------------------------------------
78 string
pkgAcquire::QueueName(string URI
)
80 const MethodConfig
*Config
= GetConfig(URIAccess(URI
));
84 // Acquire::GetConfig - Fetch the configuration information /*{{{*/
85 // ---------------------------------------------------------------------
86 /* This locates the configuration structure for an access method. If
87 a config structure cannot be found a Worker will be created to
89 const pkgAcquire::MethodConfig
*pkgAcquire::GetConfig(string Access
)
91 // Search for an existing config
93 for (Conf
= Configs
; Conf
!= 0; Conf
= Conf
->Next
)
94 if (Conf
->Access
== Access
)
97 // Create the new config class
98 Conf
= new MethodConfig
;
99 Conf
->Access
= Access
;
100 Conf
->Next
= Configs
;
103 // Create the worker to fetch the configuration
105 if (Work
.Start() == false)
112 // Acquire::MethodConfig::MethodConfig - Constructor /*{{{*/
113 // ---------------------------------------------------------------------
115 pkgAcquire::MethodConfig::MethodConfig()
117 SingleInstance
= false;