summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrew Christian <andrew.christian@nokia.com>2012-02-11 18:48:52 -0500
committerChris Craig <ext-chris.craig@nokia.com>2012-02-13 17:00:41 +0100
commit0754b06d35905bc56b0f86bb258008892f39448d (patch)
treef2739d38196ca71514778842665dfddb9729da58 /src
parent15d0b18379b82154aaf8b255ec0d17cf257d9551 (diff)
Added MatchInfo class and renamed AbstractMatcher to MatchDelegate
Change-Id: I78f88edb0e92d9feae9102aa51e3739b04ada981 Reviewed-by: Chris Craig <ext-chris.craig@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/core/core-lib.pri6
-rw-r--r--src/core/matchdelegate.cpp (renamed from src/core/abstractmatcher.cpp)14
-rw-r--r--src/core/matchdelegate.h (renamed from src/core/abstractmatcher.h)13
-rw-r--r--src/core/matchinfo.cpp120
-rw-r--r--src/core/matchinfo.h71
-rw-r--r--src/core/processbackendfactory.cpp38
-rw-r--r--src/core/processbackendfactory.h14
7 files changed, 236 insertions, 40 deletions
diff --git a/src/core/core-lib.pri b/src/core/core-lib.pri
index fee62dd..d7cbbe1 100644
--- a/src/core/core-lib.pri
+++ b/src/core/core-lib.pri
@@ -8,7 +8,8 @@ PUBLIC_HEADERS += \
$$PWD/processbackend.h \
$$PWD/processbackendfactory.h \
$$PWD/processbackendmanager.h \
- $$PWD/abstractmatcher.h \
+ $$PWD/matchdelegate.h \
+ $$PWD/matchinfo.h \
$$PWD/processinfo.h \
$$PWD/processmanager.h \
$$PWD/gdbprocessbackendfactory.h \
@@ -38,7 +39,8 @@ SOURCES += \
$$PWD/processbackend.cpp \
$$PWD/processbackendfactory.cpp \
$$PWD/processbackendmanager.cpp \
- $$PWD/abstractmatcher.cpp \
+ $$PWD/matchdelegate.cpp \
+ $$PWD/matchinfo.cpp \
$$PWD/processinfo.cpp \
$$PWD/processmanager.cpp \
$$PWD/unixprocessbackend.cpp \
diff --git a/src/core/abstractmatcher.cpp b/src/core/matchdelegate.cpp
index 6dab2a9..a90be18 100644
--- a/src/core/abstractmatcher.cpp
+++ b/src/core/matchdelegate.cpp
@@ -37,33 +37,33 @@
**
****************************************************************************/
-#include "abstractmatcher.h"
+#include "matchdelegate.h"
QT_BEGIN_NAMESPACE_PROCESSMANAGER
/*!
- \class AbstractMatcher
- \brief The AbstractMatcher class is a virtual class for matching creation requests.
+ \class MatchDelegate
+ \brief The MatchDelegate class is a virtual class for matching creation requests.
You must subclass this class to do anything useful.
*/
/*!
- Construct a AbstractMatcher with an optional \a parent.
+ Construct a MatchDelegate with an optional \a parent.
*/
-AbstractMatcher::AbstractMatcher(QObject *parent)
+MatchDelegate::MatchDelegate(QObject *parent)
: QObject(parent)
{
}
/*!
- \fn AbstractMatcher::matches(const ProcessInfo& info)
+ \fn MatchDelegate::matches(const ProcessInfo& info)
Return true if the ProcessInfo \a info record matches.
You must override this function.
*/
-#include "moc_abstractmatcher.cpp"
+#include "moc_matchdelegate.cpp"
QT_END_NAMESPACE_PROCESSMANAGER
diff --git a/src/core/abstractmatcher.h b/src/core/matchdelegate.h
index a4011a2..6a15b25 100644
--- a/src/core/abstractmatcher.h
+++ b/src/core/matchdelegate.h
@@ -37,8 +37,8 @@
**
****************************************************************************/
-#ifndef PROCESS_ABSTRACTMATCHER_H
-#define PROCESS_ABSTRACTMATCHER_H
+#ifndef PROCESS_MATCHDELEGATE_H
+#define PROCESS_MATCHDELEGATE_H
#include <QObject>
@@ -48,14 +48,17 @@ QT_BEGIN_NAMESPACE_PROCESSMANAGER
class ProcessInfo;
-class Q_ADDON_PROCESSMANAGER_EXPORT AbstractMatcher : public QObject
+class Q_ADDON_PROCESSMANAGER_EXPORT MatchDelegate : public QObject
{
Q_OBJECT
public:
- explicit AbstractMatcher(QObject *parent = 0);
+ explicit MatchDelegate(QObject *parent = 0);
virtual bool matches(const ProcessInfo& info) = 0;
+
+private:
+ Q_DISABLE_COPY(MatchDelegate);
};
QT_END_NAMESPACE_PROCESSMANAGER
-#endif // PROCESS_ABSTRACTMATCHER_H
+#endif // PROCESS_MATCHDELEGATE_H
diff --git a/src/core/matchinfo.cpp b/src/core/matchinfo.cpp
new file mode 100644
index 0000000..dedceae
--- /dev/null
+++ b/src/core/matchinfo.cpp
@@ -0,0 +1,120 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QFileInfo>
+#include <QDebug>
+#include "matchinfo.h"
+
+QT_BEGIN_NAMESPACE_PROCESSMANAGER
+
+/*!
+ \class MatchInfo
+ \brief The MatchInfo class matches based on a ProcessInfo structure.
+
+ The InfoWatcher class matches based on a ProcessInfo record. If an
+ attribute is set in the ProcessInfo record, the value must match
+ exactly. The only exception are the environment variables, which
+ only need to match exactly for environment values set in the ProcessInfo
+ record
+*/
+
+/*!
+ Construct a MatchInfo with an optional \a parent.
+*/
+
+MatchInfo::MatchInfo(QObject *parent)
+ : MatchDelegate(parent)
+{
+}
+
+/*!
+ Return the current ProcessInfo \a info data.
+*/
+
+ProcessInfo MatchInfo::info() const
+{
+ return m_info;
+}
+
+/*!
+ Set a new ProcessInfo \a info structure.
+ */
+
+void MatchInfo::setInfo(const ProcessInfo& info)
+{
+ m_info = info;
+ emit infoChanged();
+}
+
+/*!
+ \fn MatchInfo::matches(const ProcessInfo& info)
+
+ We look at each configured field in the ProcessInfo \a info record.
+ Return true if the ProcessInfo \a info record matches.
+
+ The program name is validated by comparing canonicalFilePath values.
+ The environment is compared key by key.
+ All other record entries must match exactly.
+*/
+
+bool MatchInfo::matches(const ProcessInfo& info)
+{
+ QMapIterator<QString, QVariant> iter(m_info.toMap());
+ while (iter.hasNext()) {
+ iter.next();
+ if (iter.key() == ProcessInfoConstants::Environment) {
+ QMapIterator<QString, QVariant> iter2(iter.value().toMap());
+ QVariantMap env = info.environment();
+ while (iter2.hasNext()) {
+ iter2.next();
+ if (!env.contains(iter2.key()) || iter2.value() != env.value(iter2.key()))
+ return false;
+ }
+ }
+ else {
+ if (!info.contains(iter.key()) || iter.value() != info.value(iter.key()))
+ return false;
+ }
+ }
+ return true;
+}
+
+#include "moc_matchinfo.cpp"
+
+QT_END_NAMESPACE_PROCESSMANAGER
diff --git a/src/core/matchinfo.h b/src/core/matchinfo.h
new file mode 100644
index 0000000..f1f2ed4
--- /dev/null
+++ b/src/core/matchinfo.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef PROCESS_MATCHINFO_H
+#define PROCESS_MATCHINFO_H
+
+#include "matchdelegate.h"
+#include "processinfo.h"
+
+QT_BEGIN_NAMESPACE_PROCESSMANAGER
+
+class Q_ADDON_PROCESSMANAGER_EXPORT MatchInfo : public MatchDelegate
+{
+ Q_OBJECT
+ Q_PROPERTY(ProcessInfo info READ info WRITE setInfo NOTIFY infoChanged)
+public:
+ explicit MatchInfo(QObject *parent = 0);
+ virtual bool matches(const ProcessInfo& info);
+
+ ProcessInfo info() const;
+ void setInfo(const ProcessInfo& info);
+
+signals:
+ void infoChanged();
+
+private:
+ Q_DISABLE_COPY(MatchInfo);
+
+private:
+ ProcessInfo m_info;
+};
+
+QT_END_NAMESPACE_PROCESSMANAGER
+
+#endif // PROCESS_MATCHINFO_H
diff --git a/src/core/processbackendfactory.cpp b/src/core/processbackendfactory.cpp
index 05ad79d..78932b8 100644
--- a/src/core/processbackendfactory.cpp
+++ b/src/core/processbackendfactory.cpp
@@ -38,7 +38,7 @@
****************************************************************************/
#include "processbackendfactory.h"
-#include "abstractmatcher.h"
+#include "matchdelegate.h"
QT_BEGIN_NAMESPACE_PROCESSMANAGER
@@ -55,7 +55,7 @@ QT_BEGIN_NAMESPACE_PROCESSMANAGER
ProcessBackendFactory::ProcessBackendFactory(QObject *parent)
: QObject(parent)
- , m_matcher(NULL)
+ , m_matchDelegate(NULL)
, m_memoryRestricted(false)
{
}
@@ -101,27 +101,27 @@ void ProcessBackendFactory::handleMemoryRestrictionChange()
}
/*!
- Return the current AbstractMatcher object
+ Return the current MatchDelegate object
*/
-AbstractMatcher *ProcessBackendFactory::matcher() const
+MatchDelegate *ProcessBackendFactory::matchDelegate() const
{
- return m_matcher;
+ return m_matchDelegate;
}
/*!
- Set a new process AbstractMatcher object \a matcher.
- The ProcessBackendFactory takes over parentage of the AbstractMatcher.
+ Set a new process MatchDelegate object \a matchDelegate.
+ The ProcessBackendFactory takes over parentage of the MatchDelegate.
*/
-void ProcessBackendFactory::setMatcher(AbstractMatcher *matcher)
+void ProcessBackendFactory::setMatchDelegate(MatchDelegate *matchDelegate)
{
- if (matcher != m_matcher) {
- if (m_matcher)
- delete m_matcher;
- m_matcher = matcher;
- m_matcher->setParent(this);
- emit matcherChanged();
+ if (matchDelegate != m_matchDelegate) {
+ if (m_matchDelegate)
+ delete m_matchDelegate;
+ m_matchDelegate = matchDelegate;
+ m_matchDelegate->setParent(this);
+ emit matchDelegateChanged();
}
}
@@ -130,7 +130,7 @@ void ProcessBackendFactory::setMatcher(AbstractMatcher *matcher)
Return true if this ProcessBackendFactory matches the ProcessInfo \a info
process binding and can create an appropriate process. The default implementation
- delegates the decision to the AbstractMatcher object. If no AbstractMatcher
+ delegates the decision to the MatchDelegate object. If no MatchDelegate
has been installed, the default implementation returns true.
This virtual function may be overridden.
@@ -138,15 +138,15 @@ void ProcessBackendFactory::setMatcher(AbstractMatcher *matcher)
bool ProcessBackendFactory::canCreate(const ProcessInfo& info) const
{
- if (m_matcher)
- return m_matcher->matches(info);
+ if (m_matchDelegate)
+ return m_matchDelegate->matches(info);
return true;
}
/*!
- \fn void ProcessBackendFactory::matcherChanged()
+ \fn void ProcessBackendFactory::matchDelegateChanged()
- Signal emitted whenever the AbstractMatcher is changed.
+ Signal emitted whenever the MatchDelegate is changed.
*/
/*!
diff --git a/src/core/processbackendfactory.h b/src/core/processbackendfactory.h
index 2a109ad..70a3be5 100644
--- a/src/core/processbackendfactory.h
+++ b/src/core/processbackendfactory.h
@@ -49,12 +49,12 @@ QT_BEGIN_NAMESPACE_PROCESSMANAGER
class ProcessBackend;
class ProcessInfo;
-class AbstractMatcher;
+class MatchDelegate;
class Q_ADDON_PROCESSMANAGER_EXPORT ProcessBackendFactory : public QObject
{
Q_OBJECT
- Q_PROPERTY(AbstractMatcher* matcher READ matcher WRITE setMatcher NOTIFY matcherChanged);
+ Q_PROPERTY(MatchDelegate* matchDelegate READ matchDelegate WRITE setMatchDelegate NOTIFY matchDelegateChanged);
public:
ProcessBackendFactory(QObject *parent = 0);
@@ -65,18 +65,18 @@ public:
void setMemoryRestricted(bool);
virtual QList<Q_PID> internalProcesses();
- AbstractMatcher * matcher() const;
- void setMatcher(AbstractMatcher *);
+ MatchDelegate * matchDelegate() const;
+ void setMatchDelegate(MatchDelegate *);
signals:
- void matcherChanged();
+ void matchDelegateChanged();
protected:
virtual void handleMemoryRestrictionChange();
protected:
- AbstractMatcher *m_matcher;
- bool m_memoryRestricted;
+ MatchDelegate *m_matchDelegate;
+ bool m_memoryRestricted;
};
QT_END_NAMESPACE_PROCESSMANAGER