/** * pk_backend_job_set_role: **/ void pk_backend_job_set_role (PkBackendJob *job, PkRoleEnum role) { /* Should only be called once... */ if (job->priv->role != PK_ROLE_ENUM_UNKNOWN && job->priv->role != role) { g_warning ("cannot set role to %s, already %s", pk_role_enum_to_string (role), pk_role_enum_to_string (job->priv->role)); } g_timer_reset (job->priv->timer); job->priv->role = role; job->priv->status = PK_STATUS_ENUM_WAIT; pk_backend_job_call_vfunc (job, PK_BACKEND_SIGNAL_STATUS_CHANGED, GUINT_TO_POINTER (job->priv->status), NULL); }
/** * pk_role_bitfield_to_string: * @roles: The enumerated type values * * Converts a enumerated type bitfield to its text representation * * Return value: the enumerated constant value, e.g. "install-file;update-system" * * Since: 0.5.2 **/ gchar * pk_role_bitfield_to_string (PkBitfield roles) { GString *string; guint i; string = g_string_new (""); for (i = 0; i < PK_ROLE_ENUM_LAST; i++) { if ((roles & pk_bitfield_value (i)) == 0) continue; g_string_append_printf (string, "%s;", pk_role_enum_to_string (i)); } /* do we have a no bitfield? \n */ if (string->len == 0) { g_warning ("not valid!"); g_string_append (string, pk_role_enum_to_string (PK_ROLE_ENUM_UNKNOWN)); } else { /* remove last \n */ g_string_set_size (string, string->len - 1); } return g_string_free (string, FALSE); }
/** * pk_plugin_finished_cb: **/ static void pk_plugin_finished_cb (PkBackendJob *job, PkExitEnum exit_enum, PkPlugin *plugin) { if (!g_main_loop_is_running (plugin->priv->loop)) return; if (exit_enum != PK_EXIT_ENUM_SUCCESS) { g_warning ("%s failed with exit code: %s", pk_role_enum_to_string (pk_backend_job_get_role (job)), pk_exit_enum_to_string (exit_enum)); } g_main_loop_quit (plugin->priv->loop); }
/** * pk_backend_job_finished: **/ void pk_backend_job_finished (PkBackendJob *job) { const gchar *role_text; g_return_if_fail (PK_IS_BACKEND_JOB (job)); /* check we have not already finished */ if (job->priv->finished) { g_warning ("already finished"); return; } /* find out what we just did */ role_text = pk_role_enum_to_string (job->priv->role); /* ensure the same number of ::Files() were sent as packages for DownloadPackages */ if (!job->priv->set_error && job->priv->role == PK_ROLE_ENUM_DOWNLOAD_PACKAGES && job->priv->download_files == 0) { g_warning ("required multiple Files() for each package_id!"); } /* check we sent at least one status calls */ if (job->priv->set_error == FALSE && job->priv->status == PK_STATUS_ENUM_SETUP) { g_warning ("required status signals for %s!", role_text); } /* drop any inhibits */ pk_backend_job_set_allow_cancel (job, TRUE); /* mark as finished for the UI that might only be watching status */ pk_backend_job_set_status (job, PK_STATUS_ENUM_FINISHED); /* we can't ever be re-used */ job->priv->finished = TRUE; /* this wasn't set otherwise, assume success */ if (job->priv->exit == PK_EXIT_ENUM_UNKNOWN) pk_backend_job_set_exit_code (job, PK_EXIT_ENUM_SUCCESS); /* emit */ pk_backend_job_call_vfunc (job, PK_BACKEND_SIGNAL_FINISHED, GUINT_TO_POINTER (job->priv->exit), NULL); }
/** * pk_role_enum_to_localised_present: * @role: The enumerated type value * * Converts a enumerated type to its localized description * * Return Value: the translated text * * Since: 0.7.2 **/ const gchar * pk_role_enum_to_localised_present (PkRoleEnum role) { const gchar *text = NULL; switch (role) { case PK_ROLE_ENUM_UNKNOWN: /* TRANSLATORS: The role of the transaction, in present tense */ text = dgettext("PackageKit", "Unknown role type"); break; case PK_ROLE_ENUM_DEPENDS_ON: /* TRANSLATORS: The role of the transaction, in present tense */ text = dgettext("PackageKit", "Getting dependencies"); break; case PK_ROLE_ENUM_GET_UPDATE_DETAIL: /* TRANSLATORS: The role of the transaction, in present tense */ text = dgettext("PackageKit", "Getting update details"); break; case PK_ROLE_ENUM_GET_DETAILS: /* TRANSLATORS: The role of the transaction, in present tense */ text = dgettext("PackageKit", "Getting details"); break; case PK_ROLE_ENUM_REQUIRED_BY: /* TRANSLATORS: The role of the transaction, in present tense */ text = dgettext("PackageKit", "Getting requires"); break; case PK_ROLE_ENUM_GET_UPDATES: /* TRANSLATORS: The role of the transaction, in present tense */ text = dgettext("PackageKit", "Getting updates"); break; case PK_ROLE_ENUM_SEARCH_DETAILS: /* TRANSLATORS: The role of the transaction, in present tense */ text = dgettext("PackageKit", "Searching by details"); break; case PK_ROLE_ENUM_SEARCH_FILE: /* TRANSLATORS: The role of the transaction, in present tense */ text = dgettext("PackageKit", "Searching by file"); break; case PK_ROLE_ENUM_SEARCH_GROUP: /* TRANSLATORS: The role of the transaction, in present tense */ text = dgettext("PackageKit", "Searching groups"); break; case PK_ROLE_ENUM_SEARCH_NAME: /* TRANSLATORS: The role of the transaction, in present tense */ text = dgettext("PackageKit", "Searching by name"); break; case PK_ROLE_ENUM_REMOVE_PACKAGES: /* TRANSLATORS: The role of the transaction, in present tense */ text = dgettext("PackageKit", "Removing"); break; case PK_ROLE_ENUM_INSTALL_PACKAGES: /* TRANSLATORS: The role of the transaction, in present tense */ text = dgettext("PackageKit", "Installing"); break; case PK_ROLE_ENUM_INSTALL_FILES: /* TRANSLATORS: The role of the transaction, in present tense */ text = dgettext("PackageKit", "Installing files"); break; case PK_ROLE_ENUM_REFRESH_CACHE: /* TRANSLATORS: The role of the transaction, in present tense */ text = dgettext("PackageKit", "Refreshing cache"); break; case PK_ROLE_ENUM_UPDATE_PACKAGES: /* TRANSLATORS: The role of the transaction, in present tense */ text = dgettext("PackageKit", "Updating packages"); break; case PK_ROLE_ENUM_CANCEL: /* TRANSLATORS: The role of the transaction, in present tense */ text = dgettext("PackageKit", "Canceling"); break; case PK_ROLE_ENUM_GET_REPO_LIST: /* TRANSLATORS: The role of the transaction, in present tense */ text = dgettext("PackageKit", "Getting repositories"); break; case PK_ROLE_ENUM_REPO_ENABLE: /* TRANSLATORS: The role of the transaction, in present tense */ text = dgettext("PackageKit", "Enabling repository"); break; case PK_ROLE_ENUM_REPO_SET_DATA: /* TRANSLATORS: The role of the transaction, in present tense */ text = dgettext("PackageKit", "Setting data"); break; case PK_ROLE_ENUM_RESOLVE: /* TRANSLATORS: The role of the transaction, in present tense */ text = dgettext("PackageKit", "Resolving"); break; case PK_ROLE_ENUM_GET_FILES: /* TRANSLATORS: The role of the transaction, in present tense */ text = dgettext("PackageKit", "Getting file list"); break; case PK_ROLE_ENUM_WHAT_PROVIDES: /* TRANSLATORS: The role of the transaction, in present tense */ text = dgettext("PackageKit", "Getting provides"); break; case PK_ROLE_ENUM_INSTALL_SIGNATURE: /* TRANSLATORS: The role of the transaction, in present tense */ text = dgettext("PackageKit", "Installing signature"); break; case PK_ROLE_ENUM_GET_PACKAGES: /* TRANSLATORS: The role of the transaction, in present tense */ text = dgettext("PackageKit", "Getting packages"); break; case PK_ROLE_ENUM_ACCEPT_EULA: /* TRANSLATORS: The role of the transaction, in present tense */ text = dgettext("PackageKit", "Accepting EULA"); break; case PK_ROLE_ENUM_DOWNLOAD_PACKAGES: /* TRANSLATORS: The role of the transaction, in present tense */ text = dgettext("PackageKit", "Downloading packages"); break; case PK_ROLE_ENUM_GET_DISTRO_UPGRADES: /* TRANSLATORS: The role of the transaction, in present tense */ text = dgettext("PackageKit", "Getting upgrades"); break; case PK_ROLE_ENUM_GET_CATEGORIES: /* TRANSLATORS: The role of the transaction, in present tense */ text = dgettext("PackageKit", "Getting categories"); break; case PK_ROLE_ENUM_GET_OLD_TRANSACTIONS: /* TRANSLATORS: The role of the transaction, in present tense */ text = dgettext("PackageKit", "Getting transactions"); break; default: g_warning ("role unrecognised: %s", pk_role_enum_to_string (role)); } return text; }