Commit 5b75aa2d authored by Camilo Higuita's avatar Camilo Higuita

a lot of issues on android: move away from kirigami, embed taglib into babe...

a lot of issues on android: move away from kirigami, embed taglib into babe source, fix qnetwork issues with openss on android and fixes
parent 1a456cd3
Add here, with either a script that does a git checkout
or as git submodules the two projects:
git://anongit.kde.org/kirigami.git
git://anongit.kde.org/breeze-icons.git
breeze-icons @ c0c4e4f4
Subproject commit c0c4e4f46ae1dc332277c71a4024dd0eb592c51a
kirigami @ 0c578797
Subproject commit 0c578797c7274c74cfd19d170cab09d90e71370e
This diff is collapsed.
# includes openssl libs onto android build
android {
ANDROID_EXTRA_LIBS += $$PWD/library/openssl/prebuilt/armeabi-v7a/libcrypto.so
ANDROID_EXTRA_LIBS += $$PWD/library/openssl/prebuilt/armeabi-v7a/libssl.so
}
......@@ -31,6 +31,7 @@ CollectionDB::CollectionDB(QObject *parent) : QObject(parent)
this->openDB(this->name);
qDebug()<<"Collection doesn't exists, trying to create it" << BAE::CollectionDBPath + BAE::DBName;
this->prepareCollectionDB();
emit this->initDB(BAE::MusicPath);
}else this->openDB(this->name);
}
......@@ -42,7 +43,6 @@ CollectionDB::~CollectionDB()
void CollectionDB::test()
{
qDebug()<<"call form qml";
emit qmlSignal("lalala");
}
void CollectionDB::closeConnection()
......
......@@ -126,7 +126,7 @@ signals:
void albumsCleaned(const int &amount);
void artistsCleaned(const int &amount);
void qmlSignal(QString str);
void initDB(QString musicPath);
};
#endif // COLLECTION_H
<RCC>
<qresource prefix="/">
<file alias="icons/application-menu.svg">3rdparty/breeze-icons/icons/actions/32/application-menu.svg</file>
<file alias="icons/document-decrypt.svg">3rdparty/breeze-icons/icons/actions/32/document-decrypt.svg</file>
<file alias="icons/folder-sync.svg">3rdparty/breeze-icons/icons/actions/32/folder-sync.svg</file>
<file alias="icons/go-next.svg">3rdparty/breeze-icons/icons/actions/22/go-next.svg</file>
<file alias="icons/go-previous.svg">3rdparty/breeze-icons/icons/actions/22/go-previous.svg</file>
<file alias="icons/go-up.svg">3rdparty/breeze-icons/icons/actions/22/go-up.svg</file>
<file alias="icons/handle-left.svg">3rdparty/breeze-icons/icons/actions/22/handle-left.svg</file>
<file alias="icons/handle-right.svg">3rdparty/breeze-icons/icons/actions/22/handle-right.svg</file>
<file alias="icons/view-list-icons.svg">3rdparty/breeze-icons/icons/actions/32/view-list-icons.svg</file>
<file alias="icons/applications-graphics.svg">3rdparty/breeze-icons/icons/categories/32/applications-graphics.svg</file>
<file alias="icons/media-record-symbolic.svg">3rdparty/breeze-icons/icons/actions/symbolic/media-record-symbolic.svg</file>
</qresource>
</RCC>
......@@ -6,6 +6,10 @@
#include "utils/bae.h"
#include "settings/settings.h"
#include "services/local/player.h"
#include <QLibrary>
//#ifdef Q_OS_ANDROID
//#include "./3rdparty/kirigami/src/kirigamiplugin.h"
//#endif
int main(int argc, char *argv[])
{
......@@ -15,7 +19,8 @@ int main(int argc, char *argv[])
QFontDatabase::addApplicationFont(":/utils/materialdesignicons-webfont.ttf");
QQmlApplicationEngine engine;
QQmlApplicationEngine engine;
auto context = engine.rootContext();
CollectionDB con;
settings settings;
......@@ -25,6 +30,10 @@ int main(int argc, char *argv[])
context->setContextProperty("set", &settings);
context->setContextProperty("player", &player);
//#ifdef Q_OS_ANDROID
// KirigamiPlugin::getInstance().registerTypes();
//#endif
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
if (engine.rootObjects().isEmpty())
return -1;
......
This diff is collapsed.
#ifndef ENUMS_H
#define ENUMS_H
#include <QMap>
#include <QVariant>
namespace PULPO
{
enum class SERVICES : uint8_t
{
LastFm,
Spotify,
iTunes,
MusicBrainz,
Genius,
LyricWikia,
Wikipedia,
WikiLyrics,
Deezer,
ALL,
NONE
};
enum class ONTOLOGY : uint8_t
{
ARTIST,
ALBUM,
TRACK,
NONE
};
enum class INFO : uint8_t
{
ARTWORK,
WIKI,
TAGS,
METADATA,
LYRICS,
ALL,
NONE
};
/*Generic context names. It's encouraged to use these instead of a unkown string*/
enum class CONTEXT : uint8_t
{
TRACK_STAT,
TRACK_NUMBER,
TRACK_TITLE,
TRACK_DATE,
TRACK_TEAM,
TRACK_AUTHOR,
TRACK_LANGUAGE,
TRACK_SIMILAR,
ALBUM_TEAM,
ALBUM_STAT,
ALBUM_TITLE,
ALBUM_DATE,
ALBUM_LANGUAGE,
ALBUM_SIMILAR,
ALBUM_LABEL,
ARTIST_STAT,
ARTIST_TITLE,
ARTIST_DATE,
ARTIST_LANGUAGE,
ARTIST_PLACE,
ARTIST_SIMILAR,
ARTIST_TEAM,
ARTIST_ALIAS,
ARTIST_GENDER,
GENRE,
TAG,
WIKI,
IMAGE,
LYRIC,
SOURCE
};
static const QMap<CONTEXT,QString> CONTEXT_MAP =
{
{CONTEXT::ALBUM_STAT, "album_stat"},
{CONTEXT::ALBUM_TITLE, "album_title"},
{CONTEXT::ALBUM_DATE, "album_date"},
{CONTEXT::ALBUM_LANGUAGE, "album_language"},
{CONTEXT::ALBUM_SIMILAR, "album_similar"},
{CONTEXT::ALBUM_LABEL, "album_label"},
{CONTEXT::ALBUM_TEAM, "album_team"},
{CONTEXT::ARTIST_STAT, "artist_stat"},
{CONTEXT::ARTIST_TITLE, "artist_title"},
{CONTEXT::ARTIST_DATE, "artist_date"},
{CONTEXT::ARTIST_LANGUAGE, "artist_language"},
{CONTEXT::ARTIST_PLACE, "artist_place"},
{CONTEXT::ARTIST_SIMILAR, "artist_similar"},
{CONTEXT::ARTIST_ALIAS, "artist_alias"},
{CONTEXT::ARTIST_GENDER, "artist_gender"},
{CONTEXT::ARTIST_TEAM, "artist_team"},
{CONTEXT::TRACK_STAT, "track_stat"},
{CONTEXT::TRACK_DATE, "track_date"},
{CONTEXT::TRACK_TITLE, "track_title"},
{CONTEXT::TRACK_NUMBER, "track_number"},
{CONTEXT::TRACK_TEAM, "track_team"},
{CONTEXT::TRACK_AUTHOR, "track_author"},
{CONTEXT::TRACK_LANGUAGE, "track_language"},
{CONTEXT::TRACK_SIMILAR, "track_similar"},
{CONTEXT::GENRE, "genre"},
{CONTEXT::TAG, "tag"},
{CONTEXT::WIKI, "wiki"},
{CONTEXT::IMAGE, "image"},
{CONTEXT::LYRIC, "lyric"},
{CONTEXT::SOURCE, "source"}
};
enum class RECURSIVE : bool
{
ON = true,
OFF = false
};
typedef QMap<CONTEXT, QVariant> VALUE;
typedef QMap<INFO, VALUE> INFO_K;
typedef QMap<ONTOLOGY, INFO_K> RESPONSE;
typedef QMap<ONTOLOGY, QList<INFO>> AVAILABLE;
}
#endif // ENUMS_H
#include "htmlparser.h"
htmlParser::htmlParser(QObject *parent) : QObject(parent)
{
}
void htmlParser::setHtml(const QByteArray &array)
{
this->html = array;
}
QString htmlParser::extractProp(const QString &tag,const QString &prop)
{
// qDebug()<<"extractProp"<<tag;
auto list = tag.split(" ");
auto result =list.filter(prop,Qt::CaseInsensitive);
// qDebug()<<result;
auto url = result.first().replace(prop,"").replace('\"',"");
// qDebug()<<url;
return url;
}
QStringList htmlParser::parseTag(const QString &tagRef, const QString &attribute)
{
QStringList results;
QStringList html(QString(this->html).split(">"));
for(auto i =0; i<html.size();i++)
{
QString tag = html.at(i);
tag+=">";
if(findTag(tag,"<"+tagRef+">") && tag.contains(attribute))
{
QString subResult;
// qDebug()<<subResult;
while(!html.at(i).contains("</"+tagRef))
{
auto subTag=html.at(i);
subTag+=">";
subResult+=subTag;
i++;
if(i>html.size()) break;
}
results<<subResult.simplified();
qDebug()<<subResult;
}
}
return results;
}
/*QStringList htmlParser::parseTag_old(const QString &tagRef)
{
QString html(this->html);
QStringList tags;
int i =0;
while(html.size()>i)
{
if(html.at(i)=="<")
{
QString tag;
while(html.at(i)!=">")
{
tag+=html.at(i);
i++;
if(i>html.size()) break;
}
tag+=">";
if(findTag(tag,tagRef))
{
tags<<tag;
qDebug()<<tag;
}
}
i++;
if(i>html.size()) break;
}
return tags;
}*/
bool htmlParser::findTag(const QString &txt, const QString &tagRef)
{
// qDebug()<<"size of tag<<"<<txt.size();
int i =0;
QString subTag;
while(i<txt.size())
{
if(txt.at(i).toLatin1()=='<')
{
while(!txt.at(i).isSpace() && txt.at(i).toLatin1()!='>')
{
subTag+=txt.at(i);
i++;
if(i>txt.size()) break;
}
subTag+=">";
}
i++;
if(i>txt.size()) break;
}
if(tagRef==subTag) return true;
else return false;
}
#ifndef HTMLPARSER_H
#define HTMLPARSER_H
#include <QObject>
#include <QStringList>
#include <QString>
#include <QDebug>
class htmlParser : public QObject
{
Q_OBJECT
public:
explicit htmlParser(QObject *parent = nullptr);
void setHtml(const QByteArray &html);
QStringList parseTag(const QString &tagRef, const QString &attribute=""); // return all tag matches with content
bool findTag(const QString &txt, const QString &tagRef);
QString extractProp(const QString &tag, const QString &prop);
private:
QByteArray html;
signals:
void finishedParsingTags(const QStringList &tags);
void finishedExtractingProp(const QString &prop);
public slots:
};
#endif // HTMLPARSER_H
/*
Babe - tiny music player
Copyright (C) 2017 Camilo Higuita
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "pulpo.h"
#include "services/lastfmService.h"
#include "services/spotifyService.h"
#include "services/lyricwikiaService.h"
#include "services/geniusService.h"
#include "services/musicbrainzService.h"
#include "services/deezerService.h"
Pulpo::Pulpo(const BAE::DB &song,QObject *parent)
: QObject(parent), track(song) {}
Pulpo::Pulpo(QObject *parent): QObject(parent) {}
Pulpo::~Pulpo() {}
void Pulpo::feed(const BAE::DB &song, const RECURSIVE &recursive)
{
this->track = song;
this->recursive = recursive;
this->initServices();
}
void Pulpo::registerServices(const QList<PULPO::SERVICES> &services)
{
this->registeredServices = services;
}
void Pulpo::setInfo(const PULPO::INFO &info)
{
this->info = info;
}
void Pulpo::setOntology(const PULPO::ONTOLOGY &ontology)
{
this->ontology = ontology;
}
ONTOLOGY Pulpo::getOntology()
{
return this->ontology;
}
void Pulpo::setRecursive(const RECURSIVE &state)
{
this->recursive=state;
}
bool Pulpo::initServices()
{
if(this->registeredServices.isEmpty()) return false;
if(this->track.isEmpty()) return false;
for(auto service : this->registeredServices)
switch (service)
{
case SERVICES::LastFm:
{
lastfm lastfm(this->track);
connect(&lastfm, &lastfm::infoReady, this, &Pulpo::passSignal);
if(lastfm.setUpService(this->ontology,this->info))
{
if(recursive== RECURSIVE::OFF) return true;
}else qDebug()<<"error settingUp lastfm service";
break;
}
case SERVICES::Spotify:
{
spotify spotify(this->track);
connect(&spotify, &spotify::infoReady, this, &Pulpo::passSignal);
if(spotify.setUpService(this->ontology,this->info))
{
if(recursive== RECURSIVE::OFF) return true;
}else qDebug()<<"error settingUp spotify service";
break;
}
case SERVICES::Genius:
{
genius genius(this->track);
connect(&genius, &genius::infoReady, this, &Pulpo::passSignal);
if(genius.setUpService(this->ontology,this->info))
{
if(recursive== RECURSIVE::OFF) return true;
}else qDebug()<<"error settingUp spotify service";
break;
}
case SERVICES::MusicBrainz:
{
musicBrainz musicbrainz(this->track);
connect(&musicbrainz, &musicBrainz::infoReady, this, &Pulpo::passSignal);
if(musicbrainz.setUpService(this->ontology,this->info))
{
if(recursive== RECURSIVE::OFF) return true;
}else qDebug()<<"error settingUp musicBrainz service";
break;
}
case SERVICES::iTunes:
{
break;
}
case SERVICES::WikiLyrics:
{
break;
}
case SERVICES::LyricWikia:
{
lyricWikia lyricwikia(this->track);
connect(&lyricwikia, &lyricWikia::infoReady, this, &Pulpo::passSignal);
if(lyricwikia.setUpService(this->ontology,this->info))
{
if(recursive== RECURSIVE::OFF) return true;
}else qDebug()<<"error settingUp lyricwikia service";
break;
}
case SERVICES::Wikipedia:
{
break;
}
case SERVICES::Deezer:
{
deezer deezer(this->track);
connect(&deezer, &deezer::infoReady, this, &Pulpo::passSignal);
if(deezer.setUpService(this->ontology, this->info))
{
if(recursive== RECURSIVE::OFF) return true;
}else qDebug()<<"error settingUp deezer service";
break;
}
case SERVICES::ALL:
{
break;
}
case SERVICES::NONE:
{
break;
}
}
return false;
}
void Pulpo::passSignal(const BAE::DB &track, const PULPO::RESPONSE &response)
{
emit this->infoReady(track, response);
}
PULPO::RESPONSE Pulpo::packResponse(const PULPO::ONTOLOGY ontology, const PULPO::INFO &infoKey, const PULPO::CONTEXT &context, const QVariant &value)
{
return { { ontology ,{{ infoKey, {{ context, value }} }} } };
}
PULPO::RESPONSE Pulpo::packResponse(const ONTOLOGY ontology, const PULPO::INFO &infoKey, const PULPO::VALUE &map)
{
return {{ ontology, { {infoKey, map} }} };
}
bool Pulpo::parseArray()
{
if(this->ontology != PULPO::ONTOLOGY::NONE)
switch(this->ontology)
{
case PULPO::ONTOLOGY::ALBUM: return this->parseAlbum();
case PULPO::ONTOLOGY::ARTIST: return this->parseArtist();
case PULPO::ONTOLOGY::TRACK: return this->parseTrack();
default: return false;
}
return false;
}
QByteArray Pulpo::startConnection(const QString &url, const QMap<QString,QString> &headers)
{
if(!url.isEmpty())
{
QUrl mURL(url);
QNetworkAccessManager manager;
QNetworkRequest request (mURL);
if(!headers.isEmpty())
for(auto key: headers.keys())
request.setRawHeader(key.toLocal8Bit(), headers[key].toLocal8Bit());
QNetworkReply *reply = manager.get(request);
QEventLoop loop;
connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), &loop,
SLOT(quit()));
loop.exec();
reply->deleteLater();
if(reply->error()) qDebug()<<reply->error();
return reply->readAll();
}
return QByteArray();
}
#ifndef PULPO_H
#define PULPO_H
#include <QPixmap>
#include <QList>
#include <QDebug>
#include <QImage>
#include <QtCore>
#include <QtNetwork>
#include <QUrl>
#include <QWidget>
#include <QObject>