]> git.ipfire.org Git - pakfire.git/commitdiff
libpakfire: Store description with repository
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 22 Jan 2018 18:10:15 +0000 (19:10 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 22 Jan 2018 18:10:15 +0000 (19:10 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/_pakfire/repo.c
src/libpakfire/include/pakfire/repo.h
src/libpakfire/libpakfire.sym
src/libpakfire/repo.c

index dd4266d68f8aea400b121dfc4fd003a33afec408..bceba395613b1117af11ec7d81c4e65b8b9383a3 100644 (file)
@@ -112,6 +112,21 @@ static int Repo_set_name(RepoObject* self, PyObject* value) {
        return 0;
 }
 
+static PyObject* Repo_get_description(RepoObject* self) {
+       const char* description = pakfire_repo_get_description(self->repo);
+
+       return PyUnicode_FromString(description);
+}
+
+static int Repo_set_description(RepoObject* self, PyObject* value) {
+       const char* description = NULL;
+
+       if (value != Py_None)
+               description = PyUnicode_AsUTF8(value);
+
+       return pakfire_repo_set_description(self->repo, description);
+}
+
 static PyObject* Repo_get_enabled(RepoObject* self) {
        if (pakfire_repo_get_enabled(self->repo))
                Py_RETURN_TRUE;
@@ -418,6 +433,13 @@ static struct PyGetSetDef Repo_getsetters[] = {
                "The base URL of this repository",
                NULL
        },
+       {
+               "description",
+               (getter)Repo_get_description,
+               (setter)Repo_set_description,
+               NULL,
+               NULL
+       },
        {
                "keyfile",
                (getter)Repo_get_keyfile,
index 8fde3e1f3b7bed4d8c92d19532aae5cd9b620b6a..14baf158b0c6a4a107f3a0155b240a844c567c22 100644 (file)
@@ -41,6 +41,9 @@ void pakfire_repo_internalize(PakfireRepo repo);
 const char* pakfire_repo_get_name(PakfireRepo repo);
 void pakfire_repo_set_name(PakfireRepo repo, const char* name);
 
+const char* pakfire_repo_get_description(PakfireRepo repo);
+int pakfire_repo_set_description(PakfireRepo repo, const char* description);
+
 int pakfire_repo_get_enabled(PakfireRepo repo);
 void pakfire_repo_set_enabled(PakfireRepo repo, int enabled);
 
index bd64a7a7db536cefd8960c14dcbabcbb9b6d379f..2b5a0a76b8b72ad659afd935bfd6f1ffb52b5276 100644 (file)
@@ -228,6 +228,7 @@ global:
        pakfire_repo_get_baseurl;
        pakfire_repo_get_cache;
        pakfire_repo_get_config;
+       pakfire_repo_get_description;
        pakfire_repo_get_name;
        pakfire_repo_get_enabled;
        pakfire_repo_get_keyfile;
@@ -242,6 +243,7 @@ global:
        pakfire_repo_read_solv_fp;
        pakfire_repo_ref;
        pakfire_repo_set_baseurl;
+       pakfire_repo_set_description;
        pakfire_repo_set_enabled;
        pakfire_repo_set_keyfile;
        pakfire_repo_set_mirrorlist;
index f58380fd6e3719517d16231445b4d1f1d1986b17..d1a68a366f87bcd9b5425cd32374d9ee2e42c350 100644 (file)
@@ -45,6 +45,7 @@ const size_t XZ_HEADER_LENGTH = sizeof(XZ_HEADER_MAGIC);
 struct pakfire_repo_appdata {
        Repodata* repodata;
 
+       char* description;
        char* baseurl;
        char* keyfile;
        char* mirrorlist;
@@ -60,6 +61,9 @@ struct _PakfireRepo {
 static void free_repo_appdata(struct pakfire_repo_appdata* appdata) {
        // repodata is being destroyed with the repository
 
+       if (appdata->description)
+               pakfire_free(appdata->description);
+
        if (appdata->baseurl)
                pakfire_free(appdata->baseurl);
 
@@ -232,6 +236,22 @@ PAKFIRE_EXPORT void pakfire_repo_set_name(PakfireRepo repo, const char* name) {
        repo->repo->name = pakfire_strdup(name);
 }
 
+PAKFIRE_EXPORT const char* pakfire_repo_get_description(PakfireRepo repo) {
+       return repo->appdata->description;
+}
+
+PAKFIRE_EXPORT int pakfire_repo_set_description(PakfireRepo repo, const char* description) {
+       if (repo->appdata->description)
+               pakfire_free(repo->appdata->description);
+
+       if (description)
+               repo->appdata->description = pakfire_strdup(description);
+       else
+               repo->appdata->description = NULL;
+
+       return 0;
+}
+
 PAKFIRE_EXPORT int pakfire_repo_get_enabled(PakfireRepo repo) {
        return !repo->repo->disabled;
 }