+ $self->communigate_pro_queue( $svc_domain->svcnum, 'DeleteDomain',
+ $svc_domain->domain,
+ #XXX turn on force option for domain deletion?
+ );
+}
+
+sub _export_delete_svc_forward {
+ my( $self, $svc_forward ) = (shift, shift);
+
+ $self->communigate_pro_queue( $svc_forward->svcnum, 'DeleteForwarder',
+ ($svc_forward->src || $svc_forward->srcsvc_acct->email),
+ );
+}
+
+sub _export_delete_svc_mailinglist {
+ my( $self, $svc_mailinglist ) = (shift, shift);
+
+ #real-time here, presuming CGP does some dup detection
+ eval { $self->communigate_pro_runcommand(
+ 'DeleteGroup',
+ $svc_mailinglist->username.'@'.$svc_mailinglist->domain,
+ );
+ };
+ return $@ if $@;
+
+ '';
+
+}
+
+sub _export_suspend {
+ my( $self, $svc_x ) = (shift, shift);
+
+ my $table = $svc_x->table;
+ my $method = "_export_suspend_$table";
+ $self->$method($svc_x, @_);
+
+}
+
+sub _export_suspend_svc_acct {
+ my( $self, $svc_acct ) = (shift, shift);
+
+ #XXX is this the desired suspnsion action?
+
+ $self->communigate_pro_queue(
+ $svc_acct->svcnum,
+ 'UpdateAccountSettings',
+ $self->export_username($svc_acct),
+ 'AccessModes' => 'Mail',
+ );
+
+}
+
+sub _export_suspend_svc_domain {
+ my( $self, $svc_domain) = (shift, shift);
+
+ #XXX domain operations
+ '';
+
+}
+
+sub _export_unsuspend {
+ my( $self, $svc_x ) = (shift, shift);
+
+ my $table = $svc_x->table;
+ my $method = "_export_unsuspend_$table";
+ $self->$method($svc_x, @_);
+
+}
+
+sub _export_unsuspend_svc_acct {
+ my( $self, $svc_acct ) = (shift, shift);
+
+ $self->communigate_pro_queue(
+ $svc_acct->svcnum,
+ 'UpdateAccountSettings',
+ $self->export_username($svc_acct),
+ 'AccessModes' => ( $svc_acct->cgp_accessmodes
+ || $self->option('AccessModes') ),
+ );
+
+}
+
+sub _export_unsuspend_svc_domain {
+ my( $self, $svc_domain) = (shift, shift);
+
+ #XXX domain operations
+ '';
+
+}
+
+sub export_mailinglistmember_insert {
+ my( $self, $svc_mailinglist, $mailinglistmember ) = (shift, shift, shift);
+ $svc_mailinglist->replace();
+}
+
+sub export_mailinglistmember_replace {
+ my( $self, $svc_mailinglist, $new, $old ) = (shift, shift, shift, shift);
+ die "no way to do this from the UI right now";
+}
+
+sub export_mailinglistmember_delete {
+ my( $self, $svc_mailinglist, $mailinglistmember ) = (shift, shift, shift);
+ $svc_mailinglist->replace();
+}
+
+sub export_getsettings {
+ my($self, $svc_x) = (shift, shift);
+
+ my $table = $svc_x->table;
+ my $method = "export_getsettings_$table";
+
+ $self->can($method) ? $self->$method($svc_x, @_) : '';
+
+}
+
+sub export_getsettings_svc_domain {
+ my($self, $svc_domain, $settingsref, $defaultref ) = @_;
+
+ my $settings = eval { $self->communigate_pro_runcommand(
+ 'GetDomainSettings',
+ $svc_domain->domain
+ ) };
+ return $@ if $@;
+
+ my $effective_settings = eval { $self->communigate_pro_runcommand(
+ 'GetDomainEffectiveSettings',
+ $svc_domain->domain
+ ) };
+ return $@ if $@;
+
+ my $acct_defaults = eval { $self->communigate_pro_runcommand(
+ 'GetAccountDefaults',
+ $svc_domain->domain
+ ) };
+ return $@ if $@;
+
+ my $acct_defaultprefs = eval { $self->communigate_pro_runcommand(
+ 'GetAccountDefaultPrefs',
+ $svc_domain->domain
+ ) };
+ return $@ if $@;
+
+ my $rules = eval { $self->communigate_pro_runcommand(
+ 'GetDomainMailRules',
+ $svc_domain->domain
+ ) };
+ return $@ if $@;
+
+ #aliases too
+ my $aliases = eval { $self->communigate_pro_runcommand(
+ 'GetDomainAliases',
+ $svc_domain->domain
+ ) };
+ return $@ if $@;
+
+ my %more = (
+ ( map { ("Acct. Default $_" => $acct_defaults->{$_}); }
+ keys(%$acct_defaults)
+ ),
+ ( map { ("Acct. Default $_" => $acct_defaultprefs->{$_}); } #diff label??
+ keys(%$acct_defaultprefs)
+ ),
+ ( map _rule2string($_), @$rules ),
+ 'Aliases' => join(', ', @$aliases),
+ );
+
+ %$effective_settings = ( %$effective_settings, %more );
+ %$settings = ( %$settings, %more );
+
+ #false laziness w/below
+
+ my %defaults = map { $_ => 1 }
+ grep !exists(${$settings}{$_}), keys %$effective_settings;
+
+ foreach my $key ( grep ref($effective_settings->{$_}),
+ keys %$effective_settings )
+ {
+ $effective_settings->{$key} = _pretty( $effective_settings->{$key} );
+ }
+
+ %{$settingsref} = %$effective_settings;
+ %{$defaultref} = %defaults;
+
+ '';
+}
+
+sub export_getsettings_svc_acct {
+ my($self, $svc_acct, $settingsref, $defaultref ) = @_;
+
+ my $settings = eval { $self->communigate_pro_runcommand(
+ 'GetAccountSettings',
+ $svc_acct->email
+ ) };
+ return $@ if $@;
+
+ delete($settings->{'Password'});
+
+ my $effective_settings = eval { $self->communigate_pro_runcommand(
+ 'GetAccountEffectiveSettings',
+ $svc_acct->email
+ ) };
+ return $@ if $@;
+
+ delete($effective_settings->{'Password'});
+
+ #prefs/effectiveprefs too
+
+ my $prefs = eval { $self->communigate_pro_runcommand(
+ 'GetAccountPrefs',
+ $svc_acct->email
+ ) };
+ return $@ if $@;
+
+ my $effective_prefs = eval { $self->communigate_pro_runcommand(
+ 'GetAccountEffectivePrefs',
+ $svc_acct->email
+ ) };
+ return $@ if $@;
+
+ %$effective_settings = ( %$effective_settings,
+ map { ("Pref $_" => $effective_prefs->{$_}); }
+ keys(%$effective_prefs)
+ );
+ %$settings = ( %$settings,
+ map { ("Pref $_" => $prefs->{$_}); }
+ keys(%$prefs)
+ );
+
+ #mail rules
+ my $rules = eval { $self->communigate_pro_runcommand(
+ 'GetAccountMailRules',
+ $svc_acct->email
+ ) };
+ return $@ if $@;
+
+ %$effective_settings = ( %$effective_settings,
+ map _rule2string($_), @$rules
+ );
+ %$settings = ( %$settings,
+ map _rule2string($_), @$rules
+ );
+
+# #rpops too
+# my $rpops = eval { $self->communigate_pro_runcommand(
+# 'GetAccountRPOPs',
+# $svc_acct->email
+# ) };
+# return $@ if $@;
+#
+# %$effective_settings = ( %$effective_settings,
+# map _rpop2string($_), %$rpops
+# );
+# %$settings = ( %$settings,
+# map _rpop2string($_), %rpops
+# );
+
+ #aliases too
+ my $aliases = eval { $self->communigate_pro_runcommand(
+ 'GetAccountAliases',
+ $svc_acct->email
+ ) };
+ return $@ if $@;
+
+ $effective_settings->{'Aliases'} = join(', ', @$aliases);
+ $settings->{'Aliases'} = join(', ', @$aliases);
+
+ #false laziness w/above
+
+ my %defaults = map { $_ => 1 }
+ grep !exists(${$settings}{$_}), keys %$effective_settings;
+
+ foreach my $key ( grep ref($effective_settings->{$_}),
+ keys %$effective_settings )
+ {
+ $effective_settings->{$key} = _pretty( $effective_settings->{$key} );
+ }
+
+ %{$settingsref} = %$effective_settings;
+ %{$defaultref} = %defaults;
+
+ '';
+
+}
+
+sub _pretty {
+ my $value = shift;
+ if ( ref($value) eq 'ARRAY' ) {
+ '['. join(' ', map { ref($_) ? _pretty($_) : $_ } @$value ). ']';
+ } elsif ( ref($value) eq 'HASH' ) {
+ '{'. join(', ',
+ map { my $v = $value->{$_};
+ "$_:". ( ref($v) ? _pretty($v) : $v );
+ }
+ keys %$value
+ ). '}';
+ } else {
+ warn "serializing ". ref($value). " for table display not yet handled";
+ }
+}
+
+sub export_getsettings_svc_forward {
+ my($self, $svc_forward, $settingsref, $defaultref ) = @_;
+
+ my $dest = eval { $self->communigate_pro_runcommand(
+ 'GetForwarder',
+ ($svc_forward->src || $svc_forward->srcsvc_acct->email),
+ ) };
+ return $@ if $@;
+
+ my $settings = { 'Destination' => $dest };
+
+ %{$settingsref} = %$settings;
+ %{$defaultref} = ();
+
+ '';
+}
+
+sub _rule2string {
+ my $rule = shift;
+ my($priority, $name, $conditions, $actions, $comment) = @$rule;
+ $conditions = join(', ', map { my $a = $_; join(' ', @$a); } @$conditions);
+ $actions = join(', ', map { my $a = $_; join(' ', @$a); } @$actions);
+ ("Mail rule $name" => "$priority IF $conditions THEN $actions ($comment)");
+}
+
+#sub _rpop2string {
+# my $rpop = shift;
+# my($priority, $name, $conditions, $actions, $comment) = @$rule;
+# $conditions = join(', ', map { my $a = $_; join(' ', @$a); } @$conditions);
+# $actions = join(', ', map { my $a = $_; join(' ', @$a); } @$actions);
+# ("Mail rule $name" => "$priority IF $conditions THEN $actions ($comment)");