File indexing completed on 2024-04-28 04:55:54

0001 /*
0002     This file is part of Choqok, the KDE micro-blogging client
0003 
0004     SPDX-FileCopyrightText: 2008-2012 Mehrdad Momeny <mehrdad.momeny@gmail.com>
0005     SPDX-FileCopyrightText: 2010-2012 Emanuele Bigiarini <pulmro@gmail.com>
0006 
0007     SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0008 */
0009 
0010 #ifndef VIDEOPREVIEW_H
0011 #define VIDEOPREVIEW_H
0012 
0013 #include <QMap>
0014 #include <QPixmap>
0015 #include <QPointer>
0016 #include <QQueue>
0017 #include <QRegExp>
0018 #include <QVariant>
0019 #include <QUrl>
0020 #include <QUrlQuery>
0021 
0022 #include "plugin.h"
0023 
0024 namespace Choqok
0025 {
0026 namespace UI
0027 {
0028 class PostWidget;
0029 }
0030 }
0031 
0032 class VideoPreview : public Choqok::Plugin
0033 {
0034     Q_OBJECT
0035 public:
0036     VideoPreview(QObject *parent, const QList< QVariant > &args);
0037     ~VideoPreview();
0038 
0039 protected Q_SLOTS:
0040     void slotAddNewPostWidget(Choqok::UI::PostWidget *newWidget);
0041     void startParsing();
0042     void slotImageFetched(const QUrl &remoteUrl, const QPixmap &pixmap);
0043     void slotNewUnshortenedUrl(Choqok::UI::PostWidget *widget, const QUrl &fromUrl, const QUrl &toUrl);
0044 
0045 private:
0046     enum ParserState { Running = 0, Stopped };
0047     ParserState state;
0048 
0049     void parse(QPointer< Choqok::UI::PostWidget > postToParse);
0050     QUrl parseYoutube(QString videoid , QPointer< Choqok::UI::PostWidget > postToParse);
0051     QUrl parseVimeo(QString videoid , QPointer< Choqok::UI::PostWidget > postToParse);
0052 
0053     QQueue< QPointer<Choqok::UI::PostWidget> > postsQueue;
0054     QMap<QUrl, QPointer<Choqok::UI::PostWidget> > mParsingList;//remoteUrl, Post
0055     QMap<QUrl, QString> mBaseUrlMap;//remoteUrl, BaseUrl
0056     QMap<QUrl, QString> mTitleVideoMap;//remoteUrl, TitleVideo
0057     QMap<QUrl, QString> mDescriptionVideoMap;//remoteUrl, DescriptionVideo
0058 
0059     static const QRegExp mYouTubeRegExp;
0060     static const QRegExp mYouTuRegExp;
0061     static const QRegExp mVimeoRegExp;
0062     static const QRegExp mYouTuCode;
0063 
0064     //static const QRegExp mYFrogRegExp;
0065 };
0066 
0067 #endif //VIDEOPREVIEW_H