initial commit

This commit is contained in:
mikhail "synzr" 2025-12-25 01:37:49 +05:00
commit 9d20827c46
2469 changed files with 470994 additions and 0 deletions

10
iris/.gitignore vendored Normal file
View file

@ -0,0 +1,10 @@
/Makefile
/conf.pri
/lib/libiris.a
/lib/libiris.prl
/lib/libirisnet.a
/lib/libirisnet.prl
/src/Makefile
/src/irisnet/Makefile
/src/irisnet/noncore/Makefile
/src/xmpp/Makefile

504
iris/COPYING Normal file
View file

@ -0,0 +1,504 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

41
iris/README Normal file
View file

@ -0,0 +1,41 @@
Iris XMPP Library
-----------------
Date: August 24th, 2008
Website: http://delta.affinix.com/iris/
Mailing List: Delta Project <delta@lists.affinix.com>
Install
-------
First, build Iris:
Unix:
./configure
make
Windows:
copy conf_win.pri.example conf_win.pri
copy confapp_win.pri.example confapp_win.pri
qmake
make (or nmake)
There is no installation. Just include iris.pri in your qmake project.
Iris requires Qt 4.2 or greater and QCA 2.0 or greater.
License
-------
This library is licensed under the Lesser GNU General Public License. See
the COPYING file for more information.
Description
-----------
Iris is a comprehensive library for working with the XMPP/Jabber protocol.
It complies with the XMPP RFCs and many XEPs.
In addition to XMPP, Iris also offers access to many other protocols and
concepts, including DNS, DNS-SD, connection and transport abstraction, HTTP,
SOCKS, XML streaming, network interfaces, compression, encryption,
authentication, flow control, proxies, and NAT traversal.

46
iris/TODO Normal file
View file

@ -0,0 +1,46 @@
netinterface
use qca syncthread, match keystore in thread safety concerns
"Interface ids obtained through NetInterfaceManager are guaranteed to be valid until the event loop resumes, or until the next call to interfaces() or interfaceForAddress()." ... the code seems to be lying about interfaceForAddress.
netnames
support faking srv (or perhaps any record) somehow, through config or code
support multithreading
put the netnames backend into an alternate thread (this thread should
probably be some generic irisnet thing that other modules can use too)
netnames front-end api communicates with the backend, so that one backend
is shared by all threads
NameResolver/ServiceBrowser/ServiceResolver should have isActive?
report ServiceBrowser error codes
report ServiceResolver error codes
ServiceInstance attribs arg of constructor should be optional?
ServiceInstance should cache the name() answer
ServiceProvider should support error codes and passing many ip addresses
ServiceResolver should give the hostnames and the ip addresses. hostnames
may be needed for SASL
consider reverse dns (for both internet and multicast)
dns/bonjour/idn/dns-sd
tcp/udp/rtp, bytestream abstraction
protocol http/socks/ice/ocsp/crl
lineproto, httpproto, xmlproto, binaryproto?, socksishproto?
auth/cert/pgp parameter abstraction
network interface detection
simplified keystore handling?
stringprep
built-in simplified SASL digest-md5, plain?, anonymous?
layer tracking & flow control
both sync and async api
threading capable
proxies http/httpsconnect/httppoll/socks4,5/fakessl?
dns/net/proxy/auth engine plugins?
upnp/bonjour nat dodging / port opening?
connector
questions:
1) where does it end?
2) how would a pgp-auth for xmpp-core work?
goal:
support xmpp-core for tcp/httpbind
xmpp-core should be "just another protocol"

21
iris/common.pri Normal file
View file

@ -0,0 +1,21 @@
# common stuff for iris.pro and iris.pri
# FIXME: Remove this
DEFINES += IRIS_XMPP_JID_DEPRECATED
# DEFINES += YAPSI
# default build configuration
!iris_build_pri {
# build appledns on mac
mac:CONFIG += appledns
# bundle appledns inside of irisnetcore on mac
mac:CONFIG += appledns_bundle
# bundle irisnetcore inside of iris
CONFIG += irisnetcore_bundle
# don't build iris, app will include iris.pri
#CONFIG += iris_bundle
}

17
iris/conf_win.pri.example Normal file
View file

@ -0,0 +1,17 @@
load(winlocal.prf)
# qca
CONFIG += crypto
# zlib
INCLUDEPATH += $$WINLOCAL_PREFIX/include
LIBS += -L$$WINLOCAL_PREFIX/lib
# zlib may have a different lib name depending on how it was compiled
win32-g++ {
LIBS += -lz
}
else {
LIBS += -lzlib # static
#LIBS += -lzdll # dll
}

6
iris/confapp.pri Normal file
View file

@ -0,0 +1,6 @@
unix:include(confapp_unix.pri)
windows:include(confapp_win.pri)
include(common.pri)
mac:QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.5

View file

@ -0,0 +1,17 @@
load(winlocal.prf)
# qca
CONFIG += crypto
# zlib
INCLUDEPATH += $$WINLOCAL_PREFIX/include
LIBS += -L$$WINLOCAL_PREFIX/lib
# zlib may have a different lib name depending on how it was compiled
win32-g++ {
LIBS += -lz
}
else {
LIBS += -lzlib # static
#LIBS += -lzdll # dll
}

1982
iris/configure vendored Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1 @@
#include "../../src/irisnet/corelib/addressresolver.h"

View file

@ -0,0 +1 @@
#include "../../src/irisnet/noncore/cutestuff/bsocket.h"

View file

@ -0,0 +1 @@
#include "../../src/irisnet/noncore/cutestuff/bytestream.h"

View file

@ -0,0 +1 @@
#include "../../src/xmpp/xmpp-im/filetransfer.h"

View file

@ -0,0 +1 @@
#include "../../src/irisnet/noncore/cutestuff/httpconnect.h"

View file

@ -0,0 +1 @@
#include "../../src/irisnet/noncore/cutestuff/httppoll.h"

View file

@ -0,0 +1 @@
#include "../../src/irisnet/noncore/ice176.h"

1
iris/include/iris/im.h Normal file
View file

@ -0,0 +1 @@
#include "../../src/xmpp/xmpp-im/im.h"

View file

@ -0,0 +1 @@
#include "../../src/irisnet/corelib/irisnetexport.h"

View file

@ -0,0 +1 @@
#include "../../src/irisnet/corelib/irisnetglobal.h"

View file

@ -0,0 +1 @@
#include "../../src/irisnet/corelib/irisnetplugin.h"

View file

@ -0,0 +1 @@
#include "../../src/irisnet/corelib/jdnsshared.h"

1
iris/include/iris/ndns.h Normal file
View file

@ -0,0 +1 @@
#include "../../src/irisnet/noncore/legacy/ndns.h"

View file

@ -0,0 +1 @@
#include "../../src/irisnet/corelib/netavailability.h"

View file

@ -0,0 +1 @@
#include "../../src/irisnet/corelib/netinterface.h"

View file

@ -0,0 +1 @@
#include "../../src/irisnet/corelib/netnames.h"

View file

@ -0,0 +1 @@
#include "../../src/irisnet/corelib/objectsession.h"

View file

@ -0,0 +1 @@
#include "../../src/irisnet/noncore/processquit.h"

View file

@ -0,0 +1 @@
#include "../../src/jdns/qjdns.h"

1
iris/include/iris/s5b.h Normal file
View file

@ -0,0 +1 @@
#include "../../src/xmpp/xmpp-im/s5b.h"

View file

@ -0,0 +1 @@
#include "../../src/irisnet/noncore/legacy/safedelete.h"

View file

