diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,80 @@ +project(kalgebra) +cmake_minimum_required(VERSION 3.0) + +find_package(ECM 1.7.0 REQUIRED NO_MODULE) +set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${ECM_MODULE_PATH}) + +find_package(Qt5 REQUIRED NO_MODULE COMPONENTS Qml Quick Network WebSockets Sql QuickControls2 Xml Multimedia Widgets) +include(KDEInstallDirs) +include(KDECompilerSettings NO_POLICY_SCOPE) +include(KDECMakeSettings) +include(ECMInstallIcons) +include(FeatureSummary) +include(ECMAddAppIcon) + +set(CMAKE_AUTORCC ON) + +add_executable(vvave + qml.qrc + main.cpp + babe.cpp + + pulpo/services/geniusService.cpp + pulpo/services/deezerService.cpp + pulpo/services/lastfmService.cpp + pulpo/services/lyricwikiaService.cpp + pulpo/services/spotifyService.cpp + pulpo/services/musicbrainzService.cpp + pulpo/pulpo.cpp + pulpo/htmlparser.cpp + services/local/taginfo.cpp + services/local/player.cpp + services/local/youtubedl.cpp + services/local/linking.cpp + services/local/socket.cpp + services/web/babeit.cpp + services/web/youtube.cpp + db/conthread.cpp + db/collectionDB.cpp + settings/BabeSettings.cpp + settings/fileloader.cpp + utils/brain.cpp + utils/babeconsole.cpp +) + +if (ANDROID) + find_package(Qt5 REQUIRED COMPONENTS AndroidExtras WebView) + + include(ExternalProject) + externalproject_add(taglib + URL http://taglib.org/releases/taglib-1.11.1.tar.gz + CMAKE_ARGS -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} + ) + set(TAGLIB_INCLUDE_DIRS ${CMAKE_INSTALL_PREFIX}/include ${CMAKE_INSTALL_PREFIX}/include/taglib) + find_library(TAGLIB_LIBRARIES tag PATHS ${LIB_INSTALL_DIR}) + + target_sources(vvave PRIVATE + android/android.cpp + android/notificationclient.cpp + android.qrc + ) + target_link_libraries(vvave Qt5::AndroidExtras Qt5::WebView) + kde_source_files_enable_exceptions(vvave android/android.cpp android/notificationclient.cpp babe.cpp) +else() + find_package(Taglib REQUIRED) + find_package(Qt5 REQUIRED COMPONENTS WebEngine) + find_package(KF5 ${KF5_VERSION} REQUIRED COMPONENTS I18n Notifications Config) + target_sources(vvave PRIVATE + kde/kdeconnect.cpp + kde/mpris2.cpp + kde/notify.cpp + ) + target_link_libraries(vvave Qt5::WebEngine KF5::ConfigCore KF5::Notifications KF5::I18n) +endif() +target_include_directories(vvave PRIVATE ${TAGLIB_INCLUDE_DIRS}) +target_link_libraries(vvave Qt5::Network Qt5::Sql Qt5::WebSockets Qt5::Qml Qt5::Xml Qt5::Multimedia Qt5::Widgets ${TAGLIB_LIBRARIES}) + +install(TARGETS vvave ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) +# install(FILES org.kde.vvave.appdata.xml DESTINATION ${KDE_INSTALL_METAINFODIR}) + +feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -1,5 +1,5 @@ - + android:name="com.example.android.tools.NotificationClient" @@ -13,7 +13,7 @@ - + @@ -79,7 +79,7 @@ --> - + diff --git a/android/gradle.properties b/android/gradle.properties deleted file mode 100644 --- a/android/gradle.properties +++ /dev/null @@ -1,9 +0,0 @@ -## This file is automatically generated by QtCreator. -# -# This file must *NOT* be checked into Version Control Systems, -# as it contains information specific to your local configuration. - -androidBuildToolsVersion=26.0.2 -androidCompileSdkVersion=26 -buildDir=.build -qt5AndroidDir=/home/camilo/Qt/5.10.1/android_armv7/src/android/java diff --git a/babe.cpp b/babe.cpp --- a/babe.cpp +++ b/babe.cpp @@ -7,18 +7,18 @@ #include "utils/babeconsole.h" #include -#include #include #include -#include -#include +#include #include #include #include +#include //#include "Python.h" #if (defined (Q_OS_LINUX) && !defined (Q_OS_ANDROID)) +#include #include "kde/notify.h" #include "kde/kdeconnect.h" #endif @@ -680,7 +680,7 @@ int Babe::screenGeometry(QString side) { side = side.toLower(); - auto geo = QApplication::desktop()->screenGeometry(); + auto geo = QGuiApplication::primaryScreen()->geometry(); if(side == "width") return geo.width(); @@ -892,13 +892,17 @@ { #if (defined (Q_OS_LINUX) && !defined (Q_OS_ANDROID)) return KdeConnect::getDevices(); +#else + return {}; #endif } bool Babe::sendToDevice(const QString &name, const QString &id, const QString &url) { #if (defined (Q_OS_LINUX) && !defined (Q_OS_ANDROID)) return KdeConnect::sendToDevice(name, id, url) ? true : false; +#else + return {}; #endif } diff --git a/cmake/FindTaglib.cmake b/cmake/FindTaglib.cmake new file mode 100644 --- /dev/null +++ b/cmake/FindTaglib.cmake @@ -0,0 +1,133 @@ +# - Try to find the Taglib library +# Once done this will define +# +# TAGLIB_FOUND - system has the taglib library +# TAGLIB_CFLAGS - the taglib cflags +# TAGLIB_LIBRARIES - The libraries needed to use taglib + +# Copyright (c) 2006, Laurent Montel, +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + +if(NOT TAGLIB_MIN_VERSION) + set(TAGLIB_MIN_VERSION "1.7") +endif() + +if(NOT WIN32) + find_program(TAGLIBCONFIG_EXECUTABLE + NAMES taglib-config + PATHS ${BIN_INSTALL_DIR} + ) +endif() + +#reset vars +set(TAGLIB_LIBRARIES) +set(TAGLIB_CFLAGS) + +# if taglib-config has been found +if(TAGLIBCONFIG_EXECUTABLE) + + exec_program(${TAGLIBCONFIG_EXECUTABLE} ARGS --version RETURN_VALUE _return_VALUE OUTPUT_VARIABLE TAGLIB_VERSION) + + if(TAGLIB_VERSION VERSION_LESS "${TAGLIB_MIN_VERSION}") + message(STATUS "TagLib version too old: version searched :${TAGLIB_MIN_VERSION}, found ${TAGLIB_VERSION}") + set(TAGLIB_FOUND FALSE) + else() + + exec_program(${TAGLIBCONFIG_EXECUTABLE} ARGS --libs RETURN_VALUE _return_VALUE OUTPUT_VARIABLE TAGLIB_LIBRARIES) + + exec_program(${TAGLIBCONFIG_EXECUTABLE} ARGS --cflags RETURN_VALUE _return_VALUE OUTPUT_VARIABLE TAGLIB_CFLAGS) + + if(TAGLIB_LIBRARIES AND TAGLIB_CFLAGS) + set(TAGLIB_FOUND TRUE) + endif() + + string(REGEX REPLACE " *-I" ";" TAGLIB_INCLUDE_DIRS "${TAGLIB_CFLAGS}") + string(SUBSTRING ${TAGLIB_INCLUDE_DIRS} 0 -1 TAGLIB_INCLUDE_DIRS) #we remove the initial ; +endif() + +mark_as_advanced(TAGLIB_CFLAGS TAGLIB_LIBRARIES TAGLIB_INCLUDES) + +else() + + find_path(TAGLIB_INCLUDE_DIRS + NAMES tag.h + PATH_SUFFIXES taglib + PATHS ${INCLUDE_INSTALL_DIR} + ) + + if(NOT WIN32) + # on non-win32 we don't need to take care about WIN32_DEBUG_POSTFIX + find_library(TAGLIB_LIBRARIES tag PATHS ${LIB_INSTALL_DIR}) + + else() + + # 1. get all possible libnames + set(args PATHS ${LIB_INSTALL_DIR}) + set(newargs "") + set(libnames_release "") + set(libnames_debug "") + + list(LENGTH args listCount) + + # just one name + list(APPEND libnames_release "tag") + list(APPEND libnames_debug "tagd") + + set(newargs ${args}) + + # search the release lib + find_library(TAGLIB_LIBRARIES_RELEASE + NAMES ${libnames_release} + ${newargs} + ) + + # search the debug lib + find_library(TAGLIB_LIBRARIES_DEBUG + NAMES ${libnames_debug} + ${newargs} + ) + + if(TAGLIB_LIBRARIES_RELEASE AND TAGLIB_LIBRARIES_DEBUG) + + # both libs found + set(TAGLIB_LIBRARIES optimized ${TAGLIB_LIBRARIES_RELEASE} + debug ${TAGLIB_LIBRARIES_DEBUG} + ) + + else() + + if(TAGLIB_LIBRARIES_RELEASE) + # only release found + set(TAGLIB_LIBRARIES ${TAGLIB_LIBRARIES_RELEASE}) + + else() + # only debug (or nothing) found + set(TAGLIB_LIBRARIES ${TAGLIB_LIBRARIES_DEBUG}) + + endif() + + endif() + + mark_as_advanced(TAGLIB_LIBRARIES_RELEASE) + mark_as_advanced(TAGLIB_LIBRARIES_DEBUG) + + endif() + + include(FindPackageMessage) + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args(Taglib DEFAULT_MSG TAGLIB_INCLUDE_DIRS_ TAGLIB_LIBRARIES) + +endif() + + +if(TAGLIB_FOUND) + if(NOT Taglib_FIND_QUIETLY AND TAGLIBCONFIG_EXECUTABLE) + message(STATUS "Taglib found: ${TAGLIB_LIBRARIES}") + endif() +else() + if(Taglib_FIND_REQUIRED) + message(FATAL_ERROR "Could not find Taglib") + endif() +endif() diff --git a/main.cpp b/main.cpp --- a/main.cpp +++ b/main.cpp @@ -6,12 +6,11 @@ #include "babe.h" #include "services/local/player.h" #include -#include +// #include #include #include "services/local/linking.h" #ifdef Q_OS_ANDROID -#include "./3rdparty/kirigami/src/kirigamiplugin.h" #include #else #include @@ -21,6 +20,9 @@ #include #include "services/web/youtube.h" +#ifdef Q_OS_ANDROID +Q_DECL_EXPORT +#endif int main(int argc, char *argv[]) { QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); @@ -82,7 +84,6 @@ ); #ifdef Q_OS_ANDROID - KirigamiPlugin::getInstance().registerTypes(); QtWebView::initialize(); #else // if(QQuickStyle::availableStyles().contains("nomad")) diff --git a/pulpo/pulpo.h b/pulpo/pulpo.h --- a/pulpo/pulpo.h +++ b/pulpo/pulpo.h @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include diff --git a/services/local/taginfo.h b/services/local/taginfo.h --- a/services/local/taginfo.h +++ b/services/local/taginfo.h @@ -5,8 +5,8 @@ #include #include -#include <./3rdparty/taglib/tag.h> -#include <./3rdparty/taglib/fileref.h> +#include +#include namespace TagLib { diff --git a/services/local/youtubedl.h b/services/local/youtubedl.h --- a/services/local/youtubedl.h +++ b/services/local/youtubedl.h @@ -8,9 +8,6 @@ #include #include -#include -#include - #include "../../utils/bae.h" #include "../local/taginfo.h" diff --git a/settings/BabeSettings.h b/settings/BabeSettings.h --- a/settings/BabeSettings.h +++ b/settings/BabeSettings.h @@ -1,17 +1,13 @@ #ifndef SETTINGS_H #define SETTINGS_H -#include #include #include #include #include #include #include -#include #include -#include -#include #include #include #include "fileloader.h" diff --git a/settings/fileloader.h b/settings/fileloader.h --- a/settings/fileloader.h +++ b/settings/fileloader.h @@ -13,108 +13,17 @@ Q_OBJECT public: - FileLoader() : CollectionDB(nullptr) - { - qRegisterMetaType("BAE::DB"); - qRegisterMetaType("BAE::TABLE"); - qRegisterMetaType>("QMap"); - this->moveToThread(&t); - t.start(); - } + FileLoader(); - ~FileLoader() - { - this->go = false; - this->t.quit(); - this->t.wait(); - } + ~FileLoader() override; - void requestPaths(QStringList paths) - { - qDebug()<<"FROM file loader"<< paths; + void requestPaths(const QStringList &paths); - - this->go = true; - QMetaObject::invokeMethod(this, "getTracks", Q_ARG(QStringList, paths)); - - - } - - void nextTrack() - { - this->wait = !this->wait; - } + void nextTrack(); public slots: - void getTracks(QStringList paths) - { - qDebug()<<"GETTING TRACKS FROM SETTINGS"; - - QStringList urls; - - for(auto path : paths) - { - if (QFileInfo(path).isDir()) - { - this->addFolder(path); - QDirIterator it(path, BAE::formats, QDir::Files, QDirIterator::Subdirectories); - while (it.hasNext()) urls<execQuery("PRAGMA synchronous=OFF"); - - for(auto url : urls) - { - if(go) - { - if(!check_existance(BAE::TABLEMAP[BAE::TABLE::TRACKS],BAE::KEYMAP[BAE::KEY::URL],url)) - { - if(info.feed(url)) - { - auto album = BAE::fixString(info.getAlbum()); - auto track= info.getTrack(); - auto title = BAE::fixString(info.getTitle()); /* to fix*/ - auto artist = BAE::fixString(info.getArtist()); - auto genre = info.getGenre(); - auto sourceUrl = QFileInfo(url).dir().path(); - auto duration = info.getDuration(); - auto year = info.getYear(); - - BAE::DB trackMap = - { - {BAE::KEY::URL, url}, - {BAE::KEY::TRACK, QString::number(track)}, - {BAE::KEY::TITLE, title}, - {BAE::KEY::ARTIST, artist}, - {BAE::KEY::ALBUM, album}, - {BAE::KEY::DURATION,QString::number(duration)}, - {BAE::KEY::GENRE, genre}, - {BAE::KEY::SOURCES_URL, sourceUrl}, - {BAE::KEY::BABE, url.startsWith(BAE::YoutubeCachePath) ? "1": "0"}, - {BAE::KEY::RELEASE_DATE, QString::number(year)} - }; - - qDebug()<addTrack(trackMap); - newTracks++; - } - } - - }else break; - } - } - - this->t.msleep(100); - emit this->finished(newTracks); - this->go = false; - } + void getTracks(const QStringList &paths); signals: void trackReady(BAE::DB track); diff --git a/settings/fileloader.cpp b/settings/fileloader.cpp new file mode 100644 --- /dev/null +++ b/settings/fileloader.cpp @@ -0,0 +1,104 @@ +#include "fileloader.h" + + +FileLoader::FileLoader() + : CollectionDB(nullptr) +{ + qRegisterMetaType("BAE::DB"); + qRegisterMetaType("BAE::TABLE"); + qRegisterMetaType>("QMap"); + this->moveToThread(&t); + t.start(); +} + +FileLoader::~FileLoader() +{ + this->go = false; + this->t.quit(); + this->t.wait(); +} + + +void FileLoader::requestPaths(const QStringList& paths) +{ + qDebug()<<"FROM file loader"<< paths; + + this->go = true; + QMetaObject::invokeMethod(this, "getTracks", Q_ARG(QStringList, paths)); +} + + +void FileLoader::nextTrack() +{ + this->wait = !this->wait; +} + + +void FileLoader::getTracks(const QStringList& paths) +{ + qDebug()<<"GETTING TRACKS FROM SETTINGS"; + + QStringList urls; + + for(auto path : paths) + { + if (QFileInfo(path).isDir()) + { + this->addFolder(path); + QDirIterator it(path, BAE::formats, QDir::Files, QDirIterator::Subdirectories); + while (it.hasNext()) urls<execQuery("PRAGMA synchronous=OFF"); + + for(auto url : urls) + { + if(go) + { + if(!check_existance(BAE::TABLEMAP[BAE::TABLE::TRACKS],BAE::KEYMAP[BAE::KEY::URL],url)) + { + if(info.feed(url)) + { + auto album = BAE::fixString(info.getAlbum()); + auto track= info.getTrack(); + auto title = BAE::fixString(info.getTitle()); /* to fix*/ + auto artist = BAE::fixString(info.getArtist()); + auto genre = info.getGenre(); + auto sourceUrl = QFileInfo(url).dir().path(); + auto duration = info.getDuration(); + auto year = info.getYear(); + + BAE::DB trackMap = + { + {BAE::KEY::URL, url}, + {BAE::KEY::TRACK, QString::number(track)}, + {BAE::KEY::TITLE, title}, + {BAE::KEY::ARTIST, artist}, + {BAE::KEY::ALBUM, album}, + {BAE::KEY::DURATION,QString::number(duration)}, + {BAE::KEY::GENRE, genre}, + {BAE::KEY::SOURCES_URL, sourceUrl}, + {BAE::KEY::BABE, url.startsWith(BAE::YoutubeCachePath) ? "1": "0"}, + {BAE::KEY::RELEASE_DATE, QString::number(year)} + }; + + qDebug()<addTrack(trackMap); + newTracks++; + } + } + + }else break; + } + } + + this->t.msleep(100); + emit this->finished(newTracks); + this->go = false; +} diff --git a/utils/bae.h b/utils/bae.h --- a/utils/bae.h +++ b/utils/bae.h @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include diff --git a/vvave.pro b/vvave.pro --- a/vvave.pro +++ b/vvave.pro @@ -5,7 +5,6 @@ QT += network QT += xml QT += qml -QT += quickcontrols2 QT += widgets @@ -65,7 +64,8 @@ services/web/babeit.cpp \ utils/babeconsole.cpp \ services/local/youtubedl.cpp \ - services/local/linking.cpp + services/local/linking.cpp \ + settings/fileloader.cpp RESOURCES += qml.qrc \