// Generated by gir (https://github.com/gtk-rs/gir @ f3d92ad)
// from /home/home/person/git_hub/gir-files (@ 7d95377)
// DO NOT EDIT

use package_kit_glib_sys::*;
use std::mem::{align_of, size_of};
use std::env;
use std::error::Error;
use std::ffi::OsString;
use std::path::Path;
use std::process::Command;
use std::str;
use tempfile::Builder;

static PACKAGES: &[&str] = &["packagekit-glib2"];

#[derive(Clone, Debug)]
struct Compiler {
    pub args: Vec<String>,
}

impl Compiler {
    pub fn new() -> Result<Self, Box<dyn Error>> {
        let mut args = get_var("CC", "cc")?;
        args.push("-Wno-deprecated-declarations".to_owned());
        // For _Generic
        args.push("-std=c11".to_owned());
        // For %z support in printf when using MinGW.
        args.push("-D__USE_MINGW_ANSI_STDIO".to_owned());
        args.extend(get_var("CFLAGS", "")?);
        args.extend(get_var("CPPFLAGS", "")?);
        args.extend(pkg_config_cflags(PACKAGES)?);
        Ok(Self { args })
    }

    pub fn compile(&self, src: &Path, out: &Path) -> Result<(), Box<dyn Error>> {
        let mut cmd = self.to_command();
        cmd.arg(src);
        cmd.arg("-o");
        cmd.arg(out);
        let status = cmd.spawn()?.wait()?;
        if !status.success() {
            return Err(format!("compilation command {:?} failed, {}", &cmd, status).into());
        }
        Ok(())
    }

    fn to_command(&self) -> Command {
        let mut cmd = Command::new(&self.args[0]);
        cmd.args(&self.args[1..]);
        cmd
    }
}

fn get_var(name: &str, default: &str) -> Result<Vec<String>, Box<dyn Error>> {
    match env::var(name) {
        Ok(value) => Ok(shell_words::split(&value)?),
        Err(env::VarError::NotPresent) => Ok(shell_words::split(default)?),
        Err(err) => Err(format!("{} {}", name, err).into()),
    }
}

fn pkg_config_cflags(packages: &[&str]) -> Result<Vec<String>, Box<dyn Error>> {
    if packages.is_empty() {
        return Ok(Vec::new());
    }
    let pkg_config = env::var_os("PKG_CONFIG")
        .unwrap_or_else(|| OsString::from("pkg-config"));
    let mut cmd = Command::new(pkg_config);
    cmd.arg("--cflags");
    cmd.args(packages);
    let out = cmd.output()?;
    if !out.status.success() {
        return Err(format!("command {:?} returned {}",
                           &cmd, out.status).into());
    }
    let stdout = str::from_utf8(&out.stdout)?;
    Ok(shell_words::split(stdout.trim())?)
}


#[derive(Copy, Clone, Debug, Eq, PartialEq)]
struct Layout {
    size: usize,
    alignment: usize,
}

#[derive(Copy, Clone, Debug, Default, Eq, PartialEq)]
struct Results {
    /// Number of successfully completed tests.
    passed: usize,
    /// Total number of failed tests (including those that failed to compile).
    failed: usize,
}

impl Results {
    fn record_passed(&mut self) {
        self.passed += 1;
    }
    fn record_failed(&mut self) {
        self.failed += 1;
    }
    fn summary(&self) -> String {
        format!("{} passed; {} failed", self.passed, self.failed)
    }
    fn expect_total_success(&self) {
        if self.failed == 0 {
            println!("OK: {}", self.summary());
        } else {
            panic!("FAILED: {}", self.summary());
        };
    }
}

#[test]
fn cross_validate_constants_with_c() {
    let mut c_constants: Vec<(String, String)> = Vec::new();

    for l in get_c_output("constant").unwrap().lines() {
        let mut words = l.trim().split(';');
        let name = words.next().expect("Failed to parse name").to_owned();
        let value = words
            .next()
            .and_then(|s| s.parse().ok())
            .expect("Failed to parse value");
        c_constants.push((name, value));
    }

    let mut results = Results::default();

    for ((rust_name, rust_value), (c_name, c_value)) in
        RUST_CONSTANTS.iter().zip(c_constants.iter())
    {
        if rust_name != c_name {
            results.record_failed();
            eprintln!("Name mismatch:\nRust: {:?}\nC:    {:?}", rust_name, c_name,);
            continue;
        }

        if rust_value != c_value {
            results.record_failed();
            eprintln!(
                "Constant value mismatch for {}\nRust: {:?}\nC:    {:?}",
                rust_name, rust_value, &c_value
            );
            continue;
        }

        results.record_passed();
    }

    results.expect_total_success();
}

#[test]
fn cross_validate_layout_with_c() {
    let mut c_layouts = Vec::new();

    for l in get_c_output("layout").unwrap().lines() {
        let mut words = l.trim().split(';');
        let name = words.next().expect("Failed to parse name").to_owned();
        let size = words
            .next()
            .and_then(|s| s.parse().ok())
            .expect("Failed to parse size");
        let alignment = words
            .next()
            .and_then(|s| s.parse().ok())
            .expect("Failed to parse alignment");
        c_layouts.push((name, Layout { size, alignment }));
    }

    let mut results = Results::default();

    for ((rust_name, rust_layout), (c_name, c_layout)) in
        RUST_LAYOUTS.iter().zip(c_layouts.iter())
    {
        if rust_name != c_name {
            results.record_failed();
            eprintln!("Name mismatch:\nRust: {:?}\nC:    {:?}", rust_name, c_name,);
            continue;
        }

        if rust_layout != c_layout {
            results.record_failed();
            eprintln!(
                "Layout mismatch for {}\nRust: {:?}\nC:    {:?}",
                rust_name, rust_layout, &c_layout
            );
            continue;
        }

        results.record_passed();
    }

    results.expect_total_success();
}

