Stable acquire code
[ntk/apt.git] / apt-pkg / acquire-worker.h
1 // -*- mode: cpp; mode: fold -*-
2 // Description /*{{{*/
3 // $Id: acquire-worker.h,v 1.5 1998/10/26 07:11:46 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 #include <apt-pkg/configuration.h>
17
18 #ifdef __GNUG__
19 #pragma interface "apt-pkg/acquire-worker.h"
20 #endif
21
22 // Interfacing to the method process
23 class pkgAcquire::Worker
24 {
25 friend pkgAcquire;
26
27 protected:
28 friend Queue;
29
30 /* Linked list starting at a Queue and a linked list starting
31 at Acquire */
32 Worker *NextQueue;
33 Worker *NextAcquire;
34
35 // The access association
36 Queue *OwnerQ;
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
65 bool MethodFailure();
66
67 public:
68
69 // The curent method state
70 pkgAcquire::Queue::QItem *CurrentItem;
71 string Status;
72 unsigned long CurrentSize;
73 unsigned long TotalSize;
74
75 // Load the method and do the startup
76 bool QueueItem(pkgAcquire::Queue::QItem *Item);
77 bool Start();
78
79 Worker(Queue *OwnerQ,MethodConfig *Config);
80 Worker(MethodConfig *Config);
81 ~Worker();
82 };
83
84 bool pkgInjectConfiguration(string &Message,Configuration &Cnf);
85
86 #endif