unity-scope-onlinemusic-0.1+14.04.20140306/ 0000755 0000152 0177776 00000000000 12306014762 020551 5 ustar pbuser nogroup 0000000 0000000 unity-scope-onlinemusic-0.1+14.04.20140306/tests/ 0000755 0000152 0177776 00000000000 12306014762 021713 5 ustar pbuser nogroup 0000000 0000000 unity-scope-onlinemusic-0.1+14.04.20140306/tests/CMakeLists.txt 0000644 0000152 0177776 00000002450 12306014511 024444 0 ustar pbuser nogroup 0000000 0000000 SET(TEST_SSS_PARSER_SOURCES
SmartScopesParserTest.cpp
)
SET(TEST_SSS_CLIENT_SOURCES
SmartScopesClientTest.cpp
)
INCLUDE_DIRECTORIES(
${UNITY_INCLUDE_DIRS}
${Qt5Core_INCLUDE_DIRS}
${Qt5Test_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}/../src
${CMAKE_CURRENT_BINARY_DIR}/src
)
QT5_WRAP_CPP(TEST_SSS_PARSER_MOC
SmartScopesParserTest.h)
QT5_WRAP_CPP(TEST_SSS_CLIENT_MOC
SmartScopesClientTest.h)
ADD_EXECUTABLE(
test-sss-parser
${TEST_SSS_PARSER_SOURCES}
${TEST_SSS_PARSER_MOC}
)
ADD_EXECUTABLE(
test-sss-client
${TEST_SSS_CLIENT_SOURCES}
${TEST_SSS_CLIENT_MOC}
)
QT5_USE_MODULES(test-sss-parser Test Core)
QT5_USE_MODULES(test-sss-client Test Core)
TARGET_LINK_LIBRARIES(test-sss-parser
sss-parser-lib
${DEEQT_LIBRARIES}
${UNITY_LIBRARIES}
${Qt5Core_LIBRARIES}
${Qt5Test_LIBRARIES}
${UUID_LIBRARIES}
)
TARGET_LINK_LIBRARIES(test-sss-client
sss-parser-lib
${DEEQT_LIBRARIES}
${UNITY_LIBRARIES}
${Qt5Core_LIBRARIES}
${Qt5Test_LIBRARIES}
${Qt5Network_LIBRARIES}
${UUID_LIBRARIES}
)
ADD_TEST(NAME TestSSSParser COMMAND test-sss-parser)
ADD_TEST(NAME TestSSSClient COMMAND test-sss-client)
unity-scope-onlinemusic-0.1+14.04.20140306/tests/SmartScopesClientTest.h 0000644 0000152 0177776 00000001633 12306014511 026321 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, 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, see .
*
* Author: Pawel Stolowski
*/
#ifndef TESTSMARTSCOPESCLIENT_H
#define TESTSMARTSCOPESCLIENT_H
#include
class SmartScopesClientTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void buildSearchUrlTest();
};
#endif
unity-scope-onlinemusic-0.1+14.04.20140306/tests/SmartScopesParserTest.h 0000644 0000152 0177776 00000001750 12306014511 026337 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, 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, see .
*
* Author: Pawel Stolowski
*/
#ifndef TESTSMARTSCOPESPARSER_H
#define TESTSMARTSCOPESPARSER_H
#include
class SmartScopesParserTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void parseSearchResultLineTest();
void parseGenericPreviewTest();
void parseMusicPreviewTest();
};
#endif
unity-scope-onlinemusic-0.1+14.04.20140306/tests/SmartScopesParserTest.cpp 0000644 0000152 0177776 00000016633 12306014511 026700 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, 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, see .
*
* Author: Pawel Stolowski
*/
#include "SmartScopesParserTest.h"
#include
#include
#include
#include
#include "SmartScopesClient.h"
#include "SmartScopesParser.h"
#include "SmartScopesPreviewParser.h"
void SmartScopesParserTest::parseSearchResultLineTest()
{
const QString input[] = {
"{", // invalid json
"{\"type:1\"}", // invalid type
"{\"scopes\": [[\"searchin-scopes.scope\", \"server\"], [\"info-openweathermap.scopes\", \"server\"], [\"reference-exact.scope\", \"server\"], [\"reference-rest.scope\", \"server\"], [\"news-googlenews.scope\", \"server\"], [\"info-reddit.scope\", \"server\"], [\"news-yahoostock.scope\", \"server\"], [\"music-grooveshark.scope\", \"server\"], [\"music-soundcloud.scope\", \"server\"], [\"info-foursquare.scope\", \"server\"], [\"music-songkick.scope\", \"server\"], [\"more_suggestions-u1ms.scope\", \"server\"], [\"more_suggestions-amazon.scope\", \"server\"], [\"more_suggestions-etsy.scope\", \"server\"], [\"more_suggestions-skimlinks.scope\", \"server\"], [\"more_suggestions-ebay.scope\", \"server\"]], \"server_sid\": \"abcdef\", \"type\": \"recommendations\"}",
"{\"info\": {\"info-foursquare.scope\": [{\"category\": 0, \"comment\": \"55 Basinghall St London\", \"title\": \"Imprima (LON)\", \"uri\": \"https://foursquare.com/v/imprima-lon/4b60\", \"icon_hint\": \"/usr/share/icons/unity-icon-theme/places/svg/result-info.svg\", \"mimetype\": \"text/html\", \"dnd_uri\": \"https://foursquare.com/v/imprima-lon/4b606badf964a520e6e429e3\", \"result_type\": 0, \"metadata\": {\"id\": \"foursquare:1fc9f552b1f9161ab81fbc0616234f9ff1bdeeee\"}}, {\"category\": 0, \"comment\": \"123 Buckingham Palace Rd London\", \"title\": \"LON-BEL-123 Gym\", \"uri\": \"https://foursquare.com/v/lonbel123-gym/4d9ac297674ca143ceb6c243\", \"icon_hint\": \"https://foursquare.com/img/categories_v2/building/gym_88.png\", \"mimetype\": \"text/html\", \"dnd_uri\": \"https://foursquare.com/v/lonbel123-gym/4d9ac297674ca143ceb6c243\", \"result_type\": 0, \"metadata\": {\"id\": \"foursquare:d86115198ba3a379740206d3c6da18220956a85c\"}}, {\"category\": 0, \"comment\": \"The Qube\", \"title\": \"HOK LON First Friday\", \"uri\": \"https://foursquare.com/v/hok-lon-first-friday/4f510633e4b044219085e211\", \"icon_hint\": \"https://foursquare.com/img/categories_v2/nightlife/default_88.png\", \"mimetype\": \"text/html\", \"dnd_uri\": \"https://foursquare.com/v/hok-lon-first-friday/4f510633e4b044219085e211\", \"result_type\": 0, \"metadata\": {\"id\": \"foursquare:e43c6843b4d3f0ab395a8b92e9f25b3be72e699f\"}}]}, \"type\": \"results\"}"
};
SmartScopesParser parser;
QList>> results;
QString server_sid = "";
for (unsigned i=0; i res) {
results.append(QPair>(scopeId, res));
},
[&server_sid](const QString &sid) {
server_sid = sid;
}
);
}
QCOMPARE(server_sid, QString("abcdef"));
QCOMPARE(results.size(), 3);
QCOMPARE(results[0].first, QString("info-foursquare.scope"));
QCOMPARE(results[1].first, QString("info-foursquare.scope"));
QCOMPARE(results[2].first, QString("info-foursquare.scope"));
auto res = results[0].second;
QCOMPARE(res->uri, QString("https://foursquare.com/v/imprima-lon/4b60"));
QCOMPARE(res->title, QString("Imprima (LON)"));
QCOMPARE(res->comment, QString("55 Basinghall St London"));
QCOMPARE(res->icon_hint, QString("/usr/share/icons/unity-icon-theme/places/svg/result-info.svg"));
QCOMPARE(res->dnd_uri, QString("https://foursquare.com/v/imprima-lon/4b606badf964a520e6e429e3"));
res = results[1].second;
QCOMPARE(res->uri, QString("https://foursquare.com/v/lonbel123-gym/4d9ac297674ca143ceb6c243"));
QCOMPARE(res->title, QString("LON-BEL-123 Gym"));
QCOMPARE(res->comment, QString("123 Buckingham Palace Rd London"));
QCOMPARE(res->icon_hint, QString("https://foursquare.com/img/categories_v2/building/gym_88.png"));
QCOMPARE(res->dnd_uri, QString("https://foursquare.com/v/lonbel123-gym/4d9ac297674ca143ceb6c243"));
}
void SmartScopesParserTest::parseGenericPreviewTest()
{
const QString input = "{\"info\": [{\"display_name\": \"Published\", \"icon_hint\": \"\", \"id\": \"Published\", \"value\": \"2013-05-07\"}], \"renderer_name\": \"preview-generic\", \"description\": \"The second exciting adventure in The Door Within trilogy.\", \"title\": \"The Rise of the Wyrm Lord\", \"actions\": [{\"display_name\": \"View\", \"icon_hint\": \"/usr/share/icons/unity-icon-theme/places/svg/service-googlebooks.svg\", \"id\": \"view\", \"activation_uri\": \"http://foo.com/abc\"}], \"subtitle\": \"Wayne Thomas Batson\", \"image_hint\": \"http://bks3.foo.com/books?id=R6B\"}";
SmartScopesPreviewParser parser;
auto preview = parser.parse(input);
QVERIFY(preview != nullptr);
QVERIFY(UNITY_IS_GENERIC_PREVIEW(preview) != 0);
QCOMPARE(unity_preview_get_title(preview), "The Rise of the Wyrm Lord");
QCOMPARE(unity_preview_get_subtitle(preview), "Wayne Thomas Batson");
unity_object_unref(preview);
}
void SmartScopesParserTest::parseMusicPreviewTest()
{
const QString input = "{\"info\": [], \"subtitle\": \"Los Mustang\", \"description\": \"\", \"title\": \"Los Mustang - Los Jovenes\", \"_format\": \"simple-serialization-v0\", \"attribution\": \"Certain content that appears in this preview comes from Ubuntu One Music Store. This content is provided 'as is' and is subject to change or removal at any time.\", \"actions\": [{\"icon_hint\": \"file:///usr/share/icons/unity-icon-theme/places/svg/service-u1.svg\", \"activation_uri\": \"https://foobar.com/x\", \"display_name\": \"Download\", \"extra_text\": \"9,99 USD\"}], \"tracks\": [{\"length\": 196, \"uri\": \"http://api.foobar.com/1\", \"track_no\": 1, \"title\": \"Los jovenes The young ones\"}, {\"length\": 149, \"uri\": \"http://api.foobar.com/2\", \"track_no\": 2, \"title\": \"Diana\"}, {\"length\": 162, \"uri\": \"http://api.7digital.com/3\", \"track_no\": 3, \"title\": \"Living doll\"}], \"renderer_name\": \"preview-music\", \"image_hint\": \"http://cdn.foobar.com/350.jpg\"}";
SmartScopesPreviewParser parser;
auto preview = parser.parse(input);
QVERIFY(preview != nullptr);
QVERIFY(UNITY_IS_MUSIC_PREVIEW(preview) != 0);
QCOMPARE(unity_preview_get_title(preview), "Los Mustang - Los Jovenes");
QCOMPARE(unity_preview_get_subtitle(preview), "Los Mustang");
unity_object_unref(preview);
}
QTEST_MAIN(SmartScopesParserTest)
unity-scope-onlinemusic-0.1+14.04.20140306/tests/main.cpp 0000644 0000152 0177776 00000000044 12306014511 023331 0 ustar pbuser nogroup 0000000 0000000 int main(int argc, char **argv)
{
}
unity-scope-onlinemusic-0.1+14.04.20140306/tests/SmartScopesClientTest.cpp 0000644 0000152 0177776 00000004200 12306014511 026645 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, 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, see .
*
* Author: Pawel Stolowski
*/
#include "SmartScopesClientTest.h"
#include
#include
#include "SmartScopesClient.h"
void SmartScopesClientTest::buildSearchUrlTest()
{
SmartScopesClient cli("pl");
QStringList scopes;
scopes << "a.scope" << "b.scope";
QStringList removedScopes;
removedScopes << "c.scope" << "d.scope";
auto url = cli.buildSearchUrl("foo", scopes, removedScopes, "abcdef-1234", "foobar.scope");
auto query = QUrlQuery(url.query());
QCOMPARE(query.queryItemValue("locale"), QString("pl"));
QCOMPARE(query.queryItemValue("scopes"), QString("a.scope,b.scope"));
QCOMPARE(query.queryItemValue("removed_scopes"), QString("c.scope,d.scope"));
QCOMPARE(query.queryItemValue("session_id"), QString("abcdef-1234"));
QCOMPARE(query.queryItemValue("origin"), QString("foobar.scope"));
QCOMPARE(query.queryItemValue("q"), QString("foo"));
url = cli.buildSearchUrl("bar", scopes, QStringList(), "abcdef-1234", "foobar.scope");
query = QUrlQuery(url.query());
QCOMPARE(query.queryItemValue("locale"), QString("pl"));
QCOMPARE(query.queryItemValue("scopes"), QString("a.scope,b.scope"));
QCOMPARE(query.queryItemValue("removed_scopes"), QString(""));
QCOMPARE(query.queryItemValue("session_id"), QString("abcdef-1234"));
QCOMPARE(query.queryItemValue("origin"), QString("foobar.scope"));
QCOMPARE(query.queryItemValue("q"), QString("bar"));
}
QTEST_MAIN(SmartScopesClientTest)
unity-scope-onlinemusic-0.1+14.04.20140306/CMakeLists.txt 0000644 0000152 0177776 00000002335 12306014511 023304 0 ustar pbuser nogroup 0000000 0000000 CMAKE_MINIMUM_REQUIRED(VERSION 2.8.9)
PROJECT(unity-scope-onlinemusic CXX)
SET(CMAKE_INCLUDE_CURRENT_DIR ON)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-permissive -pedantic -Wall -Wextra")
ADD_DEFINITIONS(-DQT_NO_KEYWORDS)
FIND_PACKAGE(Gettext REQUIRED)
FIND_PROGRAM(INTLTOOL_MERGE intltool-merge DOC "intltool-merge program")
FIND_PACKAGE(Qt5Core REQUIRED)
FIND_PACKAGE(Qt5Network REQUIRED)
FIND_PACKAGE(Qt5Test REQUIRED)
FIND_PACKAGE(PkgConfig REQUIRED)
PKG_CHECK_MODULES(UNITY REQUIRED unity>=7.1.0)
PKG_CHECK_MODULES(DEEQT REQUIRED libdee-qt5>=3.2)
PKG_CHECK_MODULES(UUID REQUIRED uuid>=2.20.0)
IF(${INTLTOOL_MERGE} MATCHES "INTLTOOL_MERGE-NOTFOUND")
MESSAGE(FATAL_ERROR "xxx")
ENDIF()
INCLUDE(GNUInstallDirs)
SET(ICON_DIR "${CMAKE_INSTALL_DATADIR}/icons/unity-icon-theme/places/svg")
SET(CATEGORY_ICON_PATH "${ICON_DIR}/service-soundcloud.svg")
SET(DEFAULT_ICON_PATH "${ICON_DIR}/result-music.svg")
SET(GETTEXT_PACKAGE unity-scope-onlinemusic)
SET(LOCALE_DIR "${CMAKE_INSTALL_DATADIR}/locale")
CONFIGURE_FILE(
"${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in"
"${CMAKE_CURRENT_BINARY_DIR}/src/config.h"
)
ENABLE_TESTING()
ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(po)
ADD_SUBDIRECTORY(tests)
ADD_SUBDIRECTORY(data)
unity-scope-onlinemusic-0.1+14.04.20140306/TODO.txt 0000644 0000152 0177776 00000000000 12306014511 022035 0 ustar pbuser nogroup 0000000 0000000 unity-scope-onlinemusic-0.1+14.04.20140306/po/ 0000755 0000152 0177776 00000000000 12306014762 021167 5 ustar pbuser nogroup 0000000 0000000 unity-scope-onlinemusic-0.1+14.04.20140306/po/CMakeLists.txt 0000644 0000152 0177776 00000001266 12306014511 023724 0 ustar pbuser nogroup 0000000 0000000 FILE(GLOB SOURCE_FILES ${CMAKE_SOURCE_DIR}/src/*.cpp)
SET(POT_FILE "unity-scope-onlinemusic.pot")
ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${POT_FILE}
COMMAND xgettext -o ${POT_FILE}
--copyright-holder=\"Canonical Ltd. \"
--package-name ${GETTEXT_PACKAGE}
--qt --c++ --add-comments=TRANSLATORS
--keyword=_ --keyword=tr --keyword=tr:1,2 --from-code=UTF-8 ${SOURCE_FILES}
DEPENDS ${SOURCE_FILES})
ADD_CUSTOM_TARGET(pot DEPENDS ${POT_FILE})
FILE(GLOB PO_FILES *.po)
GETTEXT_CREATE_TRANSLATIONS(${POT_FILE} ALL ${PO_FILES})
unity-scope-onlinemusic-0.1+14.04.20140306/src/ 0000755 0000152 0177776 00000000000 12306014762 021340 5 ustar pbuser nogroup 0000000 0000000 unity-scope-onlinemusic-0.1+14.04.20140306/src/Utils.h 0000644 0000152 0177776 00000002312 12306014511 022577 0 ustar pbuser nogroup 0000000 0000000 /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, 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, see .
*
* Author: Pawel Stolowski
*/
#ifndef SCOPEUTILS_H
#define SCOPEUTILS_H
#include
#include
#include
#include
GIcon* gfileIconFromUri(const QString &uri);
GVariant* hashtableToAsv(GHashTable *hashtable);
QVariantMap ghashtableToQVariantHash(GHashTable *hashtable);
QVariantHash QVariantMapToHash(const QVariantMap &map);
QString randomizedTimeUuid();
inline char* _(const char *__msgid) {
return gettext(__msgid);
}
#endif
unity-scope-onlinemusic-0.1+14.04.20140306/src/OnlineMusicScope.cpp 0000644 0000152 0177776 00000022110 12306014511 025247 0 ustar pbuser nogroup 0000000 0000000 /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, 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, see .
*
* Author: Pawel Stolowski
*/
#include "OnlineMusicScope.h"
#include "SmartScopesClient.h"
#include "Utils.h"
#include
#include
#include
#include