fn get_c_output(name: &str) -> Result<String, Box<dyn Error>> {
    let tmpdir = Builder::new().prefix("abi").tempdir()?;
    let exe = tmpdir.path().join(name);
    let c_file = Path::new("tests").join(name).with_extension("c");

    let cc = Compiler::new().expect("configured compiler");
    cc.compile(&c_file, &exe)?;

    let mut abi_cmd = Command::new(exe);
    let output = abi_cmd.output()?;
    if !output.status.success() {
        return Err(format!("command {:?} failed, {:?}", &abi_cmd, &output).into());
    }

    Ok(String::from_utf8(output.stdout)?)
}

const RUST_LAYOUTS: &[(&str, Layout)] = &[
    ("PkAuthorizeEnum", Layout {size: size_of::<PkAuthorizeEnum>(), alignment: align_of::<PkAuthorizeEnum>()}),
    ("PkBitfield", Layout {size: size_of::<PkBitfield>(), alignment: align_of::<PkBitfield>()}),
    ("PkCategory", Layout {size: size_of::<PkCategory>(), alignment: align_of::<PkCategory>()}),
    ("PkCategoryClass", Layout {size: size_of::<PkCategoryClass>(), alignment: align_of::<PkCategoryClass>()}),
    ("PkClient", Layout {size: size_of::<PkClient>(), alignment: align_of::<PkClient>()}),
    ("PkClientClass", Layout {size: size_of::<PkClientClass>(), alignment: align_of::<PkClientClass>()}),
    ("PkClientError", Layout {size: size_of::<PkClientError>(), alignment: align_of::<PkClientError>()}),
    ("PkClientHelper", Layout {size: size_of::<PkClientHelper>(), alignment: align_of::<PkClientHelper>()}),
    ("PkClientHelperClass", Layout {size: size_of::<PkClientHelperClass>(), alignment: align_of::<PkClientHelperClass>()}),
    ("PkControl", Layout {size: size_of::<PkControl>(), alignment: align_of::<PkControl>()}),
    ("PkControlClass", Layout {size: size_of::<PkControlClass>(), alignment: align_of::<PkControlClass>()}),
    ("PkControlError", Layout {size: size_of::<PkControlError>(), alignment: align_of::<PkControlError>()}),
    ("PkDesktop", Layout {size: size_of::<PkDesktop>(), alignment: align_of::<PkDesktop>()}),
    ("PkDesktopClass", Layout {size: size_of::<PkDesktopClass>(), alignment: align_of::<PkDesktopClass>()}),
    ("PkDetails", Layout {size: size_of::<PkDetails>(), alignment: align_of::<PkDetails>()}),
    ("PkDetailsClass", Layout {size: size_of::<PkDetailsClass>(), alignment: align_of::<PkDetailsClass>()}),
    ("PkDistroUpgrade", Layout {size: size_of::<PkDistroUpgrade>(), alignment: align_of::<PkDistroUpgrade>()}),
    ("PkDistroUpgradeClass", Layout {size: size_of::<PkDistroUpgradeClass>(), alignment: align_of::<PkDistroUpgradeClass>()}),
    ("PkDistroUpgradeEnum", Layout {size: size_of::<PkDistroUpgradeEnum>(), alignment: align_of::<PkDistroUpgradeEnum>()}),
    ("PkEnumMatch", Layout {size: size_of::<PkEnumMatch>(), alignment: align_of::<PkEnumMatch>()}),
    ("PkError", Layout {size: size_of::<PkError>(), alignment: align_of::<PkError>()}),
    ("PkErrorClass", Layout {size: size_of::<PkErrorClass>(), alignment: align_of::<PkErrorClass>()}),
    ("PkErrorEnum", Layout {size: size_of::<PkErrorEnum>(), alignment: align_of::<PkErrorEnum>()}),
    ("PkEulaRequired", Layout {size: size_of::<PkEulaRequired>(), alignment: align_of::<PkEulaRequired>()}),
    ("PkEulaRequiredClass", Layout {size: size_of::<PkEulaRequiredClass>(), alignment: align_of::<PkEulaRequiredClass>()}),
    ("PkExitEnum", Layout {size: size_of::<PkExitEnum>(), alignment: align_of::<PkExitEnum>()}),
    ("PkFiles", Layout {size: size_of::<PkFiles>(), alignment: align_of::<PkFiles>()}),
    ("PkFilesClass", Layout {size: size_of::<PkFilesClass>(), alignment: align_of::<PkFilesClass>()}),
    ("PkFilterEnum", Layout {size: size_of::<PkFilterEnum>(), alignment: align_of::<PkFilterEnum>()}),
    ("PkGroupEnum", Layout {size: size_of::<PkGroupEnum>(), alignment: align_of::<PkGroupEnum>()}),
    ("PkInfoEnum", Layout {size: size_of::<PkInfoEnum>(), alignment: align_of::<PkInfoEnum>()}),
    ("PkItemProgress", Layout {size: size_of::<PkItemProgress>(), alignment: align_of::<PkItemProgress>()}),
    ("PkItemProgressClass", Layout {size: size_of::<PkItemProgressClass>(), alignment: align_of::<PkItemProgressClass>()}),
    ("PkMediaChangeRequired", Layout {size: size_of::<PkMediaChangeRequired>(), alignment: align_of::<PkMediaChangeRequired>()}),
    ("PkMediaChangeRequiredClass", Layout {size: size_of::<PkMediaChangeRequiredClass>(), alignment: align_of::<PkMediaChangeRequiredClass>()}),
    ("PkMediaTypeEnum", Layout {size: size_of::<PkMediaTypeEnum>(), alignment: align_of::<PkMediaTypeEnum>()}),
    ("PkNetworkEnum", Layout {size: size_of::<PkNetworkEnum>(), alignment: align_of::<PkNetworkEnum>()}),
    ("PkOfflineAction", Layout {size: size_of::<PkOfflineAction>(), alignment: align_of::<PkOfflineAction>()}),
    ("PkOfflineError", Layout {size: size_of::<PkOfflineError>(), alignment: align_of::<PkOfflineError>()}),
    ("PkPackage", Layout {size: size_of::<PkPackage>(), alignment: align_of::<PkPackage>()}),
    ("PkPackageClass", Layout {size: size_of::<PkPackageClass>(), alignment: align_of::<PkPackageClass>()}),
    ("PkPackageSack", Layout {size: size_of::<PkPackageSack>(), alignment: align_of::<PkPackageSack>()}),
    ("PkPackageSackClass", Layout {size: size_of::<PkPackageSackClass>(), alignment: align_of::<PkPackageSackClass>()}),
    ("PkPackageSackSortType", Layout {size: size_of::<PkPackageSackSortType>(), alignment: align_of::<PkPackageSackSortType>()}),
    ("PkProgress", Layout {size: size_of::<PkProgress>(), alignment: align_of::<PkProgress>()}),
    ("PkProgressClass", Layout {size: size_of::<PkProgressClass>(), alignment: align_of::<PkProgressClass>()}),
    ("PkProgressType", Layout {size: size_of::<PkProgressType>(), alignment: align_of::<PkProgressType>()}),
    ("PkRepoDetail", Layout {size: size_of::<PkRepoDetail>(), alignment: align_of::<PkRepoDetail>()}),
    ("PkRepoDetailClass", Layout {size: size_of::<PkRepoDetailClass>(), alignment: align_of::<PkRepoDetailClass>()}),
    ("PkRepoSignatureRequired", Layout {size: size_of::<PkRepoSignatureRequired>(), alignment: align_of::<PkRepoSignatureRequired>()}),
    ("PkRepoSignatureRequiredClass", Layout {size: size_of::<PkRepoSignatureRequiredClass>(), alignment: align_of::<PkRepoSignatureRequiredClass>()}),
    ("PkRequireRestart", Layout {size: size_of::<PkRequireRestart>(), alignment: align_of::<PkRequireRestart>()}),
    ("PkRequireRestartClass", Layout {size: size_of::<PkRequireRestartClass>(), alignment: align_of::<PkRequireRestartClass>()}),
    ("PkRestartEnum", Layout {size: size_of::<PkRestartEnum>(), alignment: align_of::<PkRestartEnum>()}),
    ("PkResults", Layout {size: size_of::<PkResults>(), alignment: align_of::<PkResults>()}),
    ("PkResultsClass", Layout {size: size_of::<PkResultsClass>(), alignment: align_of::<PkResultsClass>()}),
    ("PkRoleEnum", Layout {size: size_of::<PkRoleEnum>(), alignment: align_of::<PkRoleEnum>()}),
    ("PkSigTypeEnum", Layout {size: size_of::<PkSigTypeEnum>(), alignment: align_of::<PkSigTypeEnum>()}),
    ("PkSource", Layout {size: size_of::<PkSource>(), alignment: align_of::<PkSource>()}),
    ("PkSourceClass", Layout {size: size_of::<PkSourceClass>(), alignment: align_of::<PkSourceClass>()}),
    ("PkStatusEnum", Layout {size: size_of::<PkStatusEnum>(), alignment: align_of::<PkStatusEnum>()}),
    ("PkTask", Layout {size: size_of::<PkTask>(), alignment: align_of::<PkTask>()}),
    ("PkTaskClass", Layout {size: size_of::<PkTaskClass>(), alignment: align_of::<PkTaskClass>()}),
    ("PkTransactionFlagEnum", Layout {size: size_of::<PkTransactionFlagEnum>(), alignment: align_of::<PkTransactionFlagEnum>()}),
    ("PkTransactionList", Layout {size: size_of::<PkTransactionList>(), alignment: align_of::<PkTransactionList>()}),
    ("PkTransactionListClass", Layout {size: size_of::<PkTransactionListClass>(), alignment: align_of::<PkTransactionListClass>()}),
    ("PkTransactionPast", Layout {size: size_of::<PkTransactionPast>(), alignment: align_of::<PkTransactionPast>()}),
    ("PkTransactionPastClass", Layout {size: size_of::<PkTransactionPastClass>(), alignment: align_of::<PkTransactionPastClass>()}),
    ("PkUpdateDetail", Layout {size: size_of::<PkUpdateDetail>(), alignment: align_of::<PkUpdateDetail>()}),
    ("PkUpdateDetailClass", Layout {size: size_of::<PkUpdateDetailClass>(), alignment: align_of::<PkUpdateDetailClass>()}),
    ("PkUpdateStateEnum", Layout {size: size_of::<PkUpdateStateEnum>(), alignment: align_of::<PkUpdateStateEnum>()}),
    ("PkUpgradeKindEnum", Layout {size: size_of::<PkUpgradeKindEnum>(), alignment: align_of::<PkUpgradeKindEnum>()}),
];

