]> git.saurik.com Git - apt.git/blob - apt-pkg/acquire-worker.h
* removed the pragma mess
[apt.git] / apt-pkg / acquire-worker.h
1 // -*- mode: cpp; mode: fold -*-
2 // Description /*{{{*/
3 // $Id: acquire-worker.h,v 1.12 2001/02/20 07:03:17 jgg Exp $
4 /* ######################################################################
5
6 Acquire Worker - Worker process manager
7
8 Each worker class is associated with exaclty one subprocess.
9
10 ##################################################################### */
11 /*}}}*/
12 #ifndef PKGLIB_ACQUIRE_WORKER_H
13 #define PKGLIB_ACQUIRE_WORKER_H
14
15 #include <apt-pkg/acquire.h>
16
17
18 // Interfacing to the method process
19 class pkgAcquire::Worker
20 {
21 friend class pkgAcquire;
22
23 protected:
24 friend class Queue;
25
26 /* Linked list starting at a Queue and a linked list starting
27 at Acquire */
28 Worker *NextQueue;
29 Worker *NextAcquire;
30
31 // The access association
32 Queue *OwnerQ;
33 pkgAcquireStatus *Log;
34 MethodConfig *Config;
35 string Access;
36
37 // This is the subprocess IPC setup
38 pid_t Process;
39 int InFd;
40 int OutFd;
41 bool InReady;
42 bool OutReady;
43
44 // Various internal things
45 bool Debug;
46 vector<string> MessageQueue;
47 string OutQueue;
48
49 // Private constructor helper
50 void Construct();
51
52 // Message handling things
53 bool ReadMessages();
54 bool RunMessages();
55 bool InFdReady();
56 bool OutFdReady();
57
58 // The message handlers
59 bool Capabilities(string Message);
60 bool SendConfiguration();
61 bool MediaChange(string Message);
62
63 bool MethodFailure();
64 void ItemDone();
65
66 public:
67
68 // The curent method state
69 pkgAcquire::Queue::QItem *CurrentItem;
70 string Status;
71 unsigned long CurrentSize;
72 unsigned long TotalSize;
73 unsigned long ResumePoint;
74
75 // Load the method and do the startup
76 bool QueueItem(pkgAcquire::Queue::QItem *Item);
77 bool Start();
78 void Pulse();
79 inline const MethodConfig *GetConf() const {return Config;};
80
81 Worker(Queue *OwnerQ,MethodConfig *Config,pkgAcquireStatus *Log);
82 Worker(MethodConfig *Config);
83 ~Worker();
84 };
85
86 #endif