add missing license
prepare browsing for plugins
This commit is contained in:
parent
568e21d68a
commit
ca34b7247d
@ -1,7 +1,44 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* *
|
||||
* Copyright (C) 2016 Simon Stürz <simon.stuerz@guh.guru> *
|
||||
* *
|
||||
* This file is part of guh. *
|
||||
* *
|
||||
* Guh is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, version 2 of the License. *
|
||||
* *
|
||||
* Guh 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 General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with guh. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#include "guhavahibrowser.h"
|
||||
#include "loggingcategories.h"
|
||||
|
||||
GuhAvahiBrowser::GuhAvahiBrowser(QObject *parent) : QObject(parent)
|
||||
{
|
||||
m_browser = new ZConfServiceBrowser(this);
|
||||
|
||||
connect(m_browser, &ZConfServiceBrowser::serviceEntryAdded, this, &GuhAvahiBrowser::onSeviceAdded);
|
||||
connect(m_browser, &ZConfServiceBrowser::serviceEntryRemoved, this, &GuhAvahiBrowser::onSeviceRemoved);
|
||||
connect(m_browser, &ZConfServiceBrowser::serviceBrowsingFinished, this, &GuhAvahiBrowser::onSeviceBrowsingFinished);
|
||||
}
|
||||
|
||||
void GuhAvahiBrowser::browseService(const QString &serviceType)
|
||||
{
|
||||
m_serviceEntries.clear();
|
||||
m_browser->browse(serviceType);
|
||||
}
|
||||
|
||||
void GuhAvahiBrowser::onSeviceBrowsingFinished()
|
||||
{
|
||||
|
||||
emit avahiBrowseFinished(m_serviceEntries);
|
||||
}
|
||||
|
||||
|
||||
@ -1,17 +1,50 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* *
|
||||
* Copyright (C) 2016 Simon Stürz <simon.stuerz@guh.guru> *
|
||||
* *
|
||||
* This file is part of guh. *
|
||||
* *
|
||||
* Guh is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, version 2 of the License. *
|
||||
* *
|
||||
* Guh 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 General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with guh. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#ifndef GUHAVAHIBROWSER_H
|
||||
#define GUHAVAHIBROWSER_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "zconfservicebrowser.h"
|
||||
|
||||
class GuhAvahiBrowser : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit GuhAvahiBrowser(QObject *parent = 0);
|
||||
|
||||
signals:
|
||||
void browseService(const QString &serviceType);
|
||||
|
||||
private:
|
||||
ZConfServiceBrowser *m_browser;
|
||||
QList<AvahiServiceEntry> m_serviceEntries;
|
||||
|
||||
signals:
|
||||
void avahiBrowseFinished(const QList<AvahiServiceEntry> &serviceEntries);
|
||||
|
||||
private slots:
|
||||
void onSeviceAdded(const QString &name);
|
||||
void onSeviceRemoved(const QString &name);
|
||||
void onSeviceBrowsingFinished();
|
||||
|
||||
public slots:
|
||||
};
|
||||
|
||||
#endif // GUHAVAHIBROWSER_H
|
||||
|
||||
@ -53,6 +53,7 @@ public:
|
||||
switch (event) {
|
||||
case AVAHI_BROWSER_FAILURE:
|
||||
qDebug() << ("Avahi browser error: " % QString(avahi_strerror(avahi_client_errno(serviceBrowser->d_ptr->client->client))));
|
||||
emit serviceBrowser->serviceBrowsingFinished();
|
||||
break;
|
||||
case AVAHI_BROWSER_NEW:
|
||||
qDebug() << ("New service '" % QString(name) % "' of type " % QString(type) % " in domain " % QString(domain) % ".");
|
||||
@ -76,14 +77,13 @@ public:
|
||||
case AVAHI_BROWSER_REMOVE:
|
||||
serviceBrowser->d_ptr->entries.remove(name);
|
||||
emit serviceBrowser->serviceEntryRemoved(name);
|
||||
qDebug() << "Service '" % QString(name) % "' removed from the network.";
|
||||
break;
|
||||
case AVAHI_BROWSER_ALL_FOR_NOW:
|
||||
emit serviceBrowser->serviceBrowsingFinished();
|
||||
break;
|
||||
case AVAHI_BROWSER_CACHE_EXHAUSTED:
|
||||
qDebug() << (AVAHI_BROWSER_ALL_FOR_NOW == event
|
||||
? "AVAHI_BROWSER_ALL_FOR_NOW"
|
||||
: "AVAHI_BROWSER_CACHE_EXHAUSTED");
|
||||
} // end switch
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -43,6 +43,7 @@ public:
|
||||
signals:
|
||||
void serviceEntryAdded(const QString &name);
|
||||
void serviceEntryRemoved(const QString &name);
|
||||
void serviceBrowsingFinished();
|
||||
|
||||
private slots:
|
||||
void createServiceBrowser();
|
||||
|
||||
Reference in New Issue
Block a user