Mercurial > libervia-backend
comparison sat/plugins/plugin_misc_welcome.py @ 2562:26edcf3a30eb
core, setup: huge cleaning:
- moved directories from src and frontends/src to sat and sat_frontends, which is the recommanded naming convention
- move twisted directory to root
- removed all hacks from setup.py, and added missing dependencies, it is now clean
- use https URL for website in setup.py
- removed "Environment :: X11 Applications :: GTK", as wix is deprecated and removed
- renamed sat.sh to sat and fixed its installation
- added python_requires to specify Python version needed
- replaced glib2reactor which use deprecated code by gtk3reactor
sat can now be installed directly from virtualenv without using --system-site-packages anymore \o/
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 02 Apr 2018 19:44:50 +0200 |
parents | src/plugins/plugin_misc_welcome.py@0046283a285d |
children | 56f94936df1e |
comparison
equal
deleted
inserted
replaced
2561:bd30dc3ffe5a | 2562:26edcf3a30eb |
---|---|
1 #!/usr/bin/env python2 | |
2 # -*- coding: utf-8 -*- | |
3 | |
4 # SAT plugin for file tansfer | |
5 # Copyright (C) 2009-2018 Jérôme Poisson (goffi@goffi.org) | |
6 | |
7 # This program is free software: you can redistribute it and/or modify | |
8 # it under the terms of the GNU Affero General Public License as published by | |
9 # the Free Software Foundation, either version 3 of the License, or | |
10 # (at your option) any later version. | |
11 | |
12 # This program is distributed in the hope that it will be useful, | |
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 # GNU Affero General Public License for more details. | |
16 | |
17 # You should have received a copy of the GNU Affero General Public License | |
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 | |
20 from sat.core.i18n import _, D_ | |
21 from sat.core.constants import Const as C | |
22 from sat.core.log import getLogger | |
23 log = getLogger(__name__) | |
24 from sat.tools import xml_tools | |
25 | |
26 | |
27 PLUGIN_INFO = { | |
28 C.PI_NAME: "Welcome", | |
29 C.PI_IMPORT_NAME: "WELCOME", | |
30 C.PI_TYPE: C.PLUG_TYPE_MISC, | |
31 C.PI_MAIN: "Welcome", | |
32 C.PI_HANDLER: "no", | |
33 C.PI_DESCRIPTION: _("""Plugin which manage welcome message and things to to on first connection.""") | |
34 } | |
35 | |
36 | |
37 WELCOME_PARAM_CATEGORY = "General" | |
38 WELCOME_PARAM_NAME = "welcome" | |
39 WELCOME_PARAM_LABEL = D_(u"Display welcome message") | |
40 WELCOME_MSG_TITLE = D_(u"Welcome to Libervia/Salut à Toi") | |
41 # XXX: this message is mainly targetting libervia new users for now | |
42 # (i.e.: it may look weird on other frontends) | |
43 WELCOME_MSG = D_(u"""Welcome to a free (as in freedom) network! | |
44 | |
45 If you have any trouble, or you want to help us for the bug hunting, you can contact us in real time chat by using the “Help / Official chat room” menu. | |
46 | |
47 To use Libervia, you'll need to add contacts, either people you know, or people you discover by using the “Contacts / Search directory” menu. | |
48 | |
49 We hope that you'll enjoy using this project. | |
50 | |
51 The Libervia/Salut à Toi Team | |
52 """) | |
53 | |
54 | |
55 PARAMS = """ | |
56 <params> | |
57 <individual> | |
58 <category name="{category}"> | |
59 <param name="{name}" label="{label}" type="bool" /> | |
60 </category> | |
61 </individual> | |
62 </params> | |
63 """.format(category=WELCOME_PARAM_CATEGORY, name=WELCOME_PARAM_NAME, label=WELCOME_PARAM_LABEL) | |
64 | |
65 | |
66 class Welcome(object): | |
67 | |
68 def __init__(self, host): | |
69 log.info(_("plugin Welcome initialization")) | |
70 self.host = host | |
71 host.memory.updateParams(PARAMS) | |
72 | |
73 def profileConnected(self, client): | |
74 # XXX: if you wan to try first_start again, you'll have to remove manually | |
75 # the welcome value from your profile params in sat.db | |
76 welcome = self.host.memory.params.getParamA(WELCOME_PARAM_NAME, WELCOME_PARAM_CATEGORY, use_default=False, profile_key=client.profile) | |
77 if welcome is None: | |
78 first_start = True | |
79 welcome = True | |
80 else: | |
81 first_start = False | |
82 | |
83 if welcome: | |
84 xmlui = xml_tools.note(WELCOME_MSG, WELCOME_MSG_TITLE) | |
85 self.host.actionNew({'xmlui': xmlui.toXml()}, profile=client.profile) | |
86 self.host.memory.setParam(WELCOME_PARAM_NAME, C.BOOL_FALSE, WELCOME_PARAM_CATEGORY, profile_key=client.profile) | |
87 | |
88 self.host.trigger.point("WELCOME", first_start, welcome, client.profile) | |
89 | |
90 | |
91 | |
92 | |
93 |