File indexing completed on 2019-07-28 10:35:16

0001 /*
0002 This file is part of Choqok, the KDE micro-blogging client
0003 
0004 Copyright (C) 2008-2012 Mehrdad Momeny <mehrdad.momeny@gmail.com>
0005 
0006 This program is free software; you can redistribute it and/or
0007 modify it under the terms of the GNU General Public License as
0008 published by the Free Software Foundation; either version 2 of
0009 the License or (at your option) version 3 or any later version
0010 accepted by the membership of KDE e.V. (or its successor approved
0011 by the membership of KDE e.V.), which shall act as a proxy
0012 defined in Section 14 of version 3 of the license.
0013 
0014 This program is distributed in the hope that it will be useful,
0015 but WITHOUT ANY WARRANTY; without even the implied warranty of
0016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0017 GNU General Public License for more details.
0018 
0019 You should have received a copy of the GNU General Public License
0020 along with this program; if not, see http://www.gnu.org/licenses/
0021 */
0022 
0023 #ifndef CHOQOKSHORTENMANAGER_H
0024 #define CHOQOKSHORTENMANAGER_H
0025 
0026 #include <QObject>
0027 #include <QUrl>
0028 
0029 #include "shortener.h"
0030 
0031 namespace Choqok
0032 {
0033 namespace UI
0034 {
0035 class PostWidget;
0036 }
0037 
0038 class ShortenManagerPrivate;
0039 /**
0040 Singleton class to manage URL shortening
0041 @author Mehrdad Momeny \<mehrdad.momeny@gmail.com\>
0042 */
0043 class CHOQOK_EXPORT ShortenManager: public QObject
0044 {
0045     friend class ShortenManagerPrivate;
0046     Q_OBJECT
0047 public:
0048     static ShortenManager *self();
0049     /**
0050         If there is any shorten plugin loaded/enabled return Shortened URL
0051         else return @p url
0052     */
0053     QString shortenUrl(const QString &url);
0054 
0055     /**
0056         Parse and find Urls and then shorten them. and return result text
0057     */
0058     QString parseText(const QString &text);
0059 
0060     /**
0061         Reload configurations.
0062         Should call after change on shortening plugin!
0063     */
0064     void reloadConfig();
0065 
0066     void emitNewUnshortenedUrl(Choqok::UI::PostWidget *widget, const QUrl &fromUrl, const QUrl &toUrl);
0067 
0068 Q_SIGNALS:
0069     void newUnshortenedUrl(Choqok::UI::PostWidget *widget, const QUrl &fromUrl, const QUrl &toUrl);
0070 
0071 private:
0072     ShortenManager(QObject *parent = nullptr);
0073     ~ShortenManager();
0074 };
0075 
0076 }
0077 #endif