Skip to content

Commit

Permalink
[connman-qt] Add valid property for NetworkService. JB#44033
Browse files Browse the repository at this point in the history
  • Loading branch information
monich committed Jan 7, 2019
1 parent c246318 commit daf4211
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
21 changes: 18 additions & 3 deletions libconnman-qt/networkservice.cpp
@@ -1,6 +1,6 @@
/*
* Copyright © 2010 Intel Corporation.
* Copyright © 2012-2017 Jolla Ltd.
* Copyright © 2012-2019 Jolla Ltd.
* Contact: Slava Monich <slava.monich@jolla.com>
*
* This program is licensed under the terms and conditions of the
Expand Down Expand Up @@ -55,7 +55,8 @@
ConnmanArg("Passphrase",Passphrase,passphrase) \
ConnmanArg("Identity",Identity,identity) \
ConnmanNoArg("Available",Available,available) \
ConnmanNoArg("Saved",Saved,saved)
ConnmanNoArg("Saved",Saved,saved) \
ClassNoArg(Valid,valid)

#define NETWORK_SERVICE_PROPERTIES2(Connman,Class) \
NETWORK_SERVICE_PROPERTIES(Connman,Connman,Class,Class)
Expand Down Expand Up @@ -198,6 +199,7 @@ NETWORK_SERVICE_PROPERTIES(DEFINE_EMITTER_CONNMAN_ARG,\
DEFINE_EMITTER_NO_ARG)

public:
bool m_valid;
QString m_path;
QVariantMap m_propertiesCache;
InterfaceProxy *m_proxy;
Expand Down Expand Up @@ -358,6 +360,7 @@ const QString NetworkService::Private::SecurityTypeName[] = {

NetworkService::Private::Private(const QString &path, const QVariantMap &props, NetworkService *parent) :
QObject(parent),
m_valid(!props.isEmpty()),
m_path(path),
m_propertiesCache(props),
m_proxy(NULL),
Expand Down Expand Up @@ -854,6 +857,10 @@ void NetworkService::Private::updateProperties(QVariantMap properties)
it.next();
updatePropertyCache(it.key(), it.value());
}
if (!m_valid) {
m_valid = true;
queueSignal(SignalValidChanged);
}
}

void NetworkService::Private::resetProperties()
Expand Down Expand Up @@ -950,7 +957,10 @@ void NetworkService::Private::resetProperties()
}
}
updateManaged();
emitQueuedSignals();
if (m_valid) {
m_valid = false;
queueSignal(SignalValidChanged);
}
}

void NetworkService::Private::updatePropertyCache(const QString &name, const QVariant& value)
Expand Down Expand Up @@ -1312,6 +1322,11 @@ void NetworkService::setPath(const QString &path)
m_priv->setPath(path);
}

bool NetworkService::isValid() const
{
return m_priv->m_valid;
}

bool NetworkService::connected() const
{
return m_priv->m_connected;
Expand Down
5 changes: 4 additions & 1 deletion libconnman-qt/networkservice.h
@@ -1,6 +1,6 @@
/*
* Copyright © 2010 Intel Corporation.
* Copyright © 2012-2017 Jolla Ltd.
* Copyright © 2012-2019 Jolla Ltd.
* Contact: Slava Monich <slava.monich@jolla.com>
*
* This program is licensed under the terms and conditions of the
Expand All @@ -21,6 +21,7 @@ class NetworkService : public QObject
Q_ENUMS(EapMethod)
Q_ENUMS(SecurityType)

Q_PROPERTY(bool valid READ isValid NOTIFY validChanged)
Q_PROPERTY(QString name READ name NOTIFY nameChanged)
Q_PROPERTY(QString state READ state NOTIFY stateChanged)
Q_PROPERTY(QString type READ type NOTIFY typeChanged)
Expand Down Expand Up @@ -114,6 +115,7 @@ class NetworkService : public QObject
void setPath(const QString &path);
void updateProperties(const QVariantMap &properties);

bool isValid() const;
bool connected() const;
bool available() const;
bool managed() const;
Expand Down Expand Up @@ -144,6 +146,7 @@ class NetworkService : public QObject
bool eapMethodAvailable() const;

Q_SIGNALS:
void validChanged();
void nameChanged(const QString &name);
void stateChanged(const QString &state);
void errorChanged(const QString &error);
Expand Down

0 comments on commit daf4211

Please sign in to comment.