Commit b53ad168 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

Properly convert from QString to char*

parent 88c9ac30
......@@ -141,9 +141,9 @@ FlatpakInstalledRef * FlatpakBackend::getInstalledRefForApp(FlatpakInstallation
ref = flatpak_installation_get_installed_ref(flatpakInstallation,
resource->type() == FlatpakResource::DesktopApp ? FLATPAK_REF_KIND_APP : FLATPAK_REF_KIND_RUNTIME,
resource->flatpakName().toStdString().c_str(),
resource->arch().toStdString().c_str(),
resource->branch().toStdString().c_str(),
resource->flatpakName().toUtf8().constData(),
resource->arch().toUtf8().constData(),
resource->branch().toUtf8().constData(),
m_cancellable, &localError);
// If we found installed ref this way, we can return it
......@@ -214,7 +214,7 @@ FlatpakResource * FlatpakBackend::addAppFromFlatpakBundle(const QUrl &url)
g_autoptr(FlatpakBundleRef) bundleRef = nullptr;
AppStream::Component asComponent;
file = g_file_new_for_path(url.toLocalFile().toStdString().c_str());
file = g_file_new_for_path(url.toLocalFile().toUtf8().constData());
bundleRef = flatpak_bundle_ref_new(file, &localError);
if (!bundleRef) {
......@@ -400,7 +400,7 @@ FlatpakResource * FlatpakBackend::addSourceFromFlatpakRepo(const QUrl &url)
resource->setFlatpakName(url.fileName().remove(QStringLiteral(".flatpakrepo")));
resource->setType(FlatpakResource::Source);
auto repo = flatpak_installation_get_remote_by_name(preferredInstallation(), resource->flatpakName().toStdString().c_str(), m_cancellable, nullptr);
auto repo = flatpak_installation_get_remote_by_name(preferredInstallation(), resource->flatpakName().toUtf8().constData(), m_cancellable, nullptr);
if (!repo) {
resource->setState(AbstractResource::State::None);
} else {
......@@ -656,7 +656,7 @@ bool FlatpakBackend::parseMetadataFromAppBundle(FlatpakResource *resource)
// Get arch/branch/commit/name from FlatpakRef
if (!bundle.isEmpty()) {
ref = flatpak_ref_parse(bundle.id().toStdString().c_str(), &localError);
ref = flatpak_ref_parse(bundle.id().toUtf8().constData(), &localError);
if (!ref) {
qWarning() << "Failed to parse" << bundle.id() << localError->message;
return false;
......
......@@ -63,7 +63,7 @@ void FlatpakFetchDataJob::run()
return;
}
data = flatpak_installation_fetch_remote_metadata_sync(m_installation, m_app->origin().toStdString().c_str(), fakeRef, m_cancellable, &localError);
data = flatpak_installation_fetch_remote_metadata_sync(m_installation, m_app->origin().toUtf8().constData(), fakeRef, m_cancellable, &localError);
if (data) {
gsize len = 0;
metadataContent = QByteArray((char *)g_bytes_get_data(data, &len));
......@@ -91,7 +91,7 @@ void FlatpakFetchDataJob::run()
return;
}
if (!flatpak_installation_fetch_remote_size_sync(m_installation, m_app->origin().toStdString().c_str(),
if (!flatpak_installation_fetch_remote_size_sync(m_installation, m_app->origin().toUtf8().constData(),
ref, &downloadSize, &installedSize, m_cancellable, &localError)) {
qWarning() << "Failed to get remote size of " << m_app->name() << ": " << localError->message;
Q_EMIT jobFetchSizeFailed();
......@@ -108,7 +108,7 @@ FlatpakRef * FlatpakFetchDataJob::createFakeRef(FlatpakResource *resource)
g_autoptr(GError) localError = nullptr;
const QString id = QString::fromUtf8("%1/%2/%3/%4").arg(resource->typeAsString()).arg(resource->flatpakName()).arg(resource->arch()).arg(resource->branch());
ref = flatpak_ref_parse(id.toStdString().c_str(), &localError);
ref = flatpak_ref_parse(id.toUtf8().constData(), &localError);
if (!ref) {
qWarning() << "Failed to create fake ref: " << localError->message;
......
......@@ -404,9 +404,9 @@ void FlatpakResource::invokeApplication() const
g_autoptr(GError) localError = nullptr;
if (!flatpak_installation_launch(m_installation,
flatpakName().toStdString().c_str(),
arch().toStdString().c_str(),
branch().toStdString().c_str(),
flatpakName().toUtf8().constData(),
arch().toUtf8().constData(),
branch().toUtf8().constData(),
nullptr,
cancellable,
&localError)) {
......
......@@ -71,7 +71,7 @@ bool FlatpakSourcesBackend::removeSource(const QString &id)
if (items.count() == 1) {
FlatpakSourceItem *sourceItem = static_cast<FlatpakSourceItem*>(items.first());
g_autoptr(GCancellable) cancellable = g_cancellable_new();
if (flatpak_installation_remove_remote(sourceItem->flatpakInstallation(), id.toStdString().c_str(), cancellable, nullptr)) {
if (flatpak_installation_remove_remote(sourceItem->flatpakInstallation(), id.toUtf8().constData(), cancellable, nullptr)) {
m_sources->removeRow(sourceItem->row());
return true;
} else {
......@@ -129,23 +129,23 @@ FlatpakRemote * FlatpakSourcesBackend::installSource(FlatpakResource *resource)
{
g_autoptr(GCancellable) cancellable = g_cancellable_new();
auto remote = flatpak_installation_get_remote_by_name(m_preferredInstallation, resource->flatpakName().toStdString().c_str(), cancellable, nullptr);
auto remote = flatpak_installation_get_remote_by_name(m_preferredInstallation, resource->flatpakName().toUtf8().constData(), cancellable, nullptr);
if (remote) {
qWarning() << "Source " << resource->flatpakName() << " already exists";
return nullptr;
}
remote = flatpak_remote_new(resource->flatpakName().toStdString().c_str());
flatpak_remote_set_url(remote, resource->getMetadata(QStringLiteral("repo-url")).toString().toStdString().c_str());
remote = flatpak_remote_new(resource->flatpakName().toUtf8().constData());
flatpak_remote_set_url(remote, resource->getMetadata(QStringLiteral("repo-url")).toString().toUtf8().constData());
flatpak_remote_set_noenumerate(remote, false);
flatpak_remote_set_title(remote, resource->comment().toStdString().c_str());
flatpak_remote_set_title(remote, resource->comment().toUtf8().constData());
const QString gpgKey = resource->getMetadata(QStringLiteral("gpg-key")).toString();
if (!gpgKey.isEmpty()) {
gsize dataLen = 0;
g_autofree guchar *data = nullptr;
g_autoptr(GBytes) bytes = nullptr;
data = g_base64_decode(gpgKey.toStdString().c_str(), &dataLen);
data = g_base64_decode(gpgKey.toUtf8().constData(), &dataLen);
bytes = g_bytes_new(data, dataLen);
flatpak_remote_set_gpg_verify(remote, true);
flatpak_remote_set_gpg_key(remote, bytes);
......@@ -154,7 +154,7 @@ FlatpakRemote * FlatpakSourcesBackend::installSource(FlatpakResource *resource)
}
if (!resource->branch().isEmpty()) {
flatpak_remote_set_default_branch(remote, resource->branch().toStdString().c_str());
flatpak_remote_set_default_branch(remote, resource->branch().toUtf8().constData());
}
if (!flatpak_installation_modify_remote(m_preferredInstallation, remote, cancellable, nullptr)) {
......
......@@ -66,26 +66,26 @@ void FlatpakTransactionJob::run()
ref = flatpak_installation_update(m_installation,
FLATPAK_UPDATE_FLAGS_NONE,
m_app->type() == FlatpakResource::DesktopApp ? FLATPAK_REF_KIND_APP : FLATPAK_REF_KIND_RUNTIME,
m_app->flatpakName().toStdString().c_str(),
m_app->arch().toStdString().c_str(),
m_app->branch().toStdString().c_str(),
m_app->flatpakName().toUtf8().constData(),
m_app->arch().toUtf8().constData(),
m_app->branch().toUtf8().constData(),
flatpakInstallationProgressCallback,
this,
m_cancellable, &localError);
} else {
if (m_app->flatpakFileType() == QStringLiteral("flatpak")) {
g_autoptr(GFile) file = g_file_new_for_path(m_app->resourceFile().toLocalFile().toStdString().c_str());
g_autoptr(GFile) file = g_file_new_for_path(m_app->resourceFile().toLocalFile().toUtf8().constData());
if (!file) {
qWarning() << "Failed to install bundled application" << m_app->name();
}
ref = flatpak_installation_install_bundle(m_installation, file, flatpakInstallationProgressCallback, this, m_cancellable, &localError);
} else {
ref = flatpak_installation_install(m_installation,
m_app->origin().toStdString().c_str(),
m_app->origin().toUtf8().constData(),
m_app->type() == FlatpakResource::DesktopApp ? FLATPAK_REF_KIND_APP : FLATPAK_REF_KIND_RUNTIME,
m_app->flatpakName().toStdString().c_str(),
m_app->arch().toStdString().c_str(),
m_app->branch().toStdString().c_str(),
m_app->flatpakName().toUtf8().constData(),
m_app->arch().toUtf8().constData(),
m_app->branch().toUtf8().constData(),
flatpakInstallationProgressCallback,
this,
m_cancellable, &localError);
......@@ -101,9 +101,9 @@ void FlatpakTransactionJob::run()
} else if (m_role == Transaction::Role::RemoveRole) {
if (!flatpak_installation_uninstall(m_installation,
m_app->type() == FlatpakResource::DesktopApp ? FLATPAK_REF_KIND_APP : FLATPAK_REF_KIND_RUNTIME,
m_app->flatpakName().toStdString().c_str(),
m_app->arch().toStdString().c_str(),
m_app->branch().toStdString().c_str(),
m_app->flatpakName().toUtf8().constData(),
m_app->arch().toUtf8().constData(),
m_app->branch().toUtf8().constData(),
flatpakInstallationProgressCallback,
this,
m_cancellable, &localError)) {
......
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