summaryrefslogtreecommitdiffstats
path: root/kbugbuster/backend/bugsystem.h
blob: d24b011d97a57fd5832ccab42e96438d1f3064d8 (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
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#ifndef __bugsystem_h__
#define __bugsystem_h__

#include "package.h"
#include "bug.h"
#include "bugdetails.h"
#include "bugcache.h"

#include <kurl.h>

#include <tqobject.h>
#include <tqptrlist.h>
#include <tqmap.h>
#include <tqpair.h>

class KConfig;

class BugCommand;
class BugServer;
class BugServerConfig;
class BugJob;

class BugSystem : public TQObject
{
    Q_OBJECT
  TQ_OBJECT
    friend class BugJob;
  public:
    BugSystem();
    virtual ~BugSystem();

    static BugSystem *self();

    BugCache *cache()const;
    BugServer *server() const { return mServer; }

    /**
      BugSystem takes ownership of the BugServerConfig objects.
    */
    void setServerList( const TQValueList<BugServerConfig> &servers );
    TQValueList<BugServer *> serverList();

    void setCurrentServer( const TQString & );

    void retrievePackageList();
    void retrieveBugList( const Package &, const TQString &component );
    void retrieveBugDetails( const Bug & );

    /**
     * Load the bugs the user reported himself, or for which he is the assigned to person
     */
    void retrieveMyBugsList();

    /**
      Queue a new command.
    */
    void queueCommand( BugCommand * );
    /**
      Forget all commands for a given bug.
    */
    void clearCommands( const TQString &bug );
    /**
      Forget all commands for all bugs.
    */
    void clearCommands();
    /**
      Send all commands (generate the mails).
    */
    void sendCommands();

    void setDisconnected( bool );
    bool disconnected() const;

    Package::List packageList() const;

    Package package( const TQString &pkgname ) const;
    Bug bug( const Package &pkg, const TQString &component, const TQString &number ) const;

    static void saveQuery( const KURL &url );
    static void saveResponse( const TQByteArray &d );
    static TQString lastResponse();

    void readConfig( KConfig * );
    void writeConfig( KConfig * );

  signals:
    void packageListAvailable( const Package::List &pkgs );
    void bugListAvailable( const Package &pkg, const TQString &component, const Bug::List & );
    void bugListAvailable( const TQString &label, const Bug::List & );
    void bugDetailsAvailable( const Bug &, const BugDetails & );

    void packageListLoading();
    void bugListLoading( const Package &, const TQString &component );
    void bugListLoading( const TQString &label );
    void bugDetailsLoading( const Bug & );

    void packageListCacheMiss();
    void bugListCacheMiss( const Package &package );
    void bugListCacheMiss( const TQString &label );
    void bugDetailsCacheMiss( const Bug & );

    void bugDetailsLoadingError();

    void infoMessage( const TQString &message );
    void infoPercent( unsigned long percent );

    void commandQueued( BugCommand * );
    void commandCanceled( const TQString & );

    void loadingError( const TQString &text );

  protected:
    BugServer *findServer( const TQString &name );

    void registerJob( BugJob * );

    void connectJob( BugJob * );

    void killAllJobs();

  protected slots:
    void unregisterJob( BugJob * );

  private slots:
    void setPackageList( const Package::List &pkgs );
    void setBugList( const Package &pkg, const TQString &component, const Bug::List &bugs );
    void setBugDetails( const Bug &bug, const BugDetails &details );

  private:
    bool m_disconnected;

    BugServer *mServer;

    TQValueList<BugServer *> mServerList;

    TQPtrList<BugJob> mJobs;

    static BugSystem *s_self;

    static TQString mLastResponse;
};

#endif

/*
 * vim:sw=4:ts=4:et
 */