/**
 * Send a message back to all objects that have requested creation of
 * a specific preview.
 *
 * \param[in] pginfo The program info structure from which the preview
 *            was generated.
 * \param[in] eventname The name of the event being sent to all
 *            listeners.  This will always be one of PREVIEW_FAILED,
 *            PREVIEW_QUEUED, or PREVIEW_SUCCESS.
 * \param[in] filename For a SUCCESS message, this is the name of the
 *            newly generated preview file. For a QUEUED message, this
 *            is an empty string. For a FAILED message, this will be
 *            the internal key value.
 * \param[in] token The token specified by the listener when it
 *            requested the preview generation.
 * \param[in] msg A text string giving more information about the
 *            processing of the event.
 * \param[in] dt For a PREVIEW_SUCCESS message, this is the the last
 *            modified time of the preview file.  For the other
 *            messages, this is a null datetime.
 */
void PreviewGeneratorQueue::SendEvent(
    const ProgramInfo &pginfo,
    const QString &eventname,
    const QString &filename, const QString &token, const QString &msg,
    const QDateTime &dt)
{
    QStringList list;
    list.push_back(QString::number(pginfo.GetRecordingID()));
    list.push_back(filename);
    list.push_back(msg);
    list.push_back(dt.toUTC().toString(Qt::ISODate));
    list.push_back(token);

    QMutexLocker locker(&m_lock);
    QSet<QObject*>::iterator it = m_listeners.begin();
    for (; it != m_listeners.end(); ++it)
    {
        MythEvent *e = new MythEvent(eventname, list);
        QCoreApplication::postEvent(*it, e);
    }
}