summaryrefslogtreecommitdiffstats
path: root/src/aptcache.h
blob: 297f41d48fd537a8ebd3a352c23e19dbf3921616 (plain)
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
/***************************************************************************
*   Copyright (C) 2003 by Sylvain Joyeux                                  *
*   sylvain.joyeux@m4x.org                                                *
*                                                                         *
*   This program is free software; you can redistribute it and/or modify  *
*   it under the terms of the GNU General Public License as published by  *
*   the Free Software Foundation; either version 2 of the License, or     *
*   (at your option) any later version.                                   *
***************************************************************************/
#ifndef KIOAPT_APTCACHE_H
#define KIOAPT_APTCACHE_H

#include <tqvaluelist.h>
#include <tqmap.h>
#include <tqstring.h>
#include <kprocess.h>

class AptProtocol;

/**
@author Sylvain Joyeux
*/
class AptCache : public TQObject {
  Q_OBJECT
  

  typedef void (AptCache::*ReceiveMethod) (const TQStringList& lines);
  ReceiveMethod m_receive;

  // KProcIO messes the stderr and the stdout lines :(
  TDEProcess m_process;
  TQString m_received_out, m_received_err;

  TQString m_attribute;

  TQString m_installed, m_candidate;

private slots:
  void receivedStdErr(TDEProcess* process, char* buffer, int len);
  void receivedStdOut(TDEProcess* process, char* buffer, int len);

private:
  void clear();
  void receiveSearch(const TQStringList& lines);
  void receiveShow(const TQStringList& lines);
  void receivePolicy(const TQStringList& lines);
  void parse_pkgfield(const TQString& data);

public:
  AptCache();
  ~AptCache();

  bool search(const TQString& expression);
  bool show(const TQString& package);
  bool policy(const TQString& package);

  TQString policy_installed() const;
  TQString policy_candidate() const;

signals:
  /** Tags:
   *    warning (warning text)
   *    error (error text)
   *    package (package_name)
   *      short_desc (description)
   *      field (field_name)
   *        package_link (package_name)
   *        data (plain_data)
   *        indent (value)
   *      policy
   *        installed (version)
   *        candidate (version)
   *        version_table
   *          version (version_desc)
   *            location (location_desc)
   *    file (file_name)  [for dpkg]
   * end
   */
  void token(const TQString& tag, const TQString& value);
};

#endif