945
946
submit_future.get();
948
getApplicationUri(manifest, [this, reply, manifest, app_name, &review, userid, force_cache](const std::string& uri) {
949
populateDetails([this, reply, uri, manifest, app_name](const PackageDetails &details){
950
cachedDetails = details;
951
store_department(details);
952
pushPackagePreviewWidgets(cachedWidgets, details, createButtons(uri, manifest));
954
[this, reply, &review, manifest, userid](const ReviewList& reviewlist,
955
click::Reviews::Error error) {
956
auto reviews = bring_to_front(reviewlist, userid);
957
if (manifest.removable && !cachedDetails.download_url.empty()) {
958
scopes::PreviewWidgetList review_input;
959
bool has_reviewed = reviews.size() > 0 && reviews.front().reviewer_username == userid;
961
Review existing_review;
962
existing_review.id = 0;
964
existing_review = reviews.front();
967
review_input.push_back(createRatingWidget(existing_review));
968
cachedWidgets.push(review_input);
969
cachedWidgets.layout.appendToColumn(cachedWidgets.layout.singleColumn.column1, review_input);
970
cachedWidgets.layout.appendToColumn(cachedWidgets.layout.twoColumns.column1, review_input);
973
if (error == click::Reviews::Error::NoError) {
974
auto const revs = reviewsWidgets(reviews);
975
cachedWidgets.push(revs);
976
cachedWidgets.layout.appendToColumn(cachedWidgets.layout.singleColumn.column1, revs);
977
cachedWidgets.layout.appendToColumn(cachedWidgets.layout.twoColumns.column1, revs);
979
qDebug() << "There was an error getting reviews for:" << result["name"].get_string().c_str();
981
cachedWidgets.flush(reply);
949
populateDetails([this, reply, manifest, app_name](const PackageDetails &details){
950
cachedDetails = details;
951
store_department(details);
952
pushPackagePreviewWidgets(cachedWidgets, details, createButtons(manifest));
954
[this, reply, &review, manifest, userid](const ReviewList& reviewlist,
955
click::Reviews::Error error) {
956
auto reviews = bring_to_front(reviewlist, userid);
957
if (manifest.removable && !cachedDetails.download_url.empty()) {
958
scopes::PreviewWidgetList review_input;
959
bool has_reviewed = reviews.size() > 0 && reviews.front().reviewer_username == userid;
961
Review existing_review;
962
existing_review.id = 0;
964
existing_review = reviews.front();
967
review_input.push_back(createRatingWidget(existing_review));
968
cachedWidgets.push(review_input);
969
cachedWidgets.layout.appendToColumn(cachedWidgets.layout.singleColumn.column1, review_input);
970
cachedWidgets.layout.appendToColumn(cachedWidgets.layout.twoColumns.column1, review_input);
973
if (error == click::Reviews::Error::NoError) {
974
auto const revs = reviewsWidgets(reviews);
975
cachedWidgets.push(revs);
976
cachedWidgets.layout.appendToColumn(cachedWidgets.layout.singleColumn.column1, revs);
977
cachedWidgets.layout.appendToColumn(cachedWidgets.layout.twoColumns.column1, revs);
979
qDebug() << "There was an error getting reviews for:" << result["name"].get_string().c_str();
981
cachedWidgets.flush(reply);
987
scopes::PreviewWidgetList InstalledPreview::createButtons(const std::string& uri,
988
const Manifest& manifest)
986
scopes::PreviewWidgetList InstalledPreview::createButtons(const Manifest& manifest)
990
988
scopes::PreviewWidgetList widgets;
991
989
scopes::PreviewWidget buttons("buttons", "actions");
1030
1030
return widgets;
1033
void InstalledPreview::getApplicationUri(const Manifest& manifest, std::function<void(const std::string&)> callback)
1033
std::string InstalledPreview::getApplicationUri(const Manifest& manifest)
1035
QString app_url = QString::fromStdString(result.uri());
1037
// asynchronously get application uri based on app name, if the uri is not application://.
1038
// this can happen if the app was just installed and we have its http uri from the Result.
1039
if (!app_url.startsWith("application:///")) {
1040
const std::string name = result["name"].get_string();
1035
static std::regex appurl_match{"^(application|appid)://[a-zA-Z\\._/-]+$"};
1037
if (!std::regex_match(result.uri(), appurl_match)) {
1042
1038
if (manifest.has_any_apps()) {
1043
qt::core::world::enter_with_task([this, name, callback] ()
1045
click::Interface().get_dotdesktop_filename(name,
1046
[callback, name] (std::string val, click::InterfaceError error) {
1048
if (error == click::InterfaceError::NoError) {
1049
uri = "application:///" + val;
1051
qWarning() << "Can't get .desktop filename for"
1052
<< QString::fromStdString(name);
1039
std::string uri = "appid://" + manifest.name + "/" +
1040
manifest.first_app_name + "/current-user-version";
1042
} else if (manifest.has_any_scopes()) {
1043
unity::scopes::CannedQuery cq(manifest.first_scope_id);
1044
auto scope_uri = cq.to_uri();
1045
qDebug() << "Found uri for scope"
1046
<< QString::fromStdString(manifest.first_scope_id)
1047
<< "-" << QString::fromStdString(scope_uri);
1059
if (manifest.has_any_scopes()) {
1060
unity::scopes::CannedQuery cq(manifest.first_scope_id);
1061
auto scope_uri = cq.to_uri();
1062
qDebug() << "Found uri for scope" << QString::fromStdString(manifest.first_scope_id)
1063
<< "-" << QString::fromStdString(scope_uri);
1064
callback(scope_uri);
1050
qWarning() << "Unable to find app or scope URI for:"
1051
<< QString::fromStdString(manifest.name);
1068
callback(result.uri());
1055
return result.uri();
1072
1058
// class InstalledScopePreview