1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- 2 * 3 * Copyright (C) 2013-2015 Richard Hughes <richard@hughsie.com> 4 * 5 * Licensed under the GNU Lesser General Public License Version 2.1 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Lesser General Public 9 * License as published by the Free Software Foundation; either 10 * version 2.1 of the License, or (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public 18 * License along with this library; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 */ 21 22 #ifndef __DNF_REPO_H 23 #define __DNF_REPO_H 24 25 #include <glib-object.h> 26 27 #include "hy-repo.h" 28 #include "hy-package.h" 29 30 #include "dnf-context.h" 31 #include "dnf-state.h" 32 33 #include <librepo/librepo.h> 34 35 G_BEGIN_DECLS 36 37 #define DNF_TYPE_REPO (dnf_repo_get_type ()) 38 G_DECLARE_DERIVABLE_TYPE (DnfRepo, dnf_repo, DNF, REPO, GObject) 39 40 struct _DnfRepoClass 41 { 42 GObjectClass parent_class; 43 /*< private >*/ 44 void (*_dnf_reserved1) (void); 45 void (*_dnf_reserved2) (void); 46 void (*_dnf_reserved3) (void); 47 void (*_dnf_reserved4) (void); 48 void (*_dnf_reserved5) (void); 49 void (*_dnf_reserved6) (void); 50 void (*_dnf_reserved7) (void); 51 void (*_dnf_reserved8) (void); 52 }; 53 54 /** 55 * DnfRepoUpdateFlags: 56 * @DNF_REPO_UPDATE_FLAG_NONE: No flags set 57 * @DNF_REPO_UPDATE_FLAG_FORCE: Force the repo to be updated 58 * @DNF_REPO_UPDATE_FLAG_IMPORT_PUBKEY: Import the repo public key to librpm if possible 59 * @DNF_REPO_UPDATE_FLAG_SIMULATE: Do not actually update the repo 60 * 61 * The update flags. 62 **/ 63 typedef enum { 64 DNF_REPO_UPDATE_FLAG_NONE = 0, 65 DNF_REPO_UPDATE_FLAG_FORCE = 1, 66 DNF_REPO_UPDATE_FLAG_IMPORT_PUBKEY = 2, 67 DNF_REPO_UPDATE_FLAG_SIMULATE = 4, 68 /*< private >*/ 69 DNF_REPO_UPDATE_FLAG_LAST 70 } DnfRepoUpdateFlags; 71 72 /** 73 * DnfRepoKind: 74 * @DNF_REPO_KIND_REMOTE: A remote repo 75 * @DNF_REPO_KIND_MEDIA: A media repo, e.g. a DVD 76 * @DNF_REPO_KIND_LOCAL: A local repo, e.g. file:// 77 * 78 * The repo kind. 79 **/ 80 typedef enum { 81 DNF_REPO_KIND_REMOTE, 82 DNF_REPO_KIND_MEDIA, 83 DNF_REPO_KIND_LOCAL, 84 /*< private >*/ 85 DNF_REPO_KIND_LAST 86 } DnfRepoKind; 87 88 /** 89 * DnfRepoEnabled: 90 * @DNF_REPO_ENABLED_NONE: Source is disabled 91 * @DNF_REPO_ENABLED_PACKAGES: Source is fully enabled 92 * @DNF_REPO_ENABLED_METADATA: Only repo metadata is enabled 93 * 94 * How enabled is the repo. 95 **/ 96 typedef enum { 97 DNF_REPO_ENABLED_NONE = 0, 98 DNF_REPO_ENABLED_PACKAGES = 1, 99 DNF_REPO_ENABLED_METADATA = 2, 100 /*< private >*/ 101 DNF_REPO_ENABLED_LAST 102 } DnfRepoEnabled; 103 104 DnfRepo *dnf_repo_new (DnfContext *context); 105 106 /* getters */ 107 const gchar *dnf_repo_get_id (DnfRepo *repo); 108 const gchar *dnf_repo_get_location (DnfRepo *repo); 109 const gchar *dnf_repo_get_filename (DnfRepo *repo); 110 const gchar *dnf_repo_get_packages (DnfRepo *repo); 111 gchar ** dnf_repo_get_public_keys (DnfRepo *repo); 112 DnfRepoEnabled dnf_repo_get_enabled (DnfRepo *repo); 113 gboolean dnf_repo_get_required (DnfRepo *repo); 114 guint dnf_repo_get_cost (DnfRepo *repo); 115 gboolean dnf_repo_get_module_hotfixes (DnfRepo *repo); 116 guint dnf_repo_get_metadata_expire (DnfRepo *repo); 117 DnfRepoKind dnf_repo_get_kind (DnfRepo *repo); 118 gchar **dnf_repo_get_exclude_packages (DnfRepo *repo); 119 gboolean dnf_repo_get_gpgcheck (DnfRepo *repo); 120 gboolean dnf_repo_get_gpgcheck_md (DnfRepo *repo); 121 gchar *dnf_repo_get_description (DnfRepo *repo); 122 guint64 dnf_repo_get_timestamp_generated(DnfRepo *repo); 123 guint dnf_repo_get_n_solvables (DnfRepo *repo); 124 const gchar *dnf_repo_get_filename_md (DnfRepo *repo, 125 const gchar *md_kind); 126 #ifndef __GI_SCANNER__ 127 HyRepo dnf_repo_get_repo (DnfRepo *repo); 128 #endif 129 gboolean dnf_repo_is_devel (DnfRepo *repo); 130 gboolean dnf_repo_is_local (DnfRepo *repo); 131 gboolean dnf_repo_is_source (DnfRepo *repo); 132 133 /* setters */ 134 void dnf_repo_set_id (DnfRepo *repo, 135 const gchar *id); 136 void dnf_repo_set_location (DnfRepo *repo, 137 const gchar *location); 138 void dnf_repo_set_location_tmp (DnfRepo *repo, 139 const gchar *location_tmp); 140 void dnf_repo_set_filename (DnfRepo *repo, 141 const gchar *filename); 142 void dnf_repo_set_packages (DnfRepo *repo, 143 const gchar *packages); 144 void dnf_repo_set_packages_tmp (DnfRepo *repo, 145 const gchar *packages_tmp); 146 void dnf_repo_set_enabled (DnfRepo *repo, 147 DnfRepoEnabled enabled); 148 void dnf_repo_set_required (DnfRepo *repo, 149 gboolean required); 150 void dnf_repo_set_cost (DnfRepo *repo, 151 guint cost); 152 void dnf_repo_set_module_hotfixes (DnfRepo *repo, 153 gboolean module_hotfixes); 154 void dnf_repo_set_kind (DnfRepo *repo, 155 DnfRepoKind kind); 156 void dnf_repo_set_gpgcheck (DnfRepo *repo, 157 gboolean gpgcheck_pkgs); 158 void dnf_repo_set_skip_if_unavailable(DnfRepo *repo, 159 gboolean skip_if_unavailable); 160 void dnf_repo_set_gpgcheck_md (DnfRepo *repo, 161 gboolean gpgcheck_md); 162 void dnf_repo_set_keyfile (DnfRepo *repo, 163 GKeyFile *keyfile); 164 void dnf_repo_set_metadata_expire (DnfRepo *repo, 165 guint metadata_expire); 166 gboolean dnf_repo_setup (DnfRepo *repo, 167 GError **error); 168 169 /* object methods */ 170 gboolean dnf_repo_check (DnfRepo *repo, 171 guint permissible_cache_age, 172 DnfState *state, 173 GError **error); 174 gboolean dnf_repo_update (DnfRepo *repo, 175 DnfRepoUpdateFlags flags, 176 DnfState *state, 177 GError **error); 178 gboolean dnf_repo_clean (DnfRepo *repo, 179 GError **error); 180 gboolean dnf_repo_set_data (DnfRepo *repo, 181 const gchar *parameter, 182 const gchar *value, 183 GError **error); 184 gboolean dnf_repo_commit (DnfRepo *repo, 185 GError **error); 186 187 #ifndef __GI_SCANNER__ 188 LrHandle * dnf_repo_get_lr_handle (DnfRepo *repo); 189 190 LrResult * dnf_repo_get_lr_result (DnfRepo *repo); 191 #endif 192 193 #ifndef __GI_SCANNER__ 194 gchar *dnf_repo_download_package (DnfRepo *repo, 195 DnfPackage * pkg, 196 const gchar *directory, 197 DnfState *state, 198 GError **error); 199 gboolean dnf_repo_download_packages (DnfRepo *repo, 200 GPtrArray *pkgs, 201 const gchar *directory, 202 DnfState *state, 203 GError **error); 204 205 HyRepo dnf_repo_get_hy_repo(DnfRepo *repo); 206 #endif 207 208 void dnf_repo_add_metadata_type_to_download (DnfRepo *repo, 209 const gchar *metadataType); 210 gboolean dnf_repo_get_metadata_content (DnfRepo *repo, 211 const gchar *metadataType, 212 gpointer *content, 213 gsize *length, 214 GError **error); 215 216 G_END_DECLS 217 218 #endif /* __DNF_REPO_H */ 219