+# take the output of get_state() and set up a message internally like
+# parse_message (except from a saved data struct, not by parsing the
+# files on disk).
+sub restore_state {
+ my $self = shift;
+ my $h = shift;
+
+ return(1) if ($h->{_delivered});
+ $self->_reset();
+ $self->{_message} = $h->{_message} || return(0);
+ return(0) if (!$self->{_spool_dir});
+
+ $self->{_path} = $h->{_path};
+ $self->{_vars} = $h->{_vars};
+ $self->{_numrecips} = $h->{_numrecips};
+ $self->{_udel_tree} = $h->{_udel_tree};
+ $self->{_del_tree} = $h->{_del_tree};
+ $self->{_recips} = $h->{_recips};
+
+ $self->{_vars}{message_age} = time() - $self->{_vars}{received_time};
+ return(1);
+}
+
+# This returns the state data for a specific message in a format that can
+# be later frozen back in to regain state
+#
+# after calling this function, this specific state is not expect to be
+# reused. That's because we're returning direct references to specific
+# internal structures. We're also modifying the structure ourselves
+# by deleting certain internal message variables.
+sub get_state {
+ my $self = shift;
+ my $h = {}; # this is the hash ref we'll be returning.
+
+ $h->{_delivered} = $self->{_delivered};
+ $h->{_message} = $self->{_message};
+ $h->{_path} = $self->{_path};
+ $h->{_vars} = $self->{_vars};
+ $h->{_numrecips} = $self->{_numrecips};
+ $h->{_udel_tree} = $self->{_udel_tree};
+ $h->{_del_tree} = $self->{_del_tree};
+ $h->{_recips} = $self->{_recips};
+
+ # delete some internal variables that we will rebuild later if needed
+ delete($h->{_vars}{message_body});
+ delete($h->{_vars}{message_age});
+
+ return($h);
+}
+
+# keep this sub as a feature if we ever break this module out, but do away
+# with its use in exipick (pass it in from caller instead)