Changeset 7787 for branches/gajim_0.11/src/common
- Timestamp:
- 01/06/07 12:00:50 (23 months ago)
- Location:
- branches/gajim_0.11/src/common
- Files:
-
- 14 modified
-
check_paths.py (modified) (4 diffs)
-
configpaths.py (modified) (4 diffs)
-
config.py (modified) (5 diffs)
-
connection_handlers.py (modified) (7 diffs)
-
contacts.py (modified) (1 diff)
-
fuzzyclock.py (modified) (3 diffs)
-
gajim.py (modified) (1 diff)
-
helpers.py (modified) (1 diff)
-
idle.c (modified) (6 diffs)
-
logger.py (modified) (2 diffs)
-
optparser.py (modified) (5 diffs)
-
passwords.py (modified) (3 diffs)
-
sleepy.py (modified) (4 diffs)
-
xmpp/protocol.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/gajim_0.11/src/common/check_paths.py
r7208 r7787 87 87 dot_gajim = os.path.dirname(VCARD_PATH) 88 88 if os.path.isfile(dot_gajim): 89 print _('%s is file but it should be a directory') % dot_gajim89 print _('%s is a file but it should be a directory') % dot_gajim 90 90 print _('Gajim will now exit') 91 91 sys.exit() … … 98 98 create_path(VCARD_PATH) 99 99 elif os.path.isfile(VCARD_PATH): 100 print _('%s is file but it should be a directory') % VCARD_PATH100 print _('%s is a file but it should be a directory') % VCARD_PATH 101 101 print _('Gajim will now exit') 102 102 sys.exit() … … 105 105 create_path(AVATAR_PATH) 106 106 elif os.path.isfile(AVATAR_PATH): 107 print _('%s is file but it should be a directory') % AVATAR_PATH107 print _('%s is a file but it should be a directory') % AVATAR_PATH 108 108 print _('Gajim will now exit') 109 109 sys.exit() … … 113 113 gajim.logger.init_vars() 114 114 elif os.path.isdir(LOG_DB_PATH): 115 print _('%s is directory but should befile') % LOG_DB_PATH115 print _('%s is a directory but should be a file') % LOG_DB_PATH 116 116 print _('Gajim will now exit') 117 117 sys.exit() -
branches/gajim_0.11/src/common/configpaths.py
r7510 r7787 42 42 except KeyError: 43 43 # win9x, in cwd 44 self.root = u' '44 self.root = u'.' 45 45 else: # Unices 46 46 # Pass in an Unicode string, and hopefully get one back. … … 88 88 89 89 paths.add('DATA', os.path.join(u'..', windowsify(u'data'))) 90 paths.add('HOME', os.path.expanduser(u'~'))90 paths.add('HOME', fse(os.path.expanduser('~'))) 91 91 paths.add('TMP', fse(tempfile.gettempdir())) 92 92 … … 97 97 pass 98 98 99 # for k, v in paths.iteritems():100 # print "%s: %s" % (k, v)99 # for k, v in paths.iteritems(): 100 # print "%s: %s" % (repr(k), repr(v)) 101 101 102 102 return paths … … 114 114 paths.add_from_root('CONFIG_FILE', conffile) 115 115 paths.add_from_root('PID_FILE', pidfile) 116 117 # for k, v in paths.iteritems(): 118 # print "%s: %s" % (repr(k), repr(v)) -
branches/gajim_0.11/src/common/config.py
r7582 r7787 39 39 opt_color = [ 'color', '^(#[0-9a-fA-F]{6})|()$' ] 40 40 opt_one_window_types = ['never', 'always', 'peracct', 'pertype'] 41 opt_treat_incoming_messages = ['', 'chat', 'normal'] 41 42 42 43 class Config: … … 90 91 'speller_language': [ opt_str, '', _('Language used by speller')], 91 92 'print_time': [ opt_str, 'always', _('\'always\' - print time for every message.\n\'sometimes\' - print time every print_ichat_every_foo_minutes minute.\n\'never\' - never print time.')], 92 'print_time_fuzzy': [ opt_int, 0, _('Print time in chats using Fuzzy Clock. Value of fuzziness from 1 to 4, or 0 to disable fuzzyclock. 1 is the most precise clock, 4 the le ssprecise one. This is used only if print_time is \'sometimes\'.') ],93 'print_time_fuzzy': [ opt_int, 0, _('Print time in chats using Fuzzy Clock. Value of fuzziness from 1 to 4, or 0 to disable fuzzyclock. 1 is the most precise clock, 4 the least precise one. This is used only if print_time is \'sometimes\'.') ], 93 94 'emoticons_theme': [opt_str, 'static', '', True ], 94 95 'ascii_formatting': [ opt_bool, True, … … 189 190 'muc_highlight_words': [opt_str, '', _('A semicolon-separated list of words that will be highlighted in group chats.')], 190 191 'quit_on_roster_x_button': [opt_bool, False, _('If True, quits Gajim when X button of Window Manager is clicked. This setting is taken into account only if trayicon is used.')], 191 ' set_xmpp://_handler_everytime': [opt_bool, False, _('If True, Gajim registers for xmpp://on each startup.')],192 'check_if_gajim_is_default': [opt_bool, True, _('If True, Gajim will check if it\'s the default jabber client on each startup.')], 192 193 'show_unread_tab_icon': [opt_bool, False, _('If True, Gajim will display an icon on each tab containing unread messages. Depending on the theme, this icon may be animated.')], 193 194 'show_status_msgs_in_roster': [opt_bool, True, _('If True, Gajim will display the status message, if not empty, for every contact under the contact name in roster window.'), True], … … 195 196 'ask_avatars_on_startup': [opt_bool, True, _('If True, Gajim will ask for avatar each contact that did not have an avatar last time or has one cached that is too old.')], 196 197 'print_status_in_chats': [opt_bool, True, _('If False, Gajim will no longer print status line in chats when a contact changes his or her status and/or his or her status message.')], 197 'print_status_in_muc': [opt_str, 'in_and_out', _('can be "none", "all" or "in_and_out". If "none", Gajim will no longer print status line in groupchats when a member changes his or her status and/or his or her status message. If "all" Gajim will print all status messages. If "in_and_out", gajim will only print FOO enters/leaves group chat.')],198 'print_status_in_muc': [opt_str, 'in_and_out', _('can be "none", "all" or "in_and_out". If "none", Gajim will no longer print status line in groupchats when a member changes his or her status and/or his or her status message. If "all" Gajim will print all status messages. If "in_and_out", Gajim will only print FOO enters/leaves group chat.')], 198 199 'log_contact_status_changes': [opt_bool, False], 199 200 'just_connected_bg_color': [opt_str, '#adc3c6', _('Background color of contacts when they just signed in.')], … … 217 218 'hide_groupchat_occupants_list': [opt_bool, False, _('Hides the group chat occupants list in group chat window.')], 218 219 'chat_merge_consecutive_nickname': [opt_bool, False, _('In a chat, show the nickname at the beginning of a line only when it\'s not the same person talking than in previous message.')], 219 'chat_merge_consecutive_nickname_indent': [opt_str, ' ', _('Indentation when using merge consecutive nick ame.')],220 'chat_merge_consecutive_nickname_indent': [opt_str, ' ', _('Indentation when using merge consecutive nickname.')], 220 221 'gc_nicknames_colors': [ opt_str, '#a34526:#c000ff:#0012ff:#388a99:#045723:#7c7c7c:#ff8a00:#94452d:#244b5a:#32645a', _('List of colors that will be used to color nicknames in group chats.'), True ], 221 222 'ctrl_tab_go_to_next_composing': [opt_bool, True, _('Ctrl-Tab go to next composing tab when none is unread.')], 222 223 'confirm_metacontacts': [ opt_str, '', _('Should we show the confirm metacontacts creation dialog or not? Empty string means we never show the dialog.')], 223 'enable_negative_priority': [ opt_bool, False, _('If True, you will be able to set a negative priority to your account in account modification window. BE CAREFULL, when you are logged in with a negative priority, you will NOT receive any message from your server.')], 224 'enable_negative_priority': [ opt_bool, False, _('If True, you will be able to set a negative priority to your account in account modification window. BE CAREFUL, when you are logged in with a negative priority, you will NOT receive any message from your server.')], 225 'use_gnomekeyring': [opt_bool, True, _('If True, Gajim will use Gnome Keyring (if available) to store account passwords.')], 226 'show_contacts_number': [opt_bool, True, _('If True, Gajim will show number of online and total contacts in account and group rows.')], 227 'treat_incoming_messages': [ opt_str, '', _('Can be empty, \'chat\' or \'normal\'. If not empty, treat all incoming messages as if they were of this type')], 224 228 } 225 229 -
branches/gajim_0.11/src/common/connection_handlers.py
r7591 r7787 25 25 import sys 26 26 27 from time import localtime, strftime, gmtime 27 from time import localtime, strftime, gmtime, timezone 28 28 from calendar import timegm 29 29 … … 1315 1315 raise common.xmpp.NodeProcessed 1316 1316 1317 1317 def _TimeRevisedCB(self, con, iq_obj): 1318 gajim.log.debug('TimeRevisedCB') 1319 iq_obj = iq_obj.buildReply('result') 1320 qp = iq_obj.setTag('time') 1321 qp.setTagData('utc', strftime("%Y-%m-%dT%TZ", gmtime())) 1322 qp.setTagData('tzo', "%+03d:00"% (time.timezone/(60*60))) 1323 self.connection.send(iq_obj) 1324 raise common.xmpp.NodeProcessed 1325 1318 1326 def _gMailNewMailCB(self, con, gm): 1319 1327 '''Called when we get notified of new mail messages in gmail account''' … … 1439 1447 self.dispatch('MSGERROR', (frm, msg.getErrorCode(), error_msg, msgtxt, 1440 1448 tim)) 1449 return 1441 1450 elif mtype == 'groupchat': 1442 1451 has_timestamp = False … … 1452 1461 return 1453 1462 self.dispatch('GC_MSG', (frm, msgtxt, tim, has_timestamp, msghtml)) 1454 if self.name not in no_log_for and not int(float(time.mktime(tim))) <=\1455 self.last_history_line[jid] and msgtxt:1463 if self.name not in no_log_for and not int(float(time.mktime(tim)))\ 1464 <= self.last_history_line[jid] and msgtxt: 1456 1465 gajim.logger.write('gc_msg', frm, msgtxt, tim = tim) 1466 return 1457 1467 elif mtype == 'chat': # it's type 'chat' 1458 1468 if not msg.getTag('body') and chatstate is None: #no <body> … … 1462 1472 msg_id = gajim.logger.write('chat_msg_recv', frm, msgtxt, tim = tim, 1463 1473 subject = subject) 1464 self.dispatch('MSG', (frm, msgtxt, tim, encrypted, mtype, subject,1465 chatstate, msg_id, composing_jep, user_nick, msghtml))1466 1474 else: # it's single message 1467 1475 if invite is not None: … … 1476 1484 gajim.logger.write('single_msg_recv', frm, msgtxt, tim = tim, 1477 1485 subject = subject) 1478 self.dispatch('MSG', (frm, msgtxt, tim, encrypted, 'normal', 1479 subject, chatstate, msg_id, composing_jep, user_nick, msghtml)) 1486 mtype = 'normal' 1487 treat_as = gajim.config.get('treat_incoming_messages') 1488 if treat_as: 1489 mtype = treat_as 1490 self.dispatch('MSG', (frm, msgtxt, tim, encrypted, mtype, 1491 subject, chatstate, msg_id, composing_jep, user_nick, msghtml)) 1480 1492 # END messageCB 1481 1493 … … 1963 1975 con.RegisterHandler('iq', self._TimeCB, 'get', 1964 1976 common.xmpp.NS_TIME) 1977 con.RegisterHandler('iq', self._TimeRevisedCB, 'get', 1978 common.xmpp.NS_TIME_REVISED) 1965 1979 con.RegisterHandler('iq', self._LastCB, 'get', 1966 1980 common.xmpp.NS_LAST) -
branches/gajim_0.11/src/common/contacts.py
r7516 r7787 265 265 continue 266 266 if common.gajim.jid_is_transport(jid) and not \ 267 common.gajim.config.get('show_transports_group'):267 _('Transports') in groups: 268 268 # do not count transports 269 269 continue 270 270 contact = self.get_contact_with_highest_priority(account, jid) 271 if _('Not in roster') in contact.groups: 272 continue 271 273 in_groups = False 272 274 if groups == []: -
branches/gajim_0.11/src/common/fuzzyclock.py
r6482 r7787 45 45 46 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'), _('ten past %0'),48 _('quarter past %0'), _('twenty past %0'),49 _('twenty five past %0'), _('half past %0'),50 _('twenty five to %1'), _('twenty to %1'),51 _('quarter to %1'), _('ten to %1'), _('five to %1'),52 _("%1 o'clock") ]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 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'), _("%1 o'clock") ] 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 61 63 62 64 self.__dayTime = [ _('Night'), _('Early morning'), _('Morning'), _('Almost noon'), … … 103 105 104 106 newTimeStr = self.__normalFuzzy[sector] 105 # %0 or %1?106 deltaHour = int(newTimeStr[newTimeStr.find(" %")+1])107 #$0 or $1? 108 deltaHour = int(newTimeStr[newTimeStr.find("$")+1]) 107 109 108 110 if (self.__hour + deltaHour) % 12 > 0: … … 114 116 newTimeStr = self.__normalFuzzyOne[sector] 115 117 116 newTimeStr = newTimeStr.replace(" %"+str(deltaHour),118 newTimeStr = newTimeStr.replace("$"+str(deltaHour), 117 119 self.__hourNames[realHour]) 118 120 -
branches/gajim_0.11/src/common/gajim.py
r7542 r7787 121 121 status_before_autoaway = {} 122 122 123 # jid of transport contacts for which we need to ask avatar when transport will 124 # be online 125 transport_avatar = {} # {transport_jid: [jid_list]} 126 123 127 SHOW_LIST = ['offline', 'connecting', 'online', 'chat', 'away', 'xa', 'dnd', 124 128 'invisible'] -
branches/gajim_0.11/src/common/helpers.py
r7562 r7787 350 350 return _('is composing a message...') 351 351 elif chatstate == 'paused': 352 #paused means he or she was compo ing but has stopped for a while352 #paused means he or she was composing but has stopped for a while 353 353 return _('paused composing a message') 354 354 elif chatstate == 'gone': -
branches/gajim_0.11/src/common/idle.c
r4700 r7787 6 6 * Copyright (C) 2003-2004 Yann Le Boulanger <asterix@lagaule.org> 7 7 * Vincent Hanquez <tab@snarc.org> 8 * Copyright (C) 2005 Yann Le Boulanger <asterix@lagaule.org> 9 * Vincent Hanquez <tab@snarc.org> 8 * Copyright (C) 2005-2006 Yann Le Boulanger <asterix@lagaule.org> 10 9 * Nikos Kouremenos <nkour@jabber.org> 11 * Dimitur Kirov <dkirov@gmail.com>12 * Travis Shirk <travis@pobox.com>13 * Norman Rasmussen <norman@rasmussen.co.za>14 10 * 15 11 * This program is free software; you can redistribute it and/or modify … … 27 23 #include <X11/Xutil.h> 28 24 #include <X11/extensions/scrnsaver.h> 29 #else30 #define _WIN32_WINNT 0x050031 #include <windows.h>32 #define EXPORT __declspec(dllexport)33 25 #endif 34 26 35 27 #include <Python.h> 36 28 37 #ifdef _WIN32 38 typedef BOOL (WINAPI *GETLASTINPUTINFO)(LASTINPUTINFO *); 39 static HMODULE g_user32 = NULL; 40 static GETLASTINPUTINFO g_GetLastInputInfo = NULL; 41 #else 29 #ifndef _WIN32 42 30 Display *display; 43 31 #endif … … 48 36 #ifndef _WIN32 49 37 display = XOpenDisplay(NULL); 50 #else51 g_user32 = LoadLibrary("user32.dll");52 if (g_user32) {53 g_GetLastInputInfo = (GETLASTINPUTINFO)GetProcAddress(g_user32, "GetLastInputInfo");54 }55 38 #endif 56 39 Py_INCREF(Py_None); … … 63 46 static XScreenSaverInfo *mit_info = NULL; 64 47 int idle_time, event_base, error_base; 65 #else66 int idle_time = 0;67 48 #endif 68 49 … … 77 58 else 78 59 idle_time = 0; 79 #else80 if (g_GetLastInputInfo != NULL) {81 LASTINPUTINFO lii;82 memset(&lii, 0, sizeof(lii));83 lii.cbSize = sizeof(lii);84 if (g_GetLastInputInfo(&lii)) {85 idle_time = lii.dwTime;86 }87 idle_time = (GetTickCount() - idle_time) / 1000;88 }89 60 #endif 90 61 return Py_BuildValue("i", idle_time); … … 95 66 #ifndef _WIN32 96 67 XCloseDisplay(display); 97 #else98 if (g_user32 != NULL)99 FreeLibrary(g_user32);100 68 #endif 101 69 Py_INCREF(Py_None); -
branches/gajim_0.11/src/common/logger.py
r7613 r7787 32 32 import configpaths 33 33 LOG_DB_PATH = configpaths.gajimpaths['LOG_DB'] 34 LOG_DB_FOLDER, LOG_DB_FILE = os.path.split(LOG_DB_PATH) 34 35 35 36 class Constants: … … 98 99 self.close_db() 99 100 101 # FIXME: sqlite3_open wants UTF8 strings. So a path with 102 # non-ascii chars doesn't work. See #2812 and 103 # http://lists.initd.org/pipermail/pysqlite/2005-August/000134.html 104 back = os.getcwd() 105 os.chdir(LOG_DB_FOLDER) 106 100 107 # if locked, wait up to 20 sec to unlock 101 108 # before raise (hopefully should be enough) 102 self.con = sqlite.connect(LOG_DB_PATH, timeout = 20.0, 109 110 self.con = sqlite.connect(LOG_DB_FILE, timeout = 20.0, 103 111 isolation_level = 'IMMEDIATE') 112 os.chdir(back) 104 113 self.cur = self.con.cursor() 105 114 self.set_synchronous(False) -
branches/gajim_0.11/src/common/optparser.py
r7537 r7787 99 99 def write(self): 100 100 (base_dir, filename) = os.path.split(self.__filename) 101 try:102 base_dir = base_dir.decode(sys.getfilesystemencoding())103 filename = filename.decode(sys.getfilesystemencoding())104 except:105 pass106 101 self.__tempfile = os.path.join(base_dir, '.' + filename) 107 102 try: … … 212 207 def assert_unread_msgs_table_exists(self): 213 208 '''create table unread_messages if there is no such table''' 214 con = sqlite.connect(logger.LOG_DB_PATH) 209 #FIXME see #2812 210 back = os.getcwd() 211 os.chdir(logger.LOG_DB_FOLDER) 212 con = sqlite.connect(logger.LOG_DB_FILE) 213 os.chdir(back) 215 214 cur = con.cursor() 216 215 try: … … 281 280 def update_config_to_01013(self): 282 281 '''create table transports_cache if there is no such table''' 283 con = sqlite.connect(logger.LOG_DB_PATH) 282 #FIXME see #2812 283 back = os.getcwd() 284 os.chdir(logger.LOG_DB_FOLDER) 285 con = sqlite.connect(logger.LOG_DB_FILE) 286 os.chdir(back) 284 287 cur = con.cursor() 285 288 try: … … 300 303 def update_config_to_01014(self): 301 304 '''apply indeces to the logs database''' 302 print _('migrating logs database to indeces') 303 con = sqlite.connect(logger.LOG_DB_PATH) 305 print _('migrating logs database to indices') 306 #FIXME see #2812 307 back = os.getcwd() 308 os.chdir(logger.LOG_DB_FOLDER) 309 con = sqlite.connect(logger.LOG_DB_FILE) 310 os.chdir(back) 304 311 cur = con.cursor() 305 312 # apply indeces … … 320 327 def update_config_to_01015(self): 321 328 '''clean show values in logs database''' 322 con = sqlite.connect(logger.LOG_DB_PATH) 329 #FIXME see #2812 330 back = os.getcwd() 331 os.chdir(logger.LOG_DB_FOLDER) 332 con = sqlite.connect(logger.LOG_DB_FILE) 333 os.chdir(back) 323 334 cur = con.cursor() 324 335 status = dict((i[5:].lower(), logger.constants.__dict__[i]) for i in \ -
branches/gajim_0.11/src/common/passwords.py
r7321 r7787 19 19 from common import gajim 20 20 21 try: 22 import gnomekeyring 23 except ImportError:24 USER_USES_GNOMEKEYRING = False25 else: 26 if gnomekeyring.is_available():27 USER_USES_GNOMEKEYRING = True21 USER_HAS_GNOMEKEYRING = False 22 USER_USES_GNOMEKEYRING = False 23 if gajim.config.get('use_gnomekeyring'): 24 try: 25 import gnomekeyring 26 except ImportError: 27 pass 28 28 else: 29 USER_USES_GNOMEKEYRING = False 29 USER_HAS_GNOMEKEYRING = True 30 if gnomekeyring.is_available(): 31 USER_USES_GNOMEKEYRING = True 32 else: 33 USER_USES_GNOMEKEYRING = False 30 34 31 35 class PasswordStorage(object): … … 38 42 class SimplePasswordStorage(PasswordStorage): 39 43 def get_password(self, account_name): 40 return gajim.config.get_per('accounts', account_name, 'password') 44 passwd = gajim.config.get_per('accounts', account_name, 'password') 45 if passwd and passwd.startswith('gnomekeyring:'): 46 return None # this is not a real password, it's a gnome keyring token 47 else: 48 return passwd 41 49 42 50 def save_password(self, account_name, password): … … 49 57 # self.keyring = gnomekeyring.get_default_keyring_sync() 50 58 51 ## above line commented and code below inserted as workaround 52 ## for the bug http://bugzilla.gnome.org/show_bug.cgi?id=363019 53 self.keyring = "default" 54 try: 55 gnomekeyring.create_sync(self.keyring, None) 56 except gnomekeyring.AlreadyExistsError: 59 ## above line commented and code below inserted as workaround 60 ## for the bug http://bugzilla.gnome.org/show_bug.cgi?id=363019 61 self.keyring = "default" 62 try: 63 gnomekeyring.create_sync(self.keyring, None) 64 except gnomekeyring.AlreadyExistsError: 57 65
