1 /***************************************************************************
2 * Copyright (C) 2004, 2005 by Jakub Stachowski *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
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. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
28 #include <kio/global.h>
29 #include <kio/slavebase.h>
30 #include <dnssd/servicebrowser.h>
31 #include <dnssd/servicetypebrowser.h>
32 #include <dnssd/remoteservice.h>
33 #include <qstringlist.h>
37 using namespace DNSSD
;
39 enum UrlType
{ RootDir
, ServiceDir
, Service
, Invalid
};
43 ProtocolData(const QString
& _name
, const QString
& proto
, const QString
& path
=QString(),
44 const QString
& user
=QString(), const QString
& passwd
=QString()) : pathEntry(path
),
45 name(_name
), userEntry(user
), passwordEntry(passwd
), protocol(proto
) {}
50 QString passwordEntry
;
54 class ZeroConfProtocol
: public QObject
, public KIO::SlaveBase
58 ZeroConfProtocol(const QByteArray
& protocol
, const QByteArray
&pool_socket
, const QByteArray
&app_socket
);
60 virtual void get(const KUrl
& url
);
61 virtual void mimetype(const KUrl
& url
);
62 virtual void stat(const KUrl
& url
);
63 virtual void listDir(const KUrl
& url
);
67 // Create UDSEntry for zeroconf:/ or zeroconf:/type/ paths
68 void buildDirEntry(UDSEntry
& entry
,const QString
& name
,const QString
& type
=QString());
69 // Returns root dir, service dir, service or invalid
70 UrlType
checkURL(const KUrl
& url
);
71 // extract name and type from URL
72 void dissect(const KUrl
& url
,QString
& name
,QString
& type
);
73 // resolve given service and redirect() to it
74 void resolveAndRedirect(const KUrl
& url
);
79 ServiceBrowser
* browser
;
80 ServiceTypeBrowser
* typebrowser
;
81 // service types merged from all domains - to avoid duplicates
82 QStringList mergedtypes
;
84 RemoteService
*toResolve
;
85 QHash
<QString
,ProtocolData
> knownProtocols
;
88 void newType(const QString
&);
89 void newService(DNSSD::RemoteService::Ptr
);