[shotwell] Remove some simple TimeVal deprecations
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [shotwell] Remove some simple TimeVal deprecations
- Date: Sun, 2 Feb 2020 14:37:20 +0000 (UTC)
commit daf116999ccc19234e2902cee03084ef9febcc17
Author: Jens Georg <mail jensge org>
Date: Sun Feb 2 15:10:42 2020 +0100
Remove some simple TimeVal deprecations
plugins/common/OAuth1Support.vala | 7 ++-----
src/db/PhotoTable.vala | 4 +---
src/util/Util.vala | 2 ++
src/util/misc.vala | 10 ++--------
src/util/system.vala | 3 ++-
5 files changed, 9 insertions(+), 17 deletions(-)
---
diff --git a/plugins/common/OAuth1Support.vala b/plugins/common/OAuth1Support.vala
index e5a8545e..c9a4f42f 100644
--- a/plugins/common/OAuth1Support.vala
+++ b/plugins/common/OAuth1Support.vala
@@ -111,11 +111,8 @@ namespace Publishing.RESTSupport.OAuth1 {
}
public string get_oauth_nonce() {
- TimeVal currtime = TimeVal();
- currtime.get_current_time();
-
- return Checksum.compute_for_string(ChecksumType.MD5, currtime.tv_sec.to_string() +
- currtime.tv_usec.to_string());
+ return Checksum.compute_for_string(ChecksumType.MD5,
+ GLib.get_monotonic_time().to_string());
}
public string get_oauth_timestamp() {
diff --git a/src/db/PhotoTable.vala b/src/db/PhotoTable.vala
index 369c0a31..72e43e79 100644
--- a/src/db/PhotoTable.vala
+++ b/src/db/PhotoTable.vala
@@ -44,9 +44,7 @@ public struct ImportID {
}
public static ImportID generate() {
- TimeVal timestamp = TimeVal();
- timestamp.get_current_time();
- int64 id = timestamp.tv_sec;
+ int64 id = GLib.get_real_time () / Util.USEC_PER_SEC;
return ImportID(id);
}
diff --git a/src/util/Util.vala b/src/util/Util.vala
index b87ea3a0..45943d70 100644
--- a/src/util/Util.vala
+++ b/src/util/Util.vala
@@ -8,6 +8,8 @@ namespace Util {
// Use these file attributes when loading file information for a complete FileInfo objects
public const string FILE_ATTRIBUTES = "standard::*,time::*,id::file,id::filesystem,etag::value";
+ public const int64 USEC_PER_SEC = 1000000;
+
public void init() throws Error {
}
diff --git a/src/util/misc.vala b/src/util/misc.vala
index d1d6431a..6c44dfe6 100644
--- a/src/util/misc.vala
+++ b/src/util/misc.vala
@@ -54,18 +54,12 @@ public bool int_value_equals(Value a, Value b) {
return (int) a == (int) b;
}
-public ulong timeval_to_ms(TimeVal time_val) {
- return (((ulong) time_val.tv_sec) * 1000) + (((ulong) time_val.tv_usec) / 1000);
-}
-
public ulong now_ms() {
- return timeval_to_ms(TimeVal());
+ return (ulong) (GLib.get_real_time() / 1000);
}
public ulong now_sec() {
- TimeVal time_val = TimeVal();
-
- return time_val.tv_sec;
+ return (ulong) (GLib.get_real_time() / Util.USEC_PER_SEC);
}
public inline time_t now_time_t() {
diff --git a/src/util/system.vala b/src/util/system.vala
index 8563573e..48e2cc98 100644
--- a/src/util/system.vala
+++ b/src/util/system.vala
@@ -39,7 +39,8 @@ async void show_file_in_filemanager(File file) throws Error {
DBusProxyFlags.DO_NOT_LOAD_PROPERTIES |
DBusProxyFlags.DO_NOT_CONNECT_SIGNALS);
var id = "%s_%s_%d_%s".printf(Environment.get_prgname(), Environment.get_host_name(),
- Posix.getpid(), TimeVal().to_iso8601());
+ Posix.getpid(),
+ GLib.get_monotonic_time().to_string());
yield manager.show_items({file.get_uri()}, id);
} catch (Error e) {
warning("Failed to launch file manager using DBus, using fall-back: %s", e.message);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]