* added one table in logs.db to save roster

* added "roster_version" in configuration to save roster version for the account
* added "ver" attribute when gajim requests the roster
This commit is contained in:
Anaël Verrier 2009-06-02 22:48:32 +02:00
parent a3153f2403
commit 9133960fbc
6 changed files with 43 additions and 5 deletions

View File

@ -96,6 +96,12 @@ def create_log_db():
jid_id INTEGER PRIMARY KEY UNIQUE, jid_id INTEGER PRIMARY KEY UNIQUE,
time INTEGER time INTEGER
); );
CREATE TABLE IF NOT EXISTS roster_entry(
account_jid_id INTEGER PRIMARY KEY,
jid_id INTEGER,
subscription INTEGER
);
''' '''
) )

View File

@ -342,6 +342,7 @@ class Config:
'ignore_unknown_contacts': [ opt_bool, False ], 'ignore_unknown_contacts': [ opt_bool, False ],
'send_os_info': [ opt_bool, True ], 'send_os_info': [ opt_bool, True ],
'log_encrypted_sessions': [opt_bool, True, _('When negotiating an encrypted session, should Gajim assume you want your messages to be logged?')], 'log_encrypted_sessions': [opt_bool, True, _('When negotiating an encrypted session, should Gajim assume you want your messages to be logged?')],
'roster_version': [opt_str, ''],
}, {}), }, {}),
'statusmsg': ({ 'statusmsg': ({
'message': [ opt_str, '' ], 'message': [ opt_str, '' ],

View File

@ -1164,7 +1164,9 @@ class ConnectionVcard:
if iq_obj.getErrorCode() not in ('403', '406', '404'): if iq_obj.getErrorCode() not in ('403', '406', '404'):
self.private_storage_supported = False self.private_storage_supported = False
# We can now continue connection by requesting the roster # We can now continue connection by requesting the roster
self.connection.initRoster() version = gajim.config.get_per('accounts', self.name,
'roster_version')
self.connection.initRoster(version=version)
elif self.awaiting_answers[id_][0] == PRIVACY_ARRIVED: elif self.awaiting_answers[id_][0] == PRIVACY_ARRIVED:
if iq_obj.getType() != 'error': if iq_obj.getType() != 'error':
self.privacy_rules_supported = True self.privacy_rules_supported = True

View File

@ -671,4 +671,29 @@ class OptionsParser:
gajim.config.set_per('soundevents', evt, 'path', path) gajim.config.set_per('soundevents', evt, 'path', path)
gajim.config.set('version', '0.12.1.5') gajim.config.set('version', '0.12.1.5')
def update_config_to_01216(self):
back = os.getcwd()
os.chdir(logger.LOG_DB_FOLDER)
con = sqlite.connect(logger.LOG_DB_FILE)
os.chdir(back)
cur = con.cursor()
try:
cur.executescript(
'''
CREATE TABLE IF NOT EXISTS roster_entry(
account_jid_id INTEGER PRIMARY KEY,
jid_id INTEGER,
subscription INTEGER
);
'''
)
con.commit()
except sqlite.OperationalError:
pass
con.close()
gajim.config.set('version', '0.12.1.6')
# vim: se ts=3: # vim: se ts=3:

View File

@ -503,10 +503,10 @@ class NonBlockingClient:
self.NonBlockingBind.NonBlockingBind(self._Resource, self._on_sasl_auth) self.NonBlockingBind.NonBlockingBind(self._Resource, self._on_sasl_auth)
return True return True
def initRoster(self): def initRoster(self, version=''):
''' Plug in the roster. ''' ''' Plug in the roster. '''
if not self.__dict__.has_key('NonBlockingRoster'): if not self.__dict__.has_key('NonBlockingRoster'):
roster_nb.NonBlockingRoster.get_instance().PlugIn(self) roster_nb.NonBlockingRoster.get_instance(version=version).PlugIn(self)
def getRoster(self, on_ready=None): def getRoster(self, on_ready=None):
''' Return the Roster instance, previously plugging it in and ''' Return the Roster instance, previously plugging it in and

View File

@ -36,9 +36,10 @@ class NonBlockingRoster(PlugIn):
You can also use mapping interface for access to the internal representation of You can also use mapping interface for access to the internal representation of
contacts in roster. contacts in roster.
''' '''
def __init__(self): def __init__(self, version=''):
''' Init internal variables. ''' ''' Init internal variables. '''
PlugIn.__init__(self) PlugIn.__init__(self)
self.version = version
self._data = {} self._data = {}
self.set=None self.set=None
self._exported_methods=[self.getRoster] self._exported_methods=[self.getRoster]
@ -48,7 +49,10 @@ class NonBlockingRoster(PlugIn):
(or if the 'force' argument is set). ''' (or if the 'force' argument is set). '''
if self.set is None: self.set=0 if self.set is None: self.set=0
elif not force: return elif not force: return
self._owner.send(Iq('get',NS_ROSTER))
iq = Iq('get',NS_ROSTER)
iq.setTagAttr('query', 'ver', self.version)
self._owner.send(iq)
log.info('Roster requested from server') log.info('Roster requested from server')
def RosterIqHandler(self,dis,stanza): def RosterIqHandler(self,dis,stanza):