File indexing completed on 2024-04-21 03:53:32

0001 /*
0002     This file is part of the KContacts framework.
0003     SPDX-FileCopyrightText: 2016-2019 Laurent Montel <montel@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #include "clientpidmap.h"
0009 #include "parametermap_p.h"
0010 
0011 #include <QDataStream>
0012 #include <QStringList>
0013 
0014 using namespace KContacts;
0015 
0016 class Q_DECL_HIDDEN ClientPidMap::Private : public QSharedData
0017 {
0018 public:
0019     Private()
0020     {
0021     }
0022 
0023     Private(const Private &other)
0024         : QSharedData(other)
0025     {
0026         mParamMap = other.mParamMap;
0027         clientpidmap = other.clientpidmap;
0028     }
0029 
0030     ParameterMap mParamMap;
0031     QString clientpidmap;
0032 };
0033 
0034 ClientPidMap::ClientPidMap()
0035     : d(new Private)
0036 {
0037 }
0038 
0039 ClientPidMap::ClientPidMap(const ClientPidMap &other)
0040     : d(other.d)
0041 {
0042 }
0043 
0044 ClientPidMap::ClientPidMap(const QString &clientpidmap)
0045     : d(new Private)
0046 {
0047     d->clientpidmap = clientpidmap;
0048 }
0049 
0050 ClientPidMap::~ClientPidMap()
0051 {
0052 }
0053 
0054 void ClientPidMap::setClientPidMap(const QString &clientpidmap)
0055 {
0056     d->clientpidmap = clientpidmap;
0057 }
0058 
0059 QString ClientPidMap::clientPidMap() const
0060 {
0061     return d->clientpidmap;
0062 }
0063 
0064 bool ClientPidMap::isValid() const
0065 {
0066     return !d->clientpidmap.isEmpty();
0067 }
0068 
0069 void ClientPidMap::setParams(const ParameterMap &params)
0070 {
0071     d->mParamMap = params;
0072 }
0073 
0074 ParameterMap ClientPidMap::params() const
0075 {
0076     return d->mParamMap;
0077 }
0078 
0079 bool ClientPidMap::operator==(const ClientPidMap &other) const
0080 {
0081     return (d->mParamMap == other.d->mParamMap) && (d->clientpidmap == other.clientPidMap());
0082 }
0083 
0084 bool ClientPidMap::operator!=(const ClientPidMap &other) const
0085 {
0086     return !(other == *this);
0087 }
0088 
0089 ClientPidMap &ClientPidMap::operator=(const ClientPidMap &other)
0090 {
0091     if (this != &other) {
0092         d = other.d;
0093     }
0094 
0095     return *this;
0096 }
0097 
0098 QString ClientPidMap::toString() const
0099 {
0100     QString str = QLatin1String("ClientPidMap {\n");
0101     str += QStringLiteral("    clientpidmap: %1\n").arg(d->clientpidmap);
0102     str += d->mParamMap.toString();
0103     str += QLatin1String("}\n");
0104     return str;
0105 }
0106 
0107 QDataStream &KContacts::operator<<(QDataStream &s, const ClientPidMap &clientpidmap)
0108 {
0109     return s << clientpidmap.d->mParamMap << clientpidmap.d->clientpidmap;
0110 }
0111 
0112 QDataStream &KContacts::operator>>(QDataStream &s, ClientPidMap &clientpidmap)
0113 {
0114     s >> clientpidmap.d->mParamMap >> clientpidmap.d->clientpidmap;
0115     return s;
0116 }