File: cdrom.cc

package info (click to toggle)
python-apt 0.7.7.1%2Bnmu1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 3,276 kB
  • ctags: 930
  • sloc: cpp: 4,126; python: 3,108; makefile: 52
file content (110 lines) | stat: -rw-r--r-- 2,763 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
// Description								/*{{{*/
// $Id: cdrom.cc,v 1.1 2003/06/03 03:03:23 mvo Exp $
/* ######################################################################

   Cdrom - Wrapper for the apt-cdrom support

   ##################################################################### */

#include "generic.h"
#include "apt_pkgmodule.h"
#include "progress.h"

#include <apt-pkg/cdrom.h>


struct PkgCdromStruct
{
   pkgCdrom cdrom;
};

static PyObject *PkgCdromAdd(PyObject *Self,PyObject *Args)
{   
   PkgCdromStruct &Struct = GetCpp<PkgCdromStruct>(Self);

   PyObject *pyCdromProgressInst = 0;
   if (PyArg_ParseTuple(Args, "O", &pyCdromProgressInst) == 0) {
      return 0;
   }

   PyCdromProgress progress;
   progress.setCallbackInst(pyCdromProgressInst);

   bool res = Struct.cdrom.Add(&progress);

   return HandleErrors(Py_BuildValue("b", res));   
}

static PyObject *PkgCdromIdent(PyObject *Self,PyObject *Args)
{   
   PkgCdromStruct &Struct = GetCpp<PkgCdromStruct>(Self);

   PyObject *pyCdromProgressInst = 0;
   if (PyArg_ParseTuple(Args, "O", &pyCdromProgressInst) == 0) {
      return 0;
   }

   PyCdromProgress progress;
   progress.setCallbackInst(pyCdromProgressInst);

   string ident;
   bool res = Struct.cdrom.Ident(ident, &progress);

   PyObject *result = Py_BuildValue("(bs)", res, ident.c_str());

   return HandleErrors(result);   
}


static PyMethodDef PkgCdromMethods[] = 
{
   {"Add",PkgCdromAdd,METH_VARARGS,"Add a cdrom"},
   {"Ident",PkgCdromIdent,METH_VARARGS,"Ident a cdrom"},
   {}
};


static PyObject *CdromAttr(PyObject *Self,char *Name)
{
   PkgCdromStruct &Struct = GetCpp<PkgCdromStruct>(Self);

   return Py_FindMethod(PkgCdromMethods,Self,Name);
}




PyTypeObject PkgCdromType =
{
   PyObject_HEAD_INIT(&PyType_Type)
   0,			                // ob_size
   "Cdrom",                          // tp_name
   sizeof(CppOwnedPyObject<PkgCdromStruct>),   // tp_basicsize
   0,                                   // tp_itemsize
   // Methods
   CppOwnedDealloc<PkgCdromStruct>,        // tp_dealloc
   0,                                   // tp_print
   CdromAttr,                           // tp_getattr
   0,                                   // tp_setattr
   0,                                   // tp_compare
   0,                                   // tp_repr
   0,                                   // tp_as_number
   0,                                   // tp_as_sequence
   0,	                                // tp_as_mapping
   0,                                   // tp_hash
};

PyObject *GetCdrom(PyObject *Self,PyObject *Args)
{
   pkgCdrom *cdrom = new pkgCdrom();

   CppOwnedPyObject<pkgCdrom> *CdromObj =
	   CppOwnedPyObject_NEW<pkgCdrom>(0,&PkgCdromType, *cdrom);
   
   return CdromObj;
}




									/*}}}*/