"path",
"arch",
"logger",
- "offline",
"conf",
NULL,
};
const char* path = NULL;
const char* arch = NULL;
PyObject* conf = Py_None;
- int offline = 0;
int r = 1;
FILE* fconf = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|zzpO", kwlist,
- &path, &arch, &offline, &conf))
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "|zzO", kwlist,
+ &path, &arch, &conf))
goto ERROR;
// Map the configuration
int flags = 0;
- // Enable offline mode
- if (offline)
- flags |= PAKFIRE_FLAGS_OFFLINE;
-
Py_BEGIN_ALLOW_THREADS
// Create a new Pakfire instance
break;
case OPT_OFFLINE:
- config->flags |= PAKFIRE_FLAGS_OFFLINE;
+ pakfire_ctx_set_flag(config->ctx, PAKFIRE_CTX_OFFLINE);
break;
case OPT_ROOT:
// Reference counter
int nrefs;
+ // Flags
+ int flags;
+
// Config
struct pakfire_config* config;
return NULL;
}
+// Flags
+
+PAKFIRE_EXPORT int pakfire_ctx_has_flag(struct pakfire_ctx* ctx, int flag) {
+ return ctx->flags & flag;
+}
+
+PAKFIRE_EXPORT int pakfire_ctx_set_flag(struct pakfire_ctx* ctx, int flag) {
+ ctx->flags |= flag;
+
+ return 0;
+}
+
// Config
struct pakfire_config* pakfire_ctx_get_config(struct pakfire_ctx* ctx) {
struct pakfire_downloader* d = NULL;
int r;
-#warning The OFFLINE flag must be moved into the context
-#if 0
- // Fail if pakfire is running in offline mode
- if (pakfire_has_flag(pakfire, PAKFIRE_FLAGS_OFFLINE)) {
- ERROR(pakfire, "Cannot initialize downloader in offline mode\n");
- return -ENOTSUP;
+ // Fail if the context is flagged as offline
+ if (pakfire_ctx_has_flag(ctx, PAKFIRE_CTX_OFFLINE)) {
+ CTX_ERROR(ctx, "Cannot initialize downloader in offline mode\n");
+ return -EPERM;
}
-#endif
// Allocate a new object
d = calloc(1, sizeof(*d));
struct pakfire_ctx* pakfire_ctx_ref(struct pakfire_ctx* ctx);
struct pakfire_ctx* pakfire_ctx_unref(struct pakfire_ctx* ctx);
+// Flags
+
+enum pakfire_ctx_flags {
+ PAKFIRE_CTX_OFFLINE = (1 << 0),
+};
+
+int pakfire_ctx_has_flag(struct pakfire_ctx* ctx, int flag);
+int pakfire_ctx_set_flag(struct pakfire_ctx* ctx, int flag);
+
// Config
struct pakfire_config* pakfire_ctx_get_config(struct pakfire_ctx* ctx);
enum pakfire_flags {
PAKFIRE_FLAGS_BUILD = (1 << 0),
- PAKFIRE_FLAGS_OFFLINE = (1 << 1),
};
// Callbacks
pakfire_ctx_set_confirm_callback;
pakfire_ctx_set_progress_callback;
pakfire_ctx_set_pick_solution_callback;
+ pakfire_ctx_has_flag;
+ pakfire_ctx_set_flag;
# pakfire
pakfire_check;
goto ERROR;
// Download the database
- if (!pakfire_repo_is_local(repo) && !pakfire_has_flag(repo->pakfire, PAKFIRE_FLAGS_OFFLINE)) {
+ if (!pakfire_repo_is_local(repo) && !pakfire_ctx_has_flag(repo->ctx, PAKFIRE_CTX_OFFLINE)) {
r = pakfire_repo_download_database(repo, filename, database_path);
if (r)
goto ERROR;
return 0;
// Do nothing if running in offline mode
- if (pakfire_has_flag(repo->pakfire, PAKFIRE_FLAGS_OFFLINE))
+ if (pakfire_ctx_has_flag(repo->ctx, PAKFIRE_CTX_OFFLINE))
return 0;
// This repository does not have a mirrorlist
return 0;
// Do nothing if running in offline mode
- if (pakfire_has_flag(repo->pakfire, PAKFIRE_FLAGS_OFFLINE))
+ if (pakfire_ctx_has_flag(repo->ctx, PAKFIRE_CTX_OFFLINE))
return 0;
// Fetch refresh interval