From 29ca70a6d534e1cd79963718c793ae740318cff1 Mon Sep 17 00:00:00 2001 From: Marvin W Date: Fri, 10 Mar 2017 19:34:56 +0100 Subject: Initial plugin system --- libdino/src/service/module_manager.vala | 96 +++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 libdino/src/service/module_manager.vala (limited to 'libdino/src/service/module_manager.vala') diff --git a/libdino/src/service/module_manager.vala b/libdino/src/service/module_manager.vala new file mode 100644 index 00000000..5ef93da8 --- /dev/null +++ b/libdino/src/service/module_manager.vala @@ -0,0 +1,96 @@ +using Gee; + +using Dino.Entities; +using Xmpp; + +namespace Dino { + +public class ModuleManager { + + public HashMap tls_modules = new HashMap(); + public HashMap plain_sasl_modules = new HashMap(); + public HashMap bind_modules = new HashMap(); + public HashMap roster_modules = new HashMap(); + public HashMap service_discovery_modules = new HashMap(); + public HashMap private_xmp_storage_modules = new HashMap(); + public HashMap bookmarks_module = new HashMap(); + public HashMap presence_modules = new HashMap(); + public HashMap message_modules = new HashMap(); + public HashMap message_carbons_modules = new HashMap(); + public HashMap muc_modules = new HashMap(); + public HashMap pgp_modules = new HashMap(); + public HashMap pubsub_modules = new HashMap(); + public HashMap entity_capabilities_modules = new HashMap(); + public HashMap user_avatars_modules = new HashMap(); + public HashMap vcard_modules = new HashMap(); + public HashMap message_delivery_receipts_modules = new HashMap(); + public HashMap chat_state_notifications_modules = new HashMap(); + public HashMap chat_markers_modules = new HashMap(); + public HashMap ping_modules = new HashMap(); + public HashMap delayed_delivery_module = new HashMap(); + public HashMap stream_error_modules = new HashMap(); + + private AvatarStorage avatar_storage = new AvatarStorage("./"); + private EntityCapabilitiesStorage entity_capabilities_storage; + + public ModuleManager(Database db) { + entity_capabilities_storage = new EntityCapabilitiesStorage(db); + } + + public ArrayList get_modules(Account account, string? resource = null) { + ArrayList modules = new ArrayList(); + + if (!tls_modules.has_key(account)) add_account(account); + + modules.add(tls_modules[account]); + modules.add(plain_sasl_modules[account]); + modules.add(new Bind.Module(resource == null ? account.resourcepart : resource)); + modules.add(roster_modules[account]); + modules.add(service_discovery_modules[account]); + modules.add(private_xmp_storage_modules[account]); + modules.add(bookmarks_module[account]); + modules.add(presence_modules[account]); + modules.add(message_modules[account]); + modules.add(message_carbons_modules[account]); + modules.add(muc_modules[account]); + modules.add(pgp_modules[account]); + modules.add(pubsub_modules[account]); + modules.add(entity_capabilities_modules[account]); + modules.add(user_avatars_modules[account]); + modules.add(vcard_modules[account]); + modules.add(message_delivery_receipts_modules[account]); + modules.add(chat_state_notifications_modules[account]); + modules.add(chat_markers_modules[account]); + modules.add(ping_modules[account]); + modules.add(delayed_delivery_module[account]); + modules.add(stream_error_modules[account]); + return modules; + } + + public void add_account(Account account) { + tls_modules[account] = new Tls.Module(); + plain_sasl_modules[account] = new PlainSasl.Module(account.bare_jid.to_string(), account.password); + bind_modules[account] = new Bind.Module(account.resourcepart); + roster_modules[account] = new Roster.Module(); + service_discovery_modules[account] = new Xep.ServiceDiscovery.Module.with_identity("client", "pc"); + private_xmp_storage_modules[account] = new Xep.PrivateXmlStorage.Module(); + bookmarks_module[account] = new Xep.Bookmarks.Module(); + presence_modules[account] = new Presence.Module(); + message_modules[account] = new Xmpp.Message.Module(); + message_carbons_modules[account] = new Xep.MessageCarbons.Module(); + muc_modules[account] = new Xep.Muc.Module(); + pgp_modules[account] = new Xep.Pgp.Module(); + pubsub_modules[account] = new Xep.Pubsub.Module(); + entity_capabilities_modules[account] = new Xep.EntityCapabilities.Module(entity_capabilities_storage); + user_avatars_modules[account] = new Xep.UserAvatars.Module(avatar_storage); + vcard_modules[account] = new Xep.VCard.Module(avatar_storage); + message_delivery_receipts_modules[account] = new Xep.MessageDeliveryReceipts.Module(); + chat_state_notifications_modules[account] = new Xep.ChatStateNotifications.Module(); + chat_markers_modules[account] = new Xep.ChatMarkers.Module(); + ping_modules[account] = new Xep.Ping.Module(); + delayed_delivery_module[account] = new Xep.DelayedDelivery.Module(); + stream_error_modules[account] = new StreamError.Module(); + } +} + +} \ No newline at end of file -- cgit v1.2.3-70-g09d2