Changeset 7829 for branches/gajim_0.11/src/common
- Timestamp:
- 01/13/07 23:35:41 (23 months ago)
- Location:
- branches/gajim_0.11/src/common
- Files:
-
- 12 modified
-
commands.py (modified) (1 diff)
-
config.py (modified) (1 diff)
-
connection_handlers.py (modified) (2 diffs)
-
connection.py (modified) (5 diffs)
-
dataforms.py (modified) (1 diff)
-
defs.py (modified) (1 diff)
-
GnuPG.py (modified) (2 diffs)
-
logger.py (modified) (3 diffs)
-
optparser.py (modified) (3 diffs)
-
passwords.py (modified) (1 diff)
-
sleepy.py (modified) (7 diffs)
-
xmpp/features_nb.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/gajim_0.11/src/common/commands.py
r7669 r7829 129 129 cmd.addChild('note', {}, 'The status has been changed.') 130 130 131 self.connection.connection.send(response) 131 # if going offline, we need to push response so it won't go into 132 # queue and disappear 133 self.connection.connection.send(response, presencetype=='offline') 132 134 133 135 # send new status -
branches/gajim_0.11/src/common/config.py
r7787 r7829 131 131 'latest_disco_addresses': [ opt_str, '' ], 132 132 'recently_groupchat': [ opt_str, '' ], 133 'before_time': [ opt_str, '[' ],134 'after_time': [ opt_str, ']' ],135 133 'before_nickname': [ opt_str, '' ], 134 'time_stamp': [ opt_str, '[%H:%M] ' ], 136 135 'after_nickname': [ opt_str, ':' ], 137 136 'send_os_info': [ opt_bool, True ], -
branches/gajim_0.11/src/common/connection_handlers.py
r7787 r7829 25 25 import sys 26 26 27 from time import localtime, strftime, gmtime , timezone27 from time import localtime, strftime, gmtime 28 28 from calendar import timegm 29 29 … … 887 887 c = f.read() 888 888 f.close() 889 card = common.xmpp.Node(node = c) 889 try: 890 card = common.xmpp.Node(node = c) 891 except: 892 # We are unable to parse it. Remove it 893 os.remove(path_to_file) 894 return None 890 895 vcard = self.node_to_dict(card) 891 896 if vcard.has_key('PHOTO'): -
branches/gajim_0.11/src/common/connection.py
r7634 r7829 80 80 self.continue_connect_info = None 81 81 if USE_GPG: 82 self.gpg = GnuPG.GnuPG( )82 self.gpg = GnuPG.GnuPG(gajim.config.get('use_gpg_agent')) 83 83 gajim.config.set('usegpg', True) 84 84 else: … … 197 197 self.password = self.new_account_info['password'] 198 198 if USE_GPG: 199 self.gpg = GnuPG.GnuPG( )199 self.gpg = GnuPG.GnuPG(gajim.config.get('use_gpg_agent')) 200 200 gajim.config.set('usegpg', True) 201 201 else: … … 489 489 if not self.connection: 490 490 return 491 common.xmpp.features_nb.delPrivacyList(self.connection, privacy_list) 491 def _on_del_privacy_list_result(result): 492 if result: 493 self.dispatch('PRIVACY_LIST_REMOVED', privacy_list) 494 else: 495 self.dispatch('ERROR', (_('Error while removing privacy list'), 496 _('Privacy list %s has not been removed. It is maybe active in ' 497 'one of your connected resources. Desactivate it and try ' 498 'again.') % privacy_list)) 499 common.xmpp.features_nb.delPrivacyList(self.connection, privacy_list, 500 _on_del_privacy_list_result) 492 501 493 502 def get_privacy_list(self, title): … … 1041 1050 t.setTagData('password', password) 1042 1051 self.connection.send(p) 1052 1043 1053 #last date/time in history to avoid duplicate 1044 last_log = gajim.logger.get_last_date_that_has_logs(room_jid, 1045 is_room = True) 1046 if last_log is None: 1047 last_log = 0 1048 self.last_history_line[room_jid]= last_log 1054 if not self.last_history_line.has_key(room_jid): 1055 # Not in memory, get it from DB 1056 last_log = gajim.logger.get_last_date_that_has_logs(room_jid, 1057 is_room = True) 1058 if last_log is None: 1059 last_log = 0 1060 self.last_history_line[room_jid]= last_log 1049 1061 1050 1062 def send_gc_message(self, jid, msg, xhtml = None): … … 1091 1103 # disconnect from jabber server 1092 1104 self.connection.send(p) 1105 # Save the time we quit to avoid duplicate logs AND be faster than 1106 # get that date from DB 1107 self.last_history_line[jid] = time.time() 1093 1108 1094 1109 def gc_set_role(self, room_jid, nick, role, reason = ''): -
branches/gajim_0.11/src/common/dataforms.py
r7500 r7829 342 342 def fget(self): 343 343 return self.getAttr('type') 344 def fset(self ):344 def fset(self, type): 345 345 assert type in ('form', 'submit', 'cancel', 'result') 346 346 self.setAttr('type', type) -
branches/gajim_0.11/src/common/defs.py
r7684 r7829 3 3 datadir = '../' 4 4 5 version = '0.11 '5 version = '0.11.0.1' 6 6 7 7 import sys, os.path -
branches/gajim_0.11/src/common/GnuPG.py
r7652 r7829 44 44 45 45 class GnuPG(GnuPGInterface.GnuPG): 46 def __init__(self ):46 def __init__(self, use_agent = False): 47 47 GnuPGInterface.GnuPG.__init__(self) 48 self.use_agent = use_agent 48 49 self._setup_my_options() 49 50 … … 54 55 # Nolith's patch - prevent crashs on non fully-trusted keys 55 56 self.options.extra_args.append('--always-trust') 57 if self.use_agent: 58 self.options.extra_args.append('--use-agent') 56 59 57 60 def _read_response(self, child_stdout): -
branches/gajim_0.11/src/common/logger.py
r7787 r7829 426 426 self.cur.execute(''' 427 427 SELECT time, kind, message FROM logs 428 WHERE (%s) AND kind IN (%d, %d, %d, %d ) AND time > %d428 WHERE (%s) AND kind IN (%d, %d, %d, %d, %d) AND time > %d 429 429 ORDER BY time DESC LIMIT %d OFFSET %d 430 ''' % (where_sql, constants.KIND_SINGLE_MSG_RECV, constants.KIND_CHAT_MSG_RECV, 431 constants.KIND_SINGLE_MSG_SENT, constants.KIND_CHAT_MSG_SENT, 430 ''' % (where_sql, constants.KIND_SINGLE_MSG_RECV, 431 constants.KIND_CHAT_MSG_RECV, constants.KIND_SINGLE_MSG_SENT, 432 constants.KIND_CHAT_MSG_SENT, constants.KIND_ERROR, 432 433 timed_out, restore_how_many_rows, pending_how_many) 433 434 ) … … 516 517 result = self.cur.fetchall() 517 518 518 # Copy all interes ant timein a temporary table519 # Copy all interesting times in a temporary table 519 520 self.cur.execute('CREATE TEMPORARY TABLE blabla(time,INTEGER)') 520 521 for line in result: … … 555 556 where_sql = 'jid_id = %s' % jid_id 556 557 self.cur.execute(''' 557 SELECT timeFROM logs558 SELECT MAX(time) FROM logs 558 559 WHERE (%s) 559 560 AND kind NOT IN (%d, %d) 560 ORDER BY time DESC LIMIT 1561 561 ''' % (where_sql, constants.KIND_STATUS, constants.KIND_GCSTATUS)) 562 562 -
branches/gajim_0.11/src/common/optparser.py
r7787 r7829 14 14 15 15 import os 16 import sys17 16 import locale 18 17 from common import gajim … … 151 150 if old < [0, 10, 1, 8] and new >= [0, 10, 1, 8]: 152 151 self.update_config_to_01018() 152 if old < [0, 11, 0, 1] and new >= [0, 11, 0, 1]: 153 self.update_config_to_01101() 153 154 154 155 gajim.logger.init_vars() … … 368 369 self.old_values['chat_state_notifications']) 369 370 gajim.config.set('version', '0.10.1.8') 371 372 def update_config_to_01101(self): 373 '''fill time_stamp from before_time and after_time''' 374 if self.old_values.has_key('before_time'): 375 gajim.config.set('time_stamp', '%s%%H:%%M%s ' % ( 376 self.old_values['before_time'], self.old_values['after_time'])) 377 gajim.config.set('version', '0.11.0.1') -
branches/gajim_0.11/src/common/passwords.py
r7787 r7829 14 14 15 15 __all__ = ['get_password', 'save_password'] 16 17 import gobject18 16 19 17 from common import gajim -
branches/gajim_0.11/src/common/sleepy.py
r7787 r7829 2 2 ## 3 3 ## Contributors for this file: 4 ## - Yann Le Boulanger <asterix@lagaule.org>5 ## - Nikos Kouremenos <kourem@gmail.com>4 ## - Yann Le Boulanger <asterix@lagaule.org> 5 ## - Nikos Kouremenos <kourem@gmail.com> 6 6 ## 7 7 ## Copyright (C) 2003-2004 Yann Le Boulanger <asterix@lagaule.org> 8 ## Vincent Hanquez <tab@snarc.org>8 ## Vincent Hanquez <tab@snarc.org> 9 9 ## Copyright (C) 2005-2006 Yann Le Boulanger <asterix@lagaule.org> 10 ## Nikos Kouremenos <kourem@gmail.com>10 ## Nikos Kouremenos <kourem@gmail.com> 11 11 ## 12 12 ## This program is free software; you can redistribute it and/or modify … … 27 27 STATE_XA = 'extended away' 28 28 STATE_AWAY = 'away' 29 STATE_AWAKE = 'awake'29 STATE_AWAKE = 'awake' 30 30 31 31 SUPPORTED = True 32 32 try: 33 if os.name == 'nt':34 import ctypes33 if os.name == 'nt': 34 import ctypes 35 35 36 GetTickCount = ctypes.windll.kernel32.GetTickCount37 GetLastInputInfo = ctypes.windll.user32.GetLastInputInfo36 GetTickCount = ctypes.windll.kernel32.GetTickCount 37 GetLastInputInfo = ctypes.windll.user32.GetLastInputInfo 38 38 39 class LASTINPUTINFO(ctypes.Structure): 40 _fields_ = [('cbSize', ctypes.c_uint), 41 ('dwTime', ctypes.c_uint)] 39 class LASTINPUTINFO(ctypes.Structure): 40 _fields_ = [('cbSize', ctypes.c_uint), ('dwTime', ctypes.c_uint)] 42 41 43 lastInputInfo = LASTINPUTINFO()44 lastInputInfo.cbSize = ctypes.sizeof(lastInputInfo)42 lastInputInfo = LASTINPUTINFO() 43 lastInputInfo.cbSize = ctypes.sizeof(lastInputInfo) 45 44 46 else: # unix47 import idle45 else: # unix 46 import idle 48 47 except: 49 48 gajim.log.debug('Unable to load idle module') … … 51 50 52 51 class SleepyWindows: 53 def __init__(self, away_interval = 60, xa_interval = 120):52 def __init__(self, away_interval = 60, xa_interval = 120): 54 53 self.away_interval = away_interval 55 54 self.xa_interval = xa_interval 56 55 self.state = STATE_AWAKE # assume we are awake 57 56 58 def getIdleSec(self):59 GetLastInputInfo(ctypes.byref(lastInputInfo))60 idleDelta = float(GetTickCount() - lastInputInfo.dwTime) / 100061 return idleDelta57 def getIdleSec(self): 58 GetLastInputInfo(ctypes.byref(lastInputInfo)) 59 idleDelta = float(GetTickCount() - lastInputInfo.dwTime) / 1000 60 return idleDelta 62 61 63 62 def poll(self): 64 63 '''checks to see if we should change state''' 64 if not SUPPORTED: 65 return False 66 65 67 idleTime = self.getIdleSec() 66 68 67 69 # xa is stronger than away so check for xa first 68 70 if idleTime > self.xa_interval: … … 81 83 82 84 class SleepyUnix: 83 84 85 def __init__(self, away_interval = 60, xa_interval = 120): 85 86 self.away_interval = away_interval … … 92 93 self.state = STATE_UNKNOWN 93 94 94 def getIdleSec(self):95 return idle.getIdleSec()95 def getIdleSec(self): 96 return idle.getIdleSec() 96 97 97 98 def poll(self): … … 101 102 102 103 idleTime = self.getIdleSec() 103 104 104 105 # xa is stronger than away so check for xa first 105 106 if idleTime > self.xa_interval: … … 118 119 119 120 if os.name == 'nt': 120 Sleepy = SleepyWindows121 Sleepy = SleepyWindows 121 122 else: 122 Sleepy = SleepyUnix123 Sleepy = SleepyUnix -
branches/gajim_0.11/src/common/xmpp/features_nb.py
r7521 r7829 250 250 _on_default_response(disp, iq, None) 251 251 252 def delPrivacyList(disp,listname ):252 def delPrivacyList(disp,listname,cb=None): 253 253 """ Deletes privacy list 'listname'. Returns true on success.""" 254 254 iq = Iq('set',NS_PRIVACY,payload=[Node('list',{'name':listname})]) 255 _on_default_response(disp, iq, None)255 _on_default_response(disp, iq, cb)
