void FServiceConnection::Initialize( const FProfilerServiceAuthorize2& Message, const IMessageContextRef& Context )
{
#if STATS
	ServiceAddress = Context->GetSender();
	InstanceId = Message.InstanceId;
	CurrentData.Frame = 0;

	// add the supplied meta data
	FArrayReader ArrayReader(true);
	ArrayReader.Append(Message.Data);

	MetaData.CriticalSection = &CriticalSection;
	int64 Size = ArrayReader.TotalSize();

	// read in the magic, at some point may need to know what it actually is
	uint32 Magic = 0;
	ArrayReader << Magic;

	// read in the data
	TArray<FStatMessage> StatMessages;
	{
		SCOPE_CYCLE_COUNTER(STAT_PC_ReadStatMessages);
		while(ArrayReader.Tell() < Size)
		{
			// read the message
			new (StatMessages) FStatMessage(Stream.ReadMessage(ArrayReader));
		}
		static FStatNameAndInfo Adv(NAME_AdvanceFrame, "", TEXT(""), EStatDataType::ST_int64, true, false);
		new (StatMessages) FStatMessage(Adv.GetEncodedName(), EStatOperation::AdvanceFrameEventGameThread, 1LL, false);
	}

	// generate a thread state from the data
	{
		SCOPE_CYCLE_COUNTER(STAT_PC_AddStatMessages);
		CurrentThreadState.AddMessages(StatMessages);
	}

	UpdateMetaData();
#endif
}
void MythNotificationScreen::SetNotification(MythNotification &notification)
{
    bool update;
    m_update = kNone;

    m_type = notification.type();

    if (m_type == MythNotification::Error   ||
        m_type == MythNotification::Warning ||
        m_type == MythNotification::Check ||
        m_type == MythNotification::Busy)
    {
        m_update |= kImage;
        update = false;
    }
    else if (m_type == MythNotification::Update)
    {
        update = true;
    }
    else
    {
        update = false;
    }

    MythImageNotification *img =
        dynamic_cast<MythImageNotification*>(&notification);
    if (img)
    {
        QString path = img->GetImagePath();

        m_update |= kImage;

        if (path.isNull())
        {
            UpdateArtwork(img->GetImage());
        }
        else
        {
            UpdateArtwork(path);
        }
    }

    MythPlaybackNotification *play =
        dynamic_cast<MythPlaybackNotification*>(&notification);
    if (play)
    {
        UpdatePlayback(play->GetProgress(), play->GetProgressText());

        m_update |= kDuration;
    }

    MythMediaNotification *media =
        dynamic_cast<MythMediaNotification*>(&notification);
    if (media && m_imagePath.isEmpty() && m_image.isNull())
    {
        m_update |= kNoArtwork;
    }

    if (!notification.GetMetaData().isEmpty())
    {
        UpdateMetaData(notification.GetMetaData());
        m_update  |= kMetaData;
    }
    else if (!update)
    {
        // A new notification, will always update the metadata field
        m_update |= kMetaData;
    }

    if (!notification.GetStyle().isEmpty())
    {
        m_style = notification.GetStyle();
        m_update |= kStyle;
    }

    if (!update)
    {
        m_content = m_update;
        m_fullscreen = notification.GetFullScreen();
    }

    m_duration      = notification.GetDuration();
    m_visibility    = notification.GetVisibility();
    if (!m_visibility)
    {
        // no visibility is all visibility to get around QVariant always making 0 the default
        m_visibility = ~0;
    }
    m_priority      = notification.GetPriority();

    // Set timer if need be
    SetSingleShotTimer(m_duration, update);

    // We need to re-run init
    m_refresh = true;
}