aboutsummaryrefslogtreecommitdiff
path: root/plugins/omemo/src/device_notification_populator.vala
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/omemo/src/device_notification_populator.vala')
-rw-r--r--plugins/omemo/src/device_notification_populator.vala34
1 files changed, 17 insertions, 17 deletions
diff --git a/plugins/omemo/src/device_notification_populator.vala b/plugins/omemo/src/device_notification_populator.vala
index 6b3e668b..8549e052 100644
--- a/plugins/omemo/src/device_notification_populator.vala
+++ b/plugins/omemo/src/device_notification_populator.vala
@@ -4,14 +4,14 @@ using Gtk;
namespace Dino.Plugins.Omemo {
-public class DeviceNotificationPopulator : ConversationItemPopulator, Object {
+public class DeviceNotificationPopulator : NotificationPopulator, Object {
public string id { get { return "device_notification"; } }
private StreamInteractor? stream_interactor;
private Plugin plugin;
private Conversation? current_conversation;
- private ConversationItemCollection? item_collection;
+ private NotificationCollection? notification_collection;
private ConversationNotification notification;
public DeviceNotificationPopulator(Plugin plugin, StreamInteractor stream_interactor) {
@@ -20,37 +20,37 @@ public class DeviceNotificationPopulator : ConversationItemPopulator, Object {
}
public bool has_new_devices(Jid jid) {
- return plugin.db.identity_meta.with_address(jid.bare_jid.to_string()).with(plugin.db.identity_meta.identity_id, "=", current_conversation.account.id).with_null(plugin.db.identity_meta.trusted_identity).without_null(plugin.db.identity_meta.identity_key_public_base64).count() > 0;
+ return plugin.db.identity_meta.with_address(current_conversation.account.id, jid.bare_jid.to_string()).with(plugin.db.identity_meta.trusted_identity, "=", Database.IdentityMetaTable.TrustLevel.UNKNOWN).without_null(plugin.db.identity_meta.identity_key_public_base64).count() > 0;
}
- public void init(Conversation conversation, ConversationItemCollection item_collection, Plugins.WidgetType type) {
+ public void init(Conversation conversation, NotificationCollection notification_collection, Plugins.WidgetType type) {
current_conversation = conversation;
- this.item_collection = item_collection;
+ this.notification_collection = notification_collection;
stream_interactor.module_manager.get_module(conversation.account, StreamModule.IDENTITY).device_list_loaded.connect((jid) => {
- if(jid == conversation.counterpart && has_new_devices(conversation.counterpart) && conversation.type_ == Conversation.Type.CHAT)
+ if (jid == conversation.counterpart && has_new_devices(conversation.counterpart) && conversation.type_ == Conversation.Type.CHAT) {
display_notification();
+ }
});
- if (has_new_devices(conversation.counterpart) && conversation.type_ == Conversation.Type.CHAT)
- display_notification();
+ if (has_new_devices(conversation.counterpart) && conversation.type_ == Conversation.Type.CHAT) {
+ display_notification();
+ }
}
- public void close(Conversation conversation) { }
-
- public void populate_timestamp(Conversation conversation, DateTime from, DateTime to) { }
-
- public void populate_between_widgets(Conversation conversation, DateTime from, DateTime to) { }
+ public void close(Conversation conversation) {
+ notification = null;
+ }
private void display_notification() {
if(notification == null) {
notification = new ConversationNotification(plugin, current_conversation.account, current_conversation.counterpart);
notification.should_hide.connect(should_hide);
- item_collection.add_meta_notification(notification);
+ notification_collection.add_meta_notification(notification);
}
}
- private void should_hide() {
- if (!has_new_devices(current_conversation.counterpart)){
- item_collection.remove_meta_notification(notification);
+ public void should_hide() {
+ if (!has_new_devices(current_conversation.counterpart) && notification != null){
+ notification_collection.remove_meta_notification(notification);
notification = null;
}
}