File indexing completed on 2024-04-28 15:22:05

0001 /*
0002     This file is part of the KDE project
0003 
0004     SPDX-FileCopyrightText: 2004 Jakub Stachowski <qbast@go2.pl>
0005 
0006     SPDX-License-Identifier: LGPL-2.0-or-later
0007 */
0008 
0009 #ifndef AVAHI_SERVICEBROWSER_P_H
0010 #define AVAHI_SERVICEBROWSER_P_H
0011 
0012 #include "avahi_listener_p.h"
0013 #include "avahi_servicebrowser_interface.h"
0014 #include "servicebrowser.h"
0015 #include <QList>
0016 #include <QString>
0017 #include <QTimer>
0018 
0019 namespace KDNSSD
0020 {
0021 class ServiceBrowserPrivate : public QObject, public AvahiListener
0022 {
0023     Q_OBJECT
0024     friend class ServiceBrowser; // So the public class may functor connect.
0025 public:
0026     ServiceBrowserPrivate(ServiceBrowser *parent)
0027         : QObject()
0028         , m_running(false)
0029         , m_browser(nullptr)
0030         , m_parent(parent)
0031     {
0032     }
0033     ~ServiceBrowserPrivate() override
0034     {
0035         if (m_browser) {
0036             m_browser->Free();
0037         }
0038         delete m_browser;
0039     }
0040     QList<RemoteService::Ptr> m_services;
0041     QList<RemoteService::Ptr> m_duringResolve;
0042     QString m_type;
0043     QString m_domain;
0044     QString m_subtype;
0045     bool m_autoResolve = false;
0046     bool m_running = false;
0047     bool m_finished = false;
0048     bool m_browserFinished = false;
0049     QTimer m_timer;
0050     org::freedesktop::Avahi::ServiceBrowser *m_browser = nullptr;
0051     ServiceBrowser *m_parent = nullptr;
0052 
0053     // get already found service identical to s or null if not found
0054     RemoteService::Ptr find(RemoteService::Ptr s, const QList<RemoteService::Ptr> &where) const;
0055 
0056 private Q_SLOTS:
0057     void browserFinished();
0058     void queryFinished();
0059     void serviceResolved(bool success);
0060 
0061     // NB: The global slots are runtime connected! If their signature changes
0062     // make sure the SLOT() signature gets updated!
0063     void gotGlobalItemNew(int interface, int protocol, const QString &name, const QString &type, const QString &domain, uint flags, QDBusMessage msg);
0064     void gotGlobalItemRemove(int interface, int protocol, const QString &name, const QString &type, const QString &domain, uint flags, QDBusMessage msg);
0065     void gotGlobalAllForNow(QDBusMessage msg);
0066 
0067     void gotNewService(int, int, const QString &, const QString &, const QString &, uint);
0068     void gotRemoveService(int, int, const QString &, const QString &, const QString &, uint);
0069 };
0070 
0071 }
0072 
0073 #endif