PushService: Initial release
[enigma2-plugins.git] / pushservice / src / plugin.py
1 # Plugin
2 from Plugins.Plugin import PluginDescriptor
3
4 # Config
5 from Components.config import *
6
7 # Default encoding
8 #from Components.Language import language
9
10 # Plugin internal
11 from __init__ import *
12 from PushService import PushService
13 from PushServiceConfigScreen import PushServiceConfigScreen
14 #from PluginBase import PluginBase
15 #from ConfigDirectorySelection import ConfigDirectorySelection
16
17
18 # Constants
19 NAME = "PushService"
20 VERSION = "0.1"
21 SUPPORT = "http://www.i-have-a-dreambox.com/wbb2/thread.php?threadid=167779"
22 DONATE = "http://bit.ly/pspaypal"
23 ABOUT = "\n  " + NAME + " " + VERSION + "\n\n" \
24                                 + _("  (C) 2012 by betonme @ IHAD \n\n") \
25                                 + _("  If You like this plugin and want to support it,\n") \
26                                 + _("  or if just want to say ''thanks'',\n") \
27                                 + _("  feel free to donate via PayPal. \n\n") \
28                                 + _("  Thanks a lot ! \n\n  PayPal: ") + DONATE
29
30
31 # Globals
32 gPushService = None
33
34
35 # Config options
36 config.pushservice                           = ConfigSubsection()
37
38 config.pushservice.about                     = ConfigNothing()
39
40 config.pushservice.enable                    = ConfigEnableDisable(default = True)
41
42 config.pushservice.boxname                   = ConfigText(default = "Dreambox", fixed_size = False)
43 config.pushservice.xmlpath                   = ConfigText(default = "/etc/enigma2/pushservice.xml", fixed_size = False)
44
45 config.pushservice.time                      = ConfigClock(default = 0)
46 config.pushservice.period                    = ConfigSelectionNumber(0, 1000, 1, default = 24)
47 config.pushservice.runonboot                 = ConfigEnableDisable(default = True)
48
49 config.pushservice.smtpserver                = ConfigText(default="smtp.server.com", fixed_size = False)
50 config.pushservice.smtpport                  = ConfigNumber(default = 587)
51 config.pushservice.smtptyp                   = ConfigEnableDisable(default = True)
52
53 config.pushservice.username                  = ConfigText(fixed_size = False)
54 config.pushservice.password                  = ConfigPassword()
55
56 config.pushservice.mailfrom                  = ConfigText(default = "abc@provider.com", fixed_size = False)
57 config.pushservice.mailto                    = ConfigText(fixed_size = False)
58
59
60 #######################################################
61 # Plugin main function
62 def Plugins(**kwargs):
63         localeInit()
64         
65         descriptors = []
66         
67         if config.pushservice.enable.value:
68                 # AutoStart
69                 descriptors.append( PluginDescriptor(where = PluginDescriptor.WHERE_AUTOSTART, fnc = autostart, needsRestart = False) )
70                 
71         #TODO icon
72         descriptors.append( PluginDescriptor(name = NAME, description = NAME + " " +_("configuration"), where = PluginDescriptor.WHERE_PLUGINMENU, fnc = setup, needsRestart = False) ) #icon = "/icon.png"
73
74         return descriptors
75
76
77 #######################################################
78 # Plugin configuration
79 def setup(session, **kwargs):
80         session.open(PushServiceConfigScreen)
81
82
83 #######################################################
84 # Autostart
85 def autostart(reason, **kwargs):
86         if reason == 0:  # start
87                 if config.pushservice.enable.value:
88                         global gPushService
89                         gPushService = PushService()
90                         #TODO gPushService.load()
91                         state = None
92                         if config.pushservice.runonboot.value:
93                                 state = "Boot"
94                         gPushService.start(state) #with load
95