~keith-penguin/kdegames/trunk

« back to all changes in this revision

Viewing changes to ksirk/ksirk/iris/src/irisnet/noncore/legacy/srvresolver.h

  • Committer: Keith Worrell
  • Date: 2009-03-18 05:35:28 UTC
  • Revision ID: keith.worrell@gmail.com-20090318053528-mx6x9c0ngmg0kg6p
imported project

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * srvresolver.h - class to simplify SRV lookups
 
3
 * Copyright (C) 2003  Justin Karneges
 
4
 *
 
5
 * This library is free software; you can redistribute it and/or
 
6
 * modify it under the terms of the GNU Lesser General Public
 
7
 * License as published by the Free Software Foundation; either
 
8
 * version 2.1 of the License, or (at your option) any later version.
 
9
 *
 
10
 * This library 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 GNU
 
13
 * Lesser General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU Lesser General Public
 
16
 * License along with this library; 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 CS_SRVRESOLVER_H
 
22
#define CS_SRVRESOLVER_H
 
23
 
 
24
#include <QtCore>
 
25
#include <QtNetwork>
 
26
#include "netnames.h"
 
27
 
 
28
// CS_NAMESPACE_BEGIN
 
29
 
 
30
class Q3Dns
 
31
{
 
32
public:
 
33
        class Server
 
34
        {
 
35
        public:
 
36
                Server(const QString &n = QString(), quint16 p = 0, quint16 w = 0, quint16 po = 0)
 
37
                :name(n), priority(p), weight(w), port(po) {}
 
38
 
 
39
                QString name;
 
40
                quint16 priority;
 
41
                quint16 weight;
 
42
                quint16 port;
 
43
        };
 
44
};
 
45
 
 
46
class SrvResolver : public QObject
 
47
{
 
48
        Q_OBJECT
 
49
public:
 
50
        SrvResolver(QObject *parent=0);
 
51
        ~SrvResolver();
 
52
 
 
53
        void resolve(const QString &server, const QString &type, const QString &proto);
 
54
        void resolveSrvOnly(const QString &server, const QString &type, const QString &proto);
 
55
        void next();
 
56
        void stop();
 
57
        bool isBusy() const;
 
58
 
 
59
        QList<Q3Dns::Server> servers() const;
 
60
 
 
61
        bool failed() const;
 
62
        QHostAddress resultAddress() const;
 
63
        quint16 resultPort() const;
 
64
 
 
65
signals:
 
66
        void resultsReady();
 
67
 
 
68
private slots:
 
69
        void nndns_resultsReady(const QList<XMPP::NameRecord> &);
 
70
        void nndns_error(XMPP::NameResolver::Error);
 
71
        void ndns_done();
 
72
        void t_timeout();
 
73
 
 
74
private:
 
75
        class Private;
 
76
        Private *d;
 
77
 
 
78
        void tryNext();
 
79
};
 
80
 
 
81
// CS_NAMESPACE_END
 
82
 
 
83
#endif