File indexing completed on 2019-04-16 17:04:21

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 
0015 This program is distributed in the hope that it will be useful,
0016 but WITHOUT ANY WARRANTY; without even the implied warranty of
0017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0018 GNU General Public License for more details.
0019 
0020 You should have received a copy of the GNU General Public License
0021 along with this program; if not, see http://www.gnu.org/licenses/
0022 */
0023 
0024 
0025 #ifndef CHOQOKSHORTENMANAGER_H
0026 #define CHOQOKSHORTENMANAGER_H
0027 
0028 #include <QObject>
0029 
0030 #include <KUrl>
0031 
0032 #include "shortener.h"
0033 
0034 namespace Choqok{
0035   namespace UI {
0036     class PostWidget;
0037   }
0038 
0039 class ShortenManagerPrivate;
0040 /**
0041 Singleton class to manage URL shortening
0042 @author Mehrdad Momeny \<mehrdad.momeny@gmail.com\>
0043 */
0044 class CHOQOK_EXPORT ShortenManager: public QObject
0045 {
0046     friend class ShortenManagerPrivate;
0047     Q_OBJECT
0048 public:
0049     static ShortenManager *self();
0050     /**
0051         If there is any shorten plugin loaded/enabled return Shortened URL
0052         else return @p url
0053     */
0054     QString shortenUrl(const QString &url);
0055 
0056     /**
0057         Parse and find Urls and then shorten them. and return result text
0058     */
0059     QString parseText(const QString &text);
0060 
0061     /**
0062         Reload configurations.
0063         Should call after change on shortening plugin!
0064     */
0065     void reloadConfig();
0066 
0067     void emitNewUnshortenedUrl( Choqok::UI::PostWidget *widget, const KUrl& fromUrl, const KUrl& toUrl);
0068 
0069   Q_SIGNALS:
0070     void newUnshortenedUrl( Choqok::UI::PostWidget *widget, const KUrl& fromUrl, const KUrl& toUrl);
0071 
0072 private:
0073     ShortenManager(QObject *parent=0);
0074     ~ShortenManager();
0075 };
0076 
0077 }
0078 #endif