aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkremlin <ian@kremlin.cc>1973-03-03 17:48:04 +0800
committerkremlin <ian@kremlin.cc>1973-03-03 17:48:04 +0800
commitfe95904343623a78153b89fd1c2f1c0c4544c606 (patch)
tree7ebd8f3e955f8b7448921410e03ea75578372b9d
parenta8f7171993dc1467e353bbd1f7c712c31f2b846b (diff)
downloadsystembsd-fe95904343623a78153b89fd1c2f1c0c4544c606.tar
systembsd-fe95904343623a78153b89fd1c2f1c0c4544c606.tar.gz
systembsd-fe95904343623a78153b89fd1c2f1c0c4544c606.tar.bz2
systembsd-fe95904343623a78153b89fd1c2f1c0c4544c606.tar.lz
systembsd-fe95904343623a78153b89fd1c2f1c0c4544c606.tar.xz
systembsd-fe95904343623a78153b89fd1c2f1c0c4544c606.tar.zst
systembsd-fe95904343623a78153b89fd1c2f1c0c4544c606.zip
completed timedated's SetTime method
-rw-r--r--src/interfaces/timedated/timedated.c40
1 files changed, 36 insertions, 4 deletions
diff --git a/src/interfaces/timedated/timedated.c b/src/interfaces/timedated/timedated.c
index 0aee4dc..41483a4 100644
--- a/src/interfaces/timedated/timedated.c
+++ b/src/interfaces/timedated/timedated.c
@@ -101,12 +101,43 @@ on_handle_set_time(Timedate1 *td1_passed_interf,
return FALSE;
}
- if(relative) {
+ if(!proposed_time) {
+
+ timedate1_complete_set_time(td1_passed_interf, invoc);
+ return TRUE;
- new_time = (struct timespec *) g_malloc0(sizeof(struct timespec));
+ } else if(relative) {
+ new_time = (struct timespec *) g_malloc0(sizeof(struct timespec));
cur_time = g_get_real_time();
- /* LEFT OFF HERE 9/13 */ return FALSE;
+
+ if(proposed_time < 0 && cur_time + proposed_time > proposed_time) {
+
+ g_dbus_method_invocation_return_dbus_error(invoc, "org.freedesktop.timedate1.Error.EINVAL", "Resultant time out of bounds.");
+ return FALSE;
+
+ } else if(cur_time + proposed_time < proposed_time) {
+
+ g_dbus_method_invocation_return_dbus_error(invoc, "org.freedesktop.timedate1.Error.EINVAL", "Resultant time out of bounds.");
+ return FALSE;
+ }
+
+ new_time = (struct timespec *) g_malloc0(sizeof(struct timespec));
+ new_time->tv_sec = proposed_time;
+ new_time->tv_nsec = 0;
+ g_ptr_array_add(timedated_freeable, new_time);
+
+ if(!clock_settime(CLOCK_REALTIME, new_time)) {
+
+ timedate1_complete_set_time(td1_passed_interf, invoc);
+ return TRUE;
+
+ } else {
+
+ g_dbus_method_invocation_return_dbus_error(invoc, "org.freedesktop.timedate1.Error.ECANCELED", "Failed to set system time for unknown reasons.");
+ return FALSE;
+ }
+
} else if(proposed_time >= 0) {
new_time = (struct timespec *) g_malloc0(sizeof(struct timespec));
@@ -124,9 +155,10 @@ on_handle_set_time(Timedate1 *td1_passed_interf,
g_dbus_method_invocation_return_dbus_error(invoc, "org.freedesktop.timedate1.Error.ECANCELED", "Failed to set system time for unknown reasons.");
return FALSE;
}
+
} else {
- g_dbus_method_invocation_return_dbus_error(invoc, "org.freedesktop.timedate1.EDOM", "Provided time results in a negative clock value.");
+ g_dbus_method_invocation_return_dbus_error(invoc, "org.freedesktop.timedate1.Error.EINVAL", "Resultant time out of bounds.");
return FALSE;
}
}