@ -0,0 +1 @@
#include "../../src/irisnet/noncore/legacy/servsock.h"

View file

@ -0,0 +1 @@
#include "../../src/irisnet/noncore/cutestuff/socks.h"

View file

@ -0,0 +1 @@
#include "../../src/irisnet/noncore/legacy/srvresolver.h"

View file

@ -0,0 +1 @@
#include "../../src/irisnet/noncore/stunallocate.h"

View file

@ -0,0 +1 @@
#include "../../src/irisnet/noncore/stunbinding.h"

View file

@ -0,0 +1 @@
#include "../../src/irisnet/noncore/stunmessage.h"

View file

@ -0,0 +1 @@
#include "../../src/irisnet/noncore/stuntransaction.h"

View file

@ -0,0 +1 @@
#include "../../src/irisnet/noncore/turnclient.h"

View file

@ -0,0 +1 @@
#include "../../src/irisnet/noncore/udpportreserver.h"

1
iris/include/iris/xmpp.h Normal file
View file

@ -0,0 +1 @@
#include "../../src/xmpp/xmpp-core/xmpp.h"

View file

@ -0,0 +1 @@
#include "../../src/xmpp/xmpp-im/xmpp_address.h"

View file

@ -0,0 +1 @@
#include "../../src/xmpp/xmpp-im/xmpp_agentitem.h"

View file

@ -0,0 +1 @@
#include "../../src/xmpp/xmpp-im/xmpp_chatstate.h"

View file

@ -0,0 +1 @@
#include "../../src/xmpp/xmpp-im/xmpp_client.h"

View file

@ -0,0 +1 @@
#include "../../src/xmpp/xmpp-core/xmpp_clientstream.h"

View file

@ -0,0 +1 @@
#include "../../src/xmpp/xmpp-im/xmpp_discoinfotask.h"

View file

@ -0,0 +1 @@
#include "../../src/xmpp/xmpp-im/xmpp_discoitem.h"

View file

@ -0,0 +1 @@
#include "../../src/xmpp/xmpp-im/xmpp_features.h"

View file

@ -0,0 +1 @@
#include "../../src/xmpp/xmpp-im/xmpp_htmlelement.h"

View file

@ -0,0 +1 @@
#include "../../src/xmpp/xmpp-im/xmpp_httpauthrequest.h"

View file

@ -0,0 +1 @@
#include "../../src/xmpp/jid/jid.h"

View file

@ -0,0 +1 @@
#include "../../src/xmpp/xmpp-im/xmpp_liveroster.h"

View file

@ -0,0 +1 @@
#include "../../src/xmpp/xmpp-im/xmpp_liverosteritem.h"

View file

@ -0,0 +1 @@
#include "../../src/xmpp/xmpp-im/xmpp_message.h"

View file

@ -0,0 +1 @@
#include "../../src/xmpp/xmpp-im/xmpp_muc.h"

View file

@ -0,0 +1 @@
#include "../../src/xmpp/xmpp-im/xmpp_pubsubitem.h"

View file

@ -0,0 +1 @@
#include "../../src/xmpp/xmpp-im/xmpp_pubsubretraction.h"

View file

@ -0,0 +1 @@
#include "../../src/xmpp/xmpp-im/xmpp_receipts.h"

View file

@ -0,0 +1 @@
#include "../../src/xmpp/xmpp-im/xmpp_resource.h"

View file

@ -0,0 +1 @@
#include "../../src/xmpp/xmpp-im/xmpp_resourcelist.h"

View file

@ -0,0 +1 @@
#include "../../src/xmpp/xmpp-im/xmpp_roster.h"

View file

@ -0,0 +1 @@
#include "../../src/xmpp/xmpp-im/xmpp_rosteritem.h"

View file

@ -0,0 +1 @@
#include "../../src/xmpp/xmpp-im/xmpp_rosterx.h"

View file

@ -0,0 +1 @@
#include "../../src/xmpp/xmpp-core/xmpp_stanza.h"

View file

@ -0,0 +1 @@
#include "../../src/xmpp/xmpp-im/xmpp_status.h"

View file

@ -0,0 +1 @@
#include "../../src/xmpp/xmpp-core/xmpp_stream.h"

View file

@ -0,0 +1 @@
#include "../../src/xmpp/xmpp-im/xmpp_task.h"

View file

@ -0,0 +1 @@
#include "../../src/xmpp/xmpp-im/xmpp_tasks.h"

View file

@ -0,0 +1 @@
#include "../../src/xmpp/xmpp-im/xmpp_url.h"

View file

@ -0,0 +1 @@
#include "../../src/xmpp/xmpp-im/xmpp_vcard.h"

View file

@ -0,0 +1 @@
#include "../../src/xmpp/xmpp-im/xmpp_xdata.h"

View file

@ -0,0 +1 @@
#include "../../src/xmpp/xmpp-im/xmpp_xmlcommon.h"

View file

@ -0,0 +1 @@
#include "../../src/xmpp/xmpp-core/xmpp_yadatetime.h"

View file

@ -0,0 +1 @@
#include "../../src/xmpp/xmpp-im/xmpp_yalastmail.h"

25
iris/iris.pri Normal file
View file

@ -0,0 +1,25 @@
IRIS_BASE = $$PWD
include(common.pri)
CONFIG *= depend_prl
INCLUDEPATH += $$IRIS_BASE/include $$IRIS_BASE/include/iris $$IRIS_BASE/src
iris_bundle:{
include(src/xmpp/xmpp.pri)
DEFINES += IRISNET_STATIC
}
else {
LIBS += -L$$IRIS_BASE/lib -liris
}
# qt < 4.4 doesn't enable link_prl by default. we could just enable it,
# except that in 4.3 or earlier the link_prl feature is too aggressive and
# pulls in unnecessary deps. so, for 4.3 and earlier, we'll just explicitly
# specify the stuff the prl should have given us.
# also, mingw seems to have broken prl support??
win32-g++|contains($$list($$[QT_VERSION]), 4.0.*|4.1.*|4.2.*|4.3.*) {
DEFINES += IRISNET_STATIC # from irisnet
LIBS += -L$$IRIS_BASE/lib -lirisnet # from iris
windows:LIBS += -lWs2_32 -lAdvapi32 # from jdns
}

21
iris/iris.pro Normal file
View file

@ -0,0 +1,21 @@
TEMPLATE = subdirs
IRIS_BASE = $$PWD
include(conf.pri)
windows:include(conf_win.pri)
include(common.pri)
# do we have a reason to enter the src dir?
appledns:!appledns_bundle:CONFIG *= build_src
!irisnetcore_bundle:CONFIG *= build_src
!iris_bundle:CONFIG *= build_src
sub_src.subdir = src
sub_tools.subdir = tools
sub_tools.depends = sub_src
build_src:SUBDIRS += sub_src
!no_tests:SUBDIRS += sub_tools

25
iris/iris.qc Normal file
View file

@ -0,0 +1,25 @@
<qconf>
<name>Iris</name>
<profile>iris.pro</profile>
<noprefix/>
<lib/>
<moddir>qcm</moddir>
<dep type='qt42'>
<required/>
</dep>
<dep type='buildmode'>
<required/>
</dep>
<dep type='universal'>
<required/>
</dep>
<dep type='qca'>
<required/>
</dep>
<dep type='zlib'>
<required/>
</dep>
<dep type='extra'>
<required/>
</dep>
</qconf>

5
iris/qcm/README Normal file
View file

@ -0,0 +1,5 @@
qt42, buildmode, and universal modules are all copied from qca.
do not modify them here.
the qca module is copied from qca, but modified here. we should consider
pushing the changes back.

