Changeset 7940 for branches/gajim_0.11/src
- Timestamp:
- 02/06/07 20:54:30 (22 months ago)
- Location:
- branches/gajim_0.11/src
- Files:
-
- 28 modified
-
chat_control.py (modified) (3 diffs)
-
common/commands.py (modified) (2 diffs)
-
common/connection_handlers.py (modified) (10 diffs)
-
common/connection.py (modified) (3 diffs)
-
common/contacts.py (modified) (1 diff)
-
common/fuzzyclock.py (modified) (1 diff)
-
common/helpers.py (modified) (3 diffs)
-
common/optparser.py (modified) (2 diffs)
-
common/rst_xhtml_generator.py (modified) (2 diffs)
-
common/xmpp/auth_nb.py (modified) (2 diffs)
-
common/xmpp/protocol.py (modified) (2 diffs)
-
common/xmpp_stringprep.py (modified) (6 diffs)
-
config.py (modified) (1 diff)
-
conversation_textview.py (modified) (1 diff)
-
dialogs.py (modified) (1 diff)
-
gajim.py (modified) (9 diffs)
-
groupchat_control.py (modified) (5 diffs)
-
gtkgui_helpers.py (modified) (1 diff)
-
history_manager.py (modified) (4 diffs)
-
history_window.py (modified) (1 diff)
-
htmltextview.py (modified) (2 diffs)
-
message_window.py (modified) (4 diffs)
-
music_track_listener.py (modified) (2 diffs)
-
notify.py (modified) (4 diffs)
-
profile_window.py (modified) (1 diff)
-
roster_window.py (modified) (6 diffs)
-
statusicon.py (modified) (1 diff)
-
tooltips.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/gajim_0.11/src/chat_control.py
r7829 r7940 718 718 if conversation_height + diff_y < min_height: 719 719 if message_height + conversation_height - min_height > min_height: 720 self.msg_scrolledwindow.set_property('vscrollbar-policy', 721 gtk.POLICY_AUTOMATIC) 722 self.msg_scrolledwindow.set_property('height-request', 723 message_height + conversation_height - min_height) 724 self.bring_scroll_to_end(msg_textview) 720 policy = self.msg_scrolledwindow.get_property( 721 'vscrollbar-policy') 722 # scroll only when scrollbar appear 723 if policy != gtk.POLICY_AUTOMATIC: 724 self.msg_scrolledwindow.set_property('vscrollbar-policy', 725 gtk.POLICY_AUTOMATIC) 726 self.msg_scrolledwindow.set_property('height-request', 727 message_height + conversation_height - min_height) 728 self.bring_scroll_to_end(msg_textview) 725 729 else: 726 730 self.msg_scrolledwindow.set_property('vscrollbar-policy', … … 1303 1307 theme = gajim.config.get('roster_theme') 1304 1308 color = None 1309 if not chatstate: 1310 chatstate = self.contact.chatstate 1305 1311 if chatstate is not None: 1306 1312 if chatstate == 'composing': … … 1324 1330 self.parent_win.get_active_control() != self: 1325 1331 color = self.lighten_color(color) 1326 el if chatstate == 'active' : # active, get color from gtk1332 else: # active or not chatstate, get color from gtk 1327 1333 color = self.parent_win.notebook.style.fg[gtk.STATE_ACTIVE] 1328 1334 -
branches/gajim_0.11/src/common/commands.py
r7841 r7940 118 118 presencetype = form['presence-type'].value 119 119 if not presencetype in \ 120 ('free-for-chat', 'online', 'away', 'xa', 'dnd', 'offline'):120 ('free-for-chat', 'online', 'away', 'xa', 'dnd', 'offline'): 121 121 self.badRequest(request) 122 122 return False … … 283 283 q = iq.getTag('query') 284 284 q.addChild('identity', attrs = {'type': 'command-node', 285 'category': 'automation',286 'name': cmd.commandname})285 'category': 'automation', 286 'name': cmd.commandname}) 287 287 q.addChild('feature', attrs = {'var': xmpp.NS_COMMANDS}) 288 288 for feature in cmd.commandfeatures: -
branches/gajim_0.11/src/common/connection_handlers.py
r7888 r7940 746 746 if node in (None, client_version): 747 747 q.addChild('feature', attrs = {'var': common.xmpp.NS_MUC}) 748 q.addChild('feature', attrs = {'var': common.xmpp.NS_CHATSTATES}) 749 q.addChild('feature', attrs = {'var': common.xmpp.NS_COMMANDS}) 750 q.addChild('feature', attrs = {'var': common.xmpp.NS_DISCO_INFO}) 751 748 752 if q.getChildren(): 749 753 self.connection.send(iq) … … 839 843 entry = {} 840 844 for c in info.getChildren(): 841 entry[c.getName()] = c.getData()845 entry[c.getName()] = c.getData() 842 846 dict[name].append(entry) 843 847 elif info.getChildren() == []: … … 846 850 dict[name] = {} 847 851 for c in info.getChildren(): 848 dict[name][c.getName()] = c.getData()852 dict[name][c.getName()] = c.getData() 849 853 return dict 850 854 … … 1050 1054 1051 1055 del self.awaiting_answers[id] 1052 1056 1053 1057 def _vCardCB(self, con, vc): 1054 1058 '''Called when we receive a vCard 1055 1059 Parse the vCard and send it to plugins''' 1056 1060 if not vc.getTag('vCard'): 1061 return 1062 if not vc.getTag('vCard').getNamespace() == common.xmpp.NS_VCARD: 1057 1063 return 1058 1064 frm_iq = vc.getFrom() … … 1064 1070 else: 1065 1071 who = frm = our_jid 1066 if vc.getTag('vCard').getNamespace() == common.xmpp.NS_VCARD: 1067 card = vc.getChildren()[0] 1068 vcard = self.node_to_dict(card) 1069 photo_decoded = None 1070 if vcard.has_key('PHOTO') and isinstance(vcard['PHOTO'], dict) and \ 1071 vcard['PHOTO'].has_key('BINVAL'): 1072 photo = vcard['PHOTO']['BINVAL'] 1073 try: 1074 photo_decoded = base64.decodestring(photo) 1075 avatar_sha = sha.sha(photo_decoded).hexdigest() 1076 except: 1077 avatar_sha = '' 1078 else: 1072 card = vc.getChildren()[0] 1073 vcard = self.node_to_dict(card) 1074 photo_decoded = None 1075 if vcard.has_key('PHOTO') and isinstance(vcard['PHOTO'], dict) and \ 1076 vcard['PHOTO'].has_key('BINVAL'): 1077 photo = vcard['PHOTO']['BINVAL'] 1078 try: 1079 photo_decoded = base64.decodestring(photo) 1080 avatar_sha = sha.sha(photo_decoded).hexdigest() 1081 except: 1079 1082 avatar_sha = '' 1080 1081 if avatar_sha: 1082 card.getTag('PHOTO').setTagData('SHA', avatar_sha) 1083 1084 # Save it to file 1085 self.save_vcard_to_hd(who, card) 1086 # Save the decoded avatar to a separate file too, and generate files for dbus notifications 1087 puny_jid = helpers.sanitize_filename(frm) 1088 puny_nick = None 1089 begin_path = os.path.join(gajim.AVATAR_PATH, puny_jid) 1090 if frm in self.room_jids: 1091 puny_nick = helpers.sanitize_filename(resource) 1092 # create folder if needed 1093 if not os.path.isdir(begin_path): 1094 os.mkdir(begin_path, 0700) 1095 begin_path = os.path.join(begin_path, puny_nick) 1096 if photo_decoded: 1097 avatar_file = begin_path + '_notif_size_colored.png' 1098 if frm == our_jid and avatar_sha != self.vcard_sha: 1099 gajim.interface.save_avatar_files(frm, photo_decoded, puny_nick) 1100 elif frm != our_jid and (not os.path.exists(avatar_file) or \ 1101 not self.vcard_shas.has_key(frm) or \ 1102 avatar_sha != self.vcard_shas[frm]): 1103 gajim.interface.save_avatar_files(frm, photo_decoded, puny_nick) 1104 else: 1105 for ext in ('.jpeg', '.png', '_notif_size_bw.png', 1106 '_notif_size_colored.png'): 1107 path = begin_path + ext 1108 if os.path.isfile(path): 1109 os.remove(path) 1110 1111 if frm != our_jid: 1083 else: 1084 avatar_sha = '' 1085 1086 if avatar_sha: 1087 card.getTag('PHOTO').setTagData('SHA', avatar_sha) 1088 1089 # Save it to file 1090 self.save_vcard_to_hd(who, card) 1091 # Save the decoded avatar to a separate file too, and generate files for dbus notifications 1092 puny_jid = helpers.sanitize_filename(frm) 1093 puny_nick = None 1094 begin_path = os.path.join(gajim.AVATAR_PATH, puny_jid) 1095 frm_jid = frm 1096 if frm in self.room_jids: 1097 puny_nick = helpers.sanitize_filename(resource) 1098 # create folder if needed 1099 if not os.path.isdir(begin_path): 1100 os.mkdir(begin_path, 0700) 1101 begin_path = os.path.join(begin_path, puny_nick) 1102 frm_jid += '/' + resource 1103 if photo_decoded: 1104 avatar_file = begin_path + '_notif_size_colored.png' 1105 if frm_jid == our_jid and avatar_sha != self.vcard_sha: 1106 gajim.interface.save_avatar_files(frm, photo_decoded, puny_nick) 1107 elif frm_jid != our_jid and (not os.path.exists(avatar_file) or \ 1108 not self.vcard_shas.has_key(frm_jid) or \ 1109 avatar_sha != self.vcard_shas[frm_jid]): 1110 gajim.interface.save_avatar_files(frm, photo_decoded, puny_nick) 1112 1111 if avatar_sha: 1113 self.vcard_shas[frm] = avatar_sha 1114 elif self.vcard_shas.has_key(frm): 1115 del self.vcard_shas[frm] 1116 1117 vcard['jid'] = frm 1118 vcard['resource'] = resource 1119 if frm == our_jid: 1120 self.dispatch('MYVCARD', vcard) 1121 # we re-send our presence with sha if has changed and if we are 1122 # not invisible 1123 if self.vcard_sha == avatar_sha: 1124 return 1125 self.vcard_sha = avatar_sha 1126 if STATUS_LIST[self.connected] == 'invisible': 1127 return 1128 sshow = helpers.get_xmpp_show(STATUS_LIST[self.connected]) 1129 p = common.xmpp.Presence(typ = None, priority = self.priority, 1130 show = sshow, status = self.status) 1131 p = self.add_sha(p) 1132 self.connection.send(p) 1133 else: 1134 self.dispatch('VCARD', vcard) 1112 self.vcard_shas[frm_jid] = avatar_sha 1113 elif self.vcard_shas.has_key(frm): 1114 del self.vcard_shas[frm] 1115 else: 1116 for ext in ('.jpeg', '.png', '_notif_size_bw.png', 1117 '_notif_size_colored.png'): 1118 path = begin_path + ext 1119 if os.path.isfile(path): 1120 os.remove(path) 1121 1122 vcard['jid'] = frm 1123 vcard['resource'] = resource 1124 if frm_jid == our_jid: 1125 self.dispatch('MYVCARD', vcard) 1126 # we re-send our presence with sha if has changed and if we are 1127 # not invisible 1128 if self.vcard_sha == avatar_sha: 1129 return 1130 self.vcard_sha = avatar_sha 1131 if STATUS_LIST[self.connected] == 'invisible': 1132 return 1133 sshow = helpers.get_xmpp_show(STATUS_LIST[self.connected]) 1134 p = common.xmpp.Presence(typ = None, priority = self.priority, 1135 show = sshow, status = self.status) 1136 p = self.add_sha(p) 1137 self.connection.send(p) 1138 else: 1139 self.dispatch('VCARD', vcard) 1135 1140 1136 1141 class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco, ConnectionCommands, ConnectionPubSub): … … 1460 1465 if msg.timestamp: 1461 1466 has_timestamp = True 1462 if subject :1467 if subject != None: 1463 1468 self.dispatch('GC_SUBJECT', (frm, subject, msgtxt, has_timestamp)) 1464 1469 else: … … 1633 1638 if not ptype or ptype == 'unavailable': 1634 1639 if gajim.config.get('log_contact_status_changes') and self.name\ 1635 not in no_log_for and jid_stripped not in no_log_for:1640 not in no_log_for and jid_stripped not in no_log_for: 1636 1641 gc_c = gajim.contacts.get_gc_contact(self.name, jid_stripped, resource) 1637 1642 st = status or '' … … 1649 1654 puny_nick = helpers.sanitize_filename(resource) 1650 1655 gajim.interface.remove_avatar_files(jid_stripped, puny_nick) 1651 if self.vcard_shas.has_key(who): 1656 if self.vcard_shas.has_key(who): # Verify sha cached in mem 1652 1657 if avatar_sha != self.vcard_shas[who]: 1653 1658 # avatar has been updated 1654 1659 self.request_vcard(who, True) 1655 else: 1656 self.vcard_shas[who] = avatar_sha 1660 else: # Verify sha cached in hdd 1661 cached_vcard = self.get_cached_vcard(who, True) 1662 if cached_vcard and cached_vcard.has_key('PHOTO') and \ 1663 cached_vcard['PHOTO'].has_key('SHA'): 1664 cached_sha = cached_vcard['PHOTO']['SHA'] 1665 else: 1666 cached_sha = '' 1667 if cached_sha != avatar_sha: 1668 # avatar has been updated 1669 # sha in mem will be updated later 1670 self.request_vcard(who, True) 1671 else: 1672 # save sha in mem NOW 1673 self.vcard_shas[who] = avatar_sha 1657 1674 self.dispatch('GC_NOTIFY', (jid_stripped, show, status, resource, 1658 1675 prs.getRole(), prs.getAffiliation(), prs.getJid(), … … 1847 1864 self.dispatch('MSGERROR', (jid, errcode, errmsg)) 1848 1865 1866 def _IqPingCB(self, con, iq_obj): 1867 gajim.log.debug('IqPingCB') 1868 iq_obj = iq_obj.buildReply('result') 1869 self.connection.send(iq_obj) 1870 raise common.xmpp.NodeProcessed 1871 1849 1872 def _getRosterCB(self, con, iq_obj): 1850 1873 if not self.connection: … … 2011 2034 con.RegisterHandler('iq', self._DiscoverItemsGetCB, 'get', 2012 2035 common.xmpp.NS_DISCO_ITEMS) 2036 con.RegisterHandler('iq', self._IqPingCB, 'get', 2037 common.xmpp.NS_PING) 2013 2038 con.RegisterHandler('iq', self._PubSubCB, 'result') 2014 2039 con.RegisterHandler('iq', self._ErrorCB, 'error') -
branches/gajim_0.11/src/common/connection.py
r7888 r7940 108 108 # Do not try to reco while we are already trying 109 109 self.time_to_reconnect = None 110 if self.connected < 2: # connection failed110 if self.connected < 2: # connection failed 111 111 gajim.log.debug('reconnect') 112 112 self.retrycount += 1 … … 146 146 self.connected = 1 147 147 self.dispatch('STATUS', 'connecting') 148 if gajim.status_before_autoaway[self.name]: 149 # We were auto away. So go back online 150 self.status = gajim.status_before_autoaway[self.name] 151 gajim.status_before_autoaway[self.name] = '' 152 self.old_show = 'online' 148 153 # this check has moved from _reconnect method 149 154 # do exponential backoff until 15 minutes, … … 1097 1102 if show == 'offline': 1098 1103 ptype = 'unavailable' 1099 show = helpers.get_xmpp_show(show)1104 xmpp_show = helpers.get_xmpp_show(show) 1100 1105 p = common.xmpp.Presence(to = '%s/%s' % (jid, nick), typ = ptype, 1101 show = show, status = status)1102 if gajim.config.get('send_sha_in_gc_presence') :1106 show = xmpp_show, status = status) 1107 if gajim.config.get('send_sha_in_gc_presence') and show != 'offline': 1103 1108 p = self.add_sha(p, ptype != 'unavailable') 1104 1109 # send instantly so when we go offline, status is sent to gc before we -
branches/gajim_0.11/src/common/contacts.py
r7787 r7940 277 277 contact_groups = contact.groups 278 278 if not contact_groups: 279 # Contact is not in a group, so count it in General group 280 contact_groups.append(_('General')) 279 # Contact is not in a group, so count it in General or 280 # Transports group 281 if common.gajim.jid_is_transport(jid): 282 contact_groups = [_('Transports')] 283 else: 284 contact_groups = [_('General')] 281 285 for group in groups: 282 286 if group in contact_groups: -
branches/gajim_0.11/src/common/fuzzyclock.py
r7787 r7940 35 35 36 36 class FuzzyClock: 37 def __init__(self):38 self.__hour = 039 self.__minute = 040 self.__dayOfWeek = 037 def __init__(self): 38 self.__hour = 0 39 self.__minute = 0 40 self.__dayOfWeek = 0 41 41 42 self.__hourNames = [ _('one'), _('two'), _('three'), _('four'), _('five'), _('six'),43 _('seven'), _('eight'), _('nine'), _('ten'), _('eleven'),44 _('twelve')]42 self.__hourNames = [ _('one'), _('two'), _('three'), _('four'), _('five'), _('six'), 43 _('seven'), _('eight'), _('nine'), _('ten'), _('eleven'), 44 _('twelve')] 45 45 46 #Strings to use for the output. %0 will be replaced with the preceding hour (e.g. "x PAST %0"), %1 with the coming hour (e.g. "x TO %1). '''47 self.__normalFuzzy = [ _("$0 o'clock"), _('five past $0'),48 _('ten past $0'), _('quarter past $0'),49 _('twenty past $0'), _('twenty five past $0'),50 _('half past $0'), _('twenty five to $1'),51 _('twenty to $1'), _('quarter to $1'),52 _('ten to $1'), _('five to $1'), _("$1 o'clock") ]46 #Strings to use for the output. %0 will be replaced with the preceding hour (e.g. "x PAST %0"), %1 with the coming hour (e.g. "x TO %1). ''' 47 self.__normalFuzzy = [ _("$0 o'clock"), _('five past $0'), 48 _('ten past $0'), _('quarter past $0'), 49 _('twenty past $0'), _('twenty five past $0'), 50 _('half past $0'), _('twenty five to $1'), 51 _('twenty to $1'), _('quarter to $1'), 52 _('ten to $1'), _('five to $1'), _("$1 o'clock") ] 53 53 54 #A "singular-form". It is used when talking about hour 055 self.__normalFuzzyOne = [ _("$0 o'clock"), _('five past $0'),56 _('ten past $0'), _('quarter past $0'),57 _('twenty past $0'), _('twenty five past $0'),58 _('half past $0'), _('twenty five to $1'),59 _('twenty to $1'), _('quarter to $1'),60 _('ten to $1'), _('five to $1'),61 _("$1 o'clock") ]54 #A "singular-form". It is used when talking about hour 0 55 self.__normalFuzzyOne = [ _("$0 o'clock"), _('five past $0'), 56 _('ten past $0'), _('quarter past $0'), 57 _('twenty past $0'), _('twenty five past $0'), 58 _('half past $0'), _('twenty five to $1'), 59 _('twenty to $1'), _('quarter to $1'), 60 _('ten to $1'), _('five to $1'), 61 _("$1 o'clock") ] 62 62 63 63 64 self.__dayTime = [ _('Night'), _('Early morning'), _('Morning'), _('Almost noon'),65 _('Noon'), _('Afternoon'), _('Evening'), _('Late evening') ]64 self.__dayTime = [ _('Night'), _('Early morning'), _('Morning'), _('Almost noon'), 65 _('Noon'), _('Afternoon'), _('Evening'), _('Late evening') ] 66 66 67 self.__fuzzyWeek = [ _('Start of week'), _('Middle of week'), _('End of week'),68 _('Weekend!') ]67 self.__fuzzyWeek = [ _('Start of week'), _('Middle of week'), _('End of week'), 68 _('Weekend!') ] 69 69 70 self.setCurrent()70 self.setCurrent() 71 71 72 def setHour(self,hour):73 self.__hour = int(hour)72 def setHour(self,hour): 73 self.__hour = int(hour) 74 74 75 def setMinute(self,minute):76 self.__minute=int(minute)75 def setMinute(self,minute): 76 self.__minute=int(minute) 77 77 78 def setDayOfWeek(self,day):79 self.__dayOfWeek=int(day)78 def setDayOfWeek(self,day): 79 self.__dayOfWeek=int(day) 80 80 81 def setTime(self,time):82 timeArray = time.split(":")83 self.setHour(timeArray[0])84 self.setMinute(timeArray[1])81 def setTime(self,time): 82 timeArray = time.split(":") 83 self.setHour(timeArray[0]) 84 self.setMinute(timeArray[1]) 85 85 86 def setCurrent(self):87 hour=time.strftime("%H")88  
