File: foo.h

package info (click to toggle)
libqxt 0.6.1-6
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 19,004 kB
  • sloc: cpp: 57,512; xml: 296; sh: 251; makefile: 56; php: 14
file content (47 lines) | stat: -rw-r--r-- 1,395 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#ifndef FOO_H
#define FOO_H

#include <qxtglobal.h>
#include <QObject>
#include <QFlags>
#include <QStringList>
#include <QAbstractSocket>
#include <qxtdiscoverableservicename.h>
#include <qxtdiscoverableservice.h>
#include <qxtservicebrowser.h>

class Foo : public QObject {
Q_OBJECT
public:
    QxtServiceBrowser* browser;
public slots:
    void err(int err) {
        qDebug() << "error=" << err;
    }
    void ok() {
        qDebug() << "registered yay";
    }
    void add(const QString& name, const QString& domain) {
        qDebug() << "added" << name;
        QString st = "_"+browser->serviceType()+"._";
        if(browser->socketType() == QAbstractSocket::TcpSocket) {
            st += "tcp";
        } else {
            st += "udp";
        }
        QxtDiscoverableService* svc = new QxtDiscoverableService(st, name, browser);
        svc->setDomain(domain);
        QObject::connect(svc, SIGNAL(resolved(QByteArray)), this, SLOT(resolved(QByteArray)));
        QObject::connect(svc, SIGNAL(resolveError(int)), this, SLOT(err(int)));
        svc->resolve();
    }
    void remove(const QString& name) {
        qDebug() << "removed" << name;
    }
    void resolved(const QByteArray& domainName) {
        QxtDiscoverableService* svc = static_cast<QxtDiscoverableService*>(sender());
        qDebug() << "resolved " << domainName << " on port " << svc->port();
    }
};

#endif