const RUST_CONSTANTS: &[(&str, &str)] = &[
    ("(gint) PK_AUTHORIZE_ENUM_INTERACTIVE", "3"),
    ("(gint) PK_AUTHORIZE_ENUM_LAST", "4"),
    ("(gint) PK_AUTHORIZE_ENUM_NO", "2"),
    ("(gint) PK_AUTHORIZE_ENUM_UNKNOWN", "0"),
    ("(gint) PK_AUTHORIZE_ENUM_YES", "1"),
    ("(gint) PK_CLIENT_ERROR_ALREADY_TID", "3"),
    ("(gint) PK_CLIENT_ERROR_CANNOT_START_DAEMON", "5"),
    ("(gint) PK_CLIENT_ERROR_DECLINED_SIMULATION", "9"),
    ("(gint) PK_CLIENT_ERROR_FAILED", "0"),
    ("(gint) PK_CLIENT_ERROR_FAILED_AUTH", "1"),
    ("(gint) PK_CLIENT_ERROR_INVALID_FILE", "7"),
    ("(gint) PK_CLIENT_ERROR_INVALID_INPUT", "6"),
    ("(gint) PK_CLIENT_ERROR_LAST", "10"),
    ("(gint) PK_CLIENT_ERROR_NOT_SUPPORTED", "8"),
    ("(gint) PK_CLIENT_ERROR_NO_TID", "2"),
    ("(gint) PK_CLIENT_ERROR_ROLE_UNKNOWN", "4"),
    ("(gint) PK_CONTROL_ERROR_CANNOT_START_DAEMON", "1"),
    ("(gint) PK_CONTROL_ERROR_FAILED", "0"),
    ("PK_DBUS_INTERFACE", "org.freedesktop.PackageKit"),
    ("PK_DBUS_INTERFACE_OFFLINE", "org.freedesktop.PackageKit.Offline"),
    ("PK_DBUS_INTERFACE_TRANSACTION", "org.freedesktop.PackageKit.Transaction"),
    ("PK_DBUS_PATH", "/org/freedesktop/PackageKit"),
    ("PK_DBUS_SERVICE", "org.freedesktop.PackageKit"),
    ("PK_DESKTOP_DEFAULT_APPLICATION_DIR", "/usr/share/applications"),
    ("(gint) PK_DISTRO_UPGRADE_ENUM_LAST", "3"),
    ("(gint) PK_DISTRO_UPGRADE_ENUM_STABLE", "1"),
    ("(gint) PK_DISTRO_UPGRADE_ENUM_UNKNOWN", "0"),
    ("(gint) PK_DISTRO_UPGRADE_ENUM_UNSTABLE", "2"),
    ("(gint) PK_ERROR_ENUM_ALL_PACKAGES_ALREADY_INSTALLED", "41"),
    ("(gint) PK_ERROR_ENUM_BAD_GPG_SIGNATURE", "30"),
    ("(gint) PK_ERROR_ENUM_CANCELLED_PRIORITY", "65"),
    ("(gint) PK_ERROR_ENUM_CANNOT_CANCEL", "25"),
    ("(gint) PK_ERROR_ENUM_CANNOT_DISABLE_REPOSITORY", "54"),
    ("(gint) PK_ERROR_ENUM_CANNOT_FETCH_SOURCES", "64"),
    ("(gint) PK_ERROR_ENUM_CANNOT_GET_FILELIST", "52"),
    ("(gint) PK_ERROR_ENUM_CANNOT_GET_LOCK", "26"),
    ("(gint) PK_ERROR_ENUM_CANNOT_GET_REQUIRES", "53"),
    ("(gint) PK_ERROR_ENUM_CANNOT_INSTALL_REPO_UNSIGNED", "50"),
    ("(gint) PK_ERROR_ENUM_CANNOT_INSTALL_SOURCE_PACKAGE", "32"),
    ("(gint) PK_ERROR_ENUM_CANNOT_REMOVE_SYSTEM_PACKAGE", "20"),
    ("(gint) PK_ERROR_ENUM_CANNOT_UPDATE_REPO_UNSIGNED", "51"),
    ("(gint) PK_ERROR_ENUM_CANNOT_WRITE_REPO_CONFIG", "28"),
    ("(gint) PK_ERROR_ENUM_CREATE_THREAD_FAILED", "15"),
    ("(gint) PK_ERROR_ENUM_DEP_RESOLUTION_FAILED", "13"),
    ("(gint) PK_ERROR_ENUM_FAILED_CONFIG_PARSING", "24"),
    ("(gint) PK_ERROR_ENUM_FAILED_FINALISE", "23"),
    ("(gint) PK_ERROR_ENUM_FAILED_INITIALIZATION", "22"),
    ("(gint) PK_ERROR_ENUM_FILE_CONFLICTS", "35"),
    ("(gint) PK_ERROR_ENUM_FILE_NOT_FOUND", "42"),
    ("(gint) PK_ERROR_ENUM_FILTER_INVALID", "14"),
    ("(gint) PK_ERROR_ENUM_GPG_FAILURE", "5"),
    ("(gint) PK_ERROR_ENUM_GROUP_LIST_INVALID", "12"),
    ("(gint) PK_ERROR_ENUM_GROUP_NOT_FOUND", "11"),
    ("(gint) PK_ERROR_ENUM_INCOMPATIBLE_ARCHITECTURE", "45"),
    ("(gint) PK_ERROR_ENUM_INSTALL_ROOT_INVALID", "63"),
    ("(gint) PK_ERROR_ENUM_INTERNAL_ERROR", "4"),
    ("(gint) PK_ERROR_ENUM_INVALID_PACKAGE_FILE", "38"),
    ("(gint) PK_ERROR_ENUM_LAST", "69"),
    ("(gint) PK_ERROR_ENUM_LOCAL_INSTALL_FAILED", "29"),
    ("(gint) PK_ERROR_ENUM_LOCK_REQUIRED", "67"),
    ("(gint) PK_ERROR_ENUM_MEDIA_CHANGE_REQUIRED", "47"),
    ("(gint) PK_ERROR_ENUM_MISSING_GPG_SIGNATURE", "31"),
    ("(gint) PK_ERROR_ENUM_NOT_AUTHORIZED", "48"),
    ("(gint) PK_ERROR_ENUM_NOT_SUPPORTED", "3"),
    ("(gint) PK_ERROR_ENUM_NO_CACHE", "18"),
    ("(gint) PK_ERROR_ENUM_NO_DISTRO_UPGRADE_DATA", "44"),
    ("(gint) PK_ERROR_ENUM_NO_LICENSE_AGREEMENT", "34"),
    ("(gint) PK_ERROR_ENUM_NO_MORE_MIRRORS_TO_TRY", "43"),
    ("(gint) PK_ERROR_ENUM_NO_NETWORK", "2"),
    ("(gint) PK_ERROR_ENUM_NO_PACKAGES_TO_UPDATE", "27"),
    ("(gint) PK_ERROR_ENUM_NO_SPACE_ON_DEVICE", "46"),
    ("(gint) PK_ERROR_ENUM_OOM", "1"),
    ("(gint) PK_ERROR_ENUM_PACKAGE_ALREADY_INSTALLED", "9"),
    ("(gint) PK_ERROR_ENUM_PACKAGE_CONFLICTS", "36"),
    ("(gint) PK_ERROR_ENUM_PACKAGE_CORRUPT", "40"),
    ("(gint) PK_ERROR_ENUM_PACKAGE_DATABASE_CHANGED", "61"),
    ("(gint) PK_ERROR_ENUM_PACKAGE_DOWNLOAD_FAILED", "10"),
    ("(gint) PK_ERROR_ENUM_PACKAGE_FAILED_TO_BUILD", "57"),
    ("(gint) PK_ERROR_ENUM_PACKAGE_FAILED_TO_CONFIGURE", "56"),
    ("(gint) PK_ERROR_ENUM_PACKAGE_FAILED_TO_INSTALL", "58"),
    ("(gint) PK_ERROR_ENUM_PACKAGE_FAILED_TO_REMOVE", "59"),
    ("(gint) PK_ERROR_ENUM_PACKAGE_ID_INVALID", "6"),
    ("(gint) PK_ERROR_ENUM_PACKAGE_INSTALL_BLOCKED", "39"),
    ("(gint) PK_ERROR_ENUM_PACKAGE_NOT_FOUND", "8"),
    ("(gint) PK_ERROR_ENUM_PACKAGE_NOT_INSTALLED", "7"),
    ("(gint) PK_ERROR_ENUM_PROCESS_KILL", "21"),
    ("(gint) PK_ERROR_ENUM_PROVIDE_TYPE_NOT_SUPPORTED", "62"),
    ("(gint) PK_ERROR_ENUM_REPO_ALREADY_SET", "68"),
    ("(gint) PK_ERROR_ENUM_REPO_CONFIGURATION_ERROR", "33"),
    ("(gint) PK_ERROR_ENUM_REPO_NOT_AVAILABLE", "37"),
    ("(gint) PK_ERROR_ENUM_REPO_NOT_FOUND", "19"),
    ("(gint) PK_ERROR_ENUM_RESTRICTED_DOWNLOAD", "55"),
    ("(gint) PK_ERROR_ENUM_TRANSACTION_CANCELLED", "17"),
    ("(gint) PK_ERROR_ENUM_TRANSACTION_ERROR", "16"),
    ("(gint) PK_ERROR_ENUM_UNFINISHED_TRANSACTION", "66"),
    ("(gint) PK_ERROR_ENUM_UNKNOWN", "0"),
    ("(gint) PK_ERROR_ENUM_UPDATE_FAILED_DUE_TO_RUNNING_PROCESS", "60"),
    ("(gint) PK_ERROR_ENUM_UPDATE_NOT_FOUND", "49"),
    ("(gint) PK_EXIT_ENUM_CANCELLED", "3"),
    ("(gint) PK_EXIT_ENUM_CANCELLED_PRIORITY", "9"),
    ("(gint) PK_EXIT_ENUM_EULA_REQUIRED", "5"),
    ("(gint) PK_EXIT_ENUM_FAILED", "2"),
    ("(gint) PK_EXIT_ENUM_KEY_REQUIRED", "4"),
    ("(gint) PK_EXIT_ENUM_KILLED", "6"),
    ("(gint) PK_EXIT_ENUM_LAST", "12"),
    ("(gint) PK_EXIT_ENUM_MEDIA_CHANGE_REQUIRED", "7"),
    ("(gint) PK_EXIT_ENUM_NEED_UNTRUSTED", "8"),
    ("(gint) PK_EXIT_ENUM_REPAIR_REQUIRED", "11"),
    ("(gint) PK_EXIT_ENUM_SKIP_TRANSACTION", "10"),
    ("(gint) PK_EXIT_ENUM_SUCCESS", "1"),
    ("(gint) PK_EXIT_ENUM_UNKNOWN", "0"),
    ("(gint) PK_FILTER_ENUM_APPLICATION", "24"),
    ("(gint) PK_FILTER_ENUM_ARCH", "18"),
    ("(gint) PK_FILTER_ENUM_BASENAME", "14"),
    ("(gint) PK_FILTER_ENUM_COLLECTIONS", "22"),
    ("(gint) PK_FILTER_ENUM_DEVELOPMENT", "4"),
    ("(gint) PK_FILTER_ENUM_DOWNLOADED", "26"),
    ("(gint) PK_FILTER_ENUM_FREE", "8"),
    ("(gint) PK_FILTER_ENUM_GUI", "6"),
    ("(gint) PK_FILTER_ENUM_INSTALLED", "2"),
    ("(gint) PK_FILTER_ENUM_LAST", "28"),
    ("(gint) PK_FILTER_ENUM_NEWEST", "16"),
    ("(gint) PK_FILTER_ENUM_NONE", "1"),
    ("(gint) PK_FILTER_ENUM_NOT_APPLICATION", "25"),
    ("(gint) PK_FILTER_ENUM_NOT_ARCH", "19"),
    ("(gint) PK_FILTER_ENUM_NOT_BASENAME", "15"),
    ("(gint) PK_FILTER_ENUM_NOT_COLLECTIONS", "23"),
    ("(gint) PK_FILTER_ENUM_NOT_DEVELOPMENT", "5"),
    ("(gint) PK_FILTER_ENUM_NOT_DOWNLOADED", "27"),
    ("(gint) PK_FILTER_ENUM_NOT_FREE", "9"),
    ("(gint) PK_FILTER_ENUM_NOT_GUI", "7"),
    ("(gint) PK_FILTER_ENUM_NOT_INSTALLED", "3"),
    ("(gint) PK_FILTER_ENUM_NOT_NEWEST", "17"),
    ("(gint) PK_FILTER_ENUM_NOT_SOURCE", "21"),
    ("(gint) PK_FILTER_ENUM_NOT_SUPPORTED", "13"),
    ("(gint) PK_FILTER_ENUM_NOT_VISIBLE", "11"),
    ("(gint) PK_FILTER_ENUM_SOURCE", "20"),
    ("(gint) PK_FILTER_ENUM_SUPPORTED", "12"),
    ("(gint) PK_FILTER_ENUM_UNKNOWN", "0"),
    ("(gint) PK_FILTER_ENUM_VISIBLE", "10"),
    ("(gint) PK_GROUP_ENUM_ACCESSIBILITY", "1"),
    ("(gint) PK_GROUP_ENUM_ACCESSORIES", "2"),
    ("(gint) PK_GROUP_ENUM_ADMIN_TOOLS", "3"),
    ("(gint) PK_GROUP_ENUM_COLLECTIONS", "32"),
    ("(gint) PK_GROUP_ENUM_COMMUNICATION", "4"),
    ("(gint) PK_GROUP_ENUM_DESKTOP_GNOME", "5"),
    ("(gint) PK_GROUP_ENUM_DESKTOP_KDE", "6"),
    ("(gint) PK_GROUP_ENUM_DESKTOP_OTHER", "7"),
    ("(gint) PK_GROUP_ENUM_DESKTOP_XFCE", "8"),
    ("(gint) PK_GROUP_ENUM_DOCUMENTATION", "30"),
    ("(gint) PK_GROUP_ENUM_EDUCATION", "9"),
    ("(gint) PK_GROUP_ENUM_ELECTRONICS", "31"),
    ("(gint) PK_GROUP_ENUM_FONTS", "10"),
    ("(gint) PK_GROUP_ENUM_GAMES", "11"),
    ("(gint) PK_GROUP_ENUM_GRAPHICS", "12"),
    ("(gint) PK_GROUP_ENUM_INTERNET", "13"),
    ("(gint) PK_GROUP_ENUM_LAST", "35"),
    ("(gint) PK_GROUP_ENUM_LEGACY", "14"),
    ("(gint) PK_GROUP_ENUM_LOCALIZATION", "15"),
    ("(gint) PK_GROUP_ENUM_MAPS", "16"),
    ("(gint) PK_GROUP_ENUM_MULTIMEDIA", "17"),
    ("(gint) PK_GROUP_ENUM_NETWORK", "18"),
    ("(gint) PK_GROUP_ENUM_NEWEST", "34"),
    ("(gint) PK_GROUP_ENUM_OFFICE", "19"),
    ("(gint) PK_GROUP_ENUM_OTHER", "20"),
    ("(gint) PK_GROUP_ENUM_POWER_MANAGEMENT", "21"),
    ("(gint) PK_GROUP_ENUM_PROGRAMMING", "22"),
    ("(gint) PK_GROUP_ENUM_PUBLISHING", "23"),
    ("(gint) PK_GROUP_ENUM_REPOS", "24"),
    ("(gint) PK_GROUP_ENUM_SCIENCE", "29"),
    ("(gint) PK_GROUP_ENUM_SECURITY", "25"),
    ("(gint) PK_GROUP_ENUM_SERVERS", "26"),
    ("(gint) PK_GROUP_ENUM_SYSTEM", "27"),
    ("(gint) PK_GROUP_ENUM_UNKNOWN", "0"),
    ("(gint) PK_GROUP_ENUM_VENDOR", "33"),
    ("(gint) PK_GROUP_ENUM_VIRTUALIZATION", "28"),
    ("(gint) PK_INFO_ENUM_AVAILABLE", "2"),
    ("(gint) PK_INFO_ENUM_BLOCKED", "9"),
    ("(gint) PK_INFO_ENUM_BUGFIX", "6"),
    ("(gint) PK_INFO_ENUM_CLEANUP", "14"),
    ("(gint) PK_INFO_ENUM_COLLECTION_AVAILABLE", "17"),
    ("(gint) PK_INFO_ENUM_COLLECTION_INSTALLED", "16"),
    ("(gint) PK_INFO_ENUM_DECOMPRESSING", "22"),
    ("(gint) PK_INFO_ENUM_DOWNGRADING", "20"),
    ("(gint) PK_INFO_ENUM_DOWNLOADING", "10"),
    ("(gint) PK_INFO_ENUM_ENHANCEMENT", "4"),
    ("(gint) PK_INFO_ENUM_FINISHED", "18"),
    ("(gint) PK_INFO_ENUM_IMPORTANT", "7"),
    ("(gint) PK_INFO_ENUM_INSTALLED", "1"),
    ("(gint) PK_INFO_ENUM_INSTALLING", "12"),
    ("(gint) PK_INFO_ENUM_LAST", "26"),
    ("(gint) PK_INFO_ENUM_LOW", "3"),
    ("(gint) PK_INFO_ENUM_NORMAL", "5"),
    ("(gint) PK_INFO_ENUM_OBSOLETING", "15"),
    ("(gint) PK_INFO_ENUM_PREPARING", "21"),
    ("(gint) PK_INFO_ENUM_REINSTALLING", "19"),
    ("(gint) PK_INFO_ENUM_REMOVING", "13"),
    ("(gint) PK_INFO_ENUM_SECURITY", "8"),
    ("(gint) PK_INFO_ENUM_TRUSTED", "24"),
    ("(gint) PK_INFO_ENUM_UNAVAILABLE", "25"),
    ("(gint) PK_INFO_ENUM_UNKNOWN", "0"),
    ("(gint) PK_INFO_ENUM_UNTRUSTED", "23"),
    ("(gint) PK_INFO_ENUM_UPDATING", "11"),
    ("PK_MAJOR_VERSION", "1"),
    ("(gint) PK_MEDIA_TYPE_ENUM_CD", "1"),
    ("(gint) PK_MEDIA_TYPE_ENUM_DISC", "3"),
    ("(gint) PK_MEDIA_TYPE_ENUM_DVD", "2"),
    ("(gint) PK_MEDIA_TYPE_ENUM_LAST", "4"),
    ("(gint) PK_MEDIA_TYPE_ENUM_UNKNOWN", "0"),
    ("PK_MICRO_VERSION", "2"),
    ("PK_MINOR_VERSION", "2"),
    ("(gint) PK_NETWORK_ENUM_LAST", "6"),
    ("(gint) PK_NETWORK_ENUM_MOBILE", "5"),
    ("(gint) PK_NETWORK_ENUM_OFFLINE", "1"),
    ("(gint) PK_NETWORK_ENUM_ONLINE", "2"),
    ("(gint) PK_NETWORK_ENUM_UNKNOWN", "0"),
    ("(gint) PK_NETWORK_ENUM_WIFI", "4"),
    ("(gint) PK_NETWORK_ENUM_WIRED", "3"),
    ("(gint) PK_OFFLINE_ACTION_LAST", "4"),
    ("(gint) PK_OFFLINE_ACTION_POWER_OFF", "2"),
    ("(gint) PK_OFFLINE_ACTION_REBOOT", "1"),
    ("(gint) PK_OFFLINE_ACTION_UNKNOWN", "0"),
    ("(gint) PK_OFFLINE_ACTION_UNSET", "3"),
    ("(gint) PK_OFFLINE_ERROR_FAILED", "0"),
    ("(gint) PK_OFFLINE_ERROR_INVALID_VALUE", "1"),
    ("(gint) PK_OFFLINE_ERROR_LAST", "3"),
    ("(gint) PK_OFFLINE_ERROR_NO_DATA", "2"),
    ("PK_PACKAGE_IDS_DELIM", "&"),
    ("PK_PACKAGE_ID_ARCH", "2"),
    ("PK_PACKAGE_ID_DATA", "3"),
    ("PK_PACKAGE_ID_NAME", "0"),
    ("PK_PACKAGE_ID_VERSION", "1"),
    ("(gint) PK_PACKAGE_SACK_SORT_TYPE_INFO", "1"),
    ("(gint) PK_PACKAGE_SACK_SORT_TYPE_LAST", "4"),
    ("(gint) PK_PACKAGE_SACK_SORT_TYPE_NAME", "0"),
    ("(gint) PK_PACKAGE_SACK_SORT_TYPE_PACKAGE_ID", "2"),
    ("(gint) PK_PACKAGE_SACK_SORT_TYPE_SUMMARY", "3"),
    ("(gint) PK_PROGRESS_TYPE_ALLOW_CANCEL", "3"),
    ("(gint) PK_PROGRESS_TYPE_CALLER_ACTIVE", "6"),
    ("(gint) PK_PROGRESS_TYPE_DOWNLOAD_SIZE_REMAINING", "10"),
    ("(gint) PK_PROGRESS_TYPE_ELAPSED_TIME", "7"),
    ("(gint) PK_PROGRESS_TYPE_INVALID", "15"),
    ("(gint) PK_PROGRESS_TYPE_ITEM_PROGRESS", "13"),
    ("(gint) PK_PROGRESS_TYPE_PACKAGE", "12"),
    ("(gint) PK_PROGRESS_TYPE_PACKAGE_ID", "0"),
    ("(gint) PK_PROGRESS_TYPE_PERCENTAGE", "2"),
    ("(gint) PK_PROGRESS_TYPE_REMAINING_TIME", "8"),
    ("(gint) PK_PROGRESS_TYPE_ROLE", "5"),
    ("(gint) PK_PROGRESS_TYPE_SPEED", "9"),
    ("(gint) PK_PROGRESS_TYPE_STATUS", "4"),
    ("(gint) PK_PROGRESS_TYPE_TRANSACTION_FLAGS", "14"),
    ("(gint) PK_PROGRESS_TYPE_TRANSACTION_ID", "1"),
    ("(gint) PK_PROGRESS_TYPE_UID", "11"),
    ("(gint) PK_RESTART_ENUM_APPLICATION", "2"),
    ("(gint) PK_RESTART_ENUM_LAST", "7"),
    ("(gint) PK_RESTART_ENUM_NONE", "1"),
    ("(gint) PK_RESTART_ENUM_SECURITY_SESSION", "5"),
    ("(gint) PK_RESTART_ENUM_SECURITY_SYSTEM", "6"),
    ("(gint) PK_RESTART_ENUM_SESSION", "3"),
    ("(gint) PK_RESTART_ENUM_SYSTEM", "4"),
    ("(gint) PK_RESTART_ENUM_UNKNOWN", "0"),
    ("(gint) PK_ROLE_ENUM_ACCEPT_EULA", "24"),
    ("(gint) PK_ROLE_ENUM_CANCEL", "1"),
    ("(gint) PK_ROLE_ENUM_DEPENDS_ON", "2"),
    ("(gint) PK_ROLE_ENUM_DOWNLOAD_PACKAGES", "25"),
    ("(gint) PK_ROLE_ENUM_GET_CATEGORIES", "27"),
    ("(gint) PK_ROLE_ENUM_GET_DETAILS", "3"),
    ("(gint) PK_ROLE_ENUM_GET_DETAILS_LOCAL", "30"),
    ("(gint) PK_ROLE_ENUM_GET_DISTRO_UPGRADES", "26"),
    ("(gint) PK_ROLE_ENUM_GET_FILES", "4"),
    ("(gint) PK_ROLE_ENUM_GET_FILES_LOCAL", "31"),
    ("(gint) PK_ROLE_ENUM_GET_OLD_TRANSACTIONS", "28"),
    ("(gint) PK_ROLE_ENUM_GET_PACKAGES", "5"),
    ("(gint) PK_ROLE_ENUM_GET_REPO_LIST", "6"),
    ("(gint) PK_ROLE_ENUM_GET_UPDATES", "9"),
    ("(gint) PK_ROLE_ENUM_GET_UPDATE_DETAIL", "8"),
    ("(gint) PK_ROLE_ENUM_INSTALL_FILES", "10"),
    ("(gint) PK_ROLE_ENUM_INSTALL_PACKAGES", "11"),
    ("(gint) PK_ROLE_ENUM_INSTALL_SIGNATURE", "12"),
    ("(gint) PK_ROLE_ENUM_LAST", "34"),
    ("(gint) PK_ROLE_ENUM_REFRESH_CACHE", "13"),
    ("(gint) PK_ROLE_ENUM_REMOVE_PACKAGES", "14"),
    ("(gint) PK_ROLE_ENUM_REPAIR_SYSTEM", "29"),
    ("(gint) PK_ROLE_ENUM_REPO_ENABLE", "15"),
    ("(gint) PK_ROLE_ENUM_REPO_REMOVE", "32"),
    ("(gint) PK_ROLE_ENUM_REPO_SET_DATA", "16"),
    ("(gint) PK_ROLE_ENUM_REQUIRED_BY", "7"),
    ("(gint) PK_ROLE_ENUM_RESOLVE", "17"),
    ("(gint) PK_ROLE_ENUM_SEARCH_DETAILS", "18"),
    ("(gint) PK_ROLE_ENUM_SEARCH_FILE", "19"),
    ("(gint) PK_ROLE_ENUM_SEARCH_GROUP", "20"),
    ("(gint) PK_ROLE_ENUM_SEARCH_NAME", "21"),
    ("(gint) PK_ROLE_ENUM_UNKNOWN", "0"),
    ("(gint) PK_ROLE_ENUM_UPDATE_PACKAGES", "22"),
    ("(gint) PK_ROLE_ENUM_UPGRADE_SYSTEM", "33"),
    ("(gint) PK_ROLE_ENUM_WHAT_PROVIDES", "23"),
    ("(gint) PK_SIGTYPE_ENUM_GPG", "1"),
    ("(gint) PK_SIGTYPE_ENUM_LAST", "2"),
    ("(gint) PK_SIGTYPE_ENUM_UNKNOWN", "0"),
    ("(gint) PK_STATUS_ENUM_CANCEL", "19"),
    ("(gint) PK_STATUS_ENUM_CHECK_EXECUTABLE_FILES", "33"),
    ("(gint) PK_STATUS_ENUM_CHECK_LIBRARIES", "34"),
    ("(gint) PK_STATUS_ENUM_CLEANUP", "11"),
    ("(gint) PK_STATUS_ENUM_COMMIT", "16"),
    ("(gint) PK_STATUS_ENUM_COPY_FILES", "35"),
    ("(gint) PK_STATUS_ENUM_DEP_RESOLVE", "13"),
    ("(gint) PK_STATUS_ENUM_DOWNLOAD", "8"),
    ("(gint) PK_STATUS_ENUM_DOWNLOAD_CHANGELOG", "23"),
    ("(gint) PK_STATUS_ENUM_DOWNLOAD_FILELIST", "22"),
    ("(gint) PK_STATUS_ENUM_DOWNLOAD_GROUP", "24"),
    ("(gint) PK_STATUS_ENUM_DOWNLOAD_PACKAGELIST", "21"),
    ("(gint) PK_STATUS_ENUM_DOWNLOAD_REPOSITORY", "20"),
    ("(gint) PK_STATUS_ENUM_DOWNLOAD_UPDATEINFO", "25"),
    ("(gint) PK_STATUS_ENUM_FINISHED", "18"),
    ("(gint) PK_STATUS_ENUM_GENERATE_PACKAGE_LIST", "29"),
    ("(gint) PK_STATUS_ENUM_INFO", "5"),
    ("(gint) PK_STATUS_ENUM_INSTALL", "9"),
    ("(gint) PK_STATUS_ENUM_LAST", "37"),
    ("(gint) PK_STATUS_ENUM_LOADING_CACHE", "27"),
    ("(gint) PK_STATUS_ENUM_OBSOLETE", "12"),
    ("(gint) PK_STATUS_ENUM_QUERY", "4"),
    ("(gint) PK_STATUS_ENUM_REFRESH_CACHE", "7"),
    ("(gint) PK_STATUS_ENUM_REMOVE", "6"),
    ("(gint) PK_STATUS_ENUM_REPACKAGING", "26"),
    ("(gint) PK_STATUS_ENUM_REQUEST", "17"),
    ("(gint) PK_STATUS_ENUM_RUNNING", "3"),
    ("(gint) PK_STATUS_ENUM_RUN_HOOK", "36"),
    ("(gint) PK_STATUS_ENUM_SCAN_APPLICATIONS", "28"),
    ("(gint) PK_STATUS_ENUM_SCAN_PROCESS_LIST", "32"),
    ("(gint) PK_STATUS_ENUM_SETUP", "2"),
    ("(gint) PK_STATUS_ENUM_SIG_CHECK", "14"),
    ("(gint) PK_STATUS_ENUM_TEST_COMMIT", "15"),
    ("(gint) PK_STATUS_ENUM_UNKNOWN", "0"),
    ("(gint) PK_STATUS_ENUM_UPDATE", "10"),
    ("(gint) PK_STATUS_ENUM_WAIT", "1"),
    ("(gint) PK_STATUS_ENUM_WAITING_FOR_AUTH", "31"),
    ("(gint) PK_STATUS_ENUM_WAITING_FOR_LOCK", "30"),
    ("PK_SYSTEM_PACKAGE_CACHE_FILENAME", "/var/lib/PackageKit/package-cache.db"),
    ("PK_SYSTEM_PACKAGE_LIST_FILENAME", "/var/lib/PackageKit/system.package-list"),
    ("(gint) PK_TRANSACTION_FLAG_ENUM_ALLOW_DOWNGRADE", "6"),
    ("(gint) PK_TRANSACTION_FLAG_ENUM_ALLOW_REINSTALL", "4"),
    ("(gint) PK_TRANSACTION_FLAG_ENUM_JUST_REINSTALL", "5"),
    ("(gint) PK_TRANSACTION_FLAG_ENUM_LAST", "7"),
    ("(gint) PK_TRANSACTION_FLAG_ENUM_NONE", "0"),
    ("(gint) PK_TRANSACTION_FLAG_ENUM_ONLY_DOWNLOAD", "3"),
    ("(gint) PK_TRANSACTION_FLAG_ENUM_ONLY_TRUSTED", "1"),
    ("(gint) PK_TRANSACTION_FLAG_ENUM_SIMULATE", "2"),
    ("(gint) PK_UPDATE_STATE_ENUM_LAST", "4"),
    ("(gint) PK_UPDATE_STATE_ENUM_STABLE", "1"),
    ("(gint) PK_UPDATE_STATE_ENUM_TESTING", "3"),
    ("(gint) PK_UPDATE_STATE_ENUM_UNKNOWN", "0"),
    ("(gint) PK_UPDATE_STATE_ENUM_UNSTABLE", "2"),
    ("(gint) PK_UPGRADE_KIND_ENUM_COMPLETE", "3"),
    ("(gint) PK_UPGRADE_KIND_ENUM_DEFAULT", "2"),
    ("(gint) PK_UPGRADE_KIND_ENUM_LAST", "4"),
    ("(gint) PK_UPGRADE_KIND_ENUM_MINIMAL", "1"),
    ("(gint) PK_UPGRADE_KIND_ENUM_UNKNOWN", "0"),
];


