[PATCH 0/1] Add utility to compute values for page-based services.



As some of you know, some services like Jamendo and Flickr are based on pages:
instead of specifying skip and count, they require a page number and page size.

So I added here an utility function, grl_paging_translate() which helps to
translate from skip + count to page_number, page_size and page_offset.

Page_number is the page where user can find the first requested value. To get
the exact position, user can use page_offset to know where the required values
starts inside the page. If values are not enough, user can request then
page_number+1, page_number+2, and so on.

Page_size is the size of the page. This is the most tricky value to compute.
Page_size is computed so only one request is needed to get all data, while
keeping the page_size as smaller as possible. It is worth to note that in some
services, there is a limit in page_size (for instance, in Flickr page can not
be greater than 500). So grl_paging_translate() allows to specify a limit for
page_size.

As I see this function as an utility, I added a new file to core,
grl-util.[ch]. I expect to add there other utilities that do not fit well in
any other place, but still they are useful.


	J.A.


Juan A. Suarez Romero (1):
  Add utility for services needing page_size + page_number

 src/Makefile.am             |    5 ++-
 src/grilo.h                 |    1 +
 src/grl-util.c              |   85 +++++++++++++++++++++++++++++++++++++++++++
 src/{grilo.h => grl-util.h} |   43 ++++++----------------
 4 files changed, 101 insertions(+), 33 deletions(-)
 create mode 100644 src/grl-util.c
 copy src/{grilo.h => grl-util.h} (56%)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]