* corrected the utf8 of javier fernandes pena
[ntk/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 #ifdef __GNUG__
18 #pragma interface "apt-pkg/acquire-worker.h"
19 #endif
20
21 // Interfacing to the method process
22 class pkgAcquire::Worker
23 {
24 friend class pkgAcquire;
25
26 protected:
27 friend class Queue;
28
29 /* Linked list starting at a Queue and a linked list starting
30 at Acquire */
31 Worker *NextQueue;
32 Worker *NextAcquire;
33
34 // The access association
35 Queue *OwnerQ;
36 pkgAcquireStatus *Log;
37 MethodConfig *Config;
38 string Access;
39
40 // This is the subprocess IPC setup
41 pid_t Process;
42 int InFd;
43 int OutFd;
44 bool InReady;
45 bool OutReady;
46
47 // Various internal things
48 bool Debug;
49 vector<string> MessageQueue;
50 string OutQueue;
51
52 // Private constructor helper
53 void Construct();
54
55 // Message handling things
56 bool ReadMessages();
57 bool RunMessages();
58 bool InFdReady();
59 bool OutFdReady();
60
61 // The message handlers
62 bool Capabilities(string Message);
63 bool SendConfiguration();
64 bool MediaChange(string Message);
65
66 bool MethodFailure();
67 void ItemDone();
68
69 public:
70
71 // The curent method state
72 pkgAcquire::Queue::QItem *CurrentItem;
73 string Status;
74 unsigned long CurrentSize;
75 unsigned long TotalSize;
76 unsigned long ResumePoint;
77
78 // Load the method and do the startup
79 bool QueueItem(pkgAcquire::Queue::QItem *Item);
80 bool Start();
81 void Pulse();
82 inline const MethodConfig *GetConf() const {return Config;};
83
84 Worker(Queue *OwnerQ,MethodConfig *Config,pkgAcquireStatus *Log);
85 Worker(MethodConfig *Config);
86 ~Worker();
87 };
88
89 #endif