diff --git a/com.tenderowl.bureau.json b/build-aux/com.tenderowl.bureau.json similarity index 76% rename from com.tenderowl.bureau.json rename to build-aux/com.tenderowl.bureau.json index 81fc4a1..dfe35c2 100644 --- a/com.tenderowl.bureau.json +++ b/build-aux/com.tenderowl.bureau.json @@ -9,7 +9,10 @@ "--share=ipc", "--socket=fallback-x11", "--device=dri", - "--socket=wayland" + "--socket=wayland", + "--talk-name=org.gnome.OnlineAccounts", + "--talk-name=org.gnome.ControlCenter", + "--talk-name=org.gnome.Settings" ], "cleanup" : [ "/include", @@ -23,6 +26,9 @@ "*.a" ], "modules" : [ + "python3-inject.json", + "gnome-online-accounts.json", + "python3-imapclient.json", { "name" : "bureau", "builddir" : true, diff --git a/build-aux/gnome-online-accounts.json b/build-aux/gnome-online-accounts.json new file mode 100644 index 0000000..b52e186 --- /dev/null +++ b/build-aux/gnome-online-accounts.json @@ -0,0 +1,20 @@ +{ + "name": "gnome-online-accounts", + "buildsystem": "meson", + "config-opts": [ + "-Dgoabackend=false", + "-Dvapi=false", + "-Dexchange=false", + "-Dgoogle=false", + "-Dimap_smtp=false", + "-Dkerberos=false", + "-Downcloud=false", + "-Dwindows_live=false" + ], + "sources": [ + { + "type": "git", + "url": "https://gitlab.gnome.org/GNOME/gnome-online-accounts.git" + } + ] +} \ No newline at end of file diff --git a/build-aux/python3-imapclient.json b/build-aux/python3-imapclient.json new file mode 100644 index 0000000..8818846 --- /dev/null +++ b/build-aux/python3-imapclient.json @@ -0,0 +1,14 @@ +{ + "name": "python3-imapclient", + "buildsystem": "simple", + "build-commands": [ + "pip3 install --verbose --exists-action=i --no-index --find-links=\"file://${PWD}\" --prefix=${FLATPAK_DEST} \"imapclient\" --no-build-isolation" + ], + "sources": [ + { + "type": "file", + "url": "https://files.pythonhosted.org/packages/c6/74/11a144d35e0f36e34aa09c61847c54894b143f3700c26d9fe85d2c8632b2/IMAPClient-3.0.0-py2.py3-none-any.whl", + "sha256": "31ec03da31f82fb380fdc0c79a9c31272789b50680285ade6581338c17ad8bf3" + } + ] +} \ No newline at end of file diff --git a/build-aux/python3-inject.json b/build-aux/python3-inject.json new file mode 100644 index 0000000..162fc81 --- /dev/null +++ b/build-aux/python3-inject.json @@ -0,0 +1,14 @@ +{ + "name": "python3-inject", + "buildsystem": "simple", + "build-commands": [ + "pip3 install --verbose --exists-action=i --no-index --find-links=\"file://${PWD}\" --prefix=${FLATPAK_DEST} \"inject\" --no-build-isolation" + ], + "sources": [ + { + "type": "file", + "url": "https://files.pythonhosted.org/packages/0a/d4/b812b4e7d826ce0d6ec38f03080a0118d68879ba06454275f410a02f3f21/inject-5.1.0-py2.py3-none-any.whl", + "sha256": "2375e4b3852eb9243e4f736c7c3a9ec723ad8765a23d16cb1e89c0ea425e1433" + } + ] +} \ No newline at end of file diff --git a/bureau/main.py b/bureau/main.py index b2dd4de..3b62e35 100644 --- a/bureau/main.py +++ b/bureau/main.py @@ -25,9 +25,13 @@ import sys import gi +import inject + +from bureau.providers.imap import ImapProvider gi.require_version('Gtk', '4.0') gi.require_version('Adw', '1') +gi.require_version('Goa', '1.0') from gi.repository import Gio, Adw from .window import BureauWindow @@ -44,10 +48,15 @@ def __init__(self, version: str): self.version = version + inject.configure(self.configure_providers) + self.create_action('quit', lambda *_: self.quit(), ['q']) self.create_action('about', self.on_about_action) self.create_action('preferences', self.on_preferences_action) + def configure_providers(self, binder: inject.Binder): + binder.bind(ImapProvider, ImapProvider('imap.yandex.ru')) + def do_activate(self): """Called when the application is activated. diff --git a/bureau/providers/__init__.py b/bureau/providers/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/bureau/providers/imap.py b/bureau/providers/imap.py new file mode 100644 index 0000000..828bee0 --- /dev/null +++ b/bureau/providers/imap.py @@ -0,0 +1,30 @@ +from gi.repository import GObject +from imapclient import IMAPClient + + +class ImapProvider(GObject.GObject): + __gtype_name__ = "ImapProvider" + + server: IMAPClient + + # Props + + # Signals + __gsignals__ = { + } + + def __init__(self, server_host: str): + super().__init__() + + self.server = IMAPClient(server_host, use_uid=True) + + def login(self, username: str, password: str): + self.server.login(username, password) + + def list_folders(self, directory: str = '', pattern: str = '*'): + if not self.server: + return + + folders = self.server.list_folders(directory, pattern) + print('FOLDERS:') + print(folders) diff --git a/bureau/window.py b/bureau/window.py index 045c59b..a9edb49 100644 --- a/bureau/window.py +++ b/bureau/window.py @@ -21,11 +21,13 @@ # SOFTWARE. # # SPDX-License-Identifier: MIT - +import inject from gi.repository import Adw +from gi.repository import Goa from gi.repository import Gtk from bureau.content_page import ContentPage +from bureau.providers.imap import ImapProvider @Gtk.Template(resource_path='/com/tenderowl/bureau/ui/window.ui') @@ -34,5 +36,21 @@ class BureauWindow(Adw.ApplicationWindow): content_page: ContentPage = Gtk.Template.Child() - def __init__(self, **kwargs): + @inject.autoparams() + def __init__(self, imap_provider: ImapProvider, **kwargs): super().__init__(**kwargs) + + email_addresses = [] + + goa: Goa.Client = Goa.Client.new_sync(None) + accs = goa.get_accounts() + for acc in accs: + mail_proxy = acc.props.mail + if mail_proxy: + email_address = mail_proxy.props.email_address + if email_address: + email_addresses.append(email_address) + + print(email_addresses) + + print(imap_provider)