summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backend/CMakeLists.txt5
-rw-r--r--backend/config.h.in9
-rw-r--r--backend/dl.cc1
-rw-r--r--backend/job.cc59
-rw-r--r--backend/job.h2
-rw-r--r--backend/pkgtools.cc1
-rw-r--r--backend/slackpkg.cc1
-rw-r--r--backend/utils.cc1
-rw-r--r--backend/utils.h4
9 files changed, 43 insertions, 40 deletions
diff --git a/backend/CMakeLists.txt b/backend/CMakeLists.txt
index f2eae86..05b46e9 100644
--- a/backend/CMakeLists.txt
+++ b/backend/CMakeLists.txt
@@ -3,7 +3,7 @@
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
find_package(PkgConfig REQUIRED)
-pkg_check_modules(deps REQUIRED IMPORTED_TARGET glib-2.0)
+pkg_check_modules(deps REQUIRED IMPORTED_TARGET glib-2.0 gio-2.0)
add_library(backend)
target_sources(backend
@@ -11,6 +11,9 @@ target_sources(backend
PRIVATE job.cc utils.cc pkgtools.cc slackpkg.cc dl.cc
)
+configure_file(config.h.in ${CMAKE_BINARY_DIR}/generated/config.h)
+include_directories(${CMAKE_BINARY_DIR}/generated/)
+
target_link_libraries(backend PkgConfig::deps)
# curl_dep = meson.get_compiler('c').find_library('curl')
# bzip2_dep = dependency('bzip2')
diff --git a/backend/config.h.in b/backend/config.h.in
new file mode 100644
index 0000000..2f6da9a
--- /dev/null
+++ b/backend/config.h.in
@@ -0,0 +1,9 @@
+#ifndef CONFIG_H
+#define CONFIG_H
+
+#define G_LOG_DOMAIN "Katja"
+#define LOCALSTATEDIR "@CMAKE_INSTALL_LOCALSTATEDIR@"
+#define LIBDIR "@CMAKE_INSTALL_LIBDIR@"
+#define SYSCONFDIR "@CMAKE_INSTALL_SYSCONFDIR@"
+
+#endif // CONFIG_H
diff --git a/backend/dl.cc b/backend/dl.cc
index 305b4e0..fc0fda6 100644
--- a/backend/dl.cc
+++ b/backend/dl.cc
@@ -5,6 +5,7 @@
*/
#include <sqlite3.h>
#include <stdlib.h>
+#include <gio/gio.h>
#include "dl.h"
#include "utils.h"
diff --git a/backend/job.cc b/backend/job.cc
index b9e1656..a39c2ab 100644
--- a/backend/job.cc
+++ b/backend/job.cc
@@ -3,14 +3,14 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
+#include "config.h"
#include <dirent.h>
-#include <glib/gstdio.h>
+#include <gio/gio.h>
#include <cstdint>
#include <stdlib.h>
-#include <stdio.h>
+#include <iostream>
#include <zlib.h>
#include <curl/curl.h>
-#include <pk-backend.h>
#include <sqlite3.h>
#include "job.h"
#include "dl.h"
@@ -18,6 +18,8 @@
#include "slackpkg.h"
#include "utils.h"
+using namespace katja;
+
static GSList *repos = nullptr;
void pk_backend_initialize(GKeyFile *conf)
@@ -150,10 +152,7 @@ void pk_backend_start_job(PkBackendJob *job)
}
else
{
- pk_backend_job_error_code(job, PK_ERROR_ENUM_NO_CACHE,
- "%s: %s",
- db_filename,
- sqlite3_errmsg(job_data->db));
+ std::cerr << db_filename << ": " << sqlite3_errmsg(job_data->db) << std::endl;
goto out;
}
@@ -220,10 +219,8 @@ pk_backend_search_thread (PkBackendJob *job, GVariant *params, void *user_data)
}
else
{
- pk_backend_job_error_code (job, PK_ERROR_ENUM_CANNOT_GET_FILELIST,
- "%s", sqlite3_errmsg (job_data->db));
+ std::cerr << sqlite3_errmsg(job_data->db) << std::endl;
}
-
sqlite3_free (query);
g_free (search);
}
@@ -251,8 +248,6 @@ void pk_backend_search_files(PkBackendJob *job, char **values)
Info ret;
auto job_data = static_cast<JobData *> (pk_backend_job_get_user_data(job));
- pk_backend_job_set_percentage(job, 0);
-
search = g_strjoinv("%", values);
query = sqlite3_mprintf("SELECT (p.name || ';' || p.ver || ';' || p.arch || ';' || r.repo), p.summary, "
@@ -282,12 +277,10 @@ void pk_backend_search_files(PkBackendJob *job, char **values)
}
else
{
- pk_backend_job_error_code(job, PK_ERROR_ENUM_CANNOT_GET_FILELIST, "%s", sqlite3_errmsg(job_data->db));
+ std::cerr << sqlite3_errmsg(job_data->db) << std::endl;
}
sqlite3_free(query);
g_free(search);
-
- pk_backend_job_set_percentage(job, 100);
}
void pk_backend_get_details(PkBackendJob *job, char **package_ids)
@@ -308,7 +301,7 @@ void pk_backend_get_details(PkBackendJob *job, char **package_ids)
-1,
&stmt,
nullptr) != SQLITE_OK)) {
- pk_backend_job_error_code(job, PK_ERROR_ENUM_CANNOT_GET_FILELIST, "%s", sqlite3_errmsg(job_data->db));
+ std::cerr << sqlite3_errmsg(job_data->db) << std::endl;
goto out;
}
@@ -329,7 +322,7 @@ void pk_backend_get_details(PkBackendJob *job, char **package_ids)
&err);
if (err)
{
- pk_backend_job_error_code(job, PK_ERROR_ENUM_UNKNOWN, "%s", err->message);
+ std::cerr << err->message << std::endl;
g_error_free(err);
goto out;
}
@@ -377,8 +370,6 @@ void pk_backend_resolve(PkBackendJob *job, char **packages)
PkInfoEnum ret;
auto job_data = static_cast<JobData *> (pk_backend_job_get_user_data(job));
- pk_backend_job_set_percentage(job, 0);
-
if ((sqlite3_prepare_v2(job_data->db,
"SELECT (p1.name || ';' || p1.ver || ';' || p1.arch || ';' || r.repo), p1.summary, "
"p1.full_name FROM pkglist AS p1 NATURAL JOIN repos AS r "
@@ -412,11 +403,11 @@ void pk_backend_resolve(PkBackendJob *job, char **packages)
sqlite3_reset(stmt);
}
sqlite3_finalize(stmt);
- } else {
- pk_backend_job_error_code(job, PK_ERROR_ENUM_CANNOT_GET_FILELIST, "%s", sqlite3_errmsg(job_data->db));
}
-
- pk_backend_job_set_percentage(job, 100);
+ else
+ {
+ std::cerr << sqlite3_errmsg(job_data->db) << std::endl;
+ }
}
void pk_backend_download_packages(PkBackendJob *job, char **package_ids, const char *directory)
@@ -433,7 +424,7 @@ void pk_backend_download_packages(PkBackendJob *job, char **package_ids, const c
&stmt,
nullptr) != SQLITE_OK))
{
- pk_backend_job_error_code(job, PK_ERROR_ENUM_CANNOT_GET_FILELIST, "%s", sqlite3_errmsg(job_data->db));
+ std::cerr << sqlite3_errmsg(job_data->db) << std::endl;
goto out;
}
@@ -496,7 +487,7 @@ void pk_backend_install_packages(PkBackendJob *job, char **package_ids)
&collection_stmt,
nullptr) != SQLITE_OK))
{
- pk_backend_job_error_code(job, PK_ERROR_ENUM_CANNOT_GET_FILELIST, "%s", sqlite3_errmsg(job_data->db));
+ std::cerr << sqlite3_errmsg(job_data->db) << std::endl;
goto out;
}
@@ -613,7 +604,7 @@ void pk_backend_remove_packages(PkBackendJob *job, char **package_ids)
if (err)
{
- pk_backend_job_error_code(job, PK_ERROR_ENUM_PACKAGE_FAILED_TO_REMOVE, "%s", err->message);
+ std::cerr << err->message << std::endl;
g_error_free(err);
return;
@@ -643,7 +634,7 @@ void pk_backend_get_updates(PkBackendJob *job)
&stmt,
nullptr) != SQLITE_OK))
{
- pk_backend_job_error_code(job, PK_ERROR_ENUM_CANNOT_GET_FILELIST, "%s", sqlite3_errmsg(job_data->db));
+ std::cerr << sqlite3_errmsg(job_data->db) << std::endl;
goto out;
}
@@ -656,7 +647,7 @@ void pk_backend_get_updates(PkBackendJob *job)
g_object_unref(pkg_metadata_dir);
if (err)
{
- pk_backend_job_error_code(job, PK_ERROR_ENUM_NO_CACHE, "/var/log/packages: %s", err->message);
+ std::cerr << "/var/log/packages: " << err->message << std::endl;
g_error_free(err);
goto out;
}
@@ -792,7 +783,7 @@ void pk_backend_refresh_cache(PkBackendJob *job, bool force)
tmp_dir_name = g_dir_make_tmp("PackageKit.XXXXXX", &err);
if (!tmp_dir_name)
{
- pk_backend_job_error_code(job, PK_ERROR_ENUM_INTERNAL_ERROR, "%s", err->message);
+ std::cerr << err->message << std::endl;
g_error_free(err);
return;
}
@@ -805,7 +796,7 @@ void pk_backend_refresh_cache(PkBackendJob *job, bool force)
file_info = g_file_query_info(db_file, "time::modified-usec", G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, nullptr, &err);
if (err)
{
- pk_backend_job_error_code(job, PK_ERROR_ENUM_NO_CACHE, "%s: %s", path, err->message);
+ std::cerr << path << ": " << err->message;
g_error_free(err);
goto out;
}
@@ -816,11 +807,7 @@ void pk_backend_refresh_cache(PkBackendJob *job, bool force)
nullptr);
if ((ret != SQLITE_OK) || ((ret = sqlite3_step(stmt)) != SQLITE_ROW))
{
- pk_backend_job_error_code(job,
- PK_ERROR_ENUM_NO_CACHE,
- "%s: %s",
- path,
- sqlite3_errstr(ret));
+ std::cerr << path << ": " << sqlite3_errstr(ret) << std::endl;
goto out;
}
if ((std::uint32_t) sqlite3_column_int(stmt, 0) > g_file_info_get_attribute_uint32(file_info, "time::modified-usec"))
@@ -832,7 +819,7 @@ void pk_backend_refresh_cache(PkBackendJob *job, bool force)
{
if (sqlite3_exec(job_data->db, "DELETE FROM repos", nullptr, 0, &db_err) != SQLITE_OK)
{
- pk_backend_job_error_code(job, PK_ERROR_ENUM_INTERNAL_ERROR, "%s", db_err);
+ std::cerr << db_err << std::endl;
sqlite3_free(db_err);
goto out;
}
diff --git a/backend/job.h b/backend/job.h
index 15ef341..01d0097 100644
--- a/backend/job.h
+++ b/backend/job.h
@@ -5,7 +5,7 @@
*/
#pragma once
-using namespace katja;
+#include <glib/gstdio.h>
void pk_backend_initialize(GKeyFile *conf);
void pk_backend_destroy();
diff --git a/backend/pkgtools.cc b/backend/pkgtools.cc
index 2f32b77..ebbd838 100644
--- a/backend/pkgtools.cc
+++ b/backend/pkgtools.cc
@@ -3,6 +3,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
+#include "config.h"
#include <curl/curl.h>
#include <sqlite3.h>
#include "pkgtools.h"
diff --git a/backend/slackpkg.cc b/backend/slackpkg.cc
index 33fc4d7..74a7ecb 100644
--- a/backend/slackpkg.cc
+++ b/backend/slackpkg.cc
@@ -2,6 +2,7 @@
#include <sqlite3.h>
#include <stdlib.h>
#include <string.h>
+#include <gio/gio.h>
#include "slackpkg.h"
#include "utils.h"
diff --git a/backend/utils.cc b/backend/utils.cc
index d5c8e84..208f150 100644
--- a/backend/utils.cc
+++ b/backend/utils.cc
@@ -6,6 +6,7 @@
#include <cstdint>
#include <sqlite3.h>
#include <string.h>
+#include <gio/gio.h>
#include "utils.h"
#include "pkgtools.h"
diff --git a/backend/utils.h b/backend/utils.h
index 61d8e81..66df9a4 100644
--- a/backend/utils.h
+++ b/backend/utils.h
@@ -22,9 +22,9 @@ enum class Info
// Installed in the same version.
installed,
// A different version is installed.
- updating
+ updating,
// Available, but not installed.
- installing,
+ installing
};
CURLcode get_file (CURL **curl, char *source_url, char *dest);