Browse Source

Remove setShowUnresolved

Girish Ramakrishnan 8 years ago
parent
commit
81fcb9329c
3 changed files with 12 additions and 13 deletions
  1. 5 1
      examples/servicebrowser/main.cpp
  2. 6 8
      qavahiservicebrowsermodel.cpp
  3. 1 4
      qavahiservicebrowsermodel.h

+ 5 - 1
examples/servicebrowser/main.cpp

@@ -20,10 +20,11 @@ public:
         QAvahiServiceBrowserModel *model = new QAvahiServiceBrowserModel(this);
         QString serviceType = qApp->arguments().value(1);
         model->setAutoResolve(qgetenv("AUTORESOLVE").toInt());
-        model->setShowUnresolved(qgetenv("SHOWUNRESOLVED").toInt());
         int options = 0;
         if (qgetenv("HIDELOCAL").toInt())
             options |= QAvahiServiceBrowserModel::HideLocal;
+        if (qgetenv("HIDESAMELOCALCLIENT").toInt())
+            options |= QAvahiServiceBrowserModel::HideSameLocalClient;
         model->browse(serviceType.isEmpty() ? "_tst._tcp" : serviceType, options);
         setModel(model);
         connect(this, SIGNAL(activated(QModelIndex)), model, SLOT(resolve(QModelIndex)));
@@ -34,6 +35,9 @@ int main(int argc, char *argv[])
 {
     QApplication app(argc, argv);
 
+    QAvahiServicePublisher publisher;
+    publisher.publish("Test Service", "_tst._tcp", 1234, "auth=false");
+
     ServicesView *view = new ServicesView;
     view->show();
 

+ 6 - 8
qavahiservicebrowsermodel.cpp

@@ -27,7 +27,7 @@ static void QABDEBUG(const char *fmt, ...)
 
 QAvahiServiceBrowserModel::QAvahiServiceBrowserModel(QObject *parent)
     : QAbstractListModel(parent), m_client(0), m_options(0), m_browserType(NoBrowserType),
-      m_browser(0), m_autoResolve(true), m_showUnresolvedEntries(true)
+      m_browser(0), m_autoResolve(true)
 {
     qRegisterMetaType<QAvahiServiceBrowserModel::Service>();
 
@@ -181,13 +181,11 @@ void QAvahiServiceBrowserModel::browserCallback(AvahiServiceBrowser *browser, Av
 
     case AVAHI_BROWSER_NEW: {
         QABDEBUG("New service name:%s type:%s domain:%s flags:0x%x", name, type, domain, flags);
-        if (m_showUnresolvedEntries) {
-            if (shouldAdd(m_options, service)) {
-                beginInsertRows(QModelIndex(), m_rowToServiceIndex.count(), m_rowToServiceIndex.count()+1);
-                m_services.append(service);
-                m_rowToServiceIndex.append(m_services.count()-1);
-                endInsertRows();
-            }
+        if (shouldAdd(m_options, service)) { // ## test if flags is reliable at this point
+            beginInsertRows(QModelIndex(), m_rowToServiceIndex.count(), m_rowToServiceIndex.count()+1);
+            m_services.append(service);
+            m_rowToServiceIndex.append(m_services.count()-1);
+            endInsertRows();
         } else {
             m_services.append(service);
         }

+ 1 - 4
qavahiservicebrowsermodel.h

@@ -51,9 +51,6 @@ public:
     void setAutoResolve(bool ar) { m_autoResolve = ar; }
     bool autoResolve() const { return m_autoResolve; }
 
-    void setShowUnresolved(bool s) { m_showUnresolvedEntries = s; }
-    bool showUnresolved() const { return m_showUnresolvedEntries; }
-
     struct Service {
         Service() : protocol(-1), interface(-1), port(0), flags(0), resolved(false), resolver(0) { }
 
@@ -150,7 +147,7 @@ private:
     void *m_browser;
     int m_error;
     QString m_errorString;
-    bool m_autoResolve, m_showUnresolvedEntries;
+    bool m_autoResolve;
     QList<Service> m_services;
     QList<int> m_rowToServiceIndex;
 };