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

0001 /*
0002     This file is part of Choqok, the KDE micro-blogging client
0003 
0004     SPDX-FileCopyrightText: 2016 Andrea Scarpino <scarpino@kde.org>
0005 
0006     SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0007 */
0008 
0009 #include "friendicamicroblog.h"
0010 
0011 #include <KPluginFactory>
0012 
0013 #include "gnusocialapiaccount.h"
0014 
0015 #include "friendicadebug.h"
0016 #include "friendicaeditaccount.h"
0017 
0018 K_PLUGIN_CLASS_WITH_JSON(FriendicaMicroBlog, "choqok_friendica.json")
0019 
0020 FriendicaMicroBlog::FriendicaMicroBlog(QObject *parent, const QVariantList &)
0021     : GNUSocialApiMicroBlog(QLatin1String("choqok_friendica"), parent)
0022 {
0023     qCDebug(CHOQOK);
0024     setServiceName(QLatin1String("Friendica"));
0025 }
0026 
0027 FriendicaMicroBlog::~FriendicaMicroBlog()
0028 {
0029     qCDebug(CHOQOK);
0030 }
0031 
0032 ChoqokEditAccountWidget *FriendicaMicroBlog::createEditAccountWidget(Choqok::Account *account, QWidget *parent)
0033 {
0034     qCDebug(CHOQOK);
0035     GNUSocialApiAccount *acc = qobject_cast<GNUSocialApiAccount *>(account);
0036     if (acc || !account) {
0037         return new FriendicaEditAccountWidget(this, acc, parent);
0038     } else {
0039         qCDebug(CHOQOK) << "Account passed here is not a GNUSocialApiAccount!";
0040         return nullptr;
0041     }
0042 }
0043 
0044 QUrl FriendicaMicroBlog::profileUrl(Choqok::Account *account, const QString &username) const
0045 {
0046     GNUSocialApiAccount *acc = qobject_cast<GNUSocialApiAccount *>(account);
0047     if (acc) {
0048         QUrl url(acc->host());
0049         url = url.adjusted(QUrl::StripTrailingSlash);
0050         url.setPath(QLatin1String("/profile/") + username);
0051 
0052         return url;
0053     } else {
0054         return QUrl();
0055     }
0056 }
0057 
0058 #include "friendicamicroblog.moc"
0059 #include "moc_friendicamicroblog.cpp"