annotate src/tools/memory.py @ 412:62b17854254e

database integration: first draft - using SQLite as backend /!\ Not finished yet, break execution. SàT CAN'T LAUNCH PROPERLY IN THE CURRENT STATE
author Goffi <goffi@goffi.org>
date Sun, 30 Oct 2011 23:13:40 +0100
parents 3ed53803b3b3
children dd4caab17008
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
goffi@necton2
parents:
diff changeset
1 #!/usr/bin/python
goffi@necton2
parents:
diff changeset
2 # -*- coding: utf-8 -*-
goffi@necton2
parents:
diff changeset
3
goffi@necton2
parents:
diff changeset
4 """
goffi@necton2
parents:
diff changeset
5 SAT: a jabber client
228
b1794cbb88e5 2011 copyright upgrade
Goffi <goffi@goffi.org>
parents: 224
diff changeset
6 Copyright (C) 2009, 2010, 2011 Jérôme Poisson (goffi@goffi.org)
0
goffi@necton2
parents:
diff changeset
7
goffi@necton2
parents:
diff changeset
8 This program is free software: you can redistribute it and/or modify
goffi@necton2
parents:
diff changeset
9 it under the terms of the GNU General Public License as published by
goffi@necton2
parents:
diff changeset
10 the Free Software Foundation, either version 3 of the License, or
goffi@necton2
parents:
diff changeset
11 (at your option) any later version.
goffi@necton2
parents:
diff changeset
12
goffi@necton2
parents:
diff changeset
13 This program is distributed in the hope that it will be useful,
goffi@necton2
parents:
diff changeset
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
goffi@necton2
parents:
diff changeset
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
goffi@necton2
parents:
diff changeset
16 GNU General Public License for more details.
goffi@necton2
parents:
diff changeset
17
goffi@necton2
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
goffi@necton2
parents:
diff changeset
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
goffi@necton2
parents:
diff changeset
20 """
goffi@necton2
parents:
diff changeset
21
goffi@necton2
parents:
diff changeset
22 from __future__ import with_statement
goffi@necton2
parents:
diff changeset
23
goffi@necton2
parents:
diff changeset
24 import os.path
goffi@necton2
parents:
diff changeset
25 import time
106
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 105
diff changeset
26 import cPickle as pickle
364
312ca6f9d84a core: configuration file
Goffi <goffi@goffi.org>
parents: 346
diff changeset
27 from ConfigParser import SafeConfigParser, NoOptionError, NoSectionError
17
74a39f40eb6d refactoring: using xml params (not finished yet)
Goffi <goffi@goffi.org>
parents: 14
diff changeset
28 from xml.dom import minidom
326
0f9925193586 core, plugin mblog: fixed some exceptions
Goffi <goffi@goffi.org>
parents: 318
diff changeset
29 from logging import debug, info, warning, error
20
fc8c202cda87 refactoring: using xml params part IV (default values)
Goffi <goffi@goffi.org>
parents: 19
diff changeset
30 from twisted.internet import defer
47
9aa2d9dd4045 memory methods improvement
Goffi <goffi@goffi.org>
parents: 41
diff changeset
31 from twisted.words.protocols.jabber import jid
223
86d249b6d9b7 Files reorganisation
Goffi <goffi@goffi.org>
parents: 214
diff changeset
32 from sat.tools.xml_tools import paramsXml2xmlUI
364
312ca6f9d84a core: configuration file
Goffi <goffi@goffi.org>
parents: 346
diff changeset
33 from sat.core.default_config import default_config
412
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
34 from sat.tools.sqlite import SqliteStorage
0
goffi@necton2
parents:
diff changeset
35
61
58d49fc19639 parameters are saved again
Goffi <goffi@goffi.org>
parents: 60
diff changeset
36 SAVEFILE_PARAM_XML="/param" #xml parameters template
58d49fc19639 parameters are saved again
Goffi <goffi@goffi.org>
parents: 60
diff changeset
37 SAVEFILE_PARAM_DATA="/param" #individual & general parameters; _ind and _gen suffixes will be added
41
d24629c631fc SàT: new constant management, a local dir (~/.sat) is now used
Goffi <goffi@goffi.org>
parents: 38
diff changeset
38 SAVEFILE_HISTORY="/history"
47
9aa2d9dd4045 memory methods improvement
Goffi <goffi@goffi.org>
parents: 41
diff changeset
39 SAVEFILE_PRIVATE="/private" #file used to store misc values (mainly for plugins)
412
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
40 SAVEFILE_DATABASE="/sat.db"
0
goffi@necton2
parents:
diff changeset
41
17
74a39f40eb6d refactoring: using xml params (not finished yet)
Goffi <goffi@goffi.org>
parents: 14
diff changeset
42 class Param():
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
43 """This class manage parameters with xml"""
19
f2a745ca0fbc refactoring: using xml params part III (parameters import)
Goffi <goffi@goffi.org>
parents: 18
diff changeset
44 ### TODO: add desciption in params
17
74a39f40eb6d refactoring: using xml params (not finished yet)
Goffi <goffi@goffi.org>
parents: 14
diff changeset
45
183
9ee4a1d0d7fb Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents: 182
diff changeset
46 #TODO: move Watched in a plugin
34
a544b376b6f0 use proper utf-8 encoding for parsing xml in parameters
Goffi <goffi@goffi.org>
parents: 22
diff changeset
47 default_xml = u"""
17
74a39f40eb6d refactoring: using xml params (not finished yet)
Goffi <goffi@goffi.org>
parents: 14
diff changeset
48 <params>
60
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
49 <general>
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
50 </general>
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
51 <individual>
183
9ee4a1d0d7fb Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents: 182
diff changeset
52 <category name="Connection" label="%(category_connection)s">
256
f5181f6dd98f Test value replaced by example values for memory params
Goffi <goffi@goffi.org>
parents: 228
diff changeset
53 <param name="JabberID" value="name@example.org/SàT" type="string" />
f5181f6dd98f Test value replaced by example values for memory params
Goffi <goffi@goffi.org>
parents: 228
diff changeset
54 <param name="Password" value="" type="password" />
f5181f6dd98f Test value replaced by example values for memory params
Goffi <goffi@goffi.org>
parents: 228
diff changeset
55 <param name="Server" value="example.org" type="string" />
183
9ee4a1d0d7fb Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents: 182
diff changeset
56 <param name="NewAccount" value="%(label_NewAccount)s" type="button" callback_id="registerNewAccount"/>
9ee4a1d0d7fb Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents: 182
diff changeset
57 <param name="autoconnect" label="%(label_autoconnect)s" value="true" type="bool" />
9ee4a1d0d7fb Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents: 182
diff changeset
58 <param name="autodisconnect" label="%(label_autodisconnect)s" value="false" type="bool" />
60
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
59 </category>
183
9ee4a1d0d7fb Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents: 182
diff changeset
60 <category name="Misc" label="%(category_misc)s">
60
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
61 <param name="Watched" value="test@Jabber.goffi.int" type="string" />
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
62 </category>
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
63 </individual>
17
74a39f40eb6d refactoring: using xml params (not finished yet)
Goffi <goffi@goffi.org>
parents: 14
diff changeset
64 </params>
183
9ee4a1d0d7fb Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents: 182
diff changeset
65 """ % {'category_connection': _("Connection"),
9ee4a1d0d7fb Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents: 182
diff changeset
66 'label_NewAccount': _("Register new account"),
9ee4a1d0d7fb Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents: 182
diff changeset
67 'label_autoconnect': _('Connect on frontend startup'),
9ee4a1d0d7fb Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents: 182
diff changeset
68 'label_autodisconnect': _('Disconnect on frontend closure'),
9ee4a1d0d7fb Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents: 182
diff changeset
69 'category_misc': _("Misc")
9ee4a1d0d7fb Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents: 182
diff changeset
70 }
17
74a39f40eb6d refactoring: using xml params (not finished yet)
Goffi <goffi@goffi.org>
parents: 14
diff changeset
71
74a39f40eb6d refactoring: using xml params (not finished yet)
Goffi <goffi@goffi.org>
parents: 14
diff changeset
72 def load_default_params(self):
34
a544b376b6f0 use proper utf-8 encoding for parsing xml in parameters
Goffi <goffi@goffi.org>
parents: 22
diff changeset
73 self.dom = minidom.parseString(Param.default_xml.encode('utf-8'))
38
3e24753b9e0b Fixed parameters loading/saving
Goffi <goffi@goffi.org>
parents: 34
diff changeset
74
61
58d49fc19639 parameters are saved again
Goffi <goffi@goffi.org>
parents: 60
diff changeset
75 def load_xml(self, file):
58d49fc19639 parameters are saved again
Goffi <goffi@goffi.org>
parents: 60
diff changeset
76 """Load parameters template from file"""
38
3e24753b9e0b Fixed parameters loading/saving
Goffi <goffi@goffi.org>
parents: 34
diff changeset
77 self.dom = minidom.parse(file)
3e24753b9e0b Fixed parameters loading/saving
Goffi <goffi@goffi.org>
parents: 34
diff changeset
78
412
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
79 def loadGenData(self, storage):
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
80 """Load general parameters data from storage
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
81 @param storage: xxxStorage object instance
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
82 @return: deferred triggered once params are loaded"""
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
83 return storage.loadGenParams(self.params_gen)
61
58d49fc19639 parameters are saved again
Goffi <goffi@goffi.org>
parents: 60
diff changeset
84
412
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
85 def loadIndData(self, storage, profile):
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
86 """Load individual parameters
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
87 set self.params cache
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
88 @param storage: xxxStorage object instance
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
89 @param profile: profile to load (*must exist*)
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
90 @return: deferred triggered once params are loaded"""
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
91 self.params[profile] = {}
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
92 return storage.loadIndParams(self.params, profile)
61
58d49fc19639 parameters are saved again
Goffi <goffi@goffi.org>
parents: 60
diff changeset
93
58d49fc19639 parameters are saved again
Goffi <goffi@goffi.org>
parents: 60
diff changeset
94 def save_xml(self, file):
58d49fc19639 parameters are saved again
Goffi <goffi@goffi.org>
parents: 60
diff changeset
95 """Save parameters template to xml file"""
38
3e24753b9e0b Fixed parameters loading/saving
Goffi <goffi@goffi.org>
parents: 34
diff changeset
96 with open(file, 'wb') as xml_file:
214
e178e8f6d13a fixed some unicode issue
Goffi <goffi@goffi.org>
parents: 197
diff changeset
97 xml_file.write(self.dom.toxml('utf-8'))
60
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
98
61
58d49fc19639 parameters are saved again
Goffi <goffi@goffi.org>
parents: 60
diff changeset
99 def save_data(self, file):
58d49fc19639 parameters are saved again
Goffi <goffi@goffi.org>
parents: 60
diff changeset
100 """Save parameters data to file"""
58d49fc19639 parameters are saved again
Goffi <goffi@goffi.org>
parents: 60
diff changeset
101 #TODO: save properly in a separate file/database,
58d49fc19639 parameters are saved again
Goffi <goffi@goffi.org>
parents: 60
diff changeset
102 # use different behaviour depending of the data type (e.g. password encrypted)
58d49fc19639 parameters are saved again
Goffi <goffi@goffi.org>
parents: 60
diff changeset
103
58d49fc19639 parameters are saved again
Goffi <goffi@goffi.org>
parents: 60
diff changeset
104 #general params
58d49fc19639 parameters are saved again
Goffi <goffi@goffi.org>
parents: 60
diff changeset
105 with open(file+'_gen', 'w') as param_gen_pickle:
58d49fc19639 parameters are saved again
Goffi <goffi@goffi.org>
parents: 60
diff changeset
106 pickle.dump(self.params_gen, param_gen_pickle)
58d49fc19639 parameters are saved again
Goffi <goffi@goffi.org>
parents: 60
diff changeset
107
58d49fc19639 parameters are saved again
Goffi <goffi@goffi.org>
parents: 60
diff changeset
108 #then individual params
58d49fc19639 parameters are saved again
Goffi <goffi@goffi.org>
parents: 60
diff changeset
109 with open(file+'_ind', 'w') as param_ind_pickle:
58d49fc19639 parameters are saved again
Goffi <goffi@goffi.org>
parents: 60
diff changeset
110 pickle.dump(self.params, param_ind_pickle)
58d49fc19639 parameters are saved again
Goffi <goffi@goffi.org>
parents: 60
diff changeset
111
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 21
diff changeset
112 def __init__(self, host):
17
74a39f40eb6d refactoring: using xml params (not finished yet)
Goffi <goffi@goffi.org>
parents: 14
diff changeset
113 debug("Parameters init")
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 21
diff changeset
114 self.host = host
60
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
115 self.default_profile = None
182
556c2bd7c344 Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents: 166
diff changeset
116 self.params = {}
60
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
117 self.params_gen = {}
61
58d49fc19639 parameters are saved again
Goffi <goffi@goffi.org>
parents: 60
diff changeset
118 host.set_const('savefile_param_xml', SAVEFILE_PARAM_XML)
58d49fc19639 parameters are saved again
Goffi <goffi@goffi.org>
parents: 60
diff changeset
119 host.set_const('savefile_param_data', SAVEFILE_PARAM_DATA)
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 21
diff changeset
120 host.registerGeneralCB("registerNewAccount", host.registerNewAccountCB)
19
f2a745ca0fbc refactoring: using xml params part III (parameters import)
Goffi <goffi@goffi.org>
parents: 18
diff changeset
121
66
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
122 def createProfile(self, name):
60
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
123 """Create a new profile
68
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 66
diff changeset
124 @param name: Name of the profile"""
412
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
125 if self.storage.hasProfile(name):
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
126 info (_('The profile name already exists'))
412
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
127 return True
259
11f71187d5e4 core, plugin Maildir: added "ProfileCreation" Trigger
Goffi <goffi@goffi.org>
parents: 256
diff changeset
128 if not self.host.trigger.point("ProfileCreation", name):
412
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
129 return False
60
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
130 self.params[name]={}
412
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
131 return False
60
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
132
68
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 66
diff changeset
133 def deleteProfile(self, name):
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 66
diff changeset
134 """Delete an existing profile
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 66
diff changeset
135 @param name: Name of the profile"""
412
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
136 if not self.storage.hasProfile(name):
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
137 error (_('Trying to delete an unknown profile'))
412
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
138 return True
68
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 66
diff changeset
139 del self.params[name]
412
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
140 return False
68
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 66
diff changeset
141
60
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
142 def getProfileName(self, profile_key):
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
143 """return profile according to profile_key
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
144 @param profile_key: profile name or key which can be
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
145 @ALL@ for all profiles
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
146 @DEFAULT@ for default profile
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
147 @return: requested profile name or None if it doesn't exist"""
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
148 if profile_key=='@DEFAULT@':
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
149 if not self.params:
66
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
150 return ""
68
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 66
diff changeset
151 default = self.host.memory.getPrivate('Profile_default')
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 66
diff changeset
152 if not default or not default in self.params:
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
153 info(_('No default profile, returning first one')) #TODO: manage real default profile
412
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
154 default = self.getProfilesList()[0]
68
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 66
diff changeset
155 self.host.memory.setPrivate('Profile_default', default)
182
556c2bd7c344 Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents: 166
diff changeset
156 return default #FIXME: temporary, must use real default value, and fallback to first one if it doesn't exists
412
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
157 if not self.storage.hasProfile(profile_key):
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
158 info (_('Trying to access an unknown profile'))
66
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
159 return ""
60
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
160 return profile_key
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
161
19
f2a745ca0fbc refactoring: using xml params part III (parameters import)
Goffi <goffi@goffi.org>
parents: 18
diff changeset
162 def __get_unique_node(self, parent, tag, name):
60
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
163 """return node with given tag
19
f2a745ca0fbc refactoring: using xml params part III (parameters import)
Goffi <goffi@goffi.org>
parents: 18
diff changeset
164 @param parent: parent of nodes to check (e.g. documentElement)
f2a745ca0fbc refactoring: using xml params part III (parameters import)
Goffi <goffi@goffi.org>
parents: 18
diff changeset
165 @param tag: tag to check (e.g. "category")
f2a745ca0fbc refactoring: using xml params part III (parameters import)
Goffi <goffi@goffi.org>
parents: 18
diff changeset
166 @param name: name to check (e.g. "JID")
f2a745ca0fbc refactoring: using xml params part III (parameters import)
Goffi <goffi@goffi.org>
parents: 18
diff changeset
167 @return: node if it exist or None
f2a745ca0fbc refactoring: using xml params part III (parameters import)
Goffi <goffi@goffi.org>
parents: 18
diff changeset
168 """
f2a745ca0fbc refactoring: using xml params part III (parameters import)
Goffi <goffi@goffi.org>
parents: 18
diff changeset
169 for node in parent.childNodes:
f2a745ca0fbc refactoring: using xml params part III (parameters import)
Goffi <goffi@goffi.org>
parents: 18
diff changeset
170 if node.nodeName == tag and node.getAttribute("name") == name:
f2a745ca0fbc refactoring: using xml params part III (parameters import)
Goffi <goffi@goffi.org>
parents: 18
diff changeset
171 #the node already exists
f2a745ca0fbc refactoring: using xml params part III (parameters import)
Goffi <goffi@goffi.org>
parents: 18
diff changeset
172 return node
f2a745ca0fbc refactoring: using xml params part III (parameters import)
Goffi <goffi@goffi.org>
parents: 18
diff changeset
173 #the node is new
f2a745ca0fbc refactoring: using xml params part III (parameters import)
Goffi <goffi@goffi.org>
parents: 18
diff changeset
174 return None
f2a745ca0fbc refactoring: using xml params part III (parameters import)
Goffi <goffi@goffi.org>
parents: 18
diff changeset
175
38
3e24753b9e0b Fixed parameters loading/saving
Goffi <goffi@goffi.org>
parents: 34
diff changeset
176 def importParams(self, xml):
19
f2a745ca0fbc refactoring: using xml params part III (parameters import)
Goffi <goffi@goffi.org>
parents: 18
diff changeset
177 """import xml in parameters, do nothing if the param already exist
f2a745ca0fbc refactoring: using xml params part III (parameters import)
Goffi <goffi@goffi.org>
parents: 18
diff changeset
178 @param xml: parameters in xml form"""
34
a544b376b6f0 use proper utf-8 encoding for parsing xml in parameters
Goffi <goffi@goffi.org>
parents: 22
diff changeset
179 src_dom = minidom.parseString(xml.encode('utf-8'))
19
f2a745ca0fbc refactoring: using xml params part III (parameters import)
Goffi <goffi@goffi.org>
parents: 18
diff changeset
180
f2a745ca0fbc refactoring: using xml params part III (parameters import)
Goffi <goffi@goffi.org>
parents: 18
diff changeset
181 def import_node(tgt_parent, src_parent):
f2a745ca0fbc refactoring: using xml params part III (parameters import)
Goffi <goffi@goffi.org>
parents: 18
diff changeset
182 for child in src_parent.childNodes:
f2a745ca0fbc refactoring: using xml params part III (parameters import)
Goffi <goffi@goffi.org>
parents: 18
diff changeset
183 if child.nodeName == '#text':
f2a745ca0fbc refactoring: using xml params part III (parameters import)
Goffi <goffi@goffi.org>
parents: 18
diff changeset
184 continue
f2a745ca0fbc refactoring: using xml params part III (parameters import)
Goffi <goffi@goffi.org>
parents: 18
diff changeset
185 node = self.__get_unique_node(tgt_parent, child.nodeName, child.getAttribute("name"))
f2a745ca0fbc refactoring: using xml params part III (parameters import)
Goffi <goffi@goffi.org>
parents: 18
diff changeset
186 if not node: #The node is new
f2a745ca0fbc refactoring: using xml params part III (parameters import)
Goffi <goffi@goffi.org>
parents: 18
diff changeset
187 tgt_parent.appendChild(child)
f2a745ca0fbc refactoring: using xml params part III (parameters import)
Goffi <goffi@goffi.org>
parents: 18
diff changeset
188 else:
f2a745ca0fbc refactoring: using xml params part III (parameters import)
Goffi <goffi@goffi.org>
parents: 18
diff changeset
189 import_node(node, child)
f2a745ca0fbc refactoring: using xml params part III (parameters import)
Goffi <goffi@goffi.org>
parents: 18
diff changeset
190
f2a745ca0fbc refactoring: using xml params part III (parameters import)
Goffi <goffi@goffi.org>
parents: 18
diff changeset
191 import_node(self.dom.documentElement, src_dom.documentElement)
f2a745ca0fbc refactoring: using xml params part III (parameters import)
Goffi <goffi@goffi.org>
parents: 18
diff changeset
192
20
fc8c202cda87 refactoring: using xml params part IV (default values)
Goffi <goffi@goffi.org>
parents: 19
diff changeset
193 def __default_ok(self, value, name, category):
63
0db25931b60d SàT: multi-profiles: somes fixes in core
Goffi <goffi@goffi.org>
parents: 62
diff changeset
194 #FIXME: gof: will not work with individual parameters
61
58d49fc19639 parameters are saved again
Goffi <goffi@goffi.org>
parents: 60
diff changeset
195 self.setParam(name, value, category) #FIXME: better to set param xml value ???
20
fc8c202cda87 refactoring: using xml params part IV (default values)
Goffi <goffi@goffi.org>
parents: 19
diff changeset
196
fc8c202cda87 refactoring: using xml params part IV (default values)
Goffi <goffi@goffi.org>
parents: 19
diff changeset
197 def __default_ko(self, failure, name, category):
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
198 error (_("Can't determine default value for [%(category)s/%(name)s]: %(reason)s") % {'category':category, 'name':name, 'reason':str(failure.value)})
20
fc8c202cda87 refactoring: using xml params part IV (default values)
Goffi <goffi@goffi.org>
parents: 19
diff changeset
199
fc8c202cda87 refactoring: using xml params part IV (default values)
Goffi <goffi@goffi.org>
parents: 19
diff changeset
200 def setDefault(self, name, category, callback, errback=None):
fc8c202cda87 refactoring: using xml params part IV (default values)
Goffi <goffi@goffi.org>
parents: 19
diff changeset
201 """Set default value of parameter
fc8c202cda87 refactoring: using xml params part IV (default values)
Goffi <goffi@goffi.org>
parents: 19
diff changeset
202 'default_cb' attibute of parameter must be set to 'yes'
fc8c202cda87 refactoring: using xml params part IV (default values)
Goffi <goffi@goffi.org>
parents: 19
diff changeset
203 @param name: name of the parameter
fc8c202cda87 refactoring: using xml params part IV (default values)
Goffi <goffi@goffi.org>
parents: 19
diff changeset
204 @param category: category of the parameter
fc8c202cda87 refactoring: using xml params part IV (default values)
Goffi <goffi@goffi.org>
parents: 19
diff changeset
205 @param callback: must return a string with the value (use deferred if needed)
fc8c202cda87 refactoring: using xml params part IV (default values)
Goffi <goffi@goffi.org>
parents: 19
diff changeset
206 @param errback: must manage the error with args failure, name, category
fc8c202cda87 refactoring: using xml params part IV (default values)
Goffi <goffi@goffi.org>
parents: 19
diff changeset
207 """
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 21
diff changeset
208 #TODO: send signal param update if value changed
60
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
209 node = self.__getParamNode(name, category, '@ALL@')
20
fc8c202cda87 refactoring: using xml params part IV (default values)
Goffi <goffi@goffi.org>
parents: 19
diff changeset
210 if not node:
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
211 error(_("Requested param [%(name)s] in category [%(category)s] doesn't exist !") % {'name':name, 'category':category})
20
fc8c202cda87 refactoring: using xml params part IV (default values)
Goffi <goffi@goffi.org>
parents: 19
diff changeset
212 return
60
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
213 if node[1].getAttribute('default_cb') == 'yes':
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
214 del node[1].attributes['default_cb']
20
fc8c202cda87 refactoring: using xml params part IV (default values)
Goffi <goffi@goffi.org>
parents: 19
diff changeset
215 d = defer.maybeDeferred(callback)
fc8c202cda87 refactoring: using xml params part IV (default values)
Goffi <goffi@goffi.org>
parents: 19
diff changeset
216 d.addCallback(self.__default_ok, name, category)
fc8c202cda87 refactoring: using xml params part IV (default values)
Goffi <goffi@goffi.org>
parents: 19
diff changeset
217 d.addErrback(errback or self.__default_ko, name, category)
17
74a39f40eb6d refactoring: using xml params (not finished yet)
Goffi <goffi@goffi.org>
parents: 14
diff changeset
218
60
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
219 def getParamA(self, name, category, attr="value", profile_key="@DEFAULT@"):
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 21
diff changeset
220 """Helper method to get a specific attribute
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 21
diff changeset
221 @param name: name of the parameter
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 21
diff changeset
222 @param category: category of the parameter
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 21
diff changeset
223 @param attr: name of the attribute (default: "value")
60
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
224 @param profile: owner of the param (@ALL@ for everyone)
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 21
diff changeset
225
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 21
diff changeset
226 @return: attribute"""
17
74a39f40eb6d refactoring: using xml params (not finished yet)
Goffi <goffi@goffi.org>
parents: 14
diff changeset
227 node = self.__getParamNode(name, category)
74a39f40eb6d refactoring: using xml params (not finished yet)
Goffi <goffi@goffi.org>
parents: 14
diff changeset
228 if not node:
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
229 error(_("Requested param [%(name)s] in category [%(category)s] doesn't exist !") % {'name':name, 'category':category})
19
f2a745ca0fbc refactoring: using xml params part III (parameters import)
Goffi <goffi@goffi.org>
parents: 18
diff changeset
230 return None
60
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
231
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
232 if node[0] == 'general':
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
233 value = self.__getParam(None, category, name, 'general')
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
234 return value or node[1].getAttribute(attr)
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
235
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
236 assert(node[0] == 'individual')
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
237
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
238 profile = self.getProfileName(profile_key)
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
239 if not profile:
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
240 error(_('Requesting a param for an non-existant profile'))
276
a00e87d48213 bridge, bridge constructor: fixed mix stuff
Goffi <goffi@goffi.org>
parents: 259
diff changeset
241 return ""
60
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
242
64
d46f849664aa SàT: multi-profile, plugins updated
Goffi <goffi@goffi.org>
parents: 63
diff changeset
243 if attr == "value":
d46f849664aa SàT: multi-profile, plugins updated
Goffi <goffi@goffi.org>
parents: 63
diff changeset
244 return self.__getParam(profile, category, name) or node[1].getAttribute(attr)
d46f849664aa SàT: multi-profile, plugins updated
Goffi <goffi@goffi.org>
parents: 63
diff changeset
245 else:
d46f849664aa SàT: multi-profile, plugins updated
Goffi <goffi@goffi.org>
parents: 63
diff changeset
246 return node[1].getAttribute(attr)
60
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
247
17
74a39f40eb6d refactoring: using xml params (not finished yet)
Goffi <goffi@goffi.org>
parents: 14
diff changeset
248
60
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
249 def __getParam(self, profile, category, name, type='individual'):
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
250 """Return the param, or None if it doesn't exist
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
251 @param profile: the profile name (not profile key, i.e. name and not something like @DEFAULT@)
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
252 @param category: param category
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
253 @param name: param name
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
254 """
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
255 if type == 'general':
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
256 if self.params_gen.has_key((category, name)):
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
257 return self.params_gen[(category, name)]
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
258 return None #This general param has the default value
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
259 assert (type == 'individual')
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
260 if not self.params.has_key(profile) or not self.params[profile].has_key((category, name)):
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
261 return None
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
262 return self.params[profile][(category, name)]
17
74a39f40eb6d refactoring: using xml params (not finished yet)
Goffi <goffi@goffi.org>
parents: 14
diff changeset
263
60
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
264 def __constructProfileXml(self, profile):
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
265 """Construct xml for asked profile, filling values when needed
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
266 /!\ as noticed in doc, don't forget to unlink the minidom.Document
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
267 @param profile: profile name (not key !)
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
268 @return: minidom.Document of the profile xml (cf warning above)
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
269 """
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
270 prof_xml = minidom.parseString('<params/>')
395
79fe50fc8edc memory: multiples params of the same category are now merged
Goffi <goffi@goffi.org>
parents: 392
diff changeset
271 cache = {}
79fe50fc8edc memory: multiples params of the same category are now merged
Goffi <goffi@goffi.org>
parents: 392
diff changeset
272
60
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
273 for type_node in self.dom.documentElement.childNodes:
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
274 if type_node.nodeName == 'general' or type_node.nodeName == 'individual': #we use all params, general and individual
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
275 for cat_node in type_node.childNodes:
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
276 if cat_node.nodeName == 'category':
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
277 category = cat_node.getAttribute('name')
395
79fe50fc8edc memory: multiples params of the same category are now merged
Goffi <goffi@goffi.org>
parents: 392
diff changeset
278 if not cache.has_key(category):
79fe50fc8edc memory: multiples params of the same category are now merged
Goffi <goffi@goffi.org>
parents: 392
diff changeset
279 cache[category] = dest_cat = cat_node.cloneNode(True) #we make a copy for the new xml
79fe50fc8edc memory: multiples params of the same category are now merged
Goffi <goffi@goffi.org>
parents: 392
diff changeset
280 new_node = True
79fe50fc8edc memory: multiples params of the same category are now merged
Goffi <goffi@goffi.org>
parents: 392
diff changeset
281 else:
79fe50fc8edc memory: multiples params of the same category are now merged
Goffi <goffi@goffi.org>
parents: 392
diff changeset
282 dest_cat = cache[category]
79fe50fc8edc memory: multiples params of the same category are now merged
Goffi <goffi@goffi.org>
parents: 392
diff changeset
283 new_node = False #It's not a new node, we will merge information
79fe50fc8edc memory: multiples params of the same category are now merged
Goffi <goffi@goffi.org>
parents: 392
diff changeset
284 params = cat_node.getElementsByTagName("param")
79fe50fc8edc memory: multiples params of the same category are now merged
Goffi <goffi@goffi.org>
parents: 392
diff changeset
285 dest_params = {}
79fe50fc8edc memory: multiples params of the same category are now merged
Goffi <goffi@goffi.org>
parents: 392
diff changeset
286 for node in dest_cat.childNodes:
79fe50fc8edc memory: multiples params of the same category are now merged
Goffi <goffi@goffi.org>
parents: 392
diff changeset
287 if node.nodeName != "param":
79fe50fc8edc memory: multiples params of the same category are now merged
Goffi <goffi@goffi.org>
parents: 392
diff changeset
288 continue
79fe50fc8edc memory: multiples params of the same category are now merged
Goffi <goffi@goffi.org>
parents: 392
diff changeset
289 dest_params[node.getAttribute('name')] = node
79fe50fc8edc memory: multiples params of the same category are now merged
Goffi <goffi@goffi.org>
parents: 392
diff changeset
290
60
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
291 for param_node in params:
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
292 name = param_node.getAttribute('name')
395
79fe50fc8edc memory: multiples params of the same category are now merged
Goffi <goffi@goffi.org>
parents: 392
diff changeset
293
79fe50fc8edc memory: multiples params of the same category are now merged
Goffi <goffi@goffi.org>
parents: 392
diff changeset
294 if name not in dest_params:
79fe50fc8edc memory: multiples params of the same category are now merged
Goffi <goffi@goffi.org>
parents: 392
diff changeset
295 dest_params[name] = param_node.cloneNode(True)
79fe50fc8edc memory: multiples params of the same category are now merged
Goffi <goffi@goffi.org>
parents: 392
diff changeset
296 dest_cat.appendChild(dest_params[name])
79fe50fc8edc memory: multiples params of the same category are now merged
Goffi <goffi@goffi.org>
parents: 392
diff changeset
297
60
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
298 profile_value = self.__getParam(profile, category, name, type_node.nodeName)
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
299 if profile_value: #there is a value for this profile, we must change the default
395
79fe50fc8edc memory: multiples params of the same category are now merged
Goffi <goffi@goffi.org>
parents: 392
diff changeset
300 dest_params[name].setAttribute('value', profile_value)
79fe50fc8edc memory: multiples params of the same category are now merged
Goffi <goffi@goffi.org>
parents: 392
diff changeset
301 if new_node:
79fe50fc8edc memory: multiples params of the same category are now merged
Goffi <goffi@goffi.org>
parents: 392
diff changeset
302 prof_xml.documentElement.appendChild(dest_cat)
60
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
303 return prof_xml
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
304
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
305
346
ca3a041fed30 core: fixed several subscription scheme issues + removed most of profile_key default value in core.sat_main and core.xmmp (source of bugs) + contact update
Goffi <goffi@goffi.org>
parents: 327
diff changeset
306 def getParamsUI(self, profile_key):
105
d2630fba8dfd params to XMLUI tools
Goffi <goffi@goffi.org>
parents: 79
diff changeset
307 """Return a SàT XMLUI for parameters, with given profile"""
d2630fba8dfd params to XMLUI tools
Goffi <goffi@goffi.org>
parents: 79
diff changeset
308 profile = self.getProfileName(profile_key)
d2630fba8dfd params to XMLUI tools
Goffi <goffi@goffi.org>
parents: 79
diff changeset
309 if not profile:
d2630fba8dfd params to XMLUI tools
Goffi <goffi@goffi.org>
parents: 79
diff changeset
310 error(_("Asking params for inexistant profile"))
d2630fba8dfd params to XMLUI tools
Goffi <goffi@goffi.org>
parents: 79
diff changeset
311 return ""
d2630fba8dfd params to XMLUI tools
Goffi <goffi@goffi.org>
parents: 79
diff changeset
312 param_xml = self.getParams(profile)
d2630fba8dfd params to XMLUI tools
Goffi <goffi@goffi.org>
parents: 79
diff changeset
313 return paramsXml2xmlUI(param_xml)
60
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
314
346
ca3a041fed30 core: fixed several subscription scheme issues + removed most of profile_key default value in core.sat_main and core.xmmp (source of bugs) + contact update
Goffi <goffi@goffi.org>
parents: 327
diff changeset
315 def getParams(self, profile_key):
60
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
316 """Construct xml for asked profile
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
317 Take params xml as skeleton"""
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
318 profile = self.getProfileName(profile_key)
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
319 if not profile:
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
320 error(_("Asking params for inexistant profile"))
60
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
321 return ""
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
322 prof_xml = self.__constructProfileXml(profile)
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
323 return_xml = prof_xml.toxml()
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
324 prof_xml.unlink()
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
325
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
326 return return_xml
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
327
346
ca3a041fed30 core: fixed several subscription scheme issues + removed most of profile_key default value in core.sat_main and core.xmmp (source of bugs) + contact update
Goffi <goffi@goffi.org>
parents: 327
diff changeset
328 def getParamsForCategory(self, category, profile_key):
18
6928e3cb73a8 refactoring: using xml params part II
Goffi <goffi@goffi.org>
parents: 17
diff changeset
329 """Return node's xml for selected category"""
60
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
330 #TODO: manage category of general type (without existant profile)
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
331 profile = self.getProfileName(profile_key)
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
332 if not profile:
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
333 error(_("Asking params for inexistant profile"))
60
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
334 return ""
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
335 prof_xml = self.__constructProfileXml(profile)
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
336
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
337 for node in prof_xml.getElementsByTagName("category"):
18
6928e3cb73a8 refactoring: using xml params part II
Goffi <goffi@goffi.org>
parents: 17
diff changeset
338 if node.nodeName == "category" and node.getAttribute("name") == category:
60
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
339 result = node.toxml()
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
340 prof_xml.unlink()
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
341 return result
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
342
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
343 prof_xml.unlink()
18
6928e3cb73a8 refactoring: using xml params part II
Goffi <goffi@goffi.org>
parents: 17
diff changeset
344 return "<category />"
17
74a39f40eb6d refactoring: using xml params (not finished yet)
Goffi <goffi@goffi.org>
parents: 14
diff changeset
345
60
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
346 def __getParamNode(self, name, category, type="@ALL@"): #FIXME: is type useful ?
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
347 """Return a node from the param_xml
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
348 @param name: name of the node
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
349 @param category: category of the node
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
350 @type: keyword for search:
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
351 @ALL@ search everywhere
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
352 @GENERAL@ only search in general type
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
353 @INDIVIDUAL@ only search in individual type
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
354 @return: a tuple with the node type and the the node, or None if not found"""
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
355
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
356 for type_node in self.dom.documentElement.childNodes:
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
357 if ( ((type == "@ALL@" or type == "@GENERAL@") and type_node.nodeName == 'general')
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
358 or ( (type == "@ALL@" or type == "@INDIVIDUAL@") and type_node.nodeName == 'individual') ):
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
359 for node in type_node.getElementsByTagName('category'):
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
360 if node.getAttribute("name") == category:
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
361 params = node.getElementsByTagName("param")
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
362 for param in params:
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
363 if param.getAttribute("name") == name:
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
364 return (type_node.nodeName, param)
17
74a39f40eb6d refactoring: using xml params (not finished yet)
Goffi <goffi@goffi.org>
parents: 14
diff changeset
365 return None
74a39f40eb6d refactoring: using xml params (not finished yet)
Goffi <goffi@goffi.org>
parents: 14
diff changeset
366
74a39f40eb6d refactoring: using xml params (not finished yet)
Goffi <goffi@goffi.org>
parents: 14
diff changeset
367 def getParamsCategories(self):
74a39f40eb6d refactoring: using xml params (not finished yet)
Goffi <goffi@goffi.org>
parents: 14
diff changeset
368 """return the categories availables"""
74a39f40eb6d refactoring: using xml params (not finished yet)
Goffi <goffi@goffi.org>
parents: 14
diff changeset
369 categories=[]
74a39f40eb6d refactoring: using xml params (not finished yet)
Goffi <goffi@goffi.org>
parents: 14
diff changeset
370 for cat in self.dom.getElementsByTagName("category"):
396
cecd22241d56 memory: avoid duplicate in getParamsCategories
Goffi <goffi@goffi.org>
parents: 395
diff changeset
371 name = cat.getAttribute("name")
cecd22241d56 memory: avoid duplicate in getParamsCategories
Goffi <goffi@goffi.org>
parents: 395
diff changeset
372 if name not in categories:
cecd22241d56 memory: avoid duplicate in getParamsCategories
Goffi <goffi@goffi.org>
parents: 395
diff changeset
373 categories.append(cat.getAttribute("name"))
17
74a39f40eb6d refactoring: using xml params (not finished yet)
Goffi <goffi@goffi.org>
parents: 14
diff changeset
374 return categories
74a39f40eb6d refactoring: using xml params (not finished yet)
Goffi <goffi@goffi.org>
parents: 14
diff changeset
375
392
20f11097d99b memory: general param default value fix
Goffi <goffi@goffi.org>
parents: 369
diff changeset
376 def setParam(self, name, value, category, profile_key='@NONE@'):
60
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
377 """Set a parameter, return None if the parameter is not in param xml"""
392
20f11097d99b memory: general param default value fix
Goffi <goffi@goffi.org>
parents: 369
diff changeset
378 if profile_key!="@NONE@":
20f11097d99b memory: general param default value fix
Goffi <goffi@goffi.org>
parents: 369
diff changeset
379 profile = self.getProfileName(profile_key)
20f11097d99b memory: general param default value fix
Goffi <goffi@goffi.org>
parents: 369
diff changeset
380 if not profile:
20f11097d99b memory: general param default value fix
Goffi <goffi@goffi.org>
parents: 369
diff changeset
381 error(_('Trying to set parameter for an unknown profile'))
20f11097d99b memory: general param default value fix
Goffi <goffi@goffi.org>
parents: 369
diff changeset
382 return #TODO: throw an error
60
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
383
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
384 node = self.__getParamNode(name, category, '@ALL@')
17
74a39f40eb6d refactoring: using xml params (not finished yet)
Goffi <goffi@goffi.org>
parents: 14
diff changeset
385 if not node:
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
386 error(_('Requesting an unknown parameter (%(category)s/%(name)s)') % {'category':category, 'name':name})
60
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
387 return
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
388
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
389 if node[0] == 'general':
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
390 self.params_gen[(category, name)] = value
412
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
391 self.storage.setGenParam(category, name, value)
392
20f11097d99b memory: general param default value fix
Goffi <goffi@goffi.org>
parents: 369
diff changeset
392 for profile in self.getProfilesList():
20f11097d99b memory: general param default value fix
Goffi <goffi@goffi.org>
parents: 369
diff changeset
393 if self.host.isConnected(profile):
20f11097d99b memory: general param default value fix
Goffi <goffi@goffi.org>
parents: 369
diff changeset
394 self.host.bridge.paramUpdate(name, value, category, profile)
60
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
395 return
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
396
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
397 assert (node[0] == 'individual')
392
20f11097d99b memory: general param default value fix
Goffi <goffi@goffi.org>
parents: 369
diff changeset
398 assert (profile_key != "@NONE@")
60
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
399
61
58d49fc19639 parameters are saved again
Goffi <goffi@goffi.org>
parents: 60
diff changeset
400 type = node[1].getAttribute("type")
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 21
diff changeset
401 if type=="button":
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 21
diff changeset
402 print "clique",node.toxml()
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 21
diff changeset
403 else:
412
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
404 if self.host.isConnected(profile): #key can not exists if profile is not connected
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
405 self.params[profile][(category, name)] = value
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
406 self.host.bridge.paramUpdate(name, value, category, profile)
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
407 self.storage.setIndParam(category, name, value, profile)
17
74a39f40eb6d refactoring: using xml params (not finished yet)
Goffi <goffi@goffi.org>
parents: 14
diff changeset
408
0
goffi@necton2
parents:
diff changeset
409 class Memory:
goffi@necton2
parents:
diff changeset
410 """This class manage all persistent informations"""
goffi@necton2
parents:
diff changeset
411
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 21
diff changeset
412 def __init__(self, host):
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
413 info (_("Memory manager init"))
412
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
414 self.initialized = defer.Deferred()
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
415 init_defers = [] #list of deferred to wait before initialization is finished
41
d24629c631fc SàT: new constant management, a local dir (~/.sat) is now used
Goffi <goffi@goffi.org>
parents: 38
diff changeset
416 self.host = host
47
9aa2d9dd4045 memory methods improvement
Goffi <goffi@goffi.org>
parents: 41
diff changeset
417 self.contacts={}
0
goffi@necton2
parents:
diff changeset
418 self.presenceStatus={}
399
3ed53803b3b3 core: added getLastResource method
Goffi <goffi@goffi.org>
parents: 398
diff changeset
419 self.lastResource={} #tmp, will be refactored with bdd integration
47
9aa2d9dd4045 memory methods improvement
Goffi <goffi@goffi.org>
parents: 41
diff changeset
420 self.subscriptions={}
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 21
diff changeset
421 self.params=Param(host)
47
9aa2d9dd4045 memory methods improvement
Goffi <goffi@goffi.org>
parents: 41
diff changeset
422 self.history={} #used to store chat history (key: short jid)
9aa2d9dd4045 memory methods improvement
Goffi <goffi@goffi.org>
parents: 41
diff changeset
423 self.private={} #used to store private value
282
6a0c6d8e119d added plugin xep-0115: entity capabilities
Goffi <goffi@goffi.org>
parents: 276
diff changeset
424 self.server_features={} #used to store discovery's informations
305
15a12bf2bb62 core: server identities are now save in memory
Goffi <goffi@goffi.org>
parents: 282
diff changeset
425 self.server_identities={}
364
312ca6f9d84a core: configuration file
Goffi <goffi@goffi.org>
parents: 346
diff changeset
426 self.config = self.parseMainConf()
60
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
427 host.set_const('savefile_history', SAVEFILE_HISTORY)
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
428 host.set_const('savefile_private', SAVEFILE_PRIVATE)
412
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
429 host.set_const('savefile_database', SAVEFILE_DATABASE)
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
430 database_file = os.path.expanduser(self.getConfig('','local_dir')+
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
431 self.host.get_const('savefile_database'))
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
432 self.loadFiles()
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
433 self.storage = SqliteStorage(database_file)
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
434 self.storage.initialized.addCallback(lambda ignore: self.load(init_defers))
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
435
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
436 defer.DeferredList(init_defers).chainDeferred(self.initialized)
0
goffi@necton2
parents:
diff changeset
437
364
312ca6f9d84a core: configuration file
Goffi <goffi@goffi.org>
parents: 346
diff changeset
438 def parseMainConf(self):
312ca6f9d84a core: configuration file
Goffi <goffi@goffi.org>
parents: 346
diff changeset
439 """look for main .ini configuration file, and parse it"""
312ca6f9d84a core: configuration file
Goffi <goffi@goffi.org>
parents: 346
diff changeset
440 _config = SafeConfigParser(defaults=default_config)
365
efbfccfed623 core: local_dir moved to config file
Goffi <goffi@goffi.org>
parents: 364
diff changeset
441 try:
369
e83d0c21d64d launching script now read config files
Goffi <goffi@goffi.org>
parents: 365
diff changeset
442 _config.read(map(os.path.expanduser, ['/etc/sat.conf', '~/sat.conf', '~/.sat.conf', 'sat.conf', '.sat.conf']))
365
efbfccfed623 core: local_dir moved to config file
Goffi <goffi@goffi.org>
parents: 364
diff changeset
443 except:
efbfccfed623 core: local_dir moved to config file
Goffi <goffi@goffi.org>
parents: 364
diff changeset
444 error (_("Can't read main config !"))
efbfccfed623 core: local_dir moved to config file
Goffi <goffi@goffi.org>
parents: 364
diff changeset
445
364
312ca6f9d84a core: configuration file
Goffi <goffi@goffi.org>
parents: 346
diff changeset
446 return _config
312ca6f9d84a core: configuration file
Goffi <goffi@goffi.org>
parents: 346
diff changeset
447
365
efbfccfed623 core: local_dir moved to config file
Goffi <goffi@goffi.org>
parents: 364
diff changeset
448 def getConfig(self, section, name):
364
312ca6f9d84a core: configuration file
Goffi <goffi@goffi.org>
parents: 346
diff changeset
449 """Get the main configuration option
312ca6f9d84a core: configuration file
Goffi <goffi@goffi.org>
parents: 346
diff changeset
450 @param section: section of the config file (None or '' for DEFAULT)
312ca6f9d84a core: configuration file
Goffi <goffi@goffi.org>
parents: 346
diff changeset
451 @param name: name of the option
365
efbfccfed623 core: local_dir moved to config file
Goffi <goffi@goffi.org>
parents: 364
diff changeset
452 """
364
312ca6f9d84a core: configuration file
Goffi <goffi@goffi.org>
parents: 346
diff changeset
453 if not section:
312ca6f9d84a core: configuration file
Goffi <goffi@goffi.org>
parents: 346
diff changeset
454 section='DEFAULT'
312ca6f9d84a core: configuration file
Goffi <goffi@goffi.org>
parents: 346
diff changeset
455 try:
312ca6f9d84a core: configuration file
Goffi <goffi@goffi.org>
parents: 346
diff changeset
456 _value = self.config.get(section, name)
312ca6f9d84a core: configuration file
Goffi <goffi@goffi.org>
parents: 346
diff changeset
457 except NoOptionError, NoSectionError:
312ca6f9d84a core: configuration file
Goffi <goffi@goffi.org>
parents: 346
diff changeset
458 _value = ''
312ca6f9d84a core: configuration file
Goffi <goffi@goffi.org>
parents: 346
diff changeset
459
312ca6f9d84a core: configuration file
Goffi <goffi@goffi.org>
parents: 346
diff changeset
460 return os.path.expanduser(_value) if name.endswith('_path') or name.endswith('_dir') else _value
312ca6f9d84a core: configuration file
Goffi <goffi@goffi.org>
parents: 346
diff changeset
461
412
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
462
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
463 def loadFiles(self):
0
goffi@necton2
parents:
diff changeset
464 """Load parameters and all memory things from file/db"""
365
efbfccfed623 core: local_dir moved to config file
Goffi <goffi@goffi.org>
parents: 364
diff changeset
465 param_file_xml = os.path.expanduser(self.getConfig('','local_dir')+
61
58d49fc19639 parameters are saved again
Goffi <goffi@goffi.org>
parents: 60
diff changeset
466 self.host.get_const('savefile_param_xml'))
365
efbfccfed623 core: local_dir moved to config file
Goffi <goffi@goffi.org>
parents: 364
diff changeset
467 param_file_data = os.path.expanduser(self.getConfig('','local_dir')+
61
58d49fc19639 parameters are saved again
Goffi <goffi@goffi.org>
parents: 60
diff changeset
468 self.host.get_const('savefile_param_data'))
365
efbfccfed623 core: local_dir moved to config file
Goffi <goffi@goffi.org>
parents: 364
diff changeset
469 history_file = os.path.expanduser(self.getConfig('','local_dir')+
41
d24629c631fc SàT: new constant management, a local dir (~/.sat) is now used
Goffi <goffi@goffi.org>
parents: 38
diff changeset
470 self.host.get_const('savefile_history'))
365
efbfccfed623 core: local_dir moved to config file
Goffi <goffi@goffi.org>
parents: 364
diff changeset
471 private_file = os.path.expanduser(self.getConfig('','local_dir')+
47
9aa2d9dd4045 memory methods improvement
Goffi <goffi@goffi.org>
parents: 41
diff changeset
472 self.host.get_const('savefile_private'))
0
goffi@necton2
parents:
diff changeset
473
412
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
474 #parameters template
61
58d49fc19639 parameters are saved again
Goffi <goffi@goffi.org>
parents: 60
diff changeset
475 if os.path.exists(param_file_xml):
0
goffi@necton2
parents:
diff changeset
476 try:
61
58d49fc19639 parameters are saved again
Goffi <goffi@goffi.org>
parents: 60
diff changeset
477 self.params.load_xml(param_file_xml)
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
478 debug(_("params template loaded"))
0
goffi@necton2
parents:
diff changeset
479 except:
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
480 error (_("Can't load params template !"))
17
74a39f40eb6d refactoring: using xml params (not finished yet)
Goffi <goffi@goffi.org>
parents: 14
diff changeset
481 self.params.load_default_params()
0
goffi@necton2
parents:
diff changeset
482 else:
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
483 info (_("No params template, using default template"))
17
74a39f40eb6d refactoring: using xml params (not finished yet)
Goffi <goffi@goffi.org>
parents: 14
diff changeset
484 self.params.load_default_params()
0
goffi@necton2
parents:
diff changeset
485
412
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
486
0
goffi@necton2
parents:
diff changeset
487 #history
41
d24629c631fc SàT: new constant management, a local dir (~/.sat) is now used
Goffi <goffi@goffi.org>
parents: 38
diff changeset
488 if os.path.exists(history_file):
0
goffi@necton2
parents:
diff changeset
489 try:
41
d24629c631fc SàT: new constant management, a local dir (~/.sat) is now used
Goffi <goffi@goffi.org>
parents: 38
diff changeset
490 with open(history_file, 'r') as history_pickle:
0
goffi@necton2
parents:
diff changeset
491 self.history=pickle.load(history_pickle)
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
492 debug(_("history loaded"))
0
goffi@necton2
parents:
diff changeset
493 except:
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
494 error (_("Can't load history !"))
0
goffi@necton2
parents:
diff changeset
495
47
9aa2d9dd4045 memory methods improvement
Goffi <goffi@goffi.org>
parents: 41
diff changeset
496 #private
9aa2d9dd4045 memory methods improvement
Goffi <goffi@goffi.org>
parents: 41
diff changeset
497 if os.path.exists(private_file):
9aa2d9dd4045 memory methods improvement
Goffi <goffi@goffi.org>
parents: 41
diff changeset
498 try:
9aa2d9dd4045 memory methods improvement
Goffi <goffi@goffi.org>
parents: 41
diff changeset
499 with open(private_file, 'r') as private_pickle:
9aa2d9dd4045 memory methods improvement
Goffi <goffi@goffi.org>
parents: 41
diff changeset
500 self.private=pickle.load(private_pickle)
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
501 debug(_("private values loaded"))
47
9aa2d9dd4045 memory methods improvement
Goffi <goffi@goffi.org>
parents: 41
diff changeset
502 except:
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
503 error (_("Can't load private values !"))
0
goffi@necton2
parents:
diff changeset
504
412
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
505 def load(self, init_defers):
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
506 """Load parameters and all memory things from db
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
507 @param init_defers: list of deferred to wait before parameters are loaded"""
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
508 #parameters data
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
509 init_defers.append(self.params.loadGenData(self.storage))
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
510
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
511 def loadIndividualParams(self, profile_key):
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
512 """Load individual parameters for a profile
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
513 @param profile_key: %(doc_profile_key)s"""
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
514 profile = self.getProfileName(profile_key)
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
515 if not profile:
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
516 error (_('Trying to load parameters for a non-existant profile'))
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
517 raise Exception("Profile doesn't exist")
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
518 return self.params.loadIndParams(profile)
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
519
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
520
0
goffi@necton2
parents:
diff changeset
521 def save(self):
goffi@necton2
parents:
diff changeset
522 """Save parameters and all memory things to file/db"""
38
3e24753b9e0b Fixed parameters loading/saving
Goffi <goffi@goffi.org>
parents: 34
diff changeset
523 #TODO: need to encrypt files (at least passwords !) and set permissions
365
efbfccfed623 core: local_dir moved to config file
Goffi <goffi@goffi.org>
parents: 364
diff changeset
524 param_file_xml = os.path.expanduser(self.getConfig('','local_dir')+
61
58d49fc19639 parameters are saved again
Goffi <goffi@goffi.org>
parents: 60
diff changeset
525 self.host.get_const('savefile_param_xml'))
365
efbfccfed623 core: local_dir moved to config file
Goffi <goffi@goffi.org>
parents: 364
diff changeset
526 param_file_data = os.path.expanduser(self.getConfig('','local_dir')+
61
58d49fc19639 parameters are saved again
Goffi <goffi@goffi.org>
parents: 60
diff changeset
527 self.host.get_const('savefile_param_data'))
365
efbfccfed623 core: local_dir moved to config file
Goffi <goffi@goffi.org>
parents: 364
diff changeset
528 history_file = os.path.expanduser(self.getConfig('','local_dir')+
41
d24629c631fc SàT: new constant management, a local dir (~/.sat) is now used
Goffi <goffi@goffi.org>
parents: 38
diff changeset
529 self.host.get_const('savefile_history'))
365
efbfccfed623 core: local_dir moved to config file
Goffi <goffi@goffi.org>
parents: 364
diff changeset
530 private_file = os.path.expanduser(self.getConfig('','local_dir')+
47
9aa2d9dd4045 memory methods improvement
Goffi <goffi@goffi.org>
parents: 41
diff changeset
531 self.host.get_const('savefile_private'))
41
d24629c631fc SàT: new constant management, a local dir (~/.sat) is now used
Goffi <goffi@goffi.org>
parents: 38
diff changeset
532
61
58d49fc19639 parameters are saved again
Goffi <goffi@goffi.org>
parents: 60
diff changeset
533 self.params.save_xml(param_file_xml)
58d49fc19639 parameters are saved again
Goffi <goffi@goffi.org>
parents: 60
diff changeset
534 self.params.save_data(param_file_data)
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
535 debug(_("params saved"))
41
d24629c631fc SàT: new constant management, a local dir (~/.sat) is now used
Goffi <goffi@goffi.org>
parents: 38
diff changeset
536 with open(history_file, 'w') as history_pickle:
0
goffi@necton2
parents:
diff changeset
537 pickle.dump(self.history, history_pickle)
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
538 debug(_("history saved"))
47
9aa2d9dd4045 memory methods improvement
Goffi <goffi@goffi.org>
parents: 41
diff changeset
539 with open(private_file, 'w') as private_pickle:
9aa2d9dd4045 memory methods improvement
Goffi <goffi@goffi.org>
parents: 41
diff changeset
540 pickle.dump(self.private, private_pickle)
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
541 debug(_("private values saved"))
0
goffi@necton2
parents:
diff changeset
542
60
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
543 def getProfilesList(self):
412
62b17854254e database integration: first draft
Goffi <goffi@goffi.org>
parents: 399
diff changeset
544 return self.storage.getProfilesList()
60
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
545
62
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 61
diff changeset
546
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 61
diff changeset
547 def getProfileName(self, profile_key):
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 61
diff changeset
548 """Return name of profile from keyword
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 61
diff changeset
549 @param profile_key: can be the profile name or a keywork (like @DEFAULT@)
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 61
diff changeset
550 @return: profile name or None if it doesn't exist"""
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 61
diff changeset
551 return self.params.getProfileName(profile_key)
93cb45a7420f SàT multi-profile: connection using profiles
Goffi <goffi@goffi.org>
parents: 61
diff changeset
552
68
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 66
diff changeset
553 def createProfile(self, name):
60
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
554 """Create a new profile
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
555 @param name: Profile name
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
556 """
68
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 66
diff changeset
557 return self.params.createProfile(name)
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 66
diff changeset
558
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 66
diff changeset
559 def deleteProfile(self, name):
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 66
diff changeset
560 """Delete an existing profile
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 66
diff changeset
561 @param name: Name of the profile"""
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 66
diff changeset
562 return self.params.deleteProfile(name)
60
9764e027ecc0 SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents: 57
diff changeset
563
0
goffi@necton2
parents:
diff changeset
564 def addToHistory(self, me_jid, from_jid, to_jid, type, message):
goffi@necton2
parents:
diff changeset
565 me_short=me_jid.userhost()
goffi@necton2
parents:
diff changeset
566 from_short=from_jid.userhost()
goffi@necton2
parents:
diff changeset
567 to_short=to_jid.userhost()
goffi@necton2
parents:
diff changeset
568
goffi@necton2
parents:
diff changeset
569 if from_jid==me_jid:
goffi@necton2
parents:
diff changeset
570 key=to_short
goffi@necton2
parents:
diff changeset
571 else:
goffi@necton2
parents:
diff changeset
572 key=from_short
goffi@necton2
parents:
diff changeset
573
goffi@necton2
parents:
diff changeset
574 if not self.history.has_key(me_short):
goffi@necton2
parents:
diff changeset
575 self.history[me_short]={}
goffi@necton2
parents:
diff changeset
576 if not self.history[me_short].has_key(key):
goffi@necton2
parents:
diff changeset
577 self.history[me_short][key]={}
goffi@necton2
parents:
diff changeset
578
79
db0a0f000e37 Chat presentation enhancement
Goffi <goffi@goffi.org>
parents: 69
diff changeset
579 self.history[me_short][key][int(time.time())] = (from_jid.full(), message)
0
goffi@necton2
parents:
diff changeset
580
goffi@necton2
parents:
diff changeset
581 def getHistory(self, from_jid, to_jid, size):
goffi@necton2
parents:
diff changeset
582 ret={}
goffi@necton2
parents:
diff changeset
583 if not self.history.has_key(from_jid):
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
584 error(_("source JID not found !"))
0
goffi@necton2
parents:
diff changeset
585 #TODO: throw an error here
goffi@necton2
parents:
diff changeset
586 return {}
goffi@necton2
parents:
diff changeset
587 if not self.history[from_jid].has_key(to_jid):
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
588 error(_("dest JID not found !"))
0
goffi@necton2
parents:
diff changeset
589 #TODO: throw an error here
goffi@necton2
parents:
diff changeset
590 return {}
goffi@necton2
parents:
diff changeset
591 stamps=self.history[from_jid][to_jid].keys()
goffi@necton2
parents:
diff changeset
592 stamps.sort()
goffi@necton2
parents:
diff changeset
593 for stamp in stamps[-size:]:
goffi@necton2
parents:
diff changeset
594 ret[stamp]=self.history[from_jid][to_jid][stamp]
goffi@necton2
parents:
diff changeset
595
goffi@necton2
parents:
diff changeset
596 return ret
goffi@necton2
parents:
diff changeset
597
47
9aa2d9dd4045 memory methods improvement
Goffi <goffi@goffi.org>
parents: 41
diff changeset
598 def setPrivate(self, key, value):
9aa2d9dd4045 memory methods improvement
Goffi <goffi@goffi.org>
parents: 41
diff changeset
599 """Save a misc private value (mainly useful for plugins)"""
9aa2d9dd4045 memory methods improvement
Goffi <goffi@goffi.org>
parents: 41
diff changeset
600 self.private[key] = value
9aa2d9dd4045 memory methods improvement
Goffi <goffi@goffi.org>
parents: 41
diff changeset
601
9aa2d9dd4045 memory methods improvement
Goffi <goffi@goffi.org>
parents: 41
diff changeset
602 def getPrivate(self, key):
9aa2d9dd4045 memory methods improvement
Goffi <goffi@goffi.org>
parents: 41
diff changeset
603 """return a private value
9aa2d9dd4045 memory methods improvement
Goffi <goffi@goffi.org>
parents: 41
diff changeset
604 @param key: name of wanted value
9aa2d9dd4045 memory methods improvement
Goffi <goffi@goffi.org>
parents: 41
diff changeset
605 @return: value or None if value don't exist"""
9aa2d9dd4045 memory methods improvement
Goffi <goffi@goffi.org>
parents: 41
diff changeset
606 if self.private.has_key(key):
9aa2d9dd4045 memory methods improvement
Goffi <goffi@goffi.org>
parents: 41
diff changeset
607 return self.private[key]
9aa2d9dd4045 memory methods improvement
Goffi <goffi@goffi.org>
parents: 41
diff changeset
608 return None
9aa2d9dd4045 memory methods improvement
Goffi <goffi@goffi.org>
parents: 41
diff changeset
609
282
6a0c6d8e119d added plugin xep-0115: entity capabilities
Goffi <goffi@goffi.org>
parents: 276
diff changeset
610 def addServerFeature(self, feature, profile):
6a0c6d8e119d added plugin xep-0115: entity capabilities
Goffi <goffi@goffi.org>
parents: 276
diff changeset
611 """Add a feature discovered from server
6a0c6d8e119d added plugin xep-0115: entity capabilities
Goffi <goffi@goffi.org>
parents: 276
diff changeset
612 @param feature: string of the feature
6a0c6d8e119d added plugin xep-0115: entity capabilities
Goffi <goffi@goffi.org>
parents: 276
diff changeset
613 @param profile: which profile is using this server ?"""
6a0c6d8e119d added plugin xep-0115: entity capabilities
Goffi <goffi@goffi.org>
parents: 276
diff changeset
614 if not self.server_features.has_key(profile):
6a0c6d8e119d added plugin xep-0115: entity capabilities
Goffi <goffi@goffi.org>
parents: 276
diff changeset
615 self.server_features[profile] = []
6a0c6d8e119d added plugin xep-0115: entity capabilities
Goffi <goffi@goffi.org>
parents: 276
diff changeset
616 self.server_features[profile].append(feature)
305
15a12bf2bb62 core: server identities are now save in memory
Goffi <goffi@goffi.org>
parents: 282
diff changeset
617
15a12bf2bb62 core: server identities are now save in memory
Goffi <goffi@goffi.org>
parents: 282
diff changeset
618 def addServerIdentity(self, category, type, entity, profile):
15a12bf2bb62 core: server identities are now save in memory
Goffi <goffi@goffi.org>
parents: 282
diff changeset
619 """Add an identity discovered from server
15a12bf2bb62 core: server identities are now save in memory
Goffi <goffi@goffi.org>
parents: 282
diff changeset
620 @param feature: string of the feature
15a12bf2bb62 core: server identities are now save in memory
Goffi <goffi@goffi.org>
parents: 282
diff changeset
621 @param profile: which profile is using this server ?"""
15a12bf2bb62 core: server identities are now save in memory
Goffi <goffi@goffi.org>
parents: 282
diff changeset
622 if not self.server_identities.has_key(profile):
15a12bf2bb62 core: server identities are now save in memory
Goffi <goffi@goffi.org>
parents: 282
diff changeset
623 self.server_identities[profile] = {}
318
b544bec477dd core: multiple identities with same category/type are now managed with getServerServiceEntities
Goffi <goffi@goffi.org>
parents: 305
diff changeset
624 if not self.server_identities[profile].has_key((category, type)):
b544bec477dd core: multiple identities with same category/type are now managed with getServerServiceEntities
Goffi <goffi@goffi.org>
parents: 305
diff changeset
625 self.server_identities[profile][(category, type)]=set()
b544bec477dd core: multiple identities with same category/type are now managed with getServerServiceEntities
Goffi <goffi@goffi.org>
parents: 305
diff changeset
626 self.server_identities[profile][(category, type)].add(entity)
b544bec477dd core: multiple identities with same category/type are now managed with getServerServiceEntities
Goffi <goffi@goffi.org>
parents: 305
diff changeset
627
b544bec477dd core: multiple identities with same category/type are now managed with getServerServiceEntities
Goffi <goffi@goffi.org>
parents: 305
diff changeset
628 def getServerServiceEntities(self, category, type, profile):
b544bec477dd core: multiple identities with same category/type are now managed with getServerServiceEntities
Goffi <goffi@goffi.org>
parents: 305
diff changeset
629 """Return all available entities for a service"""
b544bec477dd core: multiple identities with same category/type are now managed with getServerServiceEntities
Goffi <goffi@goffi.org>
parents: 305
diff changeset
630 if self.server_identities.has_key(profile):
b544bec477dd core: multiple identities with same category/type are now managed with getServerServiceEntities
Goffi <goffi@goffi.org>
parents: 305
diff changeset
631 return self.server_identities[profile].get((category, type), set())
b544bec477dd core: multiple identities with same category/type are now managed with getServerServiceEntities
Goffi <goffi@goffi.org>
parents: 305
diff changeset
632 else:
b544bec477dd core: multiple identities with same category/type are now managed with getServerServiceEntities
Goffi <goffi@goffi.org>
parents: 305
diff changeset
633 return None
305
15a12bf2bb62 core: server identities are now save in memory
Goffi <goffi@goffi.org>
parents: 282
diff changeset
634
15a12bf2bb62 core: server identities are now save in memory
Goffi <goffi@goffi.org>
parents: 282
diff changeset
635 def getServerServiceEntity(self, category, type, profile):
318
b544bec477dd core: multiple identities with same category/type are now managed with getServerServiceEntities
Goffi <goffi@goffi.org>
parents: 305
diff changeset
636 """Helper method to get first available entity for a service"""
b544bec477dd core: multiple identities with same category/type are now managed with getServerServiceEntities
Goffi <goffi@goffi.org>
parents: 305
diff changeset
637 entities = self.getServerServiceEntities(category, type, profile)
b544bec477dd core: multiple identities with same category/type are now managed with getServerServiceEntities
Goffi <goffi@goffi.org>
parents: 305
diff changeset
638 if entities == None:
b544bec477dd core: multiple identities with same category/type are now managed with getServerServiceEntities
Goffi <goffi@goffi.org>
parents: 305
diff changeset
639 warning(_("Entities not available, maybe they haven't been asked to server yet ?"))
b544bec477dd core: multiple identities with same category/type are now managed with getServerServiceEntities
Goffi <goffi@goffi.org>
parents: 305
diff changeset
640 return None
b544bec477dd core: multiple identities with same category/type are now managed with getServerServiceEntities
Goffi <goffi@goffi.org>
parents: 305
diff changeset
641 else:
b544bec477dd core: multiple identities with same category/type are now managed with getServerServiceEntities
Goffi <goffi@goffi.org>
parents: 305
diff changeset
642 return list(entities)[0] if entities else None
282
6a0c6d8e119d added plugin xep-0115: entity capabilities
Goffi <goffi@goffi.org>
parents: 276
diff changeset
643
346
ca3a041fed30 core: fixed several subscription scheme issues + removed most of profile_key default value in core.sat_main and core.xmmp (source of bugs) + contact update
Goffi <goffi@goffi.org>
parents: 327
diff changeset
644 def hasServerFeature(self, feature, profile_key):
282
6a0c6d8e119d added plugin xep-0115: entity capabilities
Goffi <goffi@goffi.org>
parents: 276
diff changeset
645 """Tell if the server of the profile has the required feature"""
6a0c6d8e119d added plugin xep-0115: entity capabilities
Goffi <goffi@goffi.org>
parents: 276
diff changeset
646 profile = self.getProfileName(profile_key)
6a0c6d8e119d added plugin xep-0115: entity capabilities
Goffi <goffi@goffi.org>
parents: 276
diff changeset
647 if not profile:
6a0c6d8e119d added plugin xep-0115: entity capabilities
Goffi <goffi@goffi.org>
parents: 276
diff changeset
648 error (_('Trying find server feature for a non-existant profile'))
6a0c6d8e119d added plugin xep-0115: entity capabilities
Goffi <goffi@goffi.org>
parents: 276
diff changeset
649 return
6a0c6d8e119d added plugin xep-0115: entity capabilities
Goffi <goffi@goffi.org>
parents: 276
diff changeset
650 assert(self.server_features.has_key(profile))
6a0c6d8e119d added plugin xep-0115: entity capabilities
Goffi <goffi@goffi.org>
parents: 276
diff changeset
651 return feature in self.server_features[profile]
6a0c6d8e119d added plugin xep-0115: entity capabilities
Goffi <goffi@goffi.org>
parents: 276
diff changeset
652
47
9aa2d9dd4045 memory methods improvement
Goffi <goffi@goffi.org>
parents: 41
diff changeset
653
346
ca3a041fed30 core: fixed several subscription scheme issues + removed most of profile_key default value in core.sat_main and core.xmmp (source of bugs) + contact update
Goffi <goffi@goffi.org>
parents: 327
diff changeset
654 def addContact(self, contact_jid, attributes, groups, profile_key):
47
9aa2d9dd4045 memory methods improvement
Goffi <goffi@goffi.org>
parents: 41
diff changeset
655 debug("Memory addContact: %s",contact_jid.userhost())
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
656 profile = self.getProfileName(profile_key)
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
657 if not profile:
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
658 error (_('Trying to add a contact to a non-existant profile'))
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
659 return
0
goffi@necton2
parents:
diff changeset
660 assert(isinstance(attributes,dict))
13
bd9e9997d540 wokkel integration (not finished yet)
Goffi <goffi@goffi.org>
parents: 0
diff changeset
661 assert(isinstance(groups,set))
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
662 if not self.contacts.has_key(profile):
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
663 self.contacts[profile] = {}
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
664 self.contacts[profile][contact_jid.userhost()]=[attributes, groups]
0
goffi@necton2
parents:
diff changeset
665
346
ca3a041fed30 core: fixed several subscription scheme issues + removed most of profile_key default value in core.sat_main and core.xmmp (source of bugs) + contact update
Goffi <goffi@goffi.org>
parents: 327
diff changeset
666 def delContact(self, contact_jid, profile_key):
47
9aa2d9dd4045 memory methods improvement
Goffi <goffi@goffi.org>
parents: 41
diff changeset
667 debug("Memory delContact: %s",contact_jid.userhost())
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
668 profile = self.getProfileName(profile_key)
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
669 if not profile:
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
670 error (_('Trying to delete a contact for a non-existant profile'))
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
671 return
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
672 if self.contacts.has_key(profile) and self.contacts[profile].has_key(contact_jid.userhost()):
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
673 del self.contacts[profile][contact_jid.userhost()]
47
9aa2d9dd4045 memory methods improvement
Goffi <goffi@goffi.org>
parents: 41
diff changeset
674
346
ca3a041fed30 core: fixed several subscription scheme issues + removed most of profile_key default value in core.sat_main and core.xmmp (source of bugs) + contact update
Goffi <goffi@goffi.org>
parents: 327
diff changeset
675 def getContact(self, contact_jid, profile_key):
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
676 profile = self.getProfileName(profile_key)
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
677 if not profile:
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
678 error(_('Asking a contact for a non-existant profile'))
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
679 return None
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
680 if self.contacts.has_key(profile) and self.contacts[profile].has_key(contact_jid.userhost()):
346
ca3a041fed30 core: fixed several subscription scheme issues + removed most of profile_key default value in core.sat_main and core.xmmp (source of bugs) + contact update
Goffi <goffi@goffi.org>
parents: 327
diff changeset
681 return self.contacts[profile][contact_jid.userhost()]
47
9aa2d9dd4045 memory methods improvement
Goffi <goffi@goffi.org>
parents: 41
diff changeset
682
346
ca3a041fed30 core: fixed several subscription scheme issues + removed most of profile_key default value in core.sat_main and core.xmmp (source of bugs) + contact update
Goffi <goffi@goffi.org>
parents: 327
diff changeset
683 def getContacts(self, profile_key):
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
684 """Return list of contacts for given profile
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
685 @param profile_key: profile key
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
686 @return list of [contact, attr, groups]"""
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
687 profile = self.getProfileName(profile_key)
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
688 if not profile:
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
689 error(_('Asking contacts for a non-existant profile'))
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
690 return []
0
goffi@necton2
parents:
diff changeset
691 ret=[]
327
7c9784658163 core: fixed crash when roster list is empty
Goffi <goffi@goffi.org>
parents: 326
diff changeset
692 if self.contacts.has_key(profile):
7c9784658163 core: fixed crash when roster list is empty
Goffi <goffi@goffi.org>
parents: 326
diff changeset
693 for contact in self.contacts[profile]:
7c9784658163 core: fixed crash when roster list is empty
Goffi <goffi@goffi.org>
parents: 326
diff changeset
694 attr, groups = self.contacts[profile][contact]
7c9784658163 core: fixed crash when roster list is empty
Goffi <goffi@goffi.org>
parents: 326
diff changeset
695 ret.append([contact, attr, groups ])
0
goffi@necton2
parents:
diff changeset
696 return ret
399
3ed53803b3b3 core: added getLastResource method
Goffi <goffi@goffi.org>
parents: 398
diff changeset
697
3ed53803b3b3 core: added getLastResource method
Goffi <goffi@goffi.org>
parents: 398
diff changeset
698 def getLastResource(self, contact, profile_key):
3ed53803b3b3 core: added getLastResource method
Goffi <goffi@goffi.org>
parents: 398
diff changeset
699 """Return the last resource used by a contact
3ed53803b3b3 core: added getLastResource method
Goffi <goffi@goffi.org>
parents: 398
diff changeset
700 @param contact: contact jid (unicode)
3ed53803b3b3 core: added getLastResource method
Goffi <goffi@goffi.org>
parents: 398
diff changeset
701 @param profile_key: %(doc_profile_key)s"""
3ed53803b3b3 core: added getLastResource method
Goffi <goffi@goffi.org>
parents: 398
diff changeset
702 profile = self.getProfileName(profile_key)
3ed53803b3b3 core: added getLastResource method
Goffi <goffi@goffi.org>
parents: 398
diff changeset
703 if not profile:
3ed53803b3b3 core: added getLastResource method
Goffi <goffi@goffi.org>
parents: 398
diff changeset
704 error(_('Asking contacts for a non-existant profile'))
3ed53803b3b3 core: added getLastResource method
Goffi <goffi@goffi.org>
parents: 398
diff changeset
705 return ""
3ed53803b3b3 core: added getLastResource method
Goffi <goffi@goffi.org>
parents: 398
diff changeset
706 try:
3ed53803b3b3 core: added getLastResource method
Goffi <goffi@goffi.org>
parents: 398
diff changeset
707 return self.lastResource[profile][jid.JID(contact).userhost()]
3ed53803b3b3 core: added getLastResource method
Goffi <goffi@goffi.org>
parents: 398
diff changeset
708 except:
3ed53803b3b3 core: added getLastResource method
Goffi <goffi@goffi.org>
parents: 398
diff changeset
709 return ""
47
9aa2d9dd4045 memory methods improvement
Goffi <goffi@goffi.org>
parents: 41
diff changeset
710
346
ca3a041fed30 core: fixed several subscription scheme issues + removed most of profile_key default value in core.sat_main and core.xmmp (source of bugs) + contact update
Goffi <goffi@goffi.org>
parents: 327
diff changeset
711 def addPresenceStatus(self, contact_jid, show, priority, statuses, profile_key):
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
712 profile = self.getProfileName(profile_key)
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
713 if not profile:
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
714 error(_('Trying to add presence status to a non-existant profile'))
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
715 return
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
716 if not self.presenceStatus.has_key(profile):
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
717 self.presenceStatus[profile] = {}
399
3ed53803b3b3 core: added getLastResource method
Goffi <goffi@goffi.org>
parents: 398
diff changeset
718 if not self.lastResource.has_key(profile):
3ed53803b3b3 core: added getLastResource method
Goffi <goffi@goffi.org>
parents: 398
diff changeset
719 self.lastResource[profile] = {}
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
720 if not self.presenceStatus[profile].has_key(contact_jid.userhost()):
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
721 self.presenceStatus[profile][contact_jid.userhost()] = {}
47
9aa2d9dd4045 memory methods improvement
Goffi <goffi@goffi.org>
parents: 41
diff changeset
722 resource = jid.parse(contact_jid.full())[2] or ''
399
3ed53803b3b3 core: added getLastResource method
Goffi <goffi@goffi.org>
parents: 398
diff changeset
723 if resource:
3ed53803b3b3 core: added getLastResource method
Goffi <goffi@goffi.org>
parents: 398
diff changeset
724 self.lastResource[profile][contact_jid.userhost()] = resource
3ed53803b3b3 core: added getLastResource method
Goffi <goffi@goffi.org>
parents: 398
diff changeset
725
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
726 self.presenceStatus[profile][contact_jid.userhost()][resource] = (show, priority, statuses)
47
9aa2d9dd4045 memory methods improvement
Goffi <goffi@goffi.org>
parents: 41
diff changeset
727
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
728 def addWaitingSub(self, type, contact_jid, profile_key):
47
9aa2d9dd4045 memory methods improvement
Goffi <goffi@goffi.org>
parents: 41
diff changeset
729 """Called when a subcription request is received"""
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
730 profile = self.getProfileName(profile_key)
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
731 assert(profile)
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
732 if not self.subscriptions.has_key(profile):
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
733 self.subscriptions[profile] = {}
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
734 self.subscriptions[profile][contact_jid] = type
47
9aa2d9dd4045 memory methods improvement
Goffi <goffi@goffi.org>
parents: 41
diff changeset
735
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
736 def delWaitingSub(self, contact_jid, profile_key):
47
9aa2d9dd4045 memory methods improvement
Goffi <goffi@goffi.org>
parents: 41
diff changeset
737 """Called when a subcription request is finished"""
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
738 profile = self.getProfileName(profile_key)
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
739 assert(profile)
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
740 if self.subscriptions.has_key(profile) and self.subscriptions[profile].has_key(contact_jid):
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
741 del self.subscriptions[profile][contact_jid]
47
9aa2d9dd4045 memory methods improvement
Goffi <goffi@goffi.org>
parents: 41
diff changeset
742
346
ca3a041fed30 core: fixed several subscription scheme issues + removed most of profile_key default value in core.sat_main and core.xmmp (source of bugs) + contact update
Goffi <goffi@goffi.org>
parents: 327
diff changeset
743 def getWaitingSub(self, profile_key):
47
9aa2d9dd4045 memory methods improvement
Goffi <goffi@goffi.org>
parents: 41
diff changeset
744 """Called to get a list of currently waiting subscription requests"""
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
745 profile = self.getProfileName(profile_key)
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
746 if not profile:
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
747 error(_('Asking waiting subscriptions for a non-existant profile'))
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
748 return {}
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
749 if not self.subscriptions.has_key(profile):
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
750 return {}
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
751
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
752 return self.subscriptions[profile]
0
goffi@necton2
parents:
diff changeset
753
346
ca3a041fed30 core: fixed several subscription scheme issues + removed most of profile_key default value in core.sat_main and core.xmmp (source of bugs) + contact update
Goffi <goffi@goffi.org>
parents: 327
diff changeset
754 def getPresenceStatus(self, profile_key):
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
755 profile = self.getProfileName(profile_key)
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
756 if not profile:
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 68
diff changeset
757 error(_('Asking contacts for a non-existant profile'))
65
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
758 return {}
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
759 if not self.presenceStatus.has_key(profile):
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
760 self.presenceStatus[profile] = {}
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
761 debug ("Memory getPresenceStatus (%s)", self.presenceStatus[profile])
d35c5edab53f SàT: multi-profile: memory & dbus bridge's methods profile management
Goffi <goffi@goffi.org>
parents: 64
diff changeset
762 return self.presenceStatus[profile]
0
goffi@necton2
parents:
diff changeset
763
346
ca3a041fed30 core: fixed several subscription scheme issues + removed most of profile_key default value in core.sat_main and core.xmmp (source of bugs) + contact update
Goffi <goffi@goffi.org>
parents: 327
diff changeset
764 def getParamA(self, name, category, attr="value", profile_key='@DEFAULT@'):
64
d46f849664aa SàT: multi-profile, plugins updated
Goffi <goffi@goffi.org>
parents: 63
diff changeset
765 return self.params.getParamA(name, category, attr, profile_key)
17
74a39f40eb6d refactoring: using xml params (not finished yet)
Goffi <goffi@goffi.org>
parents: 14
diff changeset
766
346
ca3a041fed30 core: fixed several subscription scheme issues + removed most of profile_key default value in core.sat_main and core.xmmp (source of bugs) + contact update
Goffi <goffi@goffi.org>
parents: 327
diff changeset
767 def getParamsUI(self, profile_key):
105
d2630fba8dfd params to XMLUI tools
Goffi <goffi@goffi.org>
parents: 79
diff changeset
768 return self.params.getParamsUI(profile_key)
d2630fba8dfd params to XMLUI tools
Goffi <goffi@goffi.org>
parents: 79
diff changeset
769
346
ca3a041fed30 core: fixed several subscription scheme issues + removed most of profile_key default value in core.sat_main and core.xmmp (source of bugs) + contact update
Goffi <goffi@goffi.org>
parents: 327
diff changeset
770 def getParams(self, profile_key):
105
d2630fba8dfd params to XMLUI tools
Goffi <goffi@goffi.org>
parents: 79
diff changeset
771 return self.params.getParams(profile_key)
17
74a39f40eb6d refactoring: using xml params (not finished yet)
Goffi <goffi@goffi.org>
parents: 14
diff changeset
772
346
ca3a041fed30 core: fixed several subscription scheme issues + removed most of profile_key default value in core.sat_main and core.xmmp (source of bugs) + contact update
Goffi <goffi@goffi.org>
parents: 327
diff changeset
773 def getParamsForCategory(self, category, profile_key):
66
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 65
diff changeset
774 return self.params.getParamsForCategory(category, profile_key)
18
6928e3cb73a8 refactoring: using xml params part II
Goffi <goffi@goffi.org>
parents: 17
diff changeset
775
0
goffi@necton2
parents:
diff changeset
776 def getParamsCategories(self):
17
74a39f40eb6d refactoring: using xml params (not finished yet)
Goffi <goffi@goffi.org>
parents: 14
diff changeset
777 return self.params.getParamsCategories()
74a39f40eb6d refactoring: using xml params (not finished yet)
Goffi <goffi@goffi.org>
parents: 14
diff changeset
778
346
ca3a041fed30 core: fixed several subscription scheme issues + removed most of profile_key default value in core.sat_main and core.xmmp (source of bugs) + contact update
Goffi <goffi@goffi.org>
parents: 327
diff changeset
779 def setParam(self, name, value, category, profile_key):
63
0db25931b60d SàT: multi-profiles: somes fixes in core
Goffi <goffi@goffi.org>
parents: 62
diff changeset
780 return self.params.setParam(name, value, category, profile_key)
19
f2a745ca0fbc refactoring: using xml params part III (parameters import)
Goffi <goffi@goffi.org>
parents: 18
diff changeset
781
38
3e24753b9e0b Fixed parameters loading/saving
Goffi <goffi@goffi.org>
parents: 34
diff changeset
782 def importParams(self, xml):
3e24753b9e0b Fixed parameters loading/saving
Goffi <goffi@goffi.org>
parents: 34
diff changeset
783 return self.params.importParams(xml)
20
fc8c202cda87 refactoring: using xml params part IV (default values)
Goffi <goffi@goffi.org>
parents: 19
diff changeset
784
fc8c202cda87 refactoring: using xml params part IV (default values)
Goffi <goffi@goffi.org>
parents: 19
diff changeset
785 def setDefault(self, name, category, callback, errback=None):
fc8c202cda87 refactoring: using xml params part IV (default values)
Goffi <goffi@goffi.org>
parents: 19
diff changeset
786 return self.params.setDefault(name, category, callback, errback)