loopbacklinkprovider.cpp 1.66 KB
Newer Older
Albert Vaca Cintora's avatar
Albert Vaca Cintora committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/**
 * Copyright 2013 Albert Vaca <albertvaka@gmail.com>
 *
 * This program 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; either version 2 of
 * the License or (at your option) version 3 or any later version
 * accepted by the membership of KDE e.V. (or its successor approved
 * by the membership of KDE e.V.), which shall act as a proxy
 * defined in Section 14 of version 3 of the license.
 *
 * This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
 */

21
#include "loopbacklinkprovider.h"
22

23
#include "core_debug.h"
24

25
LoopbackLinkProvider::LoopbackLinkProvider()
26
    : identityPackage(PACKAGE_TYPE_IDENTITY)
27
{
28
    NetworkPackage::createIdentityPackage(&identityPackage);
29 30
}

31
LoopbackLinkProvider::~LoopbackLinkProvider()
32
{
33

34 35
}

36
void LoopbackLinkProvider::onNetworkChange()
37
{
38
    LoopbackDeviceLink* newLoopbackDeviceLink = new LoopbackDeviceLink(QStringLiteral("loopback"), this);
39 40 41 42 43
    Q_EMIT onConnectionReceived(identityPackage, newLoopbackDeviceLink);

    if (loopbackDeviceLink) {
        delete loopbackDeviceLink;
    }
Albert Vaca Cintora's avatar
Albert Vaca Cintora committed
44

45
    loopbackDeviceLink = newLoopbackDeviceLink;
46 47 48 49
}

void LoopbackLinkProvider::onStart()
{
50
    onNetworkChange();
51 52 53 54
}

void LoopbackLinkProvider::onStop()
{
55 56 57
    if (loopbackDeviceLink) {
        delete loopbackDeviceLink;
    }
58
}
Albert Vaca Cintora's avatar
Albert Vaca Cintora committed
59