diff options
author | Daniel Nicoletti <dantti85-pk@yahoo.com.br> | 2009-04-13 20:40:40 -0300 |
---|---|---|
committer | Daniel Nicoletti <dantti85-pk@yahoo.com.br> | 2009-04-13 20:40:40 -0300 |
commit | a3412d08c19191cb37b56f4f41afdbc6009f690f (patch) | |
tree | 38b15f389f81fde527da9b74fafb946087ddac8b /src | |
parent | 34e2c6e65c399b0005fff0d443edc102b39ed7ae (diff) |
Squashed commit of the following:
commit a164eb3fb2e8444e15f238c9a63c208099028412
Author: Daniel Nicoletti <dantti85-pk@yahoo.com.br>
Date: Mon Apr 13 20:36:40 2009 -0300
New signal, media-change-required finished (Pk and -glib).
Diffstat (limited to 'src')
-rw-r--r-- | src/org.freedesktop.PackageKit.Transaction.xml | 47 | ||||
-rw-r--r-- | src/pk-backend.c | 35 | ||||
-rw-r--r-- | src/pk-backend.h | 4 | ||||
-rw-r--r-- | src/pk-transaction.c | 41 |
4 files changed, 127 insertions, 0 deletions
diff --git a/src/org.freedesktop.PackageKit.Transaction.xml b/src/org.freedesktop.PackageKit.Transaction.xml index 8ce2d15c3..ca75d4283 100644 --- a/src/org.freedesktop.PackageKit.Transaction.xml +++ b/src/org.freedesktop.PackageKit.Transaction.xml @@ -1891,6 +1891,53 @@ </signal> <!--*****************************************************************************************--> + <signal name="MediaChangeRequired"> + <doc:doc> + <doc:description> + <doc:para> + This signal is emitted when a transaction needsneeds a different media + to grab the packages. + </doc:para> + <doc:para> + Some backends support Media changing, which will fail the transaction each time it needs + a new media. + </doc:para> + </doc:description> + </doc:doc> + <arg type="s" name="media_type" direction="out"> + <doc:doc> + <doc:summary> + <doc:para> + Enumerated type, e.g. <doc:tt>dvd</doc:tt>. + </doc:para> + </doc:summary> + </doc:doc> + </arg> + <arg type="s" name="media_id" direction="out"> + <doc:doc> + <doc:summary> + <doc:para> + The <doc:tt>media_id</doc:tt> which identifies the Media - this is provided + so that if DeviceKit or another program is able to identify the right media + before continuing, note however that it's not the DeviceKit oblication to + check the media when the transaction is re-scheduled this is the backend task. + An example <doc:tt>media_id</doc:tt>'s is <doc:tt>Debian testing amd64 Bin-1</doc:tt>. + </doc:para> + </doc:summary> + </doc:doc> + </arg> + <arg type="s" name="media_text" direction="out"> + <doc:doc> + <doc:summary> + <doc:para> + Might be used for the disk label too, something like <doc:tt>Fedora Disk 1</doc:tt> + </doc:para> + </doc:summary> + </doc:doc> + </arg> + </signal> + + <!--*****************************************************************************************--> <signal name="RequireRestart"> <doc:doc> <doc:description> diff --git a/src/pk-backend.c b/src/pk-backend.c index d55245d02..d16c3a80e 100644 --- a/src/pk-backend.c +++ b/src/pk-backend.c @@ -139,6 +139,7 @@ enum { PK_BACKEND_ALLOW_CANCEL, PK_BACKEND_REPO_DETAIL, PK_BACKEND_CATEGORY, + PK_BACKEND_MEDIA_CHANGE_REQUIRED, PK_BACKEND_LAST_SIGNAL }; @@ -1292,6 +1293,35 @@ pk_backend_eula_required (PkBackend *backend, const gchar *eula_id, const gchar } /** + * pk_backend_media_change_required: + **/ +gboolean +pk_backend_media_change_required (PkBackend *backend, + PkMediaTypeEnum media_type, + const gchar *media_id, + const gchar *media_text) +{ + g_return_val_if_fail (PK_IS_BACKEND (backend), FALSE); + g_return_val_if_fail (media_id != NULL, FALSE); + g_return_val_if_fail (media_text != NULL, FALSE); + g_return_val_if_fail (backend->priv->locked != FALSE, FALSE); + + /* have we already set an error? */ + if (backend->priv->set_error) { + egg_warning ("already set error, cannot process: media change required"); + return FALSE; + } + + egg_debug ("emit media-change-required %s, %s, %s", + pk_media_type_enum_to_text (media_type), media_id, media_text); + + g_signal_emit (backend, signals [PK_BACKEND_MEDIA_CHANGE_REQUIRED], 0, + media_type, media_id, media_text); + + return TRUE; +} + +/** * pk_backend_repo_detail: **/ gboolean @@ -1912,6 +1942,11 @@ pk_backend_class_init (PkBackendClass *klass) 0, NULL, NULL, pk_marshal_VOID__STRING_STRING_STRING_STRING, G_TYPE_NONE, 4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); + signals [PK_BACKEND_MEDIA_CHANGE_REQUIRED] = + g_signal_new ("media-change-required", + G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST, + 0, NULL, NULL, pk_marshal_VOID__UINT_STRING_STRING, + G_TYPE_NONE, 3, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING); signals [PK_BACKEND_FINISHED] = g_signal_new ("finished", G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST, diff --git a/src/pk-backend.h b/src/pk-backend.h index 9e842202a..103a57593 100644 --- a/src/pk-backend.h +++ b/src/pk-backend.h @@ -141,6 +141,10 @@ gboolean pk_backend_eula_required (PkBackend *backend, const gchar *package_id, const gchar *vendor_name, const gchar *license_agreement); +gboolean pk_backend_media_change_required (PkBackend *backend, + PkMediaTypeEnum media_type, + const gchar *media_id, + const gchar *media_text); gboolean pk_backend_category (PkBackend *backend, const gchar *parent_id, const gchar *cat_id, diff --git a/src/pk-transaction.c b/src/pk-transaction.c index ab26050f7..912fe0425 100644 --- a/src/pk-transaction.c +++ b/src/pk-transaction.c @@ -84,6 +84,7 @@ struct PkTransactionPrivate gboolean allow_cancel; gboolean emit_eula_required; gboolean emit_signature_required; + gboolean emit_media_change_required; gchar *locale; guint uid; EggDbusMonitor *monitor; @@ -139,6 +140,7 @@ struct PkTransactionPrivate guint signal_repo_detail; guint signal_repo_signature_required; guint signal_eula_required; + guint signal_media_change_required; guint signal_require_restart; guint signal_status_changed; guint signal_update_detail; @@ -159,6 +161,7 @@ enum { PK_TRANSACTION_REPO_DETAIL, PK_TRANSACTION_REPO_SIGNATURE_REQUIRED, PK_TRANSACTION_EULA_REQUIRED, + PK_TRANSACTION_MEDIA_CHANGE_REQUIRED, PK_TRANSACTION_REQUIRE_RESTART, PK_TRANSACTION_STATUS_CHANGED, PK_TRANSACTION_TRANSACTION, @@ -553,6 +556,7 @@ pk_transaction_finished_cb (PkBackend *backend, PkExitEnum exit_enum, PkTransact g_signal_handler_disconnect (transaction->priv->backend, transaction->priv->signal_repo_detail); g_signal_handler_disconnect (transaction->priv->backend, transaction->priv->signal_repo_signature_required); g_signal_handler_disconnect (transaction->priv->backend, transaction->priv->signal_eula_required); + g_signal_handler_disconnect (transaction->priv->backend, transaction->priv->signal_media_change_required); g_signal_handler_disconnect (transaction->priv->backend, transaction->priv->signal_update_detail); g_signal_handler_disconnect (transaction->priv->backend, transaction->priv->signal_category); @@ -652,6 +656,8 @@ pk_transaction_finished_cb (PkBackend *backend, PkExitEnum exit_enum, PkTransact exit_enum = PK_EXIT_ENUM_KEY_REQUIRED; else if (transaction->priv->emit_eula_required) exit_enum = PK_EXIT_ENUM_EULA_REQUIRED; + else if (transaction->priv->emit_media_change_required) + exit_enum = PK_EXIT_ENUM_MEDIA_CHANGE_REQUIRED; /* invalidate some caches if we succeeded */ if (exit_enum == PK_EXIT_ENUM_SUCCESS) @@ -884,6 +890,32 @@ pk_transaction_eula_required_cb (PkBackend *backend, const gchar *eula_id, const } /** + * pk_transaction_media_change_required_cb: + **/ +static void +pk_transaction_media_change_required_cb (PkBackend *backend, + PkMediaTypeEnum media_type, + const gchar *media_id, + const gchar *media_text, + PkTransaction *transaction) +{ + const gchar *media_type_text; + + g_return_if_fail (PK_IS_TRANSACTION (transaction)); + g_return_if_fail (transaction->priv->tid != NULL); + + media_type_text = pk_media_type_enum_to_text (media_type); + + egg_debug ("emitting media-change-required %s, %s, %s", + media_type_text, media_id, media_text); + g_signal_emit (transaction, signals [PK_TRANSACTION_MEDIA_CHANGE_REQUIRED], 0, + media_type, media_id, media_text); + + /* we should mark this transaction so that we finish with a special code */ + transaction->priv->emit_media_change_required = TRUE; +} + +/** * pk_transaction_require_restart_cb: **/ static void @@ -1036,6 +1068,9 @@ pk_transaction_set_running (PkTransaction *transaction) transaction->priv->signal_eula_required = g_signal_connect (transaction->priv->backend, "eula-required", G_CALLBACK (pk_transaction_eula_required_cb), transaction); + transaction->priv->signal_media_change_required = + g_signal_connect (transaction->priv->backend, "media-change-required", + G_CALLBACK (pk_transaction_media_change_required_cb), transaction); transaction->priv->signal_require_restart = g_signal_connect (transaction->priv->backend, "require-restart", G_CALLBACK (pk_transaction_require_restart_cb), transaction); @@ -3831,6 +3866,11 @@ pk_transaction_class_init (PkTransactionClass *klass) G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST, 0, NULL, NULL, pk_marshal_VOID__STRING_STRING_STRING_STRING, G_TYPE_NONE, 4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); + signals [PK_TRANSACTION_MEDIA_CHANGE_REQUIRED] = + g_signal_new ("media-change-required", + G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST, + 0, NULL, NULL, pk_marshal_VOID__UINT_STRING_STRING, + G_TYPE_NONE, 3, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING); signals [PK_TRANSACTION_REQUIRE_RESTART] = g_signal_new ("require-restart", G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST, @@ -3877,6 +3917,7 @@ pk_transaction_init (PkTransaction *transaction) transaction->priv->allow_cancel = TRUE; transaction->priv->emit_eula_required = FALSE; transaction->priv->emit_signature_required = FALSE; + transaction->priv->emit_media_change_required = FALSE; transaction->priv->cached_enabled = FALSE; transaction->priv->cached_key_id = NULL; transaction->priv->cached_package_id = NULL; |