from parallels.core.global_context import GlobalMigrationContext
from parallels.core.logging import get_logger
from parallels.core.utils.common import cached
from parallels.plesk.source.mail.migrated_mail_address_pair import MigratedMailAddressPair

logger = get_logger(__name__)


class MailGlobalMigrationContext(GlobalMigrationContext):
    """
    :type session_files: parallels.plesk.source.mail.session_files.MailSessionFiles
    :type migration_list_mail_address_pair: parallels.plesk.source.mail.mail_migration_list.MigrationListMailAddressPair
    :type conn: parallels.plesk.source.mail.connections.MailConnections
    :type status_storage: parallels.plesk.source.mail.status_storage.StatusStorage
    :type settings_storage: parallels.plesk.source.mail.settings_storage.SettingsStorage
    :type target_subscription_name: str | unicode | None
    :type statistics_transfer_mail: parallels.plesk.source.mail.statistics.StatisticsTransferMail
    """
    def __init__(self):
        super(MailGlobalMigrationContext, self).__init__()
        self.session_files = None
        self.migration_list_mail_address_pair = None
        self.conn = None
        self.status_storage = None
        self.settings_storage = None
        self.target_subscription_name = None
        self.statistics_transfer_mail = None

    @property
    @cached
    def migrated_mail_address_pair(self):
        """
        :rtype: parallels.plesk.source.mail.migrated_mail_address_pair.MigratedMailAddressPair
        """
        return MigratedMailAddressPair(self, self.migration_list_mail_address_pair)
