Commit 03aeb5ba authored by Abhijeet  sharma's avatar Abhijeet sharma

Fwupd-Integration (Fixes)

* Brings uniform variable name and spaces between function.
* Changed License in findLIBFWUPD.cmake as per discussion here (https://phabricator.kde.org/T9305)
parent 2078bb73
# - Try to find the Fwupd library
# CMake support for Fwupd library
# Once done this will define
#
# LIBFWUPD_FOUND - system has the fwupd library
# LIBFWUPD_INCLUDE_DIR - the Fwupd include directory
# LIBFWUPD_LIBRARY - Link this to use the fwupd
#
# Copyright © 2018, Abhijeet Sharma <sharma.abhijeet2096@gmail.com>
# License:
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the University nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
# Copyright © 2018, Abhijeet Sharma <sharma.abhijeet2096@gmail.com>
#
# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use, copy,
# modify, merge, publish, distribute, sublicense, and/or sell copies
# of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
if(LIBFWUPD_INCLUDE_DIRS AND LIBFWUPD_LIBRARIES)
set(LIBFWUPD_FOUND TRUE)
......
......@@ -89,7 +89,7 @@ public:
void addUpdates();
void addResourceToList(FwupdResource *res);
void addHistoricalUpdates();
void setReleaseDetails(FwupdResource *res, FwupdRelease *rel);
void setReleaseDetails(FwupdResource *res, FwupdRelease *release);
void setDeviceDetails(FwupdResource *res, FwupdDevice *device);
void handleError(GError **perror);
QSet<AbstractResource*> getAllUpdates();
......
......@@ -160,11 +160,11 @@ void FwupdResource::setState(AbstractResource::State state)
void FwupdResource::setAddons(const AddonList& addons)
{
Q_FOREACH (const QString& toInstall, addons.addonsToInstall())
Q_FOREACH(const QString& toInstall, addons.addonsToInstall())
{
setAddonInstalled(toInstall, true);
}
Q_FOREACH (const QString& toRemove, addons.addonsToRemove())
Q_FOREACH(const QString& toRemove, addons.addonsToRemove())
{
setAddonInstalled(toRemove, false);
}
......
......@@ -43,7 +43,7 @@ public:
bool setData(const QModelIndex & index, const QVariant & value, int role) override {
auto item = itemFromIndex(index);
if (!item)
if(!item)
return false;
remote = fwupd_client_get_remote_by_id(m_backend->backend->client,item->data(AbstractSourcesBackend::IdRole).toString().toUtf8().constData(),nullptr,nullptr);
status = fwupd_remote_get_enabled(remote);
......@@ -101,21 +101,21 @@ FwupdSourcesBackend::FwupdSourcesBackend(AbstractResourcesBackend * parent)
void FwupdSourcesBackend::populateSources()
{
/* find all remotes */
g_autoptr(GPtrArray) remotes = fwupd_client_get_remotes (backend->client,nullptr,nullptr);
g_autoptr(GPtrArray) remotes = fwupd_client_get_remotes(backend->client,nullptr,nullptr);
if(remotes != nullptr)
{
for (uint i = 0; i < remotes->len; i++)
for(uint i = 0; i < remotes->len; i++)
{
FwupdRemote *remote = (FwupdRemote *)g_ptr_array_index (remotes, i);
if (fwupd_remote_get_kind (remote) == FWUPD_REMOTE_KIND_LOCAL)
FwupdRemote *remote = (FwupdRemote *)g_ptr_array_index(remotes, i);
if(fwupd_remote_get_kind(remote) == FWUPD_REMOTE_KIND_LOCAL)
continue;
const QString id = QString::fromUtf8(fwupd_remote_get_id (remote));
if (id.isEmpty())
const QString id = QString::fromUtf8(fwupd_remote_get_id(remote));
if(id.isEmpty())
continue;
bool status = !fwupd_remote_get_enabled(remote);
QStandardItem* it = new QStandardItem(id);
it->setData(id, AbstractSourcesBackend::IdRole);
it->setData(QVariant(QString::fromUtf8(fwupd_remote_get_title (remote))), Qt::ToolTipRole);
it->setData(QVariant(QString::fromUtf8(fwupd_remote_get_title(remote))), Qt::ToolTipRole);
it->setCheckable(true);
it->setCheckState(status ? Qt::Unchecked : Qt::Checked);
m_sources->appendRow(it);
......
......@@ -64,7 +64,7 @@ bool FwupdTransaction::check()
qWarning("Fwupd Error: No Device ID set, cannot unlock device ");
return false;
}
if (!fwupd_client_unlock (m_backend->client, device_id.toUtf8().constData(),nullptr, &error))
if(!fwupd_client_unlock(m_backend->client, device_id.toUtf8().constData(),nullptr, &error))
{
m_backend->handleError(&error);
return false;
......@@ -89,7 +89,7 @@ bool FwupdTransaction::install()
return false;
}
if (!(QFileInfo::exists(localFile)))
if(!(QFileInfo::exists(localFile)))
{
const QUrl uri(m_app->m_updateURI);
setStatus(DownloadingStatus);
......@@ -109,11 +109,11 @@ void FwupdTransaction::fwupdInstall(QNetworkReply* reply)
if(reply)
{
QString filename = m_app->m_file;
if (reply->error() == QNetworkReply::NoError)
if(reply->error() == QNetworkReply::NoError)
{
QByteArray Data = reply->readAll();
QFile file(filename);
if (file.open(QIODevice::WriteOnly))
if(file.open(QIODevice::WriteOnly))
{
file.write(Data);
}
......@@ -131,16 +131,16 @@ void FwupdTransaction::fwupdInstall(QNetworkReply* reply)
QString localFile = m_app->m_file;
QString deviceId = m_app->m_deviceID;
/* limit to single device? */
if (deviceId.isNull())
if(deviceId.isNull())
deviceId = QStringLiteral(FWUPD_DEVICE_ID_ANY);
/* only offline supported */
if (m_app->isOnlyOffline)
if(m_app->isOnlyOffline)
install_flags = static_cast<FwupdInstallFlags>(install_flags | FWUPD_INSTALL_FLAG_OFFLINE);
m_iterate = true;
QTimer::singleShot(100, this, &FwupdTransaction::updateProgress);
if (!fwupd_client_install (m_backend->client, deviceId.toUtf8().constData(), localFile.toUtf8().constData(), install_flags, nullptr, &error))
if(!fwupd_client_install(m_backend->client, deviceId.toUtf8().constData(), localFile.toUtf8().constData(), install_flags, nullptr, &error))
{
m_backend->handleError(&error);
m_iterate = false;
......@@ -158,13 +158,13 @@ bool FwupdTransaction::remove()
void FwupdTransaction::updateProgress()
{
if (!m_iterate)
if(!m_iterate)
return;
setStatus(CommittingStatus);
if(progress()<100)
{
setProgress(fwupd_client_get_percentage (m_backend->client));
setProgress(fwupd_client_get_percentage(m_backend->client));
QTimer::singleShot(100, this, &FwupdTransaction::updateProgress);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment