Use utc time everywhere
This commit is contained in:
parent
a257b16337
commit
d2a5287eff
|
@ -54,7 +54,7 @@ public class Conversation : Object {
|
||||||
counterpart = resource != null ? new Jid.with_resource(jid, resource) : new Jid(jid);
|
counterpart = resource != null ? new Jid.with_resource(jid, resource) : new Jid(jid);
|
||||||
active = row[db.conversation.active];
|
active = row[db.conversation.active];
|
||||||
int64? last_active = row[db.conversation.last_active];
|
int64? last_active = row[db.conversation.last_active];
|
||||||
if (last_active != null) this.last_active = new DateTime.from_unix_local(last_active);
|
if (last_active != null) this.last_active = new DateTime.from_unix_utc(last_active);
|
||||||
type_ = (Conversation.Type) row[db.conversation.type_];
|
type_ = (Conversation.Type) row[db.conversation.type_];
|
||||||
encryption = (Encryption) row[db.conversation.encryption];
|
encryption = (Encryption) row[db.conversation.encryption];
|
||||||
int? read_up_to = row[db.conversation.read_up_to];
|
int? read_up_to = row[db.conversation.read_up_to];
|
||||||
|
|
|
@ -52,8 +52,8 @@ public class FileTransfer : Object {
|
||||||
ourpart = account.bare_jid;
|
ourpart = account.bare_jid;
|
||||||
}
|
}
|
||||||
direction = row[db.file_transfer.direction];
|
direction = row[db.file_transfer.direction];
|
||||||
time = new DateTime.from_unix_local(row[db.file_transfer.time]);
|
time = new DateTime.from_unix_utc(row[db.file_transfer.time]);
|
||||||
local_time = new DateTime.from_unix_local(row[db.file_transfer.time]);
|
local_time = new DateTime.from_unix_utc(row[db.file_transfer.time]);
|
||||||
encryption = (Encryption) row[db.file_transfer.encryption];
|
encryption = (Encryption) row[db.file_transfer.encryption];
|
||||||
file_name = row[db.file_transfer.file_name];
|
file_name = row[db.file_transfer.file_name];
|
||||||
path = row[db.file_transfer.path];
|
path = row[db.file_transfer.path];
|
||||||
|
|
|
@ -73,8 +73,8 @@ public class Message : Object {
|
||||||
ourpart = account.bare_jid;
|
ourpart = account.bare_jid;
|
||||||
}
|
}
|
||||||
direction = row[db.message.direction];
|
direction = row[db.message.direction];
|
||||||
time = new DateTime.from_unix_local(row[db.message.time]);
|
time = new DateTime.from_unix_utc(row[db.message.time]);
|
||||||
local_time = new DateTime.from_unix_local(row[db.message.time]);
|
local_time = new DateTime.from_unix_utc(row[db.message.time]);
|
||||||
body = row[db.message.body];
|
body = row[db.message.body];
|
||||||
marked = (Message.Marked) row[db.message.marked];
|
marked = (Message.Marked) row[db.message.marked];
|
||||||
encryption = (Encryption) row[db.message.encryption];
|
encryption = (Encryption) row[db.message.encryption];
|
||||||
|
|
|
@ -51,8 +51,8 @@ public class ChatInteraction : StreamInteractionModule, Object {
|
||||||
if (!last_input_interaction.has_key(conversation)) {
|
if (!last_input_interaction.has_key(conversation)) {
|
||||||
send_chat_state_notification(conversation, Xep.ChatStateNotifications.STATE_COMPOSING);
|
send_chat_state_notification(conversation, Xep.ChatStateNotifications.STATE_COMPOSING);
|
||||||
}
|
}
|
||||||
last_input_interaction[conversation] = new DateTime.now_local();
|
last_input_interaction[conversation] = new DateTime.now_utc();
|
||||||
last_interface_interaction[conversation] = new DateTime.now_local();
|
last_interface_interaction[conversation] = new DateTime.now_utc();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void on_message_cleared(Conversation? conversation) {
|
public void on_message_cleared(Conversation? conversation) {
|
||||||
|
@ -106,7 +106,7 @@ public class ChatInteraction : StreamInteractionModule, Object {
|
||||||
if (!iter.valid && iter.has_next()) iter.next();
|
if (!iter.valid && iter.has_next()) iter.next();
|
||||||
Conversation conversation = iter.get_key();
|
Conversation conversation = iter.get_key();
|
||||||
if (last_input_interaction.has_key(conversation) &&
|
if (last_input_interaction.has_key(conversation) &&
|
||||||
(new DateTime.now_local()).difference(last_input_interaction[conversation]) >= 15 * TimeSpan.SECOND) {
|
(new DateTime.now_utc()).difference(last_input_interaction[conversation]) >= 15 * TimeSpan.SECOND) {
|
||||||
iter.unset();
|
iter.unset();
|
||||||
send_chat_state_notification(conversation, Xep.ChatStateNotifications.STATE_PAUSED);
|
send_chat_state_notification(conversation, Xep.ChatStateNotifications.STATE_PAUSED);
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,7 @@ public class ChatInteraction : StreamInteractionModule, Object {
|
||||||
if (!iter.valid && iter.has_next()) iter.next();
|
if (!iter.valid && iter.has_next()) iter.next();
|
||||||
Conversation conversation = iter.get_key();
|
Conversation conversation = iter.get_key();
|
||||||
if (last_interface_interaction.has_key(conversation) &&
|
if (last_interface_interaction.has_key(conversation) &&
|
||||||
(new DateTime.now_local()).difference(last_interface_interaction[conversation]) >= 1.5 * TimeSpan.MINUTE) {
|
(new DateTime.now_utc()).difference(last_interface_interaction[conversation]) >= 1.5 * TimeSpan.MINUTE) {
|
||||||
iter.unset();
|
iter.unset();
|
||||||
send_chat_state_notification(conversation, Xep.ChatStateNotifications.STATE_GONE);
|
send_chat_state_notification(conversation, Xep.ChatStateNotifications.STATE_GONE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,7 +155,7 @@ public class ConnectionManager {
|
||||||
}
|
}
|
||||||
stream.log = new Core.XmppLog(account.bare_jid.to_string(), log_options);
|
stream.log = new Core.XmppLog(account.bare_jid.to_string(), log_options);
|
||||||
|
|
||||||
Connection connection = new Connection(stream, new DateTime.now_local());
|
Connection connection = new Connection(stream, new DateTime.now_utc());
|
||||||
connections[account] = connection;
|
connections[account] = connection;
|
||||||
change_connection_state(account, ConnectionState.CONNECTING);
|
change_connection_state(account, ConnectionState.CONNECTING);
|
||||||
stream.attached_modules.connect((stream) => {
|
stream.attached_modules.connect((stream) => {
|
||||||
|
|
|
@ -86,7 +86,7 @@ public class ConversationManager : StreamInteractionModule, Object {
|
||||||
|
|
||||||
public void start_conversation(Conversation conversation, bool push_front = false) {
|
public void start_conversation(Conversation conversation, bool push_front = false) {
|
||||||
if (push_front) {
|
if (push_front) {
|
||||||
conversation.last_active = new DateTime.now_local();
|
conversation.last_active = new DateTime.now_utc();
|
||||||
if (conversation.active) conversation_activated(conversation);
|
if (conversation.active) conversation_activated(conversation);
|
||||||
}
|
}
|
||||||
if (!conversation.active) {
|
if (!conversation.active) {
|
||||||
|
|
|
@ -85,7 +85,7 @@ public class MessageProcessor : StreamInteractionModule, Object {
|
||||||
|
|
||||||
Xep.MessageArchiveManagement.MessageFlag? mam_message_flag = Xep.MessageArchiveManagement.MessageFlag.get_flag(message);
|
Xep.MessageArchiveManagement.MessageFlag? mam_message_flag = Xep.MessageArchiveManagement.MessageFlag.get_flag(message);
|
||||||
if (mam_message_flag != null) new_message.local_time = mam_message_flag.server_time;
|
if (mam_message_flag != null) new_message.local_time = mam_message_flag.server_time;
|
||||||
if (new_message.local_time == null || new_message.local_time.compare(new DateTime.now_local()) > 0) new_message.local_time = new DateTime.now_local();
|
if (new_message.local_time == null || new_message.local_time.compare(new DateTime.now_utc()) > 0) new_message.local_time = new DateTime.now_utc();
|
||||||
|
|
||||||
Xep.DelayedDelivery.MessageFlag? delayed_message_flag = Xep.DelayedDelivery.MessageFlag.get_flag(message);
|
Xep.DelayedDelivery.MessageFlag? delayed_message_flag = Xep.DelayedDelivery.MessageFlag.get_flag(message);
|
||||||
if (delayed_message_flag != null) new_message.time = delayed_message_flag.datetime;
|
if (delayed_message_flag != null) new_message.time = delayed_message_flag.datetime;
|
||||||
|
@ -163,8 +163,8 @@ public class MessageProcessor : StreamInteractionModule, Object {
|
||||||
message.stanza_id = random_uuid();
|
message.stanza_id = random_uuid();
|
||||||
message.account = conversation.account;
|
message.account = conversation.account;
|
||||||
message.body = text;
|
message.body = text;
|
||||||
message.time = new DateTime.now_local();
|
message.time = new DateTime.now_utc();
|
||||||
message.local_time = new DateTime.now_local();
|
message.local_time = new DateTime.now_utc();
|
||||||
message.direction = Entities.Message.DIRECTION_SENT;
|
message.direction = Entities.Message.DIRECTION_SENT;
|
||||||
message.counterpart = conversation.counterpart;
|
message.counterpart = conversation.counterpart;
|
||||||
if (conversation.type_ in new Conversation.Type[]{Conversation.Type.GROUPCHAT, Conversation.Type.GROUPCHAT_PM}) {
|
if (conversation.type_ in new Conversation.Type[]{Conversation.Type.GROUPCHAT, Conversation.Type.GROUPCHAT_PM}) {
|
||||||
|
|
|
@ -30,10 +30,10 @@ public class PresenceManager : StreamInteractionModule, Object {
|
||||||
if (stream != null) {
|
if (stream != null) {
|
||||||
Xmpp.Presence.Stanza? presence = stream.get_flag(Presence.Flag.IDENTITY).get_presence(jid.to_string());
|
Xmpp.Presence.Stanza? presence = stream.get_flag(Presence.Flag.IDENTITY).get_presence(jid.to_string());
|
||||||
if (presence != null) {
|
if (presence != null) {
|
||||||
return new Show(jid, presence.show, new DateTime.now_local());
|
return new Show(jid, presence.show, new DateTime.now_utc());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new Show(jid, Show.OFFLINE, new DateTime.now_local());
|
return new Show(jid, Show.OFFLINE, new DateTime.now_utc());
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap<Jid, ArrayList<Show>>? get_shows(Jid jid, Account account) {
|
public HashMap<Jid, ArrayList<Show>>? get_shows(Jid jid, Account account) {
|
||||||
|
@ -116,7 +116,7 @@ public class PresenceManager : StreamInteractionModule, Object {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void add_show(Account account, Jid jid, string s) {
|
private void add_show(Account account, Jid jid, string s) {
|
||||||
Show show = new Show(jid, s, new DateTime.now_local());
|
Show show = new Show(jid, s, new DateTime.now_utc());
|
||||||
lock (shows) {
|
lock (shows) {
|
||||||
if (!shows.has_key(jid)) {
|
if (!shows.has_key(jid)) {
|
||||||
shows[jid] = new HashMap<Jid, ArrayList<Show>>();
|
shows[jid] = new HashMap<Jid, ArrayList<Show>>();
|
||||||
|
|
|
@ -56,7 +56,7 @@ public abstract class ConversationRow : ListBoxRow {
|
||||||
Entities.Message? message = stream_interactor.get_module(MessageStorage.IDENTITY).get_last_message(conversation);
|
Entities.Message? message = stream_interactor.get_module(MessageStorage.IDENTITY).get_last_message(conversation);
|
||||||
if (message != null) {
|
if (message != null) {
|
||||||
update_message(message.body.replace("\n", " "));
|
update_message(message.body.replace("\n", " "));
|
||||||
update_time(message.time.to_local());
|
update_time(message.time.to_utc());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,7 +163,7 @@ public abstract class ConversationRow : ListBoxRow {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string get_relative_time(DateTime datetime) {
|
private static string get_relative_time(DateTime datetime) {
|
||||||
DateTime now = new DateTime.now_local();
|
DateTime now = new DateTime.now_utc();
|
||||||
TimeSpan timespan = now.difference(datetime);
|
TimeSpan timespan = now.difference(datetime);
|
||||||
if (timespan > 365 * TimeSpan.DAY) {
|
if (timespan > 365 * TimeSpan.DAY) {
|
||||||
return datetime.get_year().to_string();
|
return datetime.get_year().to_string();
|
||||||
|
|
|
@ -134,11 +134,11 @@ public class ConversationView : Box, Plugins.ConversationItemCollection {
|
||||||
Dino.Application app = Dino.Application.get_default();
|
Dino.Application app = Dino.Application.get_default();
|
||||||
if (item_skeletons.size == 1) {
|
if (item_skeletons.size == 1) {
|
||||||
foreach (Plugins.ConversationItemPopulator populator in app.plugin_registry.conversation_item_populators) {
|
foreach (Plugins.ConversationItemPopulator populator in app.plugin_registry.conversation_item_populators) {
|
||||||
populator.populate_between_widgets(conversation, item.sort_time, new DateTime.now_utc());
|
populator.populate_timespan(conversation, item.sort_time, new DateTime.now_utc());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
foreach (Plugins.ConversationItemPopulator populator in app.plugin_registry.conversation_item_populators) {
|
foreach (Plugins.ConversationItemPopulator populator in app.plugin_registry.conversation_item_populators) {
|
||||||
populator.populate_between_widgets(conversation, item.sort_time, meta_items.higher(item).sort_time);
|
populator.populate_timespan(conversation, item.sort_time, meta_items.higher(item).sort_time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,15 +31,15 @@ class FilePopulator : Plugins.ConversationItemPopulator, Object {
|
||||||
|
|
||||||
public void close(Conversation conversation) { }
|
public void close(Conversation conversation) { }
|
||||||
|
|
||||||
public void populate_timespan(Conversation conversation, DateTime from, DateTime to) { }
|
public void populate_timespan(Conversation conversation, DateTime from, DateTime to) {
|
||||||
|
|
||||||
public void populate_between_widgets(Conversation conversation, DateTime from, DateTime to) {
|
|
||||||
Gee.List<FileTransfer> transfers = stream_interactor.get_module(FileManager.IDENTITY).get_file_transfers(conversation.account, conversation.counterpart, from, to);
|
Gee.List<FileTransfer> transfers = stream_interactor.get_module(FileManager.IDENTITY).get_file_transfers(conversation.account, conversation.counterpart, from, to);
|
||||||
foreach (FileTransfer transfer in transfers) {
|
foreach (FileTransfer transfer in transfers) {
|
||||||
insert_file(transfer);
|
insert_file(transfer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void populate_between_widgets(Conversation conversation, DateTime from, DateTime to) { }
|
||||||
|
|
||||||
private void insert_file(FileTransfer transfer) {
|
private void insert_file(FileTransfer transfer) {
|
||||||
if (transfer.mime_type.has_prefix("image")) {
|
if (transfer.mime_type.has_prefix("image")) {
|
||||||
item_collection.insert_item(new ImageItem(stream_interactor, transfer));
|
item_collection.insert_item(new ImageItem(stream_interactor, transfer));
|
||||||
|
|
|
@ -126,7 +126,7 @@ public static bool is_dark_theme(Gtk.Widget widget) {
|
||||||
public static bool is_24h_format() {
|
public static bool is_24h_format() {
|
||||||
GLib.Settings settings = new GLib.Settings("org.gnome.desktop.interface");
|
GLib.Settings settings = new GLib.Settings("org.gnome.desktop.interface");
|
||||||
string settings_format = settings.get_string("clock-format");
|
string settings_format = settings.get_string("clock-format");
|
||||||
string p_format = (new DateTime.now_local()).format("%p");
|
string p_format = (new DateTime.now_utc()).format("%p");
|
||||||
return settings_format == "24h" || p_format == " ";
|
return settings_format == "24h" || p_format == " ";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class Context {
|
||||||
}
|
}
|
||||||
|
|
||||||
public SignedPreKeyRecord generate_signed_pre_key(IdentityKeyPair identity_key_pair, int32 id, uint64 timestamp = 0) throws Error {
|
public SignedPreKeyRecord generate_signed_pre_key(IdentityKeyPair identity_key_pair, int32 id, uint64 timestamp = 0) throws Error {
|
||||||
if (timestamp == 0) timestamp = new DateTime.now_local().to_unix();
|
if (timestamp == 0) timestamp = new DateTime.now_utc().to_unix();
|
||||||
SignedPreKeyRecord res;
|
SignedPreKeyRecord res;
|
||||||
throw_by_code(Protocol.KeyHelper.generate_signed_pre_key(out res, identity_key_pair, id, timestamp, native_context));
|
throw_by_code(Protocol.KeyHelper.generate_signed_pre_key(out res, identity_key_pair, id, timestamp, native_context));
|
||||||
return res;
|
return res;
|
||||||
|
|
|
@ -95,7 +95,7 @@ class SessionBuilderTest : Gee.TestCase {
|
||||||
PreKeyRecord bob_pre_key_record = new PreKeyRecord(bob_pre_key.pre_key_id, bob_pre_key_pair);
|
PreKeyRecord bob_pre_key_record = new PreKeyRecord(bob_pre_key.pre_key_id, bob_pre_key_pair);
|
||||||
bob_store.store_pre_key(bob_pre_key_record);
|
bob_store.store_pre_key(bob_pre_key_record);
|
||||||
|
|
||||||
SignedPreKeyRecord bob_signed_pre_key_record = new SignedPreKeyRecord(22, new DateTime.now_local().to_unix(), bob_signed_pre_key_pair, bob_signed_pre_key_signature);
|
SignedPreKeyRecord bob_signed_pre_key_record = new SignedPreKeyRecord(22, new DateTime.now_utc().to_unix(), bob_signed_pre_key_pair, bob_signed_pre_key_signature);
|
||||||
bob_store.store_signed_pre_key(bob_signed_pre_key_record);
|
bob_store.store_signed_pre_key(bob_signed_pre_key_record);
|
||||||
|
|
||||||
/* Create Bob's session cipher and decrypt the message from Alice */
|
/* Create Bob's session cipher and decrypt the message from Alice */
|
||||||
|
@ -163,7 +163,7 @@ class SessionBuilderTest : Gee.TestCase {
|
||||||
bob_pre_key_record = new PreKeyRecord(bob_pre_key.pre_key_id, bob_pre_key_pair);
|
bob_pre_key_record = new PreKeyRecord(bob_pre_key.pre_key_id, bob_pre_key_pair);
|
||||||
bob_store.store_pre_key(bob_pre_key_record);
|
bob_store.store_pre_key(bob_pre_key_record);
|
||||||
|
|
||||||
bob_signed_pre_key_record = new SignedPreKeyRecord(23, new DateTime.now_local().to_unix(), bob_signed_pre_key_pair, bob_signed_pre_key_signature);
|
bob_signed_pre_key_record = new SignedPreKeyRecord(23, new DateTime.now_utc().to_unix(), bob_signed_pre_key_pair, bob_signed_pre_key_signature);
|
||||||
bob_store.store_signed_pre_key(bob_signed_pre_key_record);
|
bob_store.store_signed_pre_key(bob_signed_pre_key_record);
|
||||||
|
|
||||||
/* Have Alice process Bob's pre key bundle */
|
/* Have Alice process Bob's pre key bundle */
|
||||||
|
@ -262,7 +262,7 @@ class SessionBuilderTest : Gee.TestCase {
|
||||||
/* Add Bob's pre keys to Bob's data store */
|
/* Add Bob's pre keys to Bob's data store */
|
||||||
PreKeyRecord bob_pre_key_record = new PreKeyRecord(bob_pre_key.pre_key_id, bob_pre_key_pair);
|
PreKeyRecord bob_pre_key_record = new PreKeyRecord(bob_pre_key.pre_key_id, bob_pre_key_pair);
|
||||||
bob_store.store_pre_key(bob_pre_key_record);
|
bob_store.store_pre_key(bob_pre_key_record);
|
||||||
SignedPreKeyRecord bob_signed_pre_key_record = new SignedPreKeyRecord(22, new DateTime.now_local().to_unix(), bob_signed_pre_key_pair, bob_signed_pre_key_signature);
|
SignedPreKeyRecord bob_signed_pre_key_record = new SignedPreKeyRecord(22, new DateTime.now_utc().to_unix(), bob_signed_pre_key_pair, bob_signed_pre_key_signature);
|
||||||
bob_store.store_signed_pre_key(bob_signed_pre_key_record);
|
bob_store.store_signed_pre_key(bob_signed_pre_key_record);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue