| 1 | /**************************************************************************** |
| 2 | ** |
| 3 | ** Copyright (C) 2018 The Qt Company Ltd and/or its subsidiary(-ies). |
| 4 | ** Contact: http://www.qt-project.org/legal |
| 5 | ** |
| 6 | ** This file is part of the QtSystems module of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ |
| 9 | ** Commercial License Usage |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in |
| 11 | ** accordance with the commercial license agreement provided with the |
| 12 | ** Software or, alternatively, in accordance with the terms contained in |
| 13 | ** a written agreement between you and The Qt Company. For licensing terms |
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
| 15 | ** information use the contact form at https://www.qt.io/contact-us. |
| 16 | ** |
| 17 | ** GNU General Public License Usage |
| 18 | ** Alternatively, this file may be used under the terms of the GNU |
| 19 | ** General Public License version 3 as published by the Free Software |
| 20 | ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT |
| 21 | ** included in the packaging of this file. Please review the following |
| 22 | ** information to ensure the GNU General Public License requirements will |
| 23 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
| 24 | ** |
| 25 | ** $QT_END_LICENSE$ |
| 26 | ** |
| 27 | ****************************************************************************/ |
| 28 | #include "sampleserviceplugin.h" |
| 29 | |
| 30 | #include <QtPlugin> |
| 31 | #include <QSettings> |
| 32 | |
| 33 | SampleServicePlugin::~SampleServicePlugin() |
| 34 | { |
| 35 | } |
| 36 | |
| 37 | QObject* SampleServicePlugin::createInstance(const QServiceInterfaceDescriptor& descriptor) |
| 38 | { |
| 39 | if ( descriptor.interfaceName() == "com.nokia.qt.TestInterfaceA" ) { |
| 40 | return new SampleServicePluginClass(descriptor); |
| 41 | } else if (descriptor.interfaceName() == "com.nokia.qt.TestInterfaceB") { |
| 42 | return new DerivedSampleServicePluginClass(descriptor); |
| 43 | } |
| 44 | |
| 45 | //As per service xml this plugin supports com.nokia.qt.TestInterfaceC as |
| 46 | //well but we deliberately return 0 to test behavior on null pointers |
| 47 | return 0; |
| 48 | } |
| 49 | |
| 50 | void SampleServicePlugin::installService() |
| 51 | { |
| 52 | QSettings settings("com.nokia.qt.serviceframework.tests", "SampleServicePlugin"); |
| 53 | settings.setValue("installed", true); |
| 54 | } |
| 55 | |
| 56 | void SampleServicePlugin::uninstallService() |
| 57 | { |
| 58 | QSettings settings("com.nokia.qt.serviceframework.tests", "SampleServicePlugin"); |
| 59 | settings.setValue("installed", false); |
| 60 | } |
| 61 | |
| 62 | |
| 63 | SampleServicePluginClass::SampleServicePluginClass(const QServiceInterfaceDescriptor& descriptor) |
| 64 | : m_descriptor(descriptor) |
| 65 | { |
| 66 | } |
| 67 | |
| 68 | void SampleServicePluginClass::testSlotOne() |
| 69 | { |
| 70 | //do something that accesses the internal data |
| 71 | m_descriptor.interfaceName(); |
| 72 | } |
| 73 | |
| 74 | DerivedSampleServicePluginClass::DerivedSampleServicePluginClass(const QServiceInterfaceDescriptor& descriptor) |
| 75 | : SampleServicePluginClass(descriptor) |
| 76 | { |
| 77 | } |
| 78 | |
| 79 | void DerivedSampleServicePluginClass::testSlotOne() |
| 80 | { |
| 81 | //do something that accesses the internal data |
| 82 | m_descriptor.serviceName(); |
| 83 | } |
| 84 | |
| 85 | |
| 86 | QServiceInterfaceDescriptor SampleServicePluginClass::descriptor() const |
| 87 | { |
| 88 | return m_descriptor; |
| 89 | } |