~unity-api-team/unity-scopes-api/child-scopes-option

« back to all changes in this revision

Viewing changes to src/scopes/internal/smartscopes/SmartScopesClient.cpp

  • Committer: Marcus Tomlinson
  • Date: 2014-10-08 10:58:57 UTC
  • mfrom: (497.1.3 devel)
  • mto: (497.1.5 devel)
  • mto: This revision was merged to the branch mainline in revision 505.
  • Revision ID: marcus.tomlinson@canonical.com-20141008105857-gf4ilb9ywfeaeroi
Merged devel

Show diffs side-by-side

added added

removed removed

Lines of Context:
335
335
                                             VariantMap const& filter_state,
336
336
                                             std::string const& locale,
337
337
                                             std::string const& country,
 
338
                                             std::string const& user_agent_hdr,
338
339
                                             uint limit)
339
340
{
340
341
    std::ostringstream search_uri;
381
382
    uint search_id = ++query_counter_;
382
383
 
383
384
    std::cout << "SmartScopesClient.search(): GET " << search_uri.str() << std::endl;
 
385
 
 
386
    HttpHeaders headers;
 
387
    if (!user_agent_hdr.empty())
 
388
    {
 
389
        std::cout << "User agent: " << user_agent_hdr;
 
390
        headers.push_back(std::make_pair("User-Agent", user_agent_hdr));
 
391
    }
 
392
 
384
393
    query_results_[search_id] = http_client_->get(search_uri.str(), [this, handler](std::string const& lineData) {
385
394
            try
386
395
            {
390
399
            {
391
400
                std::cerr << "Failed to parse: " << e.what() << std::endl;
392
401
            }
393
 
    });
 
402
    }, headers);
394
403
 
395
404
    return SearchHandle::UPtr(new SearchHandle(search_id, shared_from_this()));
396
405
}
403
412
                                               const uint widgets_api_version,
404
413
                                               VariantMap const& settings,
405
414
                                               std::string const& locale,
 
415
                                               std::string const& user_agent_hdr,
406
416
                                               std::string const& country)
407
417
{
408
418
    std::ostringstream preview_uri;
415
425
    preview_uri << "&platform=" << platform;
416
426
    preview_uri << "&widgets_api_version=" << std::to_string(widgets_api_version);
417
427
 
 
428
    HttpHeaders headers;
 
429
    if (!user_agent_hdr.empty())
 
430
    {
 
431
        headers.push_back(std::make_pair("User-Agent", user_agent_hdr));
 
432
    }
 
433
 
418
434
    // optional parameters
419
435
 
420
436
    if (!settings.empty())
447
463
            {
448
464
                std::cerr << "Failed to parse: " << e.what() << std::endl;
449
465
            }
450
 
    });
 
466
    }, headers);
451
467
 
452
468
    return PreviewHandle::UPtr(new PreviewHandle(preview_id, shared_from_this()));
453
469
}