~ubuntu-branches/ubuntu/dapper/psi/dapper

« back to all changes in this revision

Viewing changes to src/jabio.h

  • Committer: Bazaar Package Importer
  • Author(s): Jan Niehusmann
  • Date: 2004-06-15 00:10:41 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040615001041-enywb6pcpe4sjsw6
Tags: 0.9.2-1
* New upstream release
* Set KDEDIR for ./configure so kde specific files get installed
* Don't install libpsiwidgets.so. It got installed in /usr/share
  where it doesn't belong. May be included (at a better location)
  later.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/****************************************************************************
2
 
** jabio.h - handles JabTasks
3
 
** Copyright (C) 2001, 2002  Justin Karneges
4
 
**
5
 
** This program is free software; you can redistribute it and/or
6
 
** modify it under the terms of the GNU General Public License
7
 
** as published by the Free Software Foundation; either version 2
8
 
** of the License, or (at your option) any later version.
9
 
**
10
 
** This program is distributed in the hope that it will be useful,
11
 
** but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
** GNU General Public License for more details.
14
 
**
15
 
** You should have received a copy of the GNU General Public License
16
 
** along with this program; if not, write to the Free Software
17
 
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 
**
19
 
****************************************************************************/
20
 
 
21
 
#ifndef JABIO_H
22
 
#define JABIO_H
23
 
 
24
 
#include<qobject.h>
25
 
#include<qobjectlist.h>
26
 
#include<qstring.h>
27
 
#include<qstringlist.h>
28
 
#include<qdatetime.h>
29
 
#include<qptrlist.h>
30
 
#include<qdom.h>
31
 
#include"jabcommon.h"
32
 
 
33
 
 
34
 
class JabIO;
35
 
 
36
 
class JabTask : public QObject
37
 
{
38
 
        Q_OBJECT
39
 
public:
40
 
        JabTask(JabTask *parent);
41
 
        JabTask(JabIO *parent);
42
 
        virtual ~JabTask() { }
43
 
 
44
 
        bool isRoot() { return v_isRoot; }
45
 
        bool isDone() { return v_isDone; }
46
 
        JabIO *io() { return v_io; }
47
 
        QDomDocument *doc();
48
 
        JabTask *parent();
49
 
        JabTask *find(const char *);
50
 
        JabTask *findById(const QString &);
51
 
 
52
 
        const QString & id() { return v_id; }
53
 
        bool success() { return v_success; }
54
 
        const QString & errorString() { return v_errorString; }
55
 
 
56
 
        virtual void go() { }
57
 
        virtual void stop() { }
58
 
        virtual bool take(const QDomElement &);
59
 
        virtual void done(JabTask *);
60
 
        virtual QString toString();
61
 
        virtual bool fromString(const QString &);
62
 
        virtual bool isClearable() { return TRUE; }
63
 
        virtual bool isDaemon() { return FALSE; }
64
 
 
65
 
        // helper API
66
 
        bool stamp2TS(const QString &ts, QDateTime *d);
67
 
        QString TS2stamp(const QDateTime &);
68
 
        QDomElement textTag(const QString &name, const QString &content);
69
 
        QString tagContent(const QDomElement &e);
70
 
        QDomElement findSubTag(const QDomElement &e, const QString &name, bool *found);
71
 
        QDomElement createIQ(const QString &type, const QString &to, const QString &id);
72
 
        QDomElement queryTag(const QDomElement &e);
73
 
        QString queryNS(const QDomElement &e);
74
 
        JabRoster xmlReadRoster(const QDomElement &, bool push=FALSE);
75
 
        QString getErrorString(const QDomElement &e);
76
 
 
77
 
signals:
78
 
        void finished(JabTask *);
79
 
        void childFinished(JabTask *);
80
 
        void childAdded(JabTask *);
81
 
        void childRemoved(JabTask *);
82
 
 
83
 
private:
84
 
        QString v_id, v_errorString;
85
 
        bool v_success, v_isDone;
86
 
        JabIO *v_io;
87
 
        bool v_isRoot;
88
 
        JabTask *v_parent;
89
 
 
90
 
protected:
91
 
        void send(const QDomElement &);
92
 
        void setSuccess(bool);
93
 
        void setError(const QString &);
94
 
 
95
 
        // reimplemented
96
 
        void childEvent(QChildEvent *);
97
 
};
98
 
 
99
 
 
100
 
class JabIO : public QObject
101
 
{
102
 
        Q_OBJECT
103
 
 
104
 
public:
105
 
        JabIO();
106
 
        ~JabIO();
107
 
 
108
 
        QString getId();
109
 
        void reset();
110
 
        void clear();
111
 
        void send(const QDomElement &);
112
 
        JabTask *root();
113
 
        JabTask *find(const char *);
114
 
        JabTask *findById(const QString &);
115
 
 
116
 
        void doneJT(JabTask *);
117
 
 
118
 
        QDomDocument doc;
119
 
 
120
 
signals:
121
 
        void outgoingPacket(const QDomElement &);
122
 
        void done(JabTask *);
123
 
        void anyDone(JabTask *);
124
 
 
125
 
public slots:
126
 
        void incomingPacket(const QDomElement &);
127
 
 
128
 
private:
129
 
        int id_seed;
130
 
        JabTask *v_root;
131
 
 
132
 
        void distribute(const QDomElement &);
133
 
};
134
 
 
135
 
#endif