Show
Ignore:
Timestamp:
01/13/07 23:35:41 (23 months ago)
Author:
asterix
Message:

merge diff from trunc to 0.11 branch

Location:
branches/gajim_0.11/src/common
Files:
12 modified

Legend:

Unmodified
Added
Removed
  • branches/gajim_0.11/src/common/commands.py

    r7669 r7829  
    129129                cmd.addChild('note', {}, 'The status has been changed.') 
    130130 
    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') 
    132134 
    133135                # send new status 
  • branches/gajim_0.11/src/common/config.py

    r7787 r7829  
    131131                'latest_disco_addresses': [ opt_str, '' ], 
    132132                'recently_groupchat': [ opt_str, '' ], 
    133                 'before_time': [ opt_str, '[' ], 
    134                 'after_time': [ opt_str, ']' ], 
    135133                'before_nickname': [ opt_str, '' ], 
     134                'time_stamp': [ opt_str, '[%H:%M] ' ], 
    136135                'after_nickname': [ opt_str, ':' ], 
    137136                'send_os_info': [ opt_bool, True ], 
  • branches/gajim_0.11/src/common/connection_handlers.py

    r7787 r7829  
    2525import sys 
    2626 
    27 from time import localtime, strftime, gmtime, timezone 
     27from time import localtime, strftime, gmtime 
    2828from calendar import timegm 
    2929 
     
    887887                c = f.read() 
    888888                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 
    890895                vcard = self.node_to_dict(card) 
    891896                if vcard.has_key('PHOTO'): 
  • branches/gajim_0.11/src/common/connection.py

    r7634 r7829  
    8080                self.continue_connect_info = None 
    8181                if USE_GPG: 
    82                         self.gpg = GnuPG.GnuPG() 
     82                        self.gpg = GnuPG.GnuPG(gajim.config.get('use_gpg_agent')) 
    8383                        gajim.config.set('usegpg', True) 
    8484                else: 
     
    197197                                                self.password = self.new_account_info['password'] 
    198198                                                if USE_GPG: 
    199                                                         self.gpg = GnuPG.GnuPG() 
     199                                                        self.gpg = GnuPG.GnuPG(gajim.config.get('use_gpg_agent')) 
    200200                                                        gajim.config.set('usegpg', True) 
    201201                                                else: 
     
    489489                if not self.connection: 
    490490                        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) 
    492501         
    493502        def get_privacy_list(self, title): 
     
    10411050                        t.setTagData('password', password) 
    10421051                self.connection.send(p) 
     1052 
    10431053                #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 
    10491061 
    10501062        def send_gc_message(self, jid, msg, xhtml = None): 
     
    10911103                # disconnect from jabber server 
    10921104                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() 
    10931108 
    10941109        def gc_set_role(self, room_jid, nick, role, reason = ''): 
  • branches/gajim_0.11/src/common/dataforms.py

    r7500 r7829  
    342342                def fget(self): 
    343343                        return self.getAttr('type') 
    344                 def fset(self): 
     344                def fset(self, type): 
    345345                        assert type in ('form', 'submit', 'cancel', 'result') 
    346346                        self.setAttr('type', type) 
  • branches/gajim_0.11/src/common/defs.py

    r7684 r7829  
    33datadir = '../' 
    44 
    5 version = '0.11' 
     5version = '0.11.0.1' 
    66 
    77import sys, os.path 
  • branches/gajim_0.11/src/common/GnuPG.py

    r7652 r7829  
    4444 
    4545        class GnuPG(GnuPGInterface.GnuPG): 
    46                 def __init__(self): 
     46                def __init__(self, use_agent = False): 
    4747                        GnuPGInterface.GnuPG.__init__(self) 
     48                        self.use_agent = use_agent 
    4849                        self._setup_my_options() 
    4950 
     
    5455                        # Nolith's patch - prevent crashs on non fully-trusted keys 
    5556                        self.options.extra_args.append('--always-trust') 
     57                        if self.use_agent: 
     58                                self.options.extra_args.append('--use-agent') 
    5659 
    5760                def _read_response(self, child_stdout): 
  • branches/gajim_0.11/src/common/logger.py

    r7787 r7829  
    426426                self.cur.execute(''' 
    427427                        SELECT time, kind, message FROM logs 
    428                         WHERE (%s) AND kind IN (%d, %d, %d, %d) AND time > %d 
     428                        WHERE (%s) AND kind IN (%d, %d, %d, %d, %d) AND time > %d 
    429429                        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, 
    432433                                timed_out, restore_how_many_rows, pending_how_many) 
    433434                        ) 
     
    516517                result = self.cur.fetchall() 
    517518 
    518                 # Copy all interesant time in a temporary table  
     519                # Copy all interesting times in a temporary table  
    519520                self.cur.execute('CREATE TEMPORARY TABLE blabla(time,INTEGER)')  
    520521                for line in result:  
     
    555556                        where_sql = 'jid_id = %s' % jid_id       
    556557                self.cur.execute(''' 
    557                         SELECT time FROM logs 
     558                        SELECT MAX(time) FROM logs 
    558559                        WHERE (%s)  
    559560                        AND kind NOT IN (%d, %d) 
    560                         ORDER BY time DESC LIMIT 1 
    561561                        ''' % (where_sql, constants.KIND_STATUS, constants.KIND_GCSTATUS)) 
    562562 
  • branches/gajim_0.11/src/common/optparser.py

    r7787 r7829  
    1414 
    1515import os 
    16 import sys 
    1716import locale 
    1817from common import gajim 
     
    151150                if old < [0, 10, 1, 8] and new >= [0, 10, 1, 8]: 
    152151                        self.update_config_to_01018() 
     152                if old < [0, 11, 0, 1] and new >= [0, 11, 0, 1]: 
     153                        self.update_config_to_01101() 
    153154 
    154155                gajim.logger.init_vars() 
     
    368369                                 self.old_values['chat_state_notifications']) 
    369370                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  
    1414 
    1515__all__ = ['get_password', 'save_password'] 
    16  
    17 import gobject 
    1816 
    1917from common import gajim 
  • branches/gajim_0.11/src/common/sleepy.py

    r7787 r7829  
    22## 
    33## 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> 
    66## 
    77## Copyright (C) 2003-2004 Yann Le Boulanger <asterix@lagaule.org> 
    8 ##                        Vincent Hanquez <tab@snarc.org> 
     8##                                              Vincent Hanquez <tab@snarc.org> 
    99## Copyright (C) 2005-2006 Yann Le Boulanger <asterix@lagaule.org> 
    10 ##                    Nikos Kouremenos <kourem@gmail.com> 
     10##                                      Nikos Kouremenos <kourem@gmail.com> 
    1111## 
    1212## This program is free software; you can redistribute it and/or modify 
     
    2727STATE_XA   = 'extended away' 
    2828STATE_AWAY   = 'away' 
    29 STATE_AWAKE    = 'awake' 
     29STATE_AWAKE     = 'awake' 
    3030 
    3131SUPPORTED = True 
    3232try: 
    33         if os.name == 'nt': 
    34                 import ctypes 
     33                if os.name == 'nt': 
     34                        import ctypes 
    3535 
    36                 GetTickCount = ctypes.windll.kernel32.GetTickCount 
    37                 GetLastInputInfo = ctypes.windll.user32.GetLastInputInfo 
     36                        GetTickCount = ctypes.windll.kernel32.GetTickCount 
     37                        GetLastInputInfo = ctypes.windll.user32.GetLastInputInfo 
    3838 
    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)] 
    4241 
    43                 lastInputInfo = LASTINPUTINFO() 
    44                 lastInputInfo.cbSize = ctypes.sizeof(lastInputInfo) 
     42                        lastInputInfo = LASTINPUTINFO() 
     43                        lastInputInfo.cbSize = ctypes.sizeof(lastInputInfo) 
    4544 
    46         else: # unix 
    47                 import idle 
     45                else: # unix 
     46                        import idle 
    4847except: 
    4948        gajim.log.debug('Unable to load idle module') 
     
    5150 
    5251class SleepyWindows: 
    53         def __init__(self, away_interval = 60, xa_interval = 120): 
     52        def __init__(self, away_interval = 60, xa_interval = 120): 
    5453                self.away_interval = away_interval 
    5554                self.xa_interval = xa_interval 
    5655                self.state = STATE_AWAKE # assume we are awake 
    5756 
    58         def getIdleSec(self): 
    59                 GetLastInputInfo(ctypes.byref(lastInputInfo)) 
    60                 idleDelta = float(GetTickCount() - lastInputInfo.dwTime) / 1000 
    61                 return idleDelta 
     57        def getIdleSec(self): 
     58                GetLastInputInfo(ctypes.byref(lastInputInfo)) 
     59                idleDelta = float(GetTickCount() - lastInputInfo.dwTime) / 1000 
     60                return idleDelta 
    6261 
    6362        def poll(self): 
    6463                '''checks to see if we should change state''' 
     64                if not SUPPORTED: 
     65                        return False 
     66 
    6567                idleTime = self.getIdleSec() 
    66                  
     68 
    6769                # xa is stronger than away so check for xa first 
    6870                if idleTime > self.xa_interval: 
     
    8183 
    8284class SleepyUnix: 
    83  
    8485        def __init__(self, away_interval = 60, xa_interval = 120): 
    8586                self.away_interval = away_interval 
     
    9293                        self.state = STATE_UNKNOWN 
    9394 
    94         def getIdleSec(self): 
    95                 return idle.getIdleSec() 
     95        def getIdleSec(self): 
     96                return idle.getIdleSec() 
    9697 
    9798        def poll(self): 
     
    101102 
    102103                idleTime = self.getIdleSec() 
    103                  
     104 
    104105                # xa is stronger than away so check for xa first 
    105106                if idleTime > self.xa_interval: 
     
    118119 
    119120if os.name == 'nt': 
    120         Sleepy = SleepyWindows 
     121        Sleepy = SleepyWindows 
    121122else: 
    122         Sleepy = SleepyUnix 
     123        Sleepy = SleepyUnix 
  • branches/gajim_0.11/src/common/xmpp/features_nb.py

    r7521 r7829  
    250250        _on_default_response(disp, iq, None) 
    251251 
    252 def delPrivacyList(disp,listname): 
     252def delPrivacyList(disp,listname,cb=None): 
    253253        """ Deletes privacy list 'listname'. Returns true on success.""" 
    254254        iq = Iq('set',NS_PRIVACY,payload=[Node('list',{'name':listname})]) 
    255         _on_default_response(disp, iq, None) 
     255        _on_default_response(disp, iq, cb)