Package modules :: Module contacts_paroli
[hide private]
[frames] | no frames]

Source Code for Module modules.contacts_paroli

 1  """ 
 2  Synchronize with simple dump file (used by Paroli) 
 3   
 4  This file is part of Pisi. 
 5   
 6  Logic is taken from U{http://www.mail-archive.com/support@lists.openmoko.org/msg04770.html}. 
 7   
 8  Pisi is free software: you can redistribute it and/or modify 
 9  it under the terms of the GNU General Public License as published by 
10  the Free Software Foundation, either version 3 of the License, or 
11  (at your option) any later version. 
12   
13  Pisi is distributed in the hope that it will be useful, 
14  but WITHOUT ANY WARRANTY; without even the implied warranty of 
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
16  GNU General Public License for more details. 
17   
18  You should have received a copy of the GNU General Public License 
19  along with Pisi.  If not, see <http://www.gnu.org/licenses/>. 
20  """ 
21  from contacts import contacts 
22  from pisiconstants import * 
23  import pisiprogress 
24   
25  from tichy.service import Service 
26   
27 -class SynchronizationModule(contacts.AbstractContactSynchronizationModule):
28 - def __init__( self, modulesString, config, configsection, folder, verbose=False, soft=False):
29 """ 30 Constructor 31 32 Super class constructor (L{contacts.AbstractContactSynchronizationModule.__init__}) is called. 33 Local variables are initialized. 34 The settings from the configuration file are loaded. 35 36 @param modulesString: is a small string to help you make a unique id. It is the two modules configuration-names concatinated. 37 @param config: is the configuration from ~/.pisi/conf. Use like config.get(configsection,'user') 38 @param configsection: is the configuration from ~/.pisi/conf. Use like config.get(configsection,'user') 39 @param folder: is a string with the location for where your module can save its own files if necessary 40 @param verbose: should make your module "talk" more 41 @param soft: should tell you if you should make changes (ie. save) 42 """ 43 contacts.AbstractContactSynchronizationModule.__init__(self, verbose, soft, modulesString, config, configsection, "Contacts Paroli") 44 self.verbose = verbose 45 pisiprogress.getCallback().verbose("Paroli module loaded") 46 self._path = config.get(configsection,'path')
47
48 - def load(self):
49 """ 50 Load all data from backend 51 """ 52 pass
53
54 - def _saveOperationAdd(self, id):
55 """ 56 Writing through: Adds a single value to the Paroli backend 57 """ 58 c = self.getContact(id) 59 fullName = pisitools.assembleFullName(c) 60 number = c.attributes['mobile'] 61 pass
62
63 - def _saveOperationDelete(self, sim, id):
64 """ 65 Writing through: Removes a single value from the Paroli backend 66 """ 67 pass
68
69 - def saveModifications( self ):
70 """ 71 Save whatever changes have come by 72 """ 73 pisiprogress.getCallback().verbose("Paroli module: I apply %d changes now" %(len(self._history))) 74 75 i = 0 76 for listItem in self._history: 77 action = listItem[0] 78 id = listItem[1] 79 if action == ACTIONID_ADD: 80 pisiprogress.getCallback().verbose("\t\t<Paroli> adding %s" %(id)) 81 self._saveOperationAdd(sim, id) 82 elif action == ACTIONID_DELETE: 83 pisiprogress.getCallback().verbose("\t\t<Paroli> deleting %s" %(id)) 84 self._saveOperationDelete(sim, id) 85 elif action == ACTIONID_MODIFY: 86 pisiprogress.getCallback().verbose("\t\t<Paroli> replacing %s" %(id)) 87 self._saveOperationDelete(sim, id) 88 self._saveOperationAdd(sim, id) 89 i += 1 90 pisiprogress.getCallback().progress.setProgress(i * 100 / len(self._history)) 91 pisiprogress.getCallback().update('Storing') 92 93 pisiprogress.getCallback().progress.setProgress(100) 94 pisiprogress.getCallback().update('Storing')
95