summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Strode <rstrode@redhat.com>2007-05-06 12:08:25 -0400
committerRay Strode <rstrode@redhat.com>2007-05-06 12:08:25 -0400
commitb0131ce58292cf3198054e8597e0c2762d6bb966 (patch)
treec9b04b48871931e01cf68fee0feafdd3b13e3797
parent1ce7598de0e5eaf4f2f5f06a86b9ae86906cbf59 (diff)
move some functions around so that public functions
are at the bottom.
-rw-r--r--src/pop-transaction.c394
1 files changed, 197 insertions, 197 deletions
diff --git a/src/pop-transaction.c b/src/pop-transaction.c
index 0c7bebe..5938fcd 100644
--- a/src/pop-transaction.c
+++ b/src/pop-transaction.c
@@ -389,25 +389,6 @@ pop_transaction_get_property (GObject *object,
}
}
-PopTransaction *
-pop_transaction_new (void)
-{
- PopTransaction *transaction;
-
- transaction = g_object_new (POP_TYPE_TRANSACTION, NULL);
-
- return transaction;
-}
-
-PopTransactionStatus
-pop_transaction_get_status (PopTransaction *transaction)
-{
- g_return_val_if_fail (POP_IS_TRANSACTION (transaction),
- POP_TRANSACTION_STATUS_FAILED);
-
- return transaction->priv->status;
-}
-
static void
pop_transaction_set_status (PopTransaction *transaction,
PopTransactionStatus status)
@@ -454,48 +435,6 @@ pop_action_free (PopAction *action)
g_slice_free (PopAction, action);
}
-void
-pop_transaction_add_action_full (PopTransaction *transaction,
- PopActionProcessFunc action_process_func,
- PopActionRollbackFunc action_rollback_func,
- gpointer user_data,
- GDestroyNotify free_func)
-{
- PopAction *action;
-
- g_return_if_fail (POP_IS_TRANSACTION (transaction));
-
- action = pop_action_new (action_process_func, action_rollback_func, user_data,
- free_func);
-
- if (transaction->priv->current_action_node == NULL)
- {
- g_queue_push_tail (transaction->priv->actions, action);
- }
- else
- {
- gboolean can_rewind;
-
- g_queue_insert_before (transaction->priv->actions,
- transaction->priv->current_action_node,
- action);
- can_rewind = pop_transaction_rewind (transaction);
-
- g_assert (can_rewind);
- }
-}
-
-void
-pop_transaction_add_action (PopTransaction *transaction,
- PopActionProcessFunc action_process_func,
- PopActionRollbackFunc action_rollback_func,
- gpointer user_data)
-{
- pop_transaction_add_action_full (transaction, action_process_func,
- action_rollback_func,
- user_data, NULL);
-}
-
static PopActionProcessStatus
pop_transaction_process_subtransaction (PopTransaction *transaction,
PopTransaction *subtransaction)
@@ -570,80 +509,6 @@ pop_transaction_rollback_subtransaction (PopTransaction *transaction,
return POP_ACTION_ROLLBACK_STATUS_FINISHED;
}
-void
-pop_transaction_add_subtransaction (PopTransaction *transaction,
- PopTransaction *subtransaction)
-{
- g_return_if_fail (POP_IS_TRANSACTION (transaction));
- g_return_if_fail (POP_IS_TRANSACTION (subtransaction));
- g_return_if_fail (!pop_transaction_is_committed (subtransaction));
-
- pop_transaction_add_action_full (transaction,
- (PopActionProcessFunc)
- pop_transaction_process_subtransaction,
- (PopActionRollbackFunc)
- pop_transaction_rollback_subtransaction,
- g_object_ref (subtransaction),
- (GDestroyNotify) g_object_unref);
-}
-
-void
-pop_transaction_resume (PopTransaction *transaction)
-{
- g_assert (POP_IS_TRANSACTION (transaction));
-
- switch (transaction->priv->state)
- {
- case POP_TRANSACTION_STATE_PROCESSING:
- pop_transaction_process_on_idle (transaction);
- break;
-
- case POP_TRANSACTION_STATE_ROLLING_BACK:
- pop_transaction_rollback_on_idle (transaction);
- break;
-
- default:
- break;
- }
-
- if (transaction->priv->wait_id != 0)
- {
- g_source_remove (transaction->priv->wait_id);
- transaction->priv->wait_id = 0;
- }
-
- g_signal_emit (transaction, pop_transaction_signals[RESUME], 0);
-}
-
-void
-pop_transaction_wait (PopTransaction *transaction)
-{
- g_return_if_fail (POP_IS_TRANSACTION (transaction));
- g_return_if_fail (pop_transaction_is_running_action (transaction));
-
- switch (transaction->priv->state)
- {
- case POP_TRANSACTION_STATE_PROCESSING:
- g_assert (transaction->priv->process_idle_id != 0);
- g_assert (transaction->priv->rollback_idle_id == 0);
- g_source_remove (transaction->priv->process_idle_id);
- transaction->priv->process_idle_id = 0;
- break;
-
- case POP_TRANSACTION_STATE_ROLLING_BACK:
- g_assert (transaction->priv->rollback_idle_id != 0);
- g_assert (transaction->priv->process_idle_id == 0);
- g_source_remove (transaction->priv->rollback_idle_id);
- transaction->priv->rollback_idle_id = 0;
- break;
-
- default:
- break;
- }
-
- g_signal_emit (transaction, pop_transaction_signals[WAIT], 0);
-}
-
static gboolean
pop_transaction_on_fd_ready_resume (GIOChannel *channel,
GIOCondition condition,
@@ -659,32 +524,6 @@ pop_transaction_on_fd_ready_resume (GIOChannel *channel,
return FALSE;
}
-void
-pop_transaction_wait_for_fd (PopTransaction *transaction,
- int fd,
- GIOCondition condition,
- GDestroyNotify destroy_notify)
-{
- GIOChannel *channel;
- GSource *source;
-
- g_return_if_fail (POP_IS_TRANSACTION (transaction));
- g_return_if_fail (pop_transaction_is_running_action (transaction));
-
- pop_transaction_wait (transaction);
-
- channel = g_io_channel_unix_new (fd);
- g_io_channel_set_buffered (channel, FALSE);
- source = g_io_create_watch (channel, condition);
- g_source_set_callback (source,
- (GSourceFunc) pop_transaction_on_fd_ready_resume,
- transaction, NULL);
- transaction->priv->wait_id = g_source_attach (source,
- transaction->priv->context);
- g_source_unref (source);
- g_io_channel_unref (channel);
-}
-
static gboolean
pop_transaction_on_timeout_resume (gpointer data)
{
@@ -699,26 +538,6 @@ pop_transaction_on_timeout_resume (gpointer data)
return FALSE;
}
-void
-pop_transaction_wait_a_while (PopTransaction *transaction,
- int milliseconds)
-{
- GSource *source;
-
- g_return_if_fail (POP_IS_TRANSACTION (transaction));
- g_return_if_fail (pop_transaction_is_running_action (transaction));
-
- pop_transaction_wait (transaction);
-
- source = g_timeout_source_new (milliseconds);
- g_source_set_callback (source,
- (GSourceFunc) pop_transaction_on_timeout_resume,
- transaction, NULL);
- transaction->priv->wait_id = g_source_attach (source,
- transaction->priv->context);
- g_source_unref (source);
-}
-
static guint
pop_transaction_call_on_idle (PopTransaction *transaction,
PopTransactionIdleFunc callback)
@@ -1000,16 +819,6 @@ pop_transaction_is_attached (PopTransaction *transaction)
return transaction->priv->context != NULL;
}
-void
-pop_transaction_attach (PopTransaction *transaction,
- GMainContext *context)
-{
- g_return_if_fail (POP_IS_TRANSACTION (transaction));
- g_return_if_fail (!pop_transaction_is_attached (transaction));
-
- transaction->priv->context = g_main_context_ref (context);
-}
-
static gboolean
pop_transaction_is_empty (PopTransaction *transaction)
{
@@ -1026,6 +835,203 @@ pop_transaction_is_committed (PopTransaction *transaction)
return transaction->priv->state >= POP_TRANSACTION_STATE_COMMITED;
}
+static gboolean
+pop_transaction_is_finished (PopTransaction *transaction)
+{
+ return transaction->priv->state == POP_TRANSACTION_STATE_FINISHED;
+}
+
+PopTransaction *
+pop_transaction_new (void)
+{
+ PopTransaction *transaction;
+
+ transaction = g_object_new (POP_TYPE_TRANSACTION, NULL);
+
+ return transaction;
+}
+
+PopTransactionStatus
+pop_transaction_get_status (PopTransaction *transaction)
+{
+ g_return_val_if_fail (POP_IS_TRANSACTION (transaction),
+ POP_TRANSACTION_STATUS_FAILED);
+
+ return transaction->priv->status;
+}
+
+void
+pop_transaction_add_action_full (PopTransaction *transaction,
+ PopActionProcessFunc action_process_func,
+ PopActionRollbackFunc action_rollback_func,
+ gpointer user_data,
+ GDestroyNotify free_func)
+{
+ PopAction *action;
+
+ g_return_if_fail (POP_IS_TRANSACTION (transaction));
+
+ action = pop_action_new (action_process_func, action_rollback_func, user_data,
+ free_func);
+
+ if (transaction->priv->current_action_node == NULL)
+ {
+ g_queue_push_tail (transaction->priv->actions, action);
+ }
+ else
+ {
+ gboolean can_rewind;
+
+ g_queue_insert_before (transaction->priv->actions,
+ transaction->priv->current_action_node,
+ action);
+ can_rewind = pop_transaction_rewind (transaction);
+
+ g_assert (can_rewind);
+ }
+}
+
+void
+pop_transaction_add_action (PopTransaction *transaction,
+ PopActionProcessFunc action_process_func,
+ PopActionRollbackFunc action_rollback_func,
+ gpointer user_data)
+{
+ pop_transaction_add_action_full (transaction, action_process_func,
+ action_rollback_func,
+ user_data, NULL);
+}
+
+void
+pop_transaction_add_subtransaction (PopTransaction *transaction,
+ PopTransaction *subtransaction)
+{
+ g_return_if_fail (POP_IS_TRANSACTION (transaction));
+ g_return_if_fail (POP_IS_TRANSACTION (subtransaction));
+ g_return_if_fail (!pop_transaction_is_committed (subtransaction));
+
+ pop_transaction_add_action_full (transaction,
+ (PopActionProcessFunc)
+ pop_transaction_process_subtransaction,
+ (PopActionRollbackFunc)
+ pop_transaction_rollback_subtransaction,
+ g_object_ref (subtransaction),
+ (GDestroyNotify) g_object_unref);
+}
+
+void
+pop_transaction_resume (PopTransaction *transaction)
+{
+ g_assert (POP_IS_TRANSACTION (transaction));
+
+ switch (transaction->priv->state)
+ {
+ case POP_TRANSACTION_STATE_PROCESSING:
+ pop_transaction_process_on_idle (transaction);
+ break;
+
+ case POP_TRANSACTION_STATE_ROLLING_BACK:
+ pop_transaction_rollback_on_idle (transaction);
+ break;
+
+ default:
+ break;
+ }
+
+ if (transaction->priv->wait_id != 0)
+ {
+ g_source_remove (transaction->priv->wait_id);
+ transaction->priv->wait_id = 0;
+ }
+
+ g_signal_emit (transaction, pop_transaction_signals[RESUME], 0);
+}
+
+void
+pop_transaction_wait (PopTransaction *transaction)
+{
+ g_return_if_fail (POP_IS_TRANSACTION (transaction));
+ g_return_if_fail (pop_transaction_is_running_action (transaction));
+
+ switch (transaction->priv->state)
+ {
+ case POP_TRANSACTION_STATE_PROCESSING:
+ g_assert (transaction->priv->process_idle_id != 0);
+ g_assert (transaction->priv->rollback_idle_id == 0);
+ g_source_remove (transaction->priv->process_idle_id);
+ transaction->priv->process_idle_id = 0;
+ break;
+
+ case POP_TRANSACTION_STATE_ROLLING_BACK:
+ g_assert (transaction->priv->rollback_idle_id != 0);
+ g_assert (transaction->priv->process_idle_id == 0);
+ g_source_remove (transaction->priv->rollback_idle_id);
+ transaction->priv->rollback_idle_id = 0;
+ break;
+
+ default:
+ break;
+ }
+
+ g_signal_emit (transaction, pop_transaction_signals[WAIT], 0);
+}
+
+void
+pop_transaction_wait_for_fd (PopTransaction *transaction,
+ int fd,
+ GIOCondition condition,
+ GDestroyNotify destroy_notify)
+{
+ GIOChannel *channel;
+ GSource *source;
+
+ g_return_if_fail (POP_IS_TRANSACTION (transaction));
+ g_return_if_fail (pop_transaction_is_running_action (transaction));
+
+ pop_transaction_wait (transaction);
+
+ channel = g_io_channel_unix_new (fd);
+ g_io_channel_set_buffered (channel, FALSE);
+ source = g_io_create_watch (channel, condition);
+ g_source_set_callback (source,
+ (GSourceFunc) pop_transaction_on_fd_ready_resume,
+ transaction, NULL);
+ transaction->priv->wait_id = g_source_attach (source,
+ transaction->priv->context);
+ g_source_unref (source);
+ g_io_channel_unref (channel);
+}
+
+void
+pop_transaction_wait_a_while (PopTransaction *transaction,
+ int milliseconds)
+{
+ GSource *source;
+
+ g_return_if_fail (POP_IS_TRANSACTION (transaction));
+ g_return_if_fail (pop_transaction_is_running_action (transaction));
+
+ pop_transaction_wait (transaction);
+
+ source = g_timeout_source_new (milliseconds);
+ g_source_set_callback (source,
+ (GSourceFunc) pop_transaction_on_timeout_resume,
+ transaction, NULL);
+ transaction->priv->wait_id = g_source_attach (source,
+ transaction->priv->context);
+ g_source_unref (source);
+}
+
+void
+pop_transaction_attach (PopTransaction *transaction,
+ GMainContext *context)
+{
+ g_return_if_fail (POP_IS_TRANSACTION (transaction));
+ g_return_if_fail (!pop_transaction_is_attached (transaction));
+
+ transaction->priv->context = g_main_context_ref (context);
+}
+
void
pop_transaction_commit (PopTransaction *transaction)
{
@@ -1038,12 +1044,6 @@ pop_transaction_commit (PopTransaction *transaction)
transaction->priv->state = POP_TRANSACTION_STATE_COMMITED;
}
-static gboolean
-pop_transaction_is_finished (PopTransaction *transaction)
-{
- return transaction->priv->state == POP_TRANSACTION_STATE_FINISHED;
-}
-
void
pop_transaction_cancel (PopTransaction *transaction)
{