[rygel] all: Replace deprecated TimeVal
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] all: Replace deprecated TimeVal
- Date: Sun, 2 Feb 2020 14:56:33 +0000 (UTC)
commit aa1795c0020059d8779f8708ec854198b85881ae
Author: Jens Georg <mail jensge org>
Date: Thu Jan 30 23:14:58 2020 +0100
all: Replace deprecated TimeVal
Use manual iso8601 format for now until after vala 0.48 and GNOME 3.36
src/librygel-core/rygel-basic-management.vala | 7 +++----
src/librygel-server/rygel-media-object.vala | 24 +++-------------------
src/plugins/lms/rygel-lms-all-images.vala | 4 ++--
src/plugins/lms/rygel-lms-all-music.vala | 4 ++--
src/plugins/lms/rygel-lms-all-videos.vala | 4 ++--
src/plugins/lms/rygel-lms-image-year.vala | 4 ++--
.../media-export/rygel-media-export-extractor.vala | 5 +++--
.../tracker/rygel-tracker-insertion-query.vala | 4 ++--
src/plugins/tracker/rygel-tracker-new.vala | 7 ++++---
9 files changed, 23 insertions(+), 40 deletions(-)
---
diff --git a/src/librygel-core/rygel-basic-management.vala b/src/librygel-core/rygel-basic-management.vala
index c0661532..683ce50f 100644
--- a/src/librygel-core/rygel-basic-management.vala
+++ b/src/librygel-core/rygel-basic-management.vala
@@ -47,10 +47,9 @@ public class Rygel.BasicManagement : Service {
this.tests_map = new HashMap<string, BasicManagementTest> ();
this.test_ids_by_type = new HashMap<string, LinkedList> ();
- var now = TimeVal ();
- now.tv_usec = 0;
-
- this.device_status = "OK," + now.to_iso8601 ();
+ var now = new GLib.DateTime.now_utc ();
+ // TODO: Replace with to_iso8601() once glib 2.62 is a bit more widespread
+ this.device_status = "OK,%sZ".printf (now.format ("%Y-%m-%dT%H:%M:%S"));
this.query_variable["DeviceStatus"].connect
(this.query_device_status_cb);
diff --git a/src/librygel-server/rygel-media-object.vala b/src/librygel-server/rygel-media-object.vala
index fec03c30..d3e450b4 100644
--- a/src/librygel-server/rygel-media-object.vala
+++ b/src/librygel-server/rygel-media-object.vala
@@ -470,28 +470,10 @@ public abstract class Rygel.MediaObject : GLib.Object {
other_date += "T00:00:00Z";
}
- var tv1 = TimeVal ();
- assert (tv1.from_iso8601 (this.date));
+ var our_date_time = new GLib.DateTime.from_iso8601 (our_date, null);
+ var other_date_time = new GLib.DateTime.from_iso8601 (other_date, null);
- var tv2 = TimeVal ();
- assert (tv2.from_iso8601 (object.date));
-
- var ret = this.compare_long (tv1.tv_sec, tv2.tv_sec);
- if (ret == 0) {
- ret = this.compare_long (tv1.tv_usec, tv2.tv_usec);
- }
-
- return ret;
- }
- }
-
- private int compare_long (long a, long b) {
- if (a < b) {
- return -1;
- } else if (a > b) {
- return 1;
- } else {
- return 0;
+ return our_date_time.compare (other_date_time);
}
}
diff --git a/src/plugins/lms/rygel-lms-all-images.vala b/src/plugins/lms/rygel-lms-all-images.vala
index e1da656d..48bc23da 100644
--- a/src/plugins/lms/rygel-lms-all-images.vala
+++ b/src/plugins/lms/rygel-lms-all-images.vala
@@ -70,8 +70,8 @@ public class Rygel.LMS.AllImages : Rygel.LMS.CategoryContainer {
var title = statement.column_text (1);
var image = new ImageItem (this.build_child_id (id), this, title);
image.creator = statement.column_text (2);
- TimeVal tv = { (long) statement.column_int (3), (long) 0 };
- image.date = tv.to_iso8601 ();
+ var dt = new DateTime.from_unix_utc ((long) statement.column_int (3));
+ image.date = "%sZ".printf (now.format ("%Y-%m-%dT%H:%M:%S"));
image.width = statement.column_int (4);
image.height = statement.column_int (5);
image.size = statement.column_int (7);
diff --git a/src/plugins/lms/rygel-lms-all-music.vala b/src/plugins/lms/rygel-lms-all-music.vala
index f99b736d..8650f62b 100644
--- a/src/plugins/lms/rygel-lms-all-music.vala
+++ b/src/plugins/lms/rygel-lms-all-music.vala
@@ -156,8 +156,8 @@ public class Rygel.LMS.AllMusic : Rygel.LMS.CategoryContainer {
song.mime_type = mime_type;
song.artist = statement.column_text (11);
song.album = statement.column_text (12);
- TimeVal tv = { (long) statement.column_int (13), (long) 0 };
- song.date = tv.to_iso8601 ();
+ var dt = new DateTime.from_unix_utc ((long) statement.column_int (13));
+ song.date = "%sZ".printf (now.format ("%Y-%m-%dT%H:%M:%S"));
song.genre = statement.column_text (14);
var file = File.new_for_path (path);
song.add_uri (file.get_uri ());
diff --git a/src/plugins/lms/rygel-lms-all-videos.vala b/src/plugins/lms/rygel-lms-all-videos.vala
index 3721ac28..30bacfc4 100644
--- a/src/plugins/lms/rygel-lms-all-videos.vala
+++ b/src/plugins/lms/rygel-lms-all-videos.vala
@@ -83,8 +83,8 @@ public class Rygel.LMS.AllVideos : Rygel.LMS.CategoryContainer {
var video = new VideoItem (this.build_child_id (id), this, title);
video.creator = statement.column_text (2);
video.duration = statement.column_int (3);
- TimeVal tv = { (long) statement.column_int (5), (long) 0 };
- video.date = tv.to_iso8601 ();
+ var dt = new DateTime.from_unix_utc ((long) statement.column_int (5));
+ video.date = "%sZ".printf (now.format ("%Y-%m-%dT%H:%M:%S"));
video.size = statement.column_int (6);
video.dlna_profile = statement.column_text (7);
video.mime_type = mime_type;
diff --git a/src/plugins/lms/rygel-lms-image-year.vala b/src/plugins/lms/rygel-lms-image-year.vala
index a3761114..1f2b70a1 100644
--- a/src/plugins/lms/rygel-lms-image-year.vala
+++ b/src/plugins/lms/rygel-lms-image-year.vala
@@ -71,8 +71,8 @@ public class Rygel.LMS.ImageYear : Rygel.LMS.CategoryContainer {
var image = new ImageItem (this.build_child_id (id), this, title);
image.ref_id = this.build_reference_id (id);
image.creator = statement.column_text (2);
- TimeVal tv = { (long) statement.column_int (3), (long) 0 };
- image.date = tv.to_iso8601 ();
+ var dt = new DateTime.from_unix_utc ((long) statement.column_int (3));
+ image.date = "%sZ".printf (now.format ("%Y-%m-%dT%H:%M:%S"));
image.width = statement.column_int (4);
image.height = statement.column_int (5);
image.size = statement.column_int (7);
diff --git a/src/plugins/media-export/rygel-media-export-extractor.vala
b/src/plugins/media-export/rygel-media-export-extractor.vala
index 251b2491..5c46eec1 100644
--- a/src/plugins/media-export/rygel-media-export-extractor.vala
+++ b/src/plugins/media-export/rygel-media-export-extractor.vala
@@ -110,8 +110,9 @@ public class Rygel.MediaExport.Extractor : Object {
(FileAttribute.TIME_MODIFIED);
this.serialized_info.insert (Serializer.MODIFIED, "t", mtime);
- TimeVal tv = { (long) mtime, 0 };
- this.serialized_info.insert (Serializer.DATE, "s", tv.to_iso8601 ());
+ var dt = new DateTime.from_unix_utc (mtime);
+ var date = "%sZ".printf (now.format ("%Y-%m-%dT%H:%M:%S"));
+ this.serialized_info.insert (Serializer.DATE, "s", date);
var content_type = ContentType.get_mime_type
(file_info.get_content_type ());
diff --git a/src/plugins/tracker/rygel-tracker-insertion-query.vala
b/src/plugins/tracker/rygel-tracker-insertion-query.vala
index b4d6c2c9..e062d058 100644
--- a/src/plugins/tracker/rygel-tracker-insertion-query.vala
+++ b/src/plugins/tracker/rygel-tracker-insertion-query.vala
@@ -95,8 +95,8 @@ public class Rygel.Tracker.InsertionQuery : Query {
"\"" + item.get_primary_uri () + "\""));
string date;
if (item.date == null) {
- var now = TimeVal ();
- date = now.to_iso8601 ();
+ var now = new GLib.DateTime.now_utc ();
+ date = "%sZ".printf (now.format ("%Y-%m-%dT%H:%M:%S"));
} else {
// Rygel core makes sure that this is a valid ISO8601 date.
date = item.date;
diff --git a/src/plugins/tracker/rygel-tracker-new.vala b/src/plugins/tracker/rygel-tracker-new.vala
index af55bf02..efabcc86 100644
--- a/src/plugins/tracker/rygel-tracker-new.vala
+++ b/src/plugins/tracker/rygel-tracker-new.vala
@@ -41,11 +41,12 @@ public class Rygel.Tracker.New : Rygel.Tracker.SearchContainer {
ADDED_PREDICATE,
ADDED_VARIABLE));
- var time = TimeVal ();
- time.tv_sec -= THREE_DAYS_AS_SEC;
+ var now = new DateTime.now_utc ();
+ now.add_days (-3);
+ var three_days_ago = "%sZ".printf (now.format ("%Y-%m-%dT%H:%M:%S"));
var filters = new ArrayList<string> ();
- filters.add (ADDED_VARIABLE + " > \"" + time.to_iso8601 () + "\"");
+ filters.add (ADDED_VARIABLE + " > \"" + three_days_ago + "\"");
base (parent.id + "New",
parent,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]