Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=c6a55388b4eaef89e4e63b6d289ae978359a7725

commit c6a55388b4eaef89e4e63b6d289ae978359a7725
Author: Michel Hermier <herm...@frugalware.org>
Date:   Sat Nov 16 12:21:05 2013 +0100

libpacman: Add pacman_downloadstate_eta.

diff --git a/doc/libpacman-changes.txt b/doc/libpacman-changes.txt
index 2b4505c..5496ac2 100644
--- a/doc/libpacman-changes.txt
+++ b/doc/libpacman-changes.txt
@@ -48,6 +48,8 @@ pacman_downloadstate_begin: Access to download start time.

pacman_downloadstate_end: Access to download end time.

+pacman_downloadstate_eta: Access to download eta time.
+
pacman_downloadstate_resume: Access to resume download size.

pacman_downloadstate_size: Access to final download size.
diff --git a/lib/libpacman/pacman.c b/lib/libpacman/pacman.c
index 01baba2..42977b7 100644
--- a/lib/libpacman/pacman.c
+++ b/lib/libpacman/pacman.c
@@ -434,6 +434,7 @@ int pacman_downloadstate_begin(const pmdownloadstate_t 
*downloadstate, struct ti
* Calling this method before pacman_downloadstate_tell give the same value as 
pacman_downloadstate_size
* has no meaning and can give any value.
* @param downloadstate pointer to the download state to get the informations 
from.
+ * @param offset pointer to the value to be written.
* @return return 0 in case of success, !0 otherwise.
*/
int pacman_downloadstate_end(const pmdownloadstate_t *downloadstate, struct 
timeval *timeval)
@@ -445,7 +446,20 @@ int pacman_downloadstate_end(const pmdownloadstate_t 
*downloadstate, struct time
return 0;
}

-/** Get the size at the start of the download resume
+/** Get the estimate time to arrival of the download (in seconds).
+ * @param downloadstate pointer to the download state to get the informations 
from.
+ * @param offset pointer to the value to be written.
+ * @return return 0 in case of success, !0 otherwise.
+ */
+int pacman_downloadstate_eta(const pmdownloadstate_t *downloadstate, double 
*eta)
+{
+       ASSERT(downloadstate != NULL, return -1);
+       ASSERT(eta != NULL, return -1);
+
+       *eta = downloadstate->eta;
+}
+
+/** Get the size at the start of the download resume.
* @param downloadstate pointer to the download state to get the informations 
from.
* @param offset pointer to the value to be written.
* @return return 0 in case of success, !0 otherwise.
diff --git a/lib/libpacman/pacman.h b/lib/libpacman/pacman.h
index bbd5c46..7702fd4 100644
--- a/lib/libpacman/pacman.h
+++ b/lib/libpacman/pacman.h
@@ -174,6 +174,7 @@ pmlist_t *pacman_db_test(pmdb_t *db);

int pacman_downloadstate_begin(const pmdownloadstate_t *downloadstate, struct 
timeval *timeval);
int pacman_downloadstate_end(const pmdownloadstate_t *downloadstate, struct 
timeval *timeval);
+int pacman_downloadstate_eta(const pmdownloadstate_t *downloadstate, double 
*eta);
int pacman_downloadstate_resume(const pmdownloadstate_t *downloadstate, off_t 
*offset);
int pacman_downloadstate_size(const pmdownloadstate_t *downloadstate, off_t 
*offset);
int pacman_downloadstate_tell(const pmdownloadstate_t *downloadstate, off_t 
*offset);
diff --git a/lib/libpacman/server.h b/lib/libpacman/server.h
index 9cf6f19..c862929 100644
--- a/lib/libpacman/server.h
+++ b/lib/libpacman/server.h
@@ -47,6 +47,7 @@ struct __pmdownloadstate_t {
// FIXME: change int to off_t when the download backend will permit that.
struct timeval dst_begin;
struct timeval dst_end;
+       double dst_eta;
int dst_resume;
int dst_size;
int dst_tell;
_______________________________________________
Frugalware-git mailing list
Frugalware-git@frugalware.org
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to