]>
Commit | Line | Data |
---|---|---|
b792d887 MT |
1 | /*############################################################################# |
2 | # # | |
3 | # Pakfire - The IPFire package management system # | |
4 | # Copyright (C) 2011 Pakfire development team # | |
5 | # # | |
6 | # This program is free software: you can redistribute it and/or modify # | |
7 | # it under the terms of the GNU General Public License as published by # | |
8 | # the Free Software Foundation, either version 3 of the License, or # | |
9 | # (at your option) any later version. # | |
10 | # # | |
11 | # This program is distributed in the hope that it will be useful, # | |
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of # | |
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # | |
14 | # GNU General Public License for more details. # | |
15 | # # | |
16 | # You should have received a copy of the GNU General Public License # | |
17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. # | |
18 | # # | |
19 | #############################################################################*/ | |
c605d735 MT |
20 | |
21 | #include "pool.h" | |
22 | #include "relation.h" | |
23 | #include "request.h" | |
24 | #include "solvable.h" | |
25 | ||
45f5a3d9 | 26 | #include <solv/solver.h> |
c605d735 MT |
27 | |
28 | PyTypeObject RequestType = { | |
29 | PyObject_HEAD_INIT(NULL) | |
30 | tp_name: "_pakfire.Request", | |
31 | tp_basicsize: sizeof(RequestObject), | |
32 | tp_flags: Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, | |
33 | tp_new : Request_new, | |
34 | tp_dealloc: (destructor) Request_dealloc, | |
35 | tp_doc: "Sat Request objects", | |
36 | }; | |
37 | ||
38 | PyObject* Request_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { | |
39 | RequestObject *self; | |
40 | PoolObject *pool; | |
41 | ||
42 | if (!PyArg_ParseTuple(args, "O", &pool)) { | |
43 | /* XXX raise exception */ | |
44 | } | |
45 | ||
46 | self = (RequestObject *)type->tp_alloc(type, 0); | |
47 | if (self != NULL) { | |
48 | self->_pool = pool->_pool; | |
49 | if (self->_pool == NULL) { | |
50 | Py_DECREF(self); | |
51 | return NULL; | |
52 | } | |
53 | ||
54 | queue_init(&self->_queue); | |
55 | } | |
56 | ||
57 | return (PyObject *)self; | |
58 | } | |
59 | ||
60 | PyObject *Request_dealloc(RequestObject *self) { | |
61 | self->ob_type->tp_free((PyObject *)self); | |
4069d10c MT |
62 | |
63 | Py_RETURN_NONE; | |
c605d735 MT |
64 | } |
65 | ||
bd7ea616 | 66 | void _Request_solvable(RequestObject *self, Id what, Id solvable) { |
86d7503f | 67 | queue_push2(&self->_queue, what|SOLVER_SOLVABLE, solvable); |
bd7ea616 MT |
68 | } |
69 | ||
70 | void _Request_relation(RequestObject *self, Id what, Id relation) { | |
86d7503f | 71 | queue_push2(&self->_queue, what|SOLVER_SOLVABLE_PROVIDES, relation); |
bd7ea616 MT |
72 | } |
73 | ||
74 | void _Request_name(RequestObject *self, Id what, Id provides) { | |
86d7503f | 75 | queue_push2(&self->_queue, what|SOLVER_SOLVABLE_NAME, provides); |
bd7ea616 MT |
76 | } |
77 | ||
c605d735 MT |
78 | PyObject *Request_install_solvable(RequestObject *self, PyObject *args) { |
79 | SolvableObject *solv; | |
80 | ||
81 | if (!PyArg_ParseTuple(args, "O", &solv)) { | |
9b68f47c | 82 | return NULL; |
c605d735 MT |
83 | } |
84 | ||
bd7ea616 | 85 | _Request_solvable(self, SOLVER_INSTALL, solv->_id); |
c605d735 MT |
86 | Py_RETURN_NONE; |
87 | } | |
88 | ||
89 | PyObject *Request_install_relation(RequestObject *self, PyObject *args) { | |
90 | RelationObject *rel; | |
91 | ||
92 | if (!PyArg_ParseTuple(args, "O", &rel)) { | |
9b68f47c | 93 | return NULL; |
c605d735 MT |
94 | } |
95 | ||
bd7ea616 | 96 | _Request_relation(self, SOLVER_INSTALL, rel->_id); |
c605d735 MT |
97 | Py_RETURN_NONE; |
98 | } | |
99 | ||
100 | PyObject *Request_install_name(RequestObject *self, PyObject *args) { | |
101 | const char *name; | |
102 | ||
103 | if (!PyArg_ParseTuple(args, "s", &name)) { | |
9b68f47c | 104 | return NULL; |
c605d735 MT |
105 | } |
106 | ||
bd7ea616 MT |
107 | Id _name = pool_str2id(self->_pool, name, 1); |
108 | _Request_name(self, SOLVER_INSTALL, _name); | |
109 | ||
110 | Py_RETURN_NONE; | |
111 | } | |
112 | ||
113 | PyObject *Request_remove_solvable(RequestObject *self, PyObject *args) { | |
114 | SolvableObject *solv; | |
115 | ||
116 | if (!PyArg_ParseTuple(args, "O", &solv)) { | |
9b68f47c | 117 | return NULL; |
bd7ea616 MT |
118 | } |
119 | ||
120 | _Request_solvable(self, SOLVER_ERASE, solv->_id); | |
bd7ea616 MT |
121 | Py_RETURN_NONE; |
122 | } | |
123 | ||
124 | PyObject *Request_remove_relation(RequestObject *self, PyObject *args) { | |
125 | RelationObject *rel; | |
126 | ||
127 | if (!PyArg_ParseTuple(args, "O", &rel)) { | |
9b68f47c | 128 | return NULL; |
bd7ea616 MT |
129 | } |
130 | ||
131 | _Request_relation(self, SOLVER_ERASE, rel->_id); | |
bd7ea616 MT |
132 | Py_RETURN_NONE; |
133 | } | |
134 | ||
135 | PyObject *Request_remove_name(RequestObject *self, PyObject *args) { | |
136 | const char *name; | |
137 | ||
138 | if (!PyArg_ParseTuple(args, "s", &name)) { | |
9b68f47c | 139 | return NULL; |
bd7ea616 MT |
140 | } |
141 | ||
142 | Id _name = pool_str2id(self->_pool, name, 1); | |
143 | _Request_name(self, SOLVER_ERASE, _name); | |
144 | ||
145 | Py_RETURN_NONE; | |
146 | } | |
147 | ||
148 | PyObject *Request_update_solvable(RequestObject *self, PyObject *args) { | |
149 | SolvableObject *solv; | |
150 | ||
151 | if (!PyArg_ParseTuple(args, "O", &solv)) { | |
9b68f47c | 152 | return NULL; |
bd7ea616 MT |
153 | } |
154 | ||
155 | _Request_solvable(self, SOLVER_UPDATE, solv->_id); | |
bd7ea616 MT |
156 | Py_RETURN_NONE; |
157 | } | |
158 | ||
159 | PyObject *Request_update_relation(RequestObject *self, PyObject *args) { | |
160 | RelationObject *rel; | |
161 | ||
162 | if (!PyArg_ParseTuple(args, "O", &rel)) { | |
9b68f47c | 163 | return NULL; |
bd7ea616 MT |
164 | } |
165 | ||
166 | _Request_relation(self, SOLVER_UPDATE, rel->_id); | |
bd7ea616 MT |
167 | Py_RETURN_NONE; |
168 | } | |
169 | ||
170 | PyObject *Request_update_name(RequestObject *self, PyObject *args) { | |
171 | const char *name; | |
172 | ||
173 | if (!PyArg_ParseTuple(args, "s", &name)) { | |
9b68f47c | 174 | return NULL; |
bd7ea616 MT |
175 | } |
176 | ||
177 | Id _name = pool_str2id(self->_pool, name, 1); | |
178 | _Request_name(self, SOLVER_UPDATE, _name); | |
179 | ||
180 | Py_RETURN_NONE; | |
181 | } | |
182 | ||
183 | PyObject *Request_lock_solvable(RequestObject *self, PyObject *args) { | |
184 | SolvableObject *solv; | |
185 | ||
186 | if (!PyArg_ParseTuple(args, "O", &solv)) { | |
9b68f47c | 187 | return NULL; |
bd7ea616 MT |
188 | } |
189 | ||
190 | _Request_solvable(self, SOLVER_LOCK, solv->_id); | |
bd7ea616 MT |
191 | Py_RETURN_NONE; |
192 | } | |
193 | ||
194 | PyObject *Request_lock_relation(RequestObject *self, PyObject *args) { | |
195 | RelationObject *rel; | |
196 | ||
197 | if (!PyArg_ParseTuple(args, "O", &rel)) { | |
9b68f47c | 198 | return NULL; |
bd7ea616 MT |
199 | } |
200 | ||
201 | _Request_relation(self, SOLVER_LOCK, rel->_id); | |
bd7ea616 MT |
202 | Py_RETURN_NONE; |
203 | } | |
204 | ||
205 | PyObject *Request_lock_name(RequestObject *self, PyObject *args) { | |
206 | const char *name; | |
207 | ||
208 | if (!PyArg_ParseTuple(args, "s", &name)) { | |
9b68f47c | 209 | return NULL; |
bd7ea616 MT |
210 | } |
211 | ||
212 | Id _name = pool_str2id(self->_pool, name, 1); | |
213 | _Request_name(self, SOLVER_LOCK, _name); | |
c605d735 MT |
214 | |
215 | Py_RETURN_NONE; | |
216 | } | |
063606f6 MT |
217 | |
218 | PyObject *Request_noobsoletes_solvable(RequestObject *self, PyObject *args) { | |
219 | SolvableObject *solv; | |
220 | ||
221 | if (!PyArg_ParseTuple(args, "O", &solv)) { | |
9b68f47c | 222 | return NULL; |
063606f6 MT |
223 | } |
224 | ||
225 | _Request_solvable(self, SOLVER_NOOBSOLETES, solv->_id); | |
063606f6 MT |
226 | Py_RETURN_NONE; |
227 | } | |
228 | ||
229 | PyObject *Request_noobsoletes_relation(RequestObject *self, PyObject *args) { | |
230 | RelationObject *rel; | |
231 | ||
232 | if (!PyArg_ParseTuple(args, "O", &rel)) { | |
9b68f47c | 233 | return NULL; |
063606f6 MT |
234 | } |
235 | ||
236 | _Request_relation(self, SOLVER_NOOBSOLETES, rel->_id); | |
063606f6 MT |
237 | Py_RETURN_NONE; |
238 | } | |
239 | ||
240 | PyObject *Request_noobsoletes_name(RequestObject *self, PyObject *args) { | |
241 | const char *name; | |
242 | ||
243 | if (!PyArg_ParseTuple(args, "s", &name)) { | |
9b68f47c | 244 | return NULL; |
063606f6 MT |
245 | } |
246 | ||
247 | Id _name = pool_str2id(self->_pool, name, 1); | |
248 | _Request_name(self, SOLVER_NOOBSOLETES, _name); | |
249 | ||
250 | Py_RETURN_NONE; | |
251 | } | |
9b68f47c MT |
252 | |
253 | PyObject *Request_updateall(RequestObject *self, PyObject *args) { | |
254 | queue_push2(&self->_queue, SOLVER_UPDATE|SOLVER_SOLVABLE_ALL, 0); | |
255 | Py_RETURN_NONE; | |
256 | } | |
257 | ||
258 | PyObject *Request_distupgrade(RequestObject *self, PyObject *args) { | |
259 | queue_push2(&self->_queue, SOLVER_DISTUPGRADE|SOLVER_SOLVABLE_ALL, 0); | |
260 | Py_RETURN_NONE; | |
261 | } | |
262 | ||
263 | PyObject *Request_verify(RequestObject *self, PyObject *args) { | |
264 | queue_push2(&self->_queue, SOLVER_VERIFY|SOLVER_SOLVABLE_ALL, 0); | |
265 | Py_RETURN_NONE; | |
266 | } |