2 * Copyright (C) 2013 Canonical, Ltd.
5 * Michal Hruby <michal.hruby@canonical.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 3.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25#include "registry-tracker.h"
28RegistryTracker::RegistryTracker(QStringList const& scopes, bool systemScopes, bool serverScopes):
30 m_systemScopes(systemScopes),
31 m_serverScopes(serverScopes),
33 m_endpoints_dir(QDir::temp().filePath("scope-dev-endpoints.XXXXXX"))
38RegistryTracker::~RegistryTracker()
40 if (m_registry.state() != QProcess::NotRunning) {
41 m_registry.terminate();
42 m_registry.waitForFinished(5000);
47#define RUNTIME_CONFIG \
49"Registry.Identity = Registry\n" \
50"Registry.ConfigFile = %1\n" \
51"Default.Middleware = Zmq\n" \
52"Zmq.ConfigFile = %2\n" \
53"Smartscopes.Registry.Identity = %3\n"
55#define REGISTRY_CONFIG \
58"Zmq.ConfigFile = %1\n" \
59"Scope.InstallDir = %2\n" \
60"Scoperunner.Path = %3\n"
66void RegistryTracker::runRegistry()
68 QDir tmp(QDir::temp());
69 m_runtime_config.setFileTemplate(tmp.filePath("Runtime.XXXXXX.ini"));
70 m_registry_config.setFileTemplate(tmp.filePath("Registry.XXXXXX.ini"));
71 m_mw_config.setFileTemplate(tmp.filePath("Zmq.XXXXXX.ini"));
73 if (!m_runtime_config.open() || !m_registry_config.open() || !m_mw_config.open() || !m_endpoints_dir.isValid()) {
74 qWarning("Unable to open temporary files!");
78 QString scopeInstallDir;
79 QString scopeRegistryBin;
80 QString scopeRunnerBin;
84 QStringList arguments;
85 arguments << "--variable=scopesdir";
86 arguments << "libunity-scopes";
87 pkg_config.start("pkg-config", arguments);
88 pkg_config.waitForFinished();
89 output = pkg_config.readAllStandardOutput();
90 scopeInstallDir = QDir(QString::fromLocal8Bit(output)).path().trimmed();
92 arguments[0] = "--variable=scoperegistry_bin";
93 pkg_config.start("pkg-config", arguments);
94 pkg_config.waitForFinished();
95 output = pkg_config.readAllStandardOutput();
96 scopeRegistryBin = QString::fromLocal8Bit(output).trimmed();
98 arguments[0] = "--variable=scoperunner_bin";
99 pkg_config.start("pkg-config", arguments);
100 pkg_config.waitForFinished();
101 output = pkg_config.readAllStandardOutput();
102 scopeRunnerBin = QString::fromLocal8Bit(output).trimmed();
105 if (scopeInstallDir.isEmpty() || scopeRegistryBin.isEmpty() || scopeRunnerBin.isEmpty()) {
106 qWarning("Unable to find libunity-scopes package config file");
110 // FIXME: keep in sync with the SSRegistry config
111 QString runtime_ini = QString(RUNTIME_CONFIG).arg(m_registry_config.fileName()).arg(m_mw_config.fileName()).arg(m_serverScopes ? "SSRegistry" : "");
112 if (!m_systemScopes) {
113 m_scopeInstallDir.reset(new QTemporaryDir(tmp.filePath("scopes.XXXXXX")));
114 if (!m_scopeInstallDir->isValid()) {
115 qWarning("Unable to create temporary scopes directory!");
117 scopeInstallDir = m_scopeInstallDir->path();
119 QString registry_ini = QString(REGISTRY_CONFIG).arg(m_mw_config.fileName()).arg(scopeInstallDir).arg(scopeRunnerBin);
120 QString mw_ini = QString(MW_CONFIG).arg(m_endpoints_dir.path());
122 if (!m_systemScopes) {
123 // Disable OEM and Click scopes when system scopes are disabled
124 registry_ini += "OEM.InstallDir = /unused\n";
125 registry_ini += "Click.InstallDir = /unused\n";
128 m_runtime_config.write(runtime_ini.toUtf8());
129 m_registry_config.write(registry_ini.toUtf8());
130 m_mw_config.write(mw_ini.toUtf8());
132 m_runtime_config.flush();
133 m_registry_config.flush();
136 qputenv("UNITY_SCOPES_RUNTIME_PATH", m_runtime_config.fileName().toLocal8Bit());
138 QStringList arguments;
139 arguments << m_runtime_config.fileName();
140 arguments << m_scopes;
142 m_registry.setProcessChannelMode(QProcess::ForwardedChannels);
143 m_registry.start(scopeRegistryBin, arguments);
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list