~ubuntu-branches/debian/experimental/kopete/experimental

« back to all changes in this revision

Viewing changes to protocols/jabber/libiris/src/jdns/include/jdns/qjdns.h

  • Committer: Package Import Robot
  • Author(s): Maximiliano Curia
  • Date: 2015-02-24 11:32:57 UTC
  • mfrom: (1.1.41 vivid)
  • Revision ID: package-import@ubuntu.com-20150224113257-gnupg4v7lzz18ij0
Tags: 4:14.12.2-1
* New upstream release (14.12.2).
* Bump Standards-Version to 3.9.6, no changes needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2005,2006  Justin Karneges
 
3
 *
 
4
 * Permission is hereby granted, free of charge, to any person obtaining a
 
5
 * copy of this software and associated documentation files (the
 
6
 * "Software"), to deal in the Software without restriction, including
 
7
 * without limitation the rights to use, copy, modify, merge, publish,
 
8
 * distribute, sublicense, and/or sell copies of the Software, and to
 
9
 * permit persons to whom the Software is furnished to do so, subject to
 
10
 * the following conditions:
 
11
 *
 
12
 * The above copyright notice and this permission notice shall be included
 
13
 * in all copies or substantial portions of the Software.
 
14
 *
 
15
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 
16
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 
17
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 
18
 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 
19
 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 
20
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 
21
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
22
 */
 
23
 
 
24
// this is the Qt wrapper to jdns.  it requires Qt 4.1+
 
25
 
 
26
#ifndef QJDNS_H
 
27
#define QJDNS_H
 
28
 
 
29
#include "jdns_export.h"
 
30
#include <QtCore>
 
31
#include <QtNetwork>
 
32
 
 
33
class JDNS_EXPORT QJDns : public QObject
 
34
{
 
35
        Q_OBJECT
 
36
public:
 
37
        enum Mode
 
38
        {
 
39
                Unicast,
 
40
                Multicast
 
41
        };
 
42
 
 
43
        enum PublishMode
 
44
        {
 
45
                Unique,
 
46
                Shared
 
47
        };
 
48
 
 
49
        enum Type
 
50
        {
 
51
                A       = 1,
 
52
                Aaaa    = 28,
 
53
                Mx      = 15,
 
54
                Srv     = 33,
 
55
                Cname   = 5,
 
56
                Ptr     = 12,
 
57
                Txt     = 16,
 
58
                Hinfo   = 13,
 
59
                Ns      = 2,
 
60
                Any     = 255
 
61
        };
 
62
 
 
63
        enum Error
 
64
        {
 
65
                ErrorGeneric,
 
66
                ErrorNXDomain, // query only
 
67
                ErrorTimeout,  // query only
 
68
                ErrorConflict  // publish only
 
69
        };
 
70
 
 
71
        class JDNS_EXPORT NameServer
 
72
        {
 
73
        public:
 
74
                QHostAddress address;
 
75
                int port;
 
76
 
 
77
                NameServer();
 
78
        };
 
79
 
 
80
        class JDNS_EXPORT DnsHost
 
81
        {
 
82
        public:
 
83
                QByteArray name;
 
84
                QHostAddress address;
 
85
        };
 
86
 
 
87
        class JDNS_EXPORT SystemInfo
 
88
        {
 
89
        public:
 
90
                QList<NameServer> nameServers;
 
91
                QList<QByteArray> domains;
 
92
                QList<DnsHost> hosts;
 
93
        };
 
94
 
 
95
        class JDNS_EXPORT Record
 
96
        {
 
97
        public:
 
98
                QByteArray owner;
 
99
                int ttl;
 
100
                int type;
 
101
                QByteArray rdata;
 
102
                bool haveKnown;
 
103
 
 
104
                // known
 
105
                QHostAddress address;    // for A, Aaaa
 
106
                QByteArray name;         // for Mx, Srv, Cname, Ptr, Ns
 
107
                int priority;            // for Mx, Srv
 
108
                int weight;              // for Srv
 
109
                int port;                // for Srv
 
110
                QList<QByteArray> texts; // for Txt
 
111
                QByteArray cpu;          // for Hinfo
 
112
                QByteArray os;           // for Hinfo
 
113
 
 
114
                Record();
 
115
                bool verify() const;
 
116
        };
 
117
 
 
118
        class JDNS_EXPORT Response
 
119
        {
 
120
        public:
 
121
                QList<Record> answerRecords;
 
122
                QList<Record> authorityRecords;
 
123
                QList<Record> additionalRecords;
 
124
        };
 
125
 
 
126
        QJDns(QObject *parent = 0);
 
127
        ~QJDns();
 
128
 
 
129
        bool init(Mode mode, const QHostAddress &address);
 
130
        void shutdown();
 
131
        QStringList debugLines();
 
132
 
 
133
        static SystemInfo systemInfo();
 
134
        static QHostAddress detectPrimaryMulticast(const QHostAddress &address);
 
135
 
 
136
        void setNameServers(const QList<NameServer> &list);
 
137
 
 
138
        int queryStart(const QByteArray &name, int type);
 
139
        void queryCancel(int id);
 
140
 
 
141
        // for multicast mode only
 
142
        int publishStart(PublishMode m, const Record &record);
 
143
        void publishUpdate(int id, const Record &record);
 
144
        void publishCancel(int id);
 
145
 
 
146
signals:
 
147
        void resultsReady(int id, const QJDns::Response &results);
 
148
        void published(int id);
 
149
        void error(int id, QJDns::Error e);
 
150
        void shutdownFinished();
 
151
        void debugLinesReady();
 
152
 
 
153
private:
 
154
        class Private;
 
155
        friend class Private;
 
156
        Private *d;
 
157
};
 
158
 
 
159
#endif