← Back to team overview

ubuntu-phone team mailing list archive

Re: Scopes questions

 

On Mon, 2014-11-03 at 14:55 -0500, Robert Schroll wrote:
> Hi all,
> 
> I started playing around with scopes and have run into a few questions. 
>  If there's a better place to ask about this, please let me know.  
> Otherwise:
> 
> 1) Is it possible to delay a query until the user hits "Enter"?  Or 
> failing that, until a second or so has passed from the last key stroke? 
>  I'm experimenting with a service that rate-limits queries, and the 
> partial queries won't lead to useful results anyway.  I'd prefer an 
> explicit indication from the user that they're done, but I'm not sure 
> if that's possible.  I'm guessing that the delay is possible, but I 
> don't know if that should go in the client or the query or somewhere 
> else.

There should be a short delay (~100ms) already, after the last key was
pressed, before the query is sent. Maybe this needs to be closer to
300ms or so, as typing on the phone can be pretty slow, unlike typing
with a real keyboard. If you are finding the current delay is not long
enough, please file a bug that the queries are happening too fast.
However, when a new query is sent to the scope, the old query has
cancel() called on it. You may need to add additional code to close the
connection to the server, or similar, when you receive the cancel call.

> 2) Is it possible to display images without any rescaling or cropping?  
> I can tell the service the maximum size for images, but the actual size 
> and aspect ratio will depend on the content.  Both in the query and the 
> preview, I'd like to insert those images as-is, but the defaults 
> rescale and, in the query view, crop them.

I don't think so. The card size and aspect ratio you specify in the
scope, tells the dash how to draw the images. To fit properly, the dash
will scale and may crop, the images.

> In a related issue, I've set ShapeImages=false in the .ini file, but 
> that doesn't seem to have any effect.  That could be related to...
> 
> 3) How do you get an updated .ini file to be used?  I'm testing on an 
> emulator (r243), and it seems to be caching the old .ini files. The 
> only way I can get it to recognize an updated one is to restart the 
> emulator.  Surely there's a better way?

You might need to touch the directory the scope is installed in, to
trigger an update. If that doesn't work, you can run "restart
scope-registry" and it should pick up the new files. At least, the new
version of a system scope is getting picked up when I install a new
version of the package with dpkg. For click packaged scopes, I think you
need to actually get the hook to run for the package, as the .ini file
in your click package is not exactly the same as the one read by the
scopes.

> 4) Is there some guide to making asynchronous queries?  The tutorials 
> I'm working off of seem to be synchronous, although the docs suggest 
> the different parts may be running in different threads.  But I'd like 
> to fire off a query, get and display some results, and then fire off 
> some more queries based on those results and display them when those 
> replies get back.  I've never worked with asynchronous code in C++, so 
> a pointer to a C++ tutorial may be helpful.  This may be relevant for 
> (1).

It is basically up to the developer of the scope to decide how to do
that. You will need to block in the Query::run, hold the reference to
the Reply pointer, and manage asynchronous calls in the background, via
additional threads or event loops. There is no way to push additional
results though, after the Reply pointer has gone out of scope, or
finished() was called on it. And you can't update existing results with
more data after they have been pushed.




Follow ups

References