File indexing completed on 2024-05-05 03:50:44

0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 //
0003 // SPDX-FileCopyrightText: 2012 Utku Aydın <utkuaydin34@gmail.com>
0004 //
0005 
0006 #include "FoursquarePlugin.h"
0007 #include "FoursquareModel.h"
0008 
0009 #include <QSettings>
0010 #include <QIcon>
0011 
0012 namespace Marble {
0013 
0014 FoursquarePlugin::FoursquarePlugin()
0015     : AbstractDataPlugin( nullptr )
0016 {
0017 }
0018 
0019 FoursquarePlugin::FoursquarePlugin(const MarbleModel* marbleModel)
0020     : AbstractDataPlugin(marbleModel)
0021 {
0022     setEnabled( true ); // Plugin is enabled by default
0023     setVisible( false ); // Plugin is invisible by default
0024 }
0025 
0026 void FoursquarePlugin::initialize()
0027 {
0028     FoursquareModel *model = new FoursquareModel( marbleModel(), this );
0029     setModel( model );
0030     setNumberOfItems( 20 ); // Do we hardcode that?
0031 }
0032 
0033 QString FoursquarePlugin::name() const
0034 {
0035     return tr( "Places" );
0036 }
0037 
0038 QString FoursquarePlugin::guiString() const
0039 {
0040     return tr( "&Places" ); // TODO: Check if that ampersand conflicts with another
0041 }
0042 
0043 QString FoursquarePlugin::nameId() const
0044 {
0045     return QStringLiteral("foursquare");
0046 }
0047 
0048 QString FoursquarePlugin::version() const
0049 {
0050     return QStringLiteral("1.0");
0051 }
0052 
0053 QString FoursquarePlugin::description() const
0054 {
0055     return tr( "Displays trending Foursquare places" );
0056 }
0057 
0058 QString FoursquarePlugin::copyrightYears() const
0059 {
0060     return QStringLiteral("2012");
0061 }
0062 
0063 QVector<PluginAuthor> FoursquarePlugin::pluginAuthors() const
0064 {
0065     return QVector<PluginAuthor>()
0066             << PluginAuthor(QStringLiteral("Dennis Nienhüser"), QStringLiteral("nienhueser@kde.org"))
0067             << PluginAuthor(QStringLiteral("Utku Aydın"), QStringLiteral("utkuaydin34@gmail.com"));
0068 }
0069 
0070 QIcon FoursquarePlugin::icon() const
0071 {
0072     return QIcon(QStringLiteral(":/icons/places.png"));
0073 }
0074 
0075 bool FoursquarePlugin::isAuthenticated()
0076 {
0077     QSettings settings;
0078 
0079     return !settings.value(QStringLiteral("access_token")).isNull();
0080 }
0081 
0082 bool FoursquarePlugin::storeAccessToken(const QString& tokenUrl)
0083 {
0084     QString expected = "http://edu.kde.org/marble/dummy#access_token=";
0085     if( tokenUrl.startsWith( expected ) ) {
0086         QSettings settings;
0087         QString url = tokenUrl;
0088         settings.setValue(QStringLiteral("access_token"), url.remove(expected));
0089         return true;
0090     } else {
0091         return false;
0092     }
0093 }
0094 
0095 }
0096 
0097 #include "moc_FoursquarePlugin.cpp"
0098