aboutsummaryrefslogtreecommitdiff
path: root/data/usr/bin/ayatana-webmail-settings
blob: 1f5391456a282c6a862ec097aba22790779aa030 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Ayatana Webmail, Show the settings dialog
# Authors: Robert Tari <robert@tari.in>
# License: GNU GPL 3 or higher; http://www.gnu.org/licenses/gpl.html

import sys
import dbus
from gi.repository import GLib
from dbus.mainloop.glib import DBusGMainLoop
from ayatanawebmail.common import isRunning

oLoop = None

if __name__ == '__main__':

    if isRunning():

        DBusGMainLoop(set_as_default=True)
        oSessionBus = dbus.SessionBus()

        try:

            oSession = oSessionBus.get_object('org.ayatana.webmail', '/org/ayatana/webmail')
            oInterface = dbus.Interface(oSession, 'org.ayatana.webmail')

            oInterface.settings(reply_handler=lambda: oLoop.quit(), error_handler=lambda o: oLoop.quit())

            oLoop = GLib.MainLoop()
            oLoop.run()
            sys.exit(0)

        except dbus.DBusException as oDBusException:

            print(oDBusException)

    else:

        print("Cannot start ayatana-webmail-settings - Ayatana Webmail is not running.")

    sys.exit(1)