201
iris/qcm/buildmode.qcm Normal file
View file

@ -0,0 +1,201 @@
/*
-----BEGIN QCMOD-----
name: buildmode
section: project
arg: release,Build with debugging turned off (default).
arg: debug,Build with debugging turned on.
arg: debug-and-release,Build two versions, with and without debugging turned on (mac only).
arg: no-separate-debug-info,Do not store debug information in a separate file (default for mac).
arg: separate-debug-info,Strip debug information into a separate .debug file (default for non-mac).
arg: no-framework,Do not build as a Mac framework.
arg: framework,Build as a Mac framework (default).
-----END QCMOD-----
*/
#define QC_BUILDMODE
bool qc_buildmode_release = false;
bool qc_buildmode_debug = false;
bool qc_buildmode_framework = false;
bool qc_buildmode_separate_debug_info = false;
class qc_buildmode : public ConfObj
{
public:
qc_buildmode(Conf *c) : ConfObj(c) {}
QString name() const { return "buildmode"; }
QString shortname() const { return "buildmode"; }
// no output
QString checkString() const { return QString(); }
bool exec()
{
// first, parse out the options
bool opt_release = false;
bool opt_debug = false;
bool opt_debug_and_release = false;
bool opt_no_framework = false;
bool opt_framework = false;
bool opt_no_separate_debug_info = false;
bool opt_separate_debug_info = false;
if(conf->getenv("QC_RELEASE") == "Y")
opt_release = true;
if(conf->getenv("QC_DEBUG") == "Y")
opt_debug = true;
if(conf->getenv("QC_DEBUG_AND_RELEASE") == "Y")
opt_debug_and_release = true;
if(conf->getenv("QC_NO_FRAMEWORK") == "Y")
opt_no_framework = true;
if(conf->getenv("QC_FRAMEWORK") == "Y")
opt_framework = true;
if(conf->getenv("QC_NO_SEPARATE_DEBUG_INFO") == "Y")
opt_no_separate_debug_info = true;
if(conf->getenv("QC_SEPARATE_DEBUG_INFO") == "Y")
opt_separate_debug_info = true;
bool staticmode = false;
if(conf->getenv("QC_STATIC") == "Y")
staticmode = true;
#ifndef Q_OS_MAC
if(opt_debug_and_release)
{
printf("\nError: The --debug-and-release option is for mac only.\n");
exit(1);
}
if(opt_framework)
{
printf("\nError: The --framework option is for mac only.\n");
exit(1);
}
#endif
if(opt_framework && opt_debug)
{
printf("\nError: Cannot use both --framework and --debug.\n");
exit(1);
}
// sanity check exclusive options
int x;
// build mode
x = 0;
if(opt_release)
++x;
if(opt_debug)
++x;
if(opt_debug_and_release)
++x;
if(x > 1)
{
printf("\nError: Use only one of --release, --debug, or --debug-and-release.\n");
exit(1);
}
// framework
if(opt_framework && staticmode)
{
printf("\nError: Cannot use both --framework and --static.\n");
exit(1);
}
x = 0;
if(opt_no_framework)
++x;
if(opt_framework)
++x;
if(x > 1)
{
printf("\nError: Use only one of --framework or --no-framework.\n");
exit(1);
}
// debug info
x = 0;
if(opt_no_separate_debug_info)
++x;
if(opt_separate_debug_info)
++x;
if(x > 1)
{
printf("\nError: Use only one of --separate-debug-info or --no-separate-debug-info\n");
exit(1);
}
// now process the options
if(opt_release)
qc_buildmode_release = true;
else if(opt_debug)
qc_buildmode_debug = true;
else if(opt_debug_and_release)
{
qc_buildmode_release = true;
qc_buildmode_debug = true;
}
else // default
qc_buildmode_release = true;
if(opt_framework)
qc_buildmode_framework = true;
else if(opt_no_framework)
{
// nothing to do
}
else // default
{
if(!staticmode && !opt_debug)
qc_buildmode_framework = true;
}
if(opt_separate_debug_info)
qc_buildmode_separate_debug_info = true;
else if(opt_no_separate_debug_info)
{
// nothing to do
}
else // default
{
#ifndef Q_OS_MAC
qc_buildmode_separate_debug_info = true;
#endif
}
// make the string
QStringList opts;
QString other;
if(qc_buildmode_release && qc_buildmode_debug)
{
opts += "debug_and_release";
opts += "build_all";
}
else if(qc_buildmode_release)
opts += "release";
else // qc_buildmode_debug
opts += "debug";
#ifdef Q_OS_MAC
if(qc_buildmode_framework)
opts += "lib_bundle";
#endif
if(qc_buildmode_separate_debug_info)
{
opts += "separate_debug_info";
other += "QMAKE_CFLAGS += -g\n";
other += "QMAKE_CXXFLAGS += -g\n";
}
QString str = QString("CONFIG += ") + opts.join(" ") + '\n';
conf->addExtra(str);
if(!other.isEmpty())
conf->addExtra(other);
return true;
}
};

90
iris/qcm/extra.qcm Normal file
View file

@ -0,0 +1,90 @@
/*
-----BEGIN QCMOD-----
name: extra
section: project
arg: disable-tests,Don't build examples and unittests.
-----END QCMOD-----
*/
class qc_extra : public ConfObj
{
public:
qc_extra(Conf *c) : ConfObj(c) {}
QString name() const { return "extra"; }
QString shortname() const { return "extra"; }
// no output
QString checkString() const { return QString(); }
bool exec()
{
QString str;
QFile f;
if(conf->getenv("QC_DISABLE_TESTS") == "Y")
str += "CONFIG += no_tests\n";
conf->addExtra(str);
bool release = true;
bool debug = false;
bool debug_info = false;
bool universal = false;
QString sdk;
#ifdef QC_BUILDMODE
release = qc_buildmode_release;
debug = qc_buildmode_debug;
debug_info = qc_buildmode_separate_debug_info;
#endif
#ifdef QC_UNIVERSAL
universal = qc_universal_enabled;
sdk = qc_universal_sdk;
#endif
// write confapp_unix.pri
str = QString();
QString var = conf->getenv("BINDIR");
if(!var.isEmpty())
str += QString("BINDIR = %1\n").arg(var);
if(debug) // debug or debug-and-release
str += QString("CONFIG += debug\n");
else // release
str += QString("CONFIG += release\n");
if(debug_info)
{
str += QString("CONFIG += separate_debug_info\n");
str += "QMAKE_CFLAGS += -g\n";
str += "QMAKE_CXXFLAGS += -g\n";
}
if(universal)
{
str +=
"contains(QT_CONFIG,x86):contains(QT_CONFIG,ppc) {\n"
" CONFIG += x86 ppc\n"
"}\n";
if(!sdk.isEmpty())
str += QString("QMAKE_MAC_SDK = %1\n").arg(sdk);
}
#ifdef QC_QCA
if(!qc_qca_procode.isEmpty())
str += qc_qca_procode;
#endif
f.setFileName("confapp_unix.pri");
if(f.open(QFile::WriteOnly | QFile::Truncate))
f.write(str.toLatin1());
f.close();
return true;
}
QString makeEscapedDefine(const QString &var, const QString &val)
{
QString str = QString(
"DEFINES += %1=\\\\\\\\\\\\\\"%2\\\\\\\\\\\\\\"\n"
).arg(var).arg(val);
return str;
}
};

126
iris/qcm/qca.qcm Normal file
View file

@ -0,0 +1,126 @@
/*
-----BEGIN QCMOD-----
name: QCA >= 2.0
arg: with-qca=[path],Specify path to QCA tree, mainly for building against an uninstalled QCA.
-----END QCMOD-----
*/
// based on crypto.prf. any changes made to that file need to be tracked here.
static QString internal_crypto_prf(const QString &incdir, const QString &libdir)
{
QString out = QString(
"QCA_INCDIR = %1\n"
"QCA_LIBDIR = %2\n"
"\n"
"CONFIG *= qt\n"
"\n"
"LINKAGE =\n"
"\n"
"# on mac, if qca was built as a framework, link against it\n"
"mac: {\n"
" framework_dir = $$QCA_LIBDIR\n"
" exists($$framework_dir/qca.framework) {\n"
" #QMAKE_FRAMEWORKPATH *= $$framework_dir\n"
" LIBS += -F$$framework_dir\n"
" INCLUDEPATH += $$framework_dir/qca.framework/Headers\n"
" LINKAGE = -framework qca\n"
" }\n"
"}\n"
"\n"
"# else, link normally\n"
"isEmpty(LINKAGE) {\n"
" INCLUDEPATH += $$QCA_INCDIR/QtCrypto\n"
" LIBS += -L$$QCA_LIBDIR\n"
" LINKAGE = -lqca\n"
" CONFIG(debug, debug|release) {\n"
" windows:LINKAGE = -lqcad\n"
" mac:LINKAGE = -lqca_debug\n"
" }\n"
"}\n"
"\n"
"LIBS += $$LINKAGE\n"
).arg(incdir, libdir);
return out;
}
#define QC_QCA
QString qc_qca_procode;
//----------------------------------------------------------------------------
// qc_qca
//----------------------------------------------------------------------------
class qc_qca : public ConfObj
{
public:
qc_qca(Conf *c) : ConfObj(c) {}
QString name() const { return "QCA >= 2.0"; }
QString shortname() const { return "qca"; }
bool exec()
{
// get the build mode
#ifdef QC_BUILDMODE
bool release = qc_buildmode_release;
bool debug = qc_buildmode_debug;
#else
// else, default to just release mode
bool release = true;
bool debug = false;
#endif
// test for "crypto" feature and check qca version number
QString qca_prefix, qca_incdir, qca_libdir, qca_crypto_prf;
qca_prefix = conf->getenv("QC_WITH_QCA");
QString proextra;
if(!qca_prefix.isEmpty()) {
qca_incdir = qca_prefix + "/include";
qca_libdir = qca_prefix + "/lib";
qca_crypto_prf = internal_crypto_prf(qca_incdir, qca_libdir);
proextra =
"CONFIG += qt\n"
"QT -= gui\n";
proextra += qca_crypto_prf;
} else {
proextra =
"CONFIG += qt crypto\n"
"QT -= gui\n";
}
QString str =
"#include <QtCrypto>\n"
"\n"
"int main()\n"
"{\n"
" unsigned long x = QCA_VERSION;\n"
" if(x >= 0x020000 && x < 0x030000) return 0; else return 1;\n"
"}\n";
if(release)
{
int ret;
if(!conf->doCompileAndLink(str, QStringList(), QString(), proextra + "CONFIG += release\n", &ret))
return false;
if(ret != 0)
return false;
}
if(debug)
{
int ret;
if(!conf->doCompileAndLink(str, QStringList(), QString(), proextra + "CONFIG += debug\n", &ret))
return false;
if(ret != 0)
return false;
}
if(!qca_prefix.isEmpty())
str = qca_crypto_prf;
else
str = "CONFIG += crypto\n";
qc_qca_procode = str;
conf->addExtra(str);
return true;
}
};

20
iris/qcm/qt42.qcm Normal file
View file

@ -0,0 +1,20 @@
/*
-----BEGIN QCMOD-----
name: Qt >= 4.2
-----END QCMOD-----
*/
class qc_qt42 : public ConfObj
{
public:
qc_qt42(Conf *c) : ConfObj(c) {}
QString name() const { return "Qt >= 4.2"; }
QString shortname() const { return "qt42"; }
bool exec()
{
conf->debug(QString("QT_VERSION = 0x%1").arg(QString::number(QT_VERSION, 16)));
if(QT_VERSION >= 0x040200)
return true;
else
return false;
}
};

49
iris/qcm/universal.qcm Normal file
View file

@ -0,0 +1,49 @@
/*
-----BEGIN QCMOD-----
name: Mac universal binary support
section: project
arg: universal,Build with Mac universal binary support.
arg: mac-sdk=[path],Path to Mac universal SDK (PPC host only).
-----END QCMOD-----
*/
#define QC_UNIVERSAL
bool qc_universal_enabled = false;
QString qc_universal_sdk;
//----------------------------------------------------------------------------
// qc_universal
//----------------------------------------------------------------------------
class qc_universal : public ConfObj
{
public:
qc_universal(Conf *c) : ConfObj(c) {}
QString name() const { return "Mac universal binary support"; }
QString shortname() const { return "universal"; }
QString checkString() const { return QString(); }
bool exec()
{
#ifdef Q_OS_MAC
if(qc_getenv("QC_UNIVERSAL") == "Y")
{
qc_universal_enabled = true;
QString str =
"contains(QT_CONFIG,x86):contains(QT_CONFIG,ppc) {\n"
" CONFIG += x86 ppc\n"
"}\n";
QString sdk = qc_getenv("QC_MAC_SDK");
if(!sdk.isEmpty())
{
str += QString("QMAKE_MAC_SDK = %1\n").arg(sdk);
qc_universal_sdk = sdk;
}
conf->addExtra(str);
}
#endif
return true;
}
};

55
iris/qcm/zlib.qcm Normal file
View file

@ -0,0 +1,55 @@
/*
-----BEGIN QCMOD-----
name: zlib
arg: with-zlib-inc=[path],Path to zlib include files
arg: with-zlib-lib=[path],Path to zlib library files
-----END QCMOD-----
*/
//----------------------------------------------------------------------------
// qc_zlib
//----------------------------------------------------------------------------
class qc_zlib : public ConfObj
{
public:
qc_zlib(Conf *c) : ConfObj(c) {}
QString name() const { return "zlib"; }
QString shortname() const { return "zlib"; }
bool exec()
{
QString inc, lib;
QString s;
s = conf->getenv("QC_WITH_ZLIB_INC");
if(!s.isEmpty()) {
if(!conf->checkHeader(s, "zlib.h"))
return false;
inc = s;
}
else {
if(!conf->findHeader("zlib.h", QStringList(), &s))
return false;
inc = s;
}
s = conf->getenv("QC_WITH_ZLIB_LIB");
if(!s.isEmpty()) {
if(!conf->checkLibrary(s, "z"))
return false;
lib = s;
}
else {
if(!conf->findLibrary("z", &s))
return false;
lib = s;
}
if(!inc.isEmpty())
conf->addIncludePath(inc);
if(!lib.isEmpty())
conf->addLib(QString("-L") + s);
conf->addLib("-lz");
return true;
}
};

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,6 @@
QT *= network
HEADERS += $$PWD/qdnssd.h
SOURCES += $$PWD/qdnssd.cpp $$PWD/appledns.cpp
!mac:LIBS += -ldns_sd

View file

@ -0,0 +1,14 @@
IRIS_BASE = ../../..
include(../../libbase.pri)
TEMPLATE = lib
CONFIG += plugin
QT -= gui
DESTDIR = $$IRIS_BASE/plugins
VERSION = 1.0.0
INCLUDEPATH *= $$PWD/../corelib
LIBS += -L$$IRIS_BASE/lib -lirisnetcore
include(appledns.pri)

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,161 @@
/*
* Copyright (C) 2007 Justin Karneges
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
#ifndef QDNSSD_H
#define QDNSSD_H
#include <QObject>
#include <QByteArray>
#include <QList>
// DOR-compliant
class QDnsSd : public QObject
{
Q_OBJECT
public:
class LowLevelError
{
public:
QString func;
int code;
LowLevelError() :
code(0)
{
}
LowLevelError(const QString &_func, int _code) :
func(_func),
code(_code)
{
}
};
class Record
{
public:
bool added; // only used by QueryResult
QByteArray name;
int rrtype;
QByteArray rdata;
quint32 ttl;
};
class BrowseEntry
{
public:
bool added;
QByteArray serviceName;
// these may be different from request, see dns_sd docs
QByteArray serviceType;
QByteArray replyDomain;
};
class QueryResult
{
public:
bool success;
LowLevelError lowLevelError;
QList<Record> records;
};
class BrowseResult
{
public:
bool success;
LowLevelError lowLevelError;
QList<BrowseEntry> entries;
};
class ResolveResult
{
public:
bool success;
LowLevelError lowLevelError;
QByteArray fullName;
QByteArray hostTarget;
int port; // host byte-order
QByteArray txtRecord;
};
class RegResult
{
public:
enum Error
{
ErrorGeneric,
ErrorConflict
};
bool success;
Error errorCode;
LowLevelError lowLevelError;
QByteArray domain;
};
QDnsSd(QObject *parent = 0);
~QDnsSd();
int query(const QByteArray &name, int qType);
// domain may be empty
int browse(const QByteArray &serviceType, const QByteArray &domain);
int resolve(const QByteArray &serviceName, const QByteArray &serviceType, const QByteArray &domain);
// domain may be empty
int reg(const QByteArray &serviceName, const QByteArray &serviceType, const QByteArray &domain, int port, const QByteArray &txtRecord);
// return -1 on error, else a record id
int recordAdd(int reg_id, const Record &rec, LowLevelError *lowLevelError = 0);
bool recordUpdate(int rec_id, const Record &rec, LowLevelError *lowLevelError = 0);
bool recordUpdateTxt(int reg_id, const QByteArray &txtRecord, quint32 ttl, LowLevelError *lowLevelError = 0);
void recordRemove(int rec_id);
void stop(int id);
// return empty array on error
static QByteArray createTxtRecord(const QList<QByteArray> &strings);
// return empty list on error (note that it is possible to have a
// txt record with no entries, but in that case txtRecord will be
// empty and so you shouldn't call this function)
static QList<QByteArray> parseTxtRecord(const QByteArray &txtRecord);
signals:
void queryResult(int id, const QDnsSd::QueryResult &result);
void browseResult(int id, const QDnsSd::BrowseResult &result);
void resolveResult(int id, const QDnsSd::ResolveResult &result);
void regResult(int id, const QDnsSd::RegResult &result);
private:
class Private;
friend class Private;
Private *d;
};
#endif

View file

@ -0,0 +1,499 @@
/*
* Copyright (C) 2007 Justin Karneges
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
#include <QtCore>
#include <QHostAddress>
#include "qdnssd.h"
// for ntohl
#ifdef Q_OS_WIN
# include <windows.h>
#else
# include <netinet/in.h>
#endif
class Command
{
public:
enum Type
{
Query,
Browse,
Resolve,
Reg
};
Type type;
QString name; // query, resolve, reg
int rtype; // query
QString stype; // browse, resolve, reg
QString domain; // browse, resolve, reg
int port; // reg
QByteArray txtRecord; // reg
int id;
int dnsId;
bool error;
bool done; // for resolve
Command() :
error(false),
done(false)
{
}
};
static QString nameToString(const QByteArray &in)
{
QStringList parts;
int at = 0;
while(at < in.size())
{
int len = in[at++];
parts += QString::fromUtf8(in.mid(at, len));
at += len;
}
return parts.join(".");
}
static QString recordToDesc(const QDnsSd::Record &rec)
{
QString desc;
if(rec.rrtype == 1) // A
{
quint32 *p = (quint32 *)rec.rdata.data();
desc = QHostAddress(ntohl(*p)).toString();
}
else if(rec.rrtype == 28) // AAAA
{
desc = QHostAddress((quint8 *)rec.rdata.data()).toString();
}
else if(rec.rrtype == 12) // PTR
{
desc = QString("[%1]").arg(nameToString(rec.rdata));
}
else
desc = QString("%1 bytes").arg(rec.rdata.size());
return desc;
}
static QStringList txtRecordToStringList(const QByteArray &rdata)
{
QList<QByteArray> txtEntries = QDnsSd::parseTxtRecord(rdata);
if(txtEntries.isEmpty())
return QStringList();
QStringList out;
foreach(const QByteArray &entry, txtEntries)
out += QString::fromUtf8(entry);
return out;
}
static void printIndentedTxt(const QByteArray &txtRecord)
{
QStringList list = txtRecordToStringList(txtRecord);
if(!list.isEmpty())
{
foreach(const QString &s, list)
printf(" %s\n", qPrintable(s));
}
else
printf(" (TXT parsing error)\n");
}
class App : public QObject
{
Q_OBJECT
public:
QList<Command> commands;
QDnsSd *dns;
App()
{
dns = new QDnsSd(this);
connect(dns, SIGNAL(queryResult(int, const QDnsSd::QueryResult &)), SLOT(dns_queryResult(int, const QDnsSd::QueryResult &)));
connect(dns, SIGNAL(browseResult(int, const QDnsSd::BrowseResult &)), SLOT(dns_browseResult(int, const QDnsSd::BrowseResult &)));
connect(dns, SIGNAL(resolveResult(int, const QDnsSd::ResolveResult &)), SLOT(dns_resolveResult(int, const QDnsSd::ResolveResult &)));
connect(dns, SIGNAL(regResult(int, const QDnsSd::RegResult &)), SLOT(dns_regResult(int, const QDnsSd::RegResult &)));
}
public slots:
void start()
{
for(int n = 0; n < commands.count(); ++n)
{
Command &c = commands[n];
c.id = n;
if(c.type == Command::Query)
{
printf("%2d: Query name=[%s], type=%d ...\n", c.id, qPrintable(c.name), c.rtype);
c.dnsId = dns->query(c.name.toUtf8(), c.rtype);
}
else if(c.type == Command::Browse)
{
printf("%2d: Browse type=[%s]", c.id, qPrintable(c.stype));
if(!c.domain.isEmpty())
printf(", domain=[%s]", qPrintable(c.domain));
printf(" ...\n");
c.dnsId = dns->browse(c.stype.toUtf8(), c.domain.toUtf8());
}
else if(c.type == Command::Resolve)
{
printf("%2d: Resolve name=[%s], type=[%s], domain=[%s] ...\n", c.id, qPrintable(c.name), qPrintable(c.stype), qPrintable(c.domain));
c.dnsId = dns->resolve(c.name.toUtf8(), c.stype.toUtf8(), c.domain.toUtf8());
}
else if(c.type == Command::Reg)
{
printf("%2d: Register name=[%s], type=[%s]", c.id, qPrintable(c.name), qPrintable(c.stype));
if(!c.domain.isEmpty())
printf(", domain=[%s]", qPrintable(c.domain));
printf(", port=%d ...\n", c.port);
if(!c.txtRecord.isEmpty())
printIndentedTxt(c.txtRecord);
c.dnsId = dns->reg(c.name.toUtf8(), c.stype.toUtf8(), c.domain.toUtf8(), c.port, c.txtRecord);
}
}
}
signals:
void quit();
private:
int cmdIdToCmdIndex(int cmdId)
{
for(int n = 0; n < commands.count(); ++n)
{
const Command &c = commands[n];
if(c.id == cmdId)
return n;
}
return -1;
}
int dnsIdToCmdIndex(int dnsId)
{
for(int n = 0; n < commands.count(); ++n)
{
const Command &c = commands[n];
if(c.dnsId == dnsId)
return n;
}
return -1;
}
void tryQuit()
{
// quit if there are nothing but errors or completed resolves
bool doQuit = true;
foreach(const Command &c, commands)
{
if(c.error || (c.type == Command::Resolve && c.done))
continue;
doQuit = false;
break;
}
if(doQuit)
emit quit();
}
private slots:
void dns_queryResult(int id, const QDnsSd::QueryResult &result)
{
int at = dnsIdToCmdIndex(id);
Command &c = commands[at];
if(!result.success)
{
printf("%2d: Error.", c.id);
if(!result.lowLevelError.func.isEmpty())
printf(" (%s, %d)", qPrintable(result.lowLevelError.func), result.lowLevelError.code);
printf("\n");
c.error = true;
tryQuit();
return;
}
foreach(const QDnsSd::Record &rec, result.records)
{
if(rec.added)
{
printf("%2d: Added: %s, ttl=%d\n", c.id, qPrintable(recordToDesc(rec)), rec.ttl);
if(rec.rrtype == 16)
printIndentedTxt(rec.rdata);
}
else
printf("%2d: Removed: %s, ttl=%d\n", c.id, qPrintable(recordToDesc(rec)), rec.ttl);
}
}
void dns_browseResult(int id, const QDnsSd::BrowseResult &result)
{
int at = dnsIdToCmdIndex(id);
Command &c = commands[at];
if(!result.success)
{
printf("%2d: Error.", c.id);
if(!result.lowLevelError.func.isEmpty())
printf(" (%s, %d)", qPrintable(result.lowLevelError.func), result.lowLevelError.code);
printf("\n");
c.error = true;
tryQuit();
return;
}
foreach(const QDnsSd::BrowseEntry &e, result.entries)
{
if(e.added)
printf("%2d: Added: [%s] [%s] [%s]\n", c.id, qPrintable(QString::fromUtf8(e.serviceName)), qPrintable(QString::fromUtf8(e.serviceType)), qPrintable(QString::fromUtf8(e.replyDomain)));
else
printf("%2d: Removed: [%s]\n", c.id, qPrintable(QString::fromUtf8(e.serviceName)));
}
}
void dns_resolveResult(int id, const QDnsSd::ResolveResult &result)
{
int at = dnsIdToCmdIndex(id);
Command &c = commands[at];
if(!result.success)
{
printf("%2d: Error.", c.id);
if(!result.lowLevelError.func.isEmpty())
printf(" (%s, %d)", qPrintable(result.lowLevelError.func), result.lowLevelError.code);
printf("\n");
c.error = true;
tryQuit();
return;
}
printf("%2d: Result: host=[%s] port=%d\n", c.id, qPrintable(QString::fromUtf8(result.hostTarget)), result.port);
if(!result.txtRecord.isEmpty())
printIndentedTxt(result.txtRecord);
c.done = true;
tryQuit();
}
void dns_regResult(int id, const QDnsSd::RegResult &result)
{
int at = dnsIdToCmdIndex(id);
Command &c = commands[at];
if(!result.success)
{
QString errstr;
if(result.errorCode == QDnsSd::RegResult::ErrorConflict)
errstr = "Conflict";
else
errstr = "Generic";
printf("%2d: Error (%s).", c.id, qPrintable(errstr));
if(!result.lowLevelError.func.isEmpty())
printf(" (%s, %d)", qPrintable(result.lowLevelError.func), result.lowLevelError.code);
printf("\n");
c.error = true;
tryQuit();
return;
}
printf("%2d: Registered: domain=[%s]\n", c.id, qPrintable(QString::fromUtf8(result.domain)));
}
};
#include "sdtest.moc"
void usage()
{
printf("usage: sdtest [[command] (command) ...]\n");
printf(" options: --txt=str0,...,strn\n");
printf("\n");
printf(" q=name,type# query for a record\n");
printf(" b=type(,domain) browse for services\n");
printf(" r=name,type,domain resolve a service\n");
printf(" e=name,type,port(,domain) register a service\n");
printf("\n");
}
int main(int argc, char **argv)
{
QCoreApplication qapp(argc, argv);
QStringList args = qapp.arguments();
args.removeFirst();
if(args.count() < 1)
{
usage();
return 1;
}
// options
QStringList txt;
for(int n = 0; n < args.count(); ++n)
{
QString s = args[n];
if(!s.startsWith("--"))
continue;
QString var;
QString val;
int x = s.indexOf('=');
if(x != -1)
{
var = s.mid(2, x - 2);
val = s.mid(x + 1);
}
else
{
var = s.mid(2);
}
bool known = true;
if(var == "txt")
{
txt = val.split(',');
}
else
known = false;
if(known)
{
args.removeAt(n);
--n; // adjust position
}
}
// commands
QList<Command> commands;
for(int n = 0; n < args.count(); ++n)
{
QString str = args[n];
int n = str.indexOf('=');
if(n == -1)
{
printf("Error: bad format of command.\n");
return 1;
}
QString type = str.mid(0, n);
QString rest = str.mid(n + 1);
QStringList parts = rest.split(',');
if(type == "q")
{
if(parts.count() < 2)
{
usage();
return 1;
}
Command c;
c.type = Command::Query;
c.name = parts[0];
c.rtype = parts[1].toInt();
commands += c;
}
else if(type == "b")
{
if(parts.count() < 1)
{
usage();
return 1;
}
Command c;
c.type = Command::Browse;
c.stype = parts[0];
if(parts.count() >= 2)
c.domain = parts[1];
commands += c;
}
else if(type == "r")
{
if(parts.count() < 3)
{
usage();
return 1;
}
Command c;
c.type = Command::Resolve;
c.name = parts[0];
c.stype = parts[1];
c.domain = parts[2];
commands += c;
}
else if(type == "e")
{
if(parts.count() < 3)
{
usage();
return 1;
}
Command c;
c.type = Command::Reg;
c.name = parts[0];
c.stype = parts[1];
c.port = parts[2].toInt();
if(parts.count() >= 4)
c.domain = parts[3];
if(!txt.isEmpty())
{
QList<QByteArray> strings;
foreach(const QString &str, txt)
strings += str.toUtf8();
QByteArray txtRecord = QDnsSd::createTxtRecord(strings);
if(txtRecord.isEmpty())
{
printf("Error: failed to create TXT record, input too large or invalid\n");
return 1;
}
c.txtRecord = txtRecord;
}
commands += c;
}
else
{
printf("Error: unknown command type '%s'.\n", qPrintable(type));
return 1;
}
}
App app;
app.commands = commands;
QObject::connect(&app, SIGNAL(quit()), &qapp, SLOT(quit()));
QTimer::singleShot(0, &app, SLOT(start()));
qapp.exec();
return 0;
}

View file

@ -0,0 +1,9 @@
CONFIG += console
CONFIG -= app_bundle
QT -= gui
QT += network
HEADERS += qdnssd.h
SOURCES += qdnssd.cpp sdtest.cpp
!mac:LIBS += -ldns_sd

View file

@ -0,0 +1,213 @@
/*
* Copyright (C) 2010 Barracuda Networks, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include "addressresolver.h"
#include "objectsession.h"
#include "netnames.h"
namespace XMPP {
class AddressResolver::Private : public QObject
{
Q_OBJECT
public:
enum State
{
AddressWait,
AddressFirstCome
};
AddressResolver *q;
ObjectSession sess;
State state;
NameResolver req6;
NameResolver req4;
bool done6;
bool done4;
QList<QHostAddress> addrs6;
QList<QHostAddress> addrs4;
QTimer *opTimer;
Private(AddressResolver *_q) :
QObject(_q),
q(_q),
sess(this),
req6(this),
req4(this)
{
connect(&req6, SIGNAL(resultsReady(const QList<XMPP::NameRecord> &)), SLOT(req6_resultsReady(const QList<XMPP::NameRecord> &)));
connect(&req6, SIGNAL(error(XMPP::NameResolver::Error)), SLOT(req6_error(XMPP::NameResolver::Error)));
connect(&req4, SIGNAL(resultsReady(const QList<XMPP::NameRecord> &)), SLOT(req4_resultsReady(const QList<XMPP::NameRecord> &)));
connect(&req4, SIGNAL(error(XMPP::NameResolver::Error)), SLOT(req4_error(XMPP::NameResolver::Error)));
opTimer = new QTimer(this);
connect(opTimer, SIGNAL(timeout()), SLOT(op_timeout()));
opTimer->setSingleShot(true);
}
~Private()
{
opTimer->disconnect(this);
opTimer->setParent(0);
opTimer->deleteLater();
}
void start(const QByteArray &hostName)
{
state = AddressWait;
// was an IP address used as input?
QHostAddress addr;
if(addr.setAddress(QString::fromLatin1(hostName)))
{
// use this as the result, no need to perform dns query
done6 = true;
done4 = true;
if(addr.protocol() == QAbstractSocket::IPv6Protocol)
addrs6 += addr;
else
addrs4 += addr;
sess.defer(this, "ipAddress_input");
return;
}
done6 = false;
done4 = false;
// wait at least 5 seconds for one of AAAA or A, to be
// consistent with netnames_jdns' dns-sd resolves
opTimer->start(5000);
req6.start(hostName, NameRecord::Aaaa);
req4.start(hostName, NameRecord::A);
}
void stop()
{
cleanup();
}
private:
void cleanup()
{
sess.reset();
req6.stop();
req4.stop();
opTimer->stop();
addrs6.clear();
addrs4.clear();
}
bool tryDone()
{
if((done6 && done4) || (state == AddressFirstCome && (done6 || done4)))
{
QList<QHostAddress> results = addrs6 + addrs4;
cleanup();
if(!results.isEmpty())
emit q->resultsReady(results);
else
emit q->error(ErrorGeneric);
return true;
}
return false;
}
private slots:
void req6_resultsReady(const QList<XMPP::NameRecord> &results)
{
foreach(const NameRecord &rec, results)
addrs6 += rec.address();
done6 = true;
tryDone();
}
void req6_error(XMPP::NameResolver::Error e)
{
Q_UNUSED(e);
done6 = true;
tryDone();
}
void req4_resultsReady(const QList<XMPP::NameRecord> &results)
{
foreach(const NameRecord &rec, results)
addrs4 += rec.address();
done4 = true;
tryDone();
}
void req4_error(XMPP::NameResolver::Error e)
{
Q_UNUSED(e);
done4 = true;
tryDone();
}
void op_timeout()
{
state = AddressFirstCome;
if(done6 || done4)
tryDone();
}
void ipAddress_input()
{
tryDone();
}
};
AddressResolver::AddressResolver(QObject *parent) :
QObject(parent)
{
d = new Private(this);
}
AddressResolver::~AddressResolver()
{
delete d;
}
void AddressResolver::start(const QByteArray &hostName)
{
d->start(hostName);
}
void AddressResolver::stop()
{
d->stop();
}
}
#include "addressresolver.moc"

View file

@ -0,0 +1,57 @@
/*
* Copyright (C) 2010 Barracuda Networks, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef ADDRESSRESOLVER_H
#define ADDRESSRESOLVER_H
#include <QObject>
#include <QHostAddress>
namespace XMPP {
// resolve both AAAA and A for a hostname
class AddressResolver : public QObject
{
Q_OBJECT
public:
enum Error
{
ErrorGeneric
};
AddressResolver(QObject *parent = 0);
~AddressResolver();
void start(const QByteArray &hostName);
void stop();
signals:
void resultsReady(const QList<QHostAddress> &results);
void error(XMPP::AddressResolver::Error e);
private:
class Private;
friend class Private;
Private *d;
};
}
#endif

View file

@ -0,0 +1,49 @@
QT *= network
# libidn
#LIBS += -lidn
include(../../jdns/jdns.pri)
INCLUDEPATH += $$PWD/../../jdns
HEADERS += \
$$PWD/jdnsshared.h \
$$PWD/objectsession.h \
$$PWD/irisnetexport.h \
$$PWD/irisnetplugin.h \
$$PWD/irisnetglobal.h \
$$PWD/irisnetglobal_p.h \
$$PWD/netinterface.h \
$$PWD/netavailability.h \
$$PWD/netnames.h \
$$PWD/addressresolver.h
SOURCES += \
$$PWD/jdnsshared.cpp \
$$PWD/objectsession.cpp \
$$PWD/irisnetplugin.cpp \
$$PWD/irisnetglobal.cpp \
$$PWD/netinterface.cpp \
$$PWD/netavailability.cpp \
$$PWD/netnames.cpp \
$$PWD/addressresolver.cpp
unix {
SOURCES += \
$$PWD/netinterface_unix.cpp
}
windows {
SOURCES += \
$$PWD/netinterface_win.cpp
}
SOURCES += \
$$PWD/netnames_jdns.cpp
#include(legacy/legacy.pri)
appledns:appledns_bundle {
DEFINES += APPLEDNS_STATIC
include(../appledns/appledns.pri)
}

View file

@ -0,0 +1,17 @@
IRIS_BASE = ../../..
TEMPLATE = lib
QT -= gui
TARGET = irisnetcore
DESTDIR = $$IRIS_BASE/lib
windows:DLLDESTDIR = $$IRIS_BASE/bin
VERSION = 1.0.0
include(../../libbase.pri)
include(corelib.pri)
# fixme: irisnetcore builds as dll or bundled, never static?
CONFIG += create_prl
windows:!staticlib:DEFINES += IRISNET_MAKEDLL
staticlib:PRL_EXPORT_DEFINES += IRISNET_STATIC

View file

@ -0,0 +1,36 @@
/*
* Copyright (C) 2006 Justin Karneges
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
#ifndef IRISNETEXPORT_H
#define IRISNETEXPORT_H
#include <QtGlobal>
#ifdef IRISNET_STATIC
# define IRISNET_EXPORT
#else
# ifdef IRISNET_MAKEDLL
# define IRISNET_EXPORT Q_DECL_EXPORT
# else
# define IRISNET_EXPORT Q_DECL_IMPORT
# endif
#endif
#endif

View file

@ -0,0 +1,304 @@
/*
* Copyright (C) 2006 Justin Karneges
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
#include "irisnetglobal_p.h"
#include "irisnetplugin.h"
namespace XMPP {
// built-in providers
#ifdef Q_OS_WIN
extern IrisNetProvider *irisnet_createWinNetProvider();
#endif
#ifdef Q_OS_UNIX
extern IrisNetProvider *irisnet_createUnixNetProvider();
#endif
extern IrisNetProvider *irisnet_createJDnsProvider();
#ifdef APPLEDNS_STATIC
extern IrisNetProvider *irisnet_createAppleProvider();
#endif
//----------------------------------------------------------------------------
// internal
//----------------------------------------------------------------------------
class PluginInstance
{
private:
QPluginLoader *_loader;
QObject *_instance;
bool _ownInstance;
PluginInstance()
{
}
public:
static PluginInstance *fromFile(const QString &fname)
{
QPluginLoader *loader = new QPluginLoader(fname);
if(!loader->load())
{
delete loader;
return 0;
}
QObject *obj = loader->instance();
if(!obj)
{
loader->unload();
delete loader;
return 0;
}
PluginInstance *i = new PluginInstance;
i->_loader = loader;
i->_instance = obj;
i->_ownInstance = true;
return i;
}
static PluginInstance *fromStatic(QObject *obj)
{
PluginInstance *i = new PluginInstance;
i->_loader = 0;
i->_instance = obj;
i->_ownInstance = false;
return i;
}
static PluginInstance *fromInstance(QObject *obj)
{
PluginInstance *i = new PluginInstance;
i->_loader = 0;
i->_instance = obj;
i->_ownInstance = true;
return i;
}
~PluginInstance()
{
if(_ownInstance)
delete _instance;
if(_loader)
{
_loader->unload();
delete _loader;
}
}
void claim()
{
if(_loader)
_loader->moveToThread(0);
if(_ownInstance)
_instance->moveToThread(0);
}
QObject *instance()
{
return _instance;
}
bool sameType(const PluginInstance *other)
{
if(!_instance || !other->_instance)
return false;
if(qstrcmp(_instance->metaObject()->className(), other->_instance->metaObject()->className()) != 0)
return false;
return true;
}
};
class PluginManager
{
public:
bool builtin_done;
QStringList paths;
QList<PluginInstance*> plugins;
QList<IrisNetProvider*> providers;
PluginManager()
{
builtin_done = false;
}
~PluginManager()
{
unload();
}
bool tryAdd(PluginInstance *i, bool lowPriority = false)
{
// is it the right kind of plugin?
IrisNetProvider *p = qobject_cast<IrisNetProvider*>(i->instance());
if(!p)
return false;
// make sure we don't have it already
for(int n = 0; n < plugins.count(); ++n)
{
if(i->sameType(plugins[n]))
return false;
}
i->claim();
plugins += i;
if(lowPriority)
providers.append(p);
else
providers.prepend(p);
return true;
}
void addBuiltIn(IrisNetProvider *p)
{
PluginInstance *i = PluginInstance::fromInstance(p);
if(!tryAdd(i, true))
delete i;
}
void scan()
{
if(!builtin_done)
{
#ifdef Q_OS_WIN
addBuiltIn(irisnet_createWinNetProvider());
#endif
#ifdef Q_OS_UNIX
addBuiltIn(irisnet_createUnixNetProvider());
#endif
addBuiltIn(irisnet_createJDnsProvider());
builtin_done = true;
}
QObjectList list = QPluginLoader::staticInstances();
for(int n = 0; n < list.count(); ++n)
{
PluginInstance *i = PluginInstance::fromStatic(list[n]);
if(!tryAdd(i))
delete i;
}
for(int n = 0; n < paths.count(); ++n)
{
QDir dir(paths[n]);
if(!dir.exists())
continue;
QStringList entries = dir.entryList();
for(int k = 0; k < entries.count(); ++k)
{
QFileInfo fi(dir.filePath(entries[k]));
if(!fi.exists())
continue;
QString fname = fi.filePath();
PluginInstance *i = PluginInstance::fromFile(fname);
if(!i)
continue;
if(!tryAdd(i))
delete i;
}
}
}
void unload()
{
// unload in reverse order
QList<PluginInstance*> revlist;
for(int n = 0; n < plugins.count(); ++n)
revlist.prepend(plugins[n]);
qDeleteAll(revlist);
plugins.clear();
providers.clear();
}
};
class IrisNetGlobal
{
public:
QMutex m;
PluginManager pluginManager;
QList<IrisNetCleanUpFunction> cleanupList;
};
Q_GLOBAL_STATIC(QMutex, global_mutex)
static IrisNetGlobal *global = 0;
static void deinit();
static void init()
{
QMutexLocker locker(global_mutex());
if(global)
return;
global = new IrisNetGlobal;
qAddPostRoutine(deinit);
}
void deinit()
{
if(!global)
return;
while(!global->cleanupList.isEmpty())
(global->cleanupList.takeFirst())();
delete global;
global = 0;
}
//----------------------------------------------------------------------------
// Global
//----------------------------------------------------------------------------
void irisNetSetPluginPaths(const QStringList &paths)
{
init();
QMutexLocker locker(&global->m);
global->pluginManager.paths = paths;
}
void irisNetCleanup()
{
deinit();
}
void irisNetAddPostRoutine(IrisNetCleanUpFunction func)
{
init();
QMutexLocker locker(&global->m);
global->cleanupList.prepend(func);
}
QList<IrisNetProvider*> irisNetProviders()
{
init();
QMutexLocker locker(&global->m);
global->pluginManager.scan();
return global->pluginManager.providers;
}
}

View file

@ -0,0 +1,39 @@
/*
* Copyright (C) 2006 Justin Karneges
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
#ifndef IRISNETGLOBAL_H
#define IRISNETGLOBAL_H
#include <QtCore>
#include <QtNetwork>
#include "irisnetexport.h"
namespace XMPP {
// set the directories for plugins. call before doing anything else.
IRISNET_EXPORT void irisNetSetPluginPaths(const QStringList &paths);
// free any shared data and plugins.
// note: this is automatically called when qapp shuts down.
IRISNET_EXPORT void irisNetCleanup();
}
#endif

View file

@ -0,0 +1,36 @@
/*
* Copyright (C) 2006 Justin Karneges
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
#ifndef IRISNETGLOBAL_P_H
#define IRISNETGLOBAL_P_H
#include "irisnetglobal.h"
#include "irisnetplugin.h"
namespace XMPP {
typedef void (*IrisNetCleanUpFunction)();
IRISNET_EXPORT void irisNetAddPostRoutine(IrisNetCleanUpFunction func);
IRISNET_EXPORT QList<IrisNetProvider*> irisNetProviders();
}
#endif

View file

@ -0,0 +1,84 @@
/*
* Copyright (C) 2006 Justin Karneges
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
#include "irisnetplugin.h"
namespace XMPP {
//----------------------------------------------------------------------------
// IrisNetProvider
//----------------------------------------------------------------------------
NetInterfaceProvider *IrisNetProvider::createNetInterfaceProvider()
{
return 0;
}
NetAvailabilityProvider *IrisNetProvider::createNetAvailabilityProvider()
{
return 0;
}
NameProvider *IrisNetProvider::createNameProviderInternet()
{
return 0;
}
NameProvider *IrisNetProvider::createNameProviderLocal()
{
return 0;
}
ServiceProvider *IrisNetProvider::createServiceProvider()
{
return 0;
}
//----------------------------------------------------------------------------
// NameProvider
//----------------------------------------------------------------------------
bool NameProvider::supportsSingle() const
{
return false;
}
bool NameProvider::supportsLongLived() const
{
return false;
}
bool NameProvider::supportsRecordType(int type) const
{
Q_UNUSED(type);
return false;
}
void NameProvider::resolve_localResultsReady(int id, const QList<XMPP::NameRecord> &results)
{
Q_UNUSED(id);
Q_UNUSED(results);
}
void NameProvider::resolve_localError(int id, XMPP::NameResolver::Error e)
{
Q_UNUSED(id);
Q_UNUSED(e);
}
}

Some files were not shown because too many files have changed in this diff Show more