| 1 | ##Â Â Â core/core.py |
|---|
| 2 | ## |
|---|
| 3 | ## Gajim Team: |
|---|
| 4 | ##Â Â Â - Yann Le Boulanger <asterix@lagaule.org> |
|---|
| 5 | ##Â Â Â - Vincent Hanquez <tab@snarc.org> |
|---|
| 6 | ## |
|---|
| 7 | ##Â Â Â Copyright (C) 2003-2005 Gajim Team |
|---|
| 8 | ## |
|---|
| 9 | ## This program is free software; you can redistribute it and/or modify |
|---|
| 10 | ## it under the terms of the GNU General Public License as published |
|---|
| 11 | ## by the Free Software Foundation; version 2 only. |
|---|
| 12 | ## |
|---|
| 13 | ## This program is distributed in the hope that it will be useful, |
|---|
| 14 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 15 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 16 | ## GNU General Public License for more details. |
|---|
| 17 | ## |
|---|
| 18 | |
|---|
| 19 | import sys, os, time, string, logging |
|---|
| 20 | |
|---|
| 21 | import common.hub, common.optparser |
|---|
| 22 | import common.jabber |
|---|
| 23 | import socket, select, pickle |
|---|
| 24 | from tempfile import * |
|---|
| 25 | |
|---|
| 26 | from common import i18n |
|---|
| 27 | _ =Â i18n._ |
|---|
| 28 | |
|---|
| 29 | log =Â logging.getLogger('core.core') |
|---|
| 30 | log.setLevel(logging.DEBUG) |
|---|
| 31 | |
|---|
| 32 | CONFPATH =Â "~/.gajim/config" |
|---|
| 33 | LOGPATH =Â os.path.expanduser("~/.gajim/logs/") |
|---|
| 34 | |
|---|
| 35 | def XMLescape(txt): |
|---|
| 36 | Â Â Â Â "Escape XML entities" |
|---|
| 37 |     txt = txt.replace("&", "&") |
|---|
| 38 |     txt = txt.replace("<", "<") |
|---|
| 39 |     txt = txt.replace(">", ">") |
|---|
| 40 |     return txt |
|---|
| 41 | |
|---|
| 42 | def XMLunescape(txt): |
|---|
| 43 | Â Â Â Â "Unescape XML entities" |
|---|
| 44 |     txt = txt.replace(">", ">") |
|---|
| 45 |     txt = txt.replace("<", "<") |
|---|
| 46 |     txt = txt.replace("&", "&") |
|---|
| 47 |     return txt |
|---|
| 48 | |
|---|
| 49 | USE_GPG =Â 1 |
|---|
| 50 | try: |
|---|
| 51 |     import GnuPGInterface |
|---|
| 52 | except: |
|---|
| 53 | Â Â Â Â USE_GPG =Â 0 |
|---|
| 54 | else:Â Â |
|---|
| 55 |     class MyGnuPG(GnuPGInterface.GnuPG): |
|---|
| 56 |         def __init__(self): |
|---|
| 57 | Â Â Â Â Â Â Â Â Â Â Â Â GnuPGInterface.GnuPG.__init__(self) |
|---|
| 58 | Â Â Â Â Â Â Â Â Â Â Â Â self.setup_my_options() |
|---|
| 59 | |
|---|
| 60 |         def setup_my_options(self): |
|---|
| 61 | Â Â Â Â Â Â Â Â Â Â Â Â self.options.armor =Â 1 |
|---|
| 62 | Â Â Â Â Â Â Â Â Â Â Â Â self.options.meta_interactive =Â 0 |
|---|
| 63 | Â Â Â Â Â Â Â Â Â Â Â Â self.options.extra_args.append('--no-secmem-warning') |
|---|
| 64 | |
|---|
| 65 |         def _read_response(self, child_stdout): |
|---|
| 66 | Â Â Â Â Â Â Â Â Â Â Â Â # Internal method: reads all the output from GPG, taking notice |
|---|
| 67 | Â Â Â Â Â Â Â Â Â Â Â Â # only of lines that begin with the magic [GNUPG:] prefix. |
|---|
| 68 | Â Â Â Â Â Â Â Â Â Â Â Â # (See doc/DETAILS in the GPG distribution for info on GPG's |
|---|
| 69 | Â Â Â Â Â Â Â Â Â Â Â Â # output when --status-fd is specified.) |
|---|
| 70 | Â Â Â Â Â Â Â Â Â Â Â Â # |
|---|
| 71 | Â Â Â Â Â Â Â Â Â Â Â Â # Returns a dictionary, mapping GPG's keywords to the arguments |
|---|
| 72 | Â Â Â Â Â Â Â Â Â Â Â Â # for that keyword. |
|---|
| 73 | |
|---|
| 74 | Â Â Â Â Â Â Â Â Â Â Â Â resp =Â {} |
|---|
| 75 |             while 1: |
|---|
| 76 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â line =Â child_stdout.readline() |
|---|
| 77 |                 if line == "": break |
|---|
| 78 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â line =Â string.rstrip(Â line ) |
|---|
| 79 |                 if line[0:9] == '[GNUPG:] ': |
|---|
| 80 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â # Chop off the prefix |
|---|
| 81 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â line =Â line[9:] |
|---|
| 82 |                     L = string.split(line, None, 1) |
|---|
| 83 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â keyword =Â L[0] |
|---|
| 84 |                     if len(L) > 1: |
|---|
| 85 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â resp[Â keyword ]Â =Â L[1] |
|---|
| 86 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â else: |
|---|
| 87 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â resp[Â keyword ]Â =Â "" |
|---|
| 88 |             return resp |
|---|
| 89 | |
|---|
| 90 |         def encrypt(self, string, recipients): |
|---|
| 91 |             self.options.recipients = recipients  # a list! |
|---|
| 92 | |
|---|
| 93 |             proc = self.run(['--encrypt'], create_fhs=['stdin', 'stdout']) |
|---|
| 94 | Â Â Â Â Â Â Â Â Â Â Â Â proc.handles['stdin'].write(string) |
|---|
| 95 | Â Â Â Â Â Â Â Â Â Â Â Â proc.handles['stdin'].close() |
|---|
| 96 | |
|---|
| 97 | Â Â Â Â Â Â Â Â Â Â Â Â output =Â proc.handles['stdout'].read() |
|---|
| 98 | Â Â Â Â Â Â Â Â Â Â Â Â proc.handles['stdout'].close() |
|---|
| 99 | |
|---|
| 100 | Â Â Â Â Â Â Â Â Â Â Â Â try:Â proc.wait() |
|---|
| 101 |             except IOError: pass |
|---|
| 102 |             return self.stripHeaderFooter(output) |
|---|
| 103 | |
|---|
| 104 |         def decrypt(self, string, keyID): |
|---|
| 105 |             proc = self.run(['--decrypt', '-q', '-u %s'%keyID], create_fhs=['stdin', 'stdout', 'status']) |
|---|
| 106 |             enc = self.addHeaderFooter(string, 'MESSAGE') |
|---|
| 107 | Â Â Â Â Â Â Â Â Â Â Â Â proc.handles['stdin'].write(enc) |
|---|
| 108 | Â Â Â Â Â Â Â Â Â Â Â Â proc.handles['stdin'].close() |
|---|
| 109 | Â Â Â Â Â Â Â Â |
|---|
| 110 | Â Â Â Â Â Â Â Â Â Â Â Â output =Â proc.handles['stdout'].read() |
|---|
| 111 | Â Â Â Â Â Â Â Â Â Â Â Â proc.handles['stdout'].close() |
|---|
| 112 | |
|---|
| 113 | Â Â Â Â Â Â Â Â Â Â Â Â resp =Â proc.handles['status'].read() |
|---|
| 114 | Â Â Â Â Â Â Â Â Â Â Â Â proc.handles['status'].close() |
|---|
| 115 | |
|---|
| 116 | Â Â Â Â Â Â Â Â Â Â Â Â try:Â proc.wait() |
|---|
| 117 |             except IOError: pass |
|---|
| 118 |             return output |
|---|
| 119 | Â Â Â Â |
|---|
| 120 |         def sign(self, string, keyID): |
|---|
| 121 |             proc = self.run(['-b', '-u %s'%keyID], create_fhs=['stdin', 'stdout', 'status', 'stderr']) |
|---|
| 122 | Â Â Â Â Â Â Â Â Â Â Â Â proc.handles['stdin'].write(string) |
|---|
| 123 | Â Â Â Â Â Â Â Â Â Â Â Â proc.handles['stdin'].close() |
|---|
| 124 | |
|---|
| 125 | Â Â Â Â Â Â Â Â Â Â Â Â output =Â proc.handles['stdout'].read() |
|---|
| 126 | Â Â Â Â Â Â Â Â Â Â Â Â proc.handles['stdout'].close() |
|---|
| 127 | Â Â Â Â Â Â Â Â Â Â Â Â proc.handles['stderr'].close() |
|---|
| 128 | |
|---|
| 129 | Â Â Â Â Â Â Â Â Â Â Â Â stat =Â proc.handles['status'] |
|---|
| 130 | Â Â Â Â Â Â Â Â Â Â Â Â resp =Â self._read_response(stat) |
|---|
| 131 | Â Â Â Â Â Â Â Â Â Â Â Â proc.handles['status'].close() |
|---|
| 132 | |
|---|
| 133 | Â Â Â Â Â Â Â Â Â Â Â Â try:Â proc.wait() |
|---|
| 134 |             except IOError: pass |
|---|
| 135 |             if resp.has_key('BAD_PASSPHRASE'): |
|---|
| 136 |                 return 'BAD_PASSPHRASE' |
|---|
| 137 |             elif resp.has_key('GOOD_PASSPHRASE'): |
|---|
| 138 |                 return self.stripHeaderFooter(output) |
|---|
| 139 | |
|---|
| 140 |         def verify(self, str, sign): |
|---|
| 141 |             if not str: |
|---|
| 142 |                 return '' |
|---|
| 143 |             file = TemporaryFile(prefix='gajim') |
|---|
| 144 | Â Â Â Â Â Â Â Â Â Â Â Â fd =Â file.fileno() |
|---|
| 145 | Â Â Â Â Â Â Â Â Â Â Â Â file.write(str) |
|---|
| 146 | Â Â Â Â Â Â Â Â Â Â Â Â file.seek(0) |
|---|
| 147 | Â Â Â Â Â Â Â Â |
|---|
| 148 |             proc = self.run(['--verify', '--enable-special-filenames', '-', '-&%s'%fd], create_fhs=['stdin', 'status', 'stderr']) |
|---|
| 149 | |
|---|
| 150 | Â Â Â Â Â Â Â Â Â Â Â Â file.close |
|---|
| 151 |             sign = self.addHeaderFooter(sign, 'SIGNATURE') |
|---|
| 152 | Â Â Â Â Â Â Â Â Â Â Â Â proc.handles['stdin'].write(sign) |
|---|
| 153 | Â Â Â Â Â Â Â Â Â Â Â Â proc.handles['stdin'].close() |
|---|
| 154 | Â Â Â Â Â Â Â Â Â Â Â Â proc.handles['stderr'].close() |
|---|
| 155 | |
|---|
| 156 | Â Â Â Â Â Â Â Â Â Â Â Â stat =Â proc.handles['status'] |
|---|
| 157 | Â Â Â Â Â Â Â Â Â Â Â Â resp =Â self._read_response(stat) |
|---|
| 158 | Â Â Â Â Â Â Â Â Â Â Â Â proc.handles['status'].close() |
|---|
| 159 | |
|---|
| 160 | Â Â Â Â Â Â Â Â Â Â Â Â try:Â proc.wait() |
|---|
| 161 |             except IOError: pass |
|---|
| 162 | |
|---|
| 163 | Â Â Â Â Â Â Â Â Â Â Â Â keyid =Â '' |
|---|
| 164 |             if resp.has_key('GOODSIG'): |
|---|
| 165 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â keyid =Â string.split(resp['GOODSIG'])[0] |
|---|
| 166 |             return keyid |
|---|
| 167 | |
|---|
| 168 |         def get_secret_keys(self): |
|---|
| 169 |             proc = self.run(['--with-colons', '--list-secret-keys'], \ |
|---|
| 170 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â create_fhs=['stdout']) |
|---|
| 171 | Â Â Â Â Â Â Â Â Â Â Â Â output =Â proc.handles['stdout'].read() |
|---|
| 172 | Â Â Â Â Â Â Â Â Â Â Â Â proc.handles['stdout'].close() |
|---|
| 173 | |
|---|
| 174 | Â Â Â Â Â Â Â Â Â Â Â Â keys =Â {} |
|---|
| 175 |             lines = string.split(output, '\n') |
|---|
| 176 |             for line in lines: |
|---|
| 177 |                 sline = string.split(line, ':') |
|---|
| 178 |                 if sline[0] == 'sec': |
|---|
| 179 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â keys[sline[4][8:]]Â =Â sline[9] |
|---|
| 180 |             return keys |
|---|
| 181 | Â Â Â Â Â Â Â Â Â Â Â Â try:Â proc.wait() |
|---|
| 182 |             except IOError: pass |
|---|
| 183 | |
|---|
| 184 |         def stripHeaderFooter(self, data): |
|---|
| 185 | Â Â Â Â Â Â Â Â Â Â Â Â """Remove header and footer from data""" |
|---|
| 186 |             lines = string.split(data, '\n') |
|---|
| 187 |             while lines[0] != '': |
|---|
| 188 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lines.remove(lines[0]) |
|---|
| 189 |             while lines[0] == '': |
|---|
| 190 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â lines.remove(lines[0]) |
|---|
| 191 | Â Â Â Â Â Â Â Â Â Â Â Â i =Â 0 |
|---|
| 192 |             for line in lines: |
|---|
| 193 |                 if line: |
|---|
| 194 |                     if line[0] == '-': break |
|---|
| 195 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â i =Â i+1 |
|---|
| 196 |             line = string.join(lines[0:i], '\n') |
|---|
| 197 |             return line |
|---|
| 198 | |
|---|
| 199 |         def addHeaderFooter(self, data, type): |
|---|
| 200 | Â Â Â Â Â Â Â Â Â Â Â Â """Add header and footer from data""" |
|---|
| 201 | Â Â Â Â Â Â Â Â Â Â Â Â out =Â "-----BEGIN PGP %s-----\n"Â %Â type |
|---|
| 202 | Â Â Â Â Â Â Â Â Â Â Â Â out =Â out +Â "Version: PGP\n" |
|---|
| 203 | Â Â Â Â Â Â Â Â Â Â Â Â out =Â out +Â "\n" |
|---|
| 204 | Â Â Â Â Â Â Â Â Â Â Â Â out =Â out +Â data +Â "\n" |
|---|
| 205 | Â Â Â Â Â Â Â Â Â Â Â Â out =Â out +Â "-----END PGP %s-----\n"Â %Â type |
|---|
| 206 |             return out |
|---|
| 207 | |
|---|
| 208 | class GajimCore: |
|---|
| 209 | Â Â Â Â """Core""" |
|---|
| 210 |     def __init__(self, mode='client'): |
|---|
| 211 | Â Â Â Â Â Â Â Â self.mode =Â mode |
|---|
| 212 | Â Â Â Â Â Â Â Â self.log =Â 0 |
|---|
| 213 | Â Â Â Â Â Â Â Â self.init_cfg_file() |
|---|
| 214 |         if mode == 'client': |
|---|
| 215 | Â Â Â Â Â Â Â Â Â Â Â Â self.data =Â '' |
|---|
| 216 | Â Â Â Â Â Â Â Â Â Â Â Â self.connect_core() |
|---|
| 217 | Â Â Â Â Â Â Â Â self.hub =Â common.hub.GajimHub() |
|---|
| 218 |         if self.log: |
|---|
| 219 | Â Â Â Â Â Â Â Â Â Â Â Â log.setLevel(logging.DEBUG) |
|---|
| 220 | Â Â Â Â Â Â Â Â else: |
|---|
| 221 | Â Â Â Â Â Â Â Â Â Â Â Â log.setLevel(None) |
|---|
| 222 |         if mode == 'server': |
|---|
| 223 | Â Â Â Â Â Â Â Â Â Â Â Â self.connected =Â {} |
|---|
| 224 | Â Â Â Â Â Â Â Â Â Â Â Â #connexions {con: name, ...} |
|---|
| 225 | Â Â Â Â Â Â Â Â Â Â Â Â self.connexions =Â {} |
|---|
| 226 | Â Â Â Â Â Â Â Â Â Â Â Â self.gpg =Â {} |
|---|
| 227 | Â Â Â Â Â Â Â Â Â Â Â Â self.passwords =Â {} |
|---|
| 228 |             if USE_GPG: |
|---|
| 229 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â self.gpg_common =Â MyGnuPG() |
|---|
| 230 |             for a in self.accounts: |
|---|
| 231 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â self.connected[a]Â =Â 0Â #0:offline, 1:online, 2:away, |
|---|
| 232 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â #3:xa, 4:dnd, 5:invisible |
|---|
| 233 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â self.passwords[a]Â =Â self.cfgParser.tab[a]["password"] |
|---|
| 234 |                 if USE_GPG: |
|---|
| 235 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â self.gpg[a]Â =Â MyGnuPG() |
|---|
| 236 | Â Â Â Â Â Â Â Â Â Â Â Â self.myVCardID =Â [] |
|---|
| 237 | Â Â Â Â Â Â Â Â Â Â Â Â self.loadPlugins(self.cfgParser.tab['Core']['modules']) |
|---|
| 238 | Â Â Â Â Â Â Â Â else: |
|---|
| 239 | Â Â Â Â Â Â Â Â Â Â Â Â self.loadPlugins(self.cfgParser.tab['Core_client']['modules']) |
|---|
| 240 | Â Â Â Â # END __init__ |
|---|
| 241 | |
|---|
| 242 |     def loadPlugins(self, moduleStr): |
|---|
| 243 | Â Â Â Â Â Â Â Â """Load defaults plugins : plugins in 'modules' option of Core section |
|---|
| 244 | Â Â Â Â Â Â Â Â in ConfFile and register them to the hub""" |
|---|
| 245 |         if moduleStr: |
|---|
| 246 |             mods = string.split (moduleStr, ' ') |
|---|
| 247 | |
|---|
| 248 |             for mod in mods: |
|---|
| 249 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â try: |
|---|
| 250 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â modObj =Â self.hub.newPlugin(mod) |
|---|
| 251 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â except: |
|---|
| 252 |                     print _("The plugin %s cannot be launched" % mod) |
|---|
| 253 |                 if not modObj: |
|---|
| 254 |                     print _("The plugin %s is already launched" % mod) |
|---|
| 255 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â return |
|---|
| 256 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â modObj.load() |
|---|
| 257 | Â Â Â Â # END loadPLugins |
|---|
| 258 | |
|---|
| 259 |     def connect_core(self): |
|---|
| 260 |         self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
|---|
| 261 |         self.socket.connect((self.cfgParser.tab['Core_client']['host'], \ |
|---|
| 262 | Â Â Â Â Â Â Â Â Â Â Â Â self.cfgParser.tab['Core_client']['port'])) |
|---|
| 263 | Â Â Â Â # END connect_core |
|---|
| 264 | |
|---|
| 265 |     def init_cfg_file(self): |
|---|
| 266 | Â Â Â Â Â Â Â Â """Initialize configuration file""" |
|---|
| 267 |         if self.mode == 'server': |
|---|
| 268 |             default_tab = {'Profile': {'accounts': '', 'log': 0}, 'Core': \ |
|---|
| 269 |                 {'delauth': 1, 'alwaysauth': 0, 'modules': 'logger gtkgui', \ |
|---|
| 270 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 'delroster':Â 1}} |
|---|
| 271 | Â Â Â Â Â Â Â Â else: |
|---|
| 272 |             default_tab = {'Profile': {'log': 0}, 'Core_client': {'host': \ |
|---|
| 273 |             'localhost', 'port': 8255, 'modules': 'gtkgui'}} |
|---|
| 274 | Â Â Â Â Â Â Â Â fname =Â os.path.expanduser(CONFPATH) |
|---|
| 275 |         reps = string.split(fname, '/') |
|---|
| 276 | Â Â Â Â Â Â Â Â path =Â '' |
|---|
| 277 |         while len(reps) > 1: |
|---|
| 278 | Â Â Â Â Â Â Â Â Â Â Â Â path =Â path +Â reps[0]Â +Â '/' |
|---|
| 279 |             del reps[0] |
|---|
| 280 | Â Â Â Â Â Â Â Â Â Â Â Â try: |
|---|
| 281 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â os.stat(os.path.expanduser(path)) |
|---|
| 282 |             except OSError: |
|---|
| 283 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â try: |
|---|
| 284 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â os.mkdir(os.path.expanduser(path)) |
|---|
| 285 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â except: |
|---|
| 286 |                     print _("Can't create %s") % path |
|---|
| 287 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sys.exit |
|---|
| 288 | Â Â Â Â Â Â Â Â try: |
|---|
| 289 | Â Â Â Â Â Â Â Â Â Â Â Â os.stat(fname) |
|---|
| 290 | Â Â Â Â Â Â Â Â except: |
|---|
| 291 |             print _("creating %s") % fname |
|---|
| 292 |             fic = open(fname, "w") |
|---|
| 293 | Â Â Â Â Â Â Â Â Â Â Â Â fic.close() |
|---|
| 294 | Â Â Â Â Â Â Â Â self.cfgParser =Â common.optparser.OptionsParser(CONFPATH) |
|---|
| 295 | Â Â Â Â Â Â Â Â self.parse() |
|---|
| 296 |         for part in default_tab.keys(): |
|---|
| 297 |             if not self.cfgParser.tab.has_key(part): |
|---|
| 298 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â self.cfgParser.tab[part]Â =Â {} |
|---|
| 299 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â self.cfgParser.writeCfgFile() |
|---|
| 300 |             for option in default_tab[part].keys(): |
|---|
| 301 |                 if not self.cfgParser.tab[part].has_key(option): |
|---|
| 302 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â self.cfgParser.tab[part][option]Â =Â default_tab[part][option] |
|---|
| 303 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â self.cfgParser.writeCfgFile() |
|---|
| 304 | Â Â Â Â Â Â Â Â self.parse() |
|---|
| 305 | Â Â Â Â # END init_cfg_file |
|---|
| 306 | |
|---|
| 307 |     def parse(self): |
|---|
| 308 | Â Â Â Â Â Â Â Â """Parse configuratoin file and create self.accounts""" |
|---|
| 309 | Â Â Â Â Â Â Â Â self.cfgParser.parseCfgFile() |
|---|
| 310 |         if self.cfgParser.tab.has_key('Profile'): |
|---|
| 311 |             if self.cfgParser.tab['Profile'].has_key('log'): |
|---|
| 312 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â self.log =Â self.cfgParser.tab['Profile']['log'] |
|---|
| 313 |             if self.mode == 'server': |
|---|
| 314 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â self.accounts =Â {} |
|---|
| 315 |                 if self.cfgParser.tab['Profile'].has_key('accounts'): |
|---|
| 316 |                     accts = string.split(self.cfgParser.tab['Profile']['accounts'], ' ') |
|---|
| 317 |                     if accts == ['']: |
|---|
| 318 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â accts =Â [] |
|---|
| 319 |                     for a in accts: |
|---|
| 320 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â self.accounts[a]Â =Â self.cfgParser.tab[a] |
|---|
| 321 | |
|---|
| 322 |     def vCardCB(self, con, vc): |
|---|
| 323 | Â Â Â Â Â Â Â Â """Called when we recieve a vCard |
|---|
| 324 | Â Â Â Â Â Â Â Â Parse the vCard and send it to plugins""" |
|---|
| 325 | Â Â Â Â Â Â Â Â vcard =Â {'jid':Â vc.getFrom().getStripped()} |
|---|
| 326 |         if vc._getTag('vCard') == common.jabber.NS_VCARD: |
|---|
| 327 | Â Â Â Â Â Â Â Â Â Â Â Â card =Â vc.getChildren()[0] |
|---|
| 328 |             for info in card.getChildren(): |
|---|
| 329 |                 if info.getChildren() == []: |
|---|
| 330 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â vcard[info.getName()]Â =Â info.getData() |
|---|
| 331 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â else: |
|---|
| 332 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â vcard[info.getName()]Â =Â {} |
|---|
| 333 |                     for c in info.getChildren(): |
|---|
| 334 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â vcard[info.getName()][c.getName()]Â =Â c.getData() |
|---|
| 335 |             if vc.getID() in self.myVCardID: |
|---|
| 336 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â self.myVCardID.remove(vc.getID()) |
|---|
| 337 |                 self.hub.sendPlugin('MYVCARD', self.connexions[con], vcard) |
|---|
| 338 | Â Â Â Â Â Â Â Â Â Â Â Â else: |
|---|
| 339 |                 self.hub.sendPlugin('VCARD', self.connexions[con], vcard) |
|---|
| 340 | |
|---|
| 341 |     def messageCB(self, con, msg): |
|---|
| 342 | Â Â Â Â Â Â Â Â """Called when we recieve a message""" |
|---|
| 343 | Â Â Â Â Â Â Â Â typ =Â msg.getType() |
|---|
| 344 | Â Â Â Â Â Â Â Â tim =Â msg.getTimestamp() |
|---|
| 345 |         tim = time.strptime(tim, "%Y%m%dT%H:%M:%S") |
|---|
| 346 | Â Â Â Â Â Â Â Â msgtxt =Â msg.getBody() |
|---|
| 347 | Â Â Â Â Â Â Â Â xtags =Â msg.getXNodes() |
|---|
| 348 | Â Â Â Â Â Â Â Â encTag =Â None |
|---|
| 349 | Â Â Â Â Â Â Â Â decmsg =Â '' |
|---|
| 350 |         for xtag in xtags: |
|---|
| 351 |             if xtag.getNamespace() == common.jabber.NS_XENCRYPTED: |
|---|
| 352 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â encTag =Â xtag |
|---|
| 353 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â break |
|---|
| 354 |         if encTag and USE_GPG: |
|---|
| 355 | Â Â Â Â Â Â Â Â Â Â Â Â #decrypt |
|---|
| 356 | Â Â Â Â Â Â Â Â Â Â Â Â encmsg =Â encTag.getData() |
|---|
| 357 | Â Â Â Â Â Â Â Â Â Â Â Â keyID =Â '' |
|---|
| 358 |             if self.cfgParser.tab[self.connexions[con]].has_key("keyid"): |
|---|
| 359 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â keyID =Â self.cfgParser.tab[self.connexions[con]]["keyid"] |
|---|
| 360 |             if keyID: |
|---|
| 361 |                 decmsg = self.gpg[self.connexions[con]].decrypt(encmsg, keyID) |
|---|
| 362 |         if decmsg: |
|---|
| 363 | Â Â Â Â Â Â Â Â Â Â Â Â msgtxt =Â decmsg |
|---|
| 364 |         if typ == 'error': |
|---|
| 365 |             self.hub.sendPlugin('MSGERROR', self.connexions[con], \ |
|---|
| 366 |                 (str(msg.getFrom()), msg.getErrorCode(), msg.getError(), msgtxt, tim)) |
|---|
| 367 |         elif typ == 'groupchat': |
|---|
| 368 |             self.hub.sendPlugin('GC_MSG', self.connexions[con], \ |
|---|
| 369 |                 (str(msg.getFrom()), msgtxt, tim)) |
|---|
| 370 | Â Â Â Â Â Â Â Â else: |
|---|
| 371 |             self.hub.sendPlugin('MSG', self.connexions[con], \ |
|---|
| 372 |                 (str(msg.getFrom()), msgtxt, tim)) |
|---|
| 373 | Â Â Â Â # END messageCB |
|---|
| 374 | |
|---|
| 375 |     def presenceCB(self, con, prs): |
|---|
| 376 | Â Â Â Â Â Â Â Â """Called when we recieve a presence""" |
|---|
| 377 | #Â Â Â Â Â Â Â Â if prs.getXNode(common.jabber.NS_DELAY): return |
|---|
| 378 | Â Â Â Â Â Â Â Â who =Â str(prs.getFrom()) |
|---|
| 379 | Â Â Â Â Â Â Â Â prio =Â prs.getPriority() |
|---|
| 380 |         if not prio: |
|---|
| 381 | Â Â Â Â Â Â Â Â Â Â Â Â prio =Â 0 |
|---|
| 382 | Â Â Â Â Â Â Â Â typ =Â prs.getType() |
|---|
| 383 |         if typ == None: typ = 'available' |
|---|
| 384 | Â Â Â Â Â Â Â Â log.debug("PresenceCB : %s"Â %Â typ) |
|---|
| 385 | Â Â Â Â Â Â Â Â xtags =Â prs.getXNodes() |
|---|
| 386 | Â Â Â Â Â Â Â Â sigTag =Â None |
|---|
| 387 | Â Â Â Â Â Â Â Â keyID =Â '' |
|---|
| 388 | Â Â Â Â Â Â Â Â status =Â prs.getStatus() |
|---|
| 389 |         for xtag in xtags: |
|---|
| 390 |             if xtag.getNamespace() == common.jabber.NS_XSIGNED: |
|---|
| 391 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sigTag =Â xtag |
|---|
| 392 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â break |
|---|
| 393 |         if sigTag and USE_GPG: |
|---|
| 394 | Â Â Â Â Â Â Â Â Â Â Â Â #verify |
|---|
| 395 | Â Â Â Â Â Â Â Â Â Â Â Â sigmsg =Â sigTag.getData() |
|---|
| 396 |             keyID = self.gpg[self.connexions[con]].verify(status, sigmsg) |
|---|
| 397 |         if typ == 'available': |
|---|
| 398 | Â Â Â Â Â Â Â Â Â Â Â Â show =Â prs.getShow() |
|---|
| 399 |             if not show: |
|---|
| 400 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â show =Â 'online' |
|---|
| 401 |             self.hub.sendPlugin('NOTIFY', self.connexions[con], \ |
|---|
| 402 |                 (prs.getFrom().getStripped(), show, status, \ |
|---|
| 403 |                 prs.getFrom().getResource(), prio, keyID, prs.getRole(), \ |
|---|
| 404 |                 prs.getAffiliation(), prs.getJid(), prs.getReason(), \ |
|---|
| 405 |                 prs.getActor(), prs.getStatusCode())) |
|---|
| 406 |         elif typ == 'unavailable': |
|---|
| 407 |             self.hub.sendPlugin('NOTIFY', self.connexions[con], \ |
|---|
| 408 |                 (prs.getFrom().getStripped(), 'offline', status, \ |
|---|
| 409 |                 prs.getFrom().getResource(), prio, keyID, prs.getRole(), \ |
|---|
| 410 |                 prs.getAffiliation(), prs.getJid(), prs.getReason(), \ |
|---|
| 411 |                 prs.getActor(), prs.getStatusCode())) |
|---|
| 412 |         elif typ == 'subscribe': |
|---|
| 413 | Â Â Â Â Â Â Â Â Â Â Â Â log.debug("subscribe request from %s"Â %Â who) |
|---|
| 414 |             if self.cfgParser.Core['alwaysauth'] == 1 or \ |
|---|
| 415 |                 string.find(who, "@") <= 0: |
|---|
| 416 |                 con.send(common.jabber.Presence(who, 'subscribed')) |
|---|
| 417 |                 if string.find(who, "@") <= 0: |
|---|
| 418 |                     self.hub.sendPlugin('NOTIFY', self.connexions[con], \ |
|---|
| 419 |                         (prs.getFrom().getStripped(), 'offline', 'offline', \ |
|---|
| 420 |                         prs.getFrom().getResource(), prio, keyID, None, None, None, \ |
|---|
| 421 |                         None, None, None)) |
|---|
| 422 | Â Â Â Â Â Â Â Â Â Â Â Â else: |
|---|
| 423 |                 if not status: |
|---|
| 424 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â status =Â _("I would like to add you to my roster.") |
|---|
| 425 |                 self.hub.sendPlugin('SUBSCRIBE', self.connexions[con], (who, \ |
|---|
| 426 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â status)) |
|---|
| 427 |         elif typ == 'subscribed': |
|---|
| 428 | Â Â Â Â Â Â Â Â Â Â Â Â jid =Â prs.getFrom() |
|---|
| 429 |             self.hub.sendPlugin('SUBSCRIBED', self.connexions[con],\ |
|---|
| 430 |                 (jid.getStripped(), jid.getNode(), jid.getResource())) |
|---|
| 431 |             self.hub.queueIn.put(('UPDUSER', self.connexions[con], \ |
|---|
| 432 |                 (jid.getStripped(), jid.getNode(), ['general']))) |
|---|
| 433 | Â Â Â Â Â Â Â Â Â Â Â Â #BE CAREFUL : no con.updateRosterItem() in a callback |
|---|
| 434 | Â Â Â Â Â Â Â Â Â Â Â Â log.debug("we are now subscribed to %s"Â %Â who) |
|---|
| 435 |         elif typ == 'unsubscribe': |
|---|
| 436 | Â Â Â Â Â Â Â Â Â Â Â Â log.debug("unsubscribe request from %s"Â %Â who) |
|---|
| 437 |         elif typ == 'unsubscribed': |
|---|
| 438 | Â Â Â Â Â Â Â Â Â Â Â Â log.debug("we are now unsubscribed to %s"Â %Â who) |
|---|
| 439 |             self.hub.sendPlugin('UNSUBSCRIBED', self.connexions[con], \ |
|---|
| 440 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â prs.getFrom().getStripped()) |
|---|
| 441 |         elif typ == 'error': |
|---|
| 442 | Â Â Â Â Â Â Â Â Â Â Â Â errmsg =Â prs.getError() |
|---|
| 443 | Â Â Â Â Â Â Â Â Â Â Â Â errcode =Â prs.getErrorCode() |
|---|
| 444 |             if errcode == '400': #Bad Request : JID Malformed or Private message when not allowed |
|---|
| 445 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â pass |
|---|
| 446 |             elif errcode == '401': #No Password Provided |
|---|
| 447 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â pass |
|---|
| 448 |             elif errcode == '403': #forbidden :  User is Banned |
|---|
| 449 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â #Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Unauthorized Subject Change |
|---|
| 450 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â #Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Attempt by Mere Member to Invite Others to a Members-Only Room |
|---|
| 451 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â #Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Configuration Access to Non-Owner |
|---|
| 452 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â #Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Attempt by Non-Owner to Modify Owner List |
|---|
| 453 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â #Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Attempt by Non-Owner to Modify Admin List |
|---|
| 454 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â #Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Destroy Request Submitted by Non-Owner |
|---|
| 455 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â pass |
|---|
| 456 |             elif errcode == '404': #item not found :    Room Does Not Exist |
|---|
| 457 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â pass |
|---|
| 458 |             elif errcode == '405': #Not allowed : Attempt to Kick Moderator, Admin, or Owner |
|---|
| 459 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â #Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Attempt to Ban an Admin or Owner |
|---|
| 460 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â #Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Attempt to Revoke Voice from an Admin, Owner, or User with a Higher Affiliation |
|---|
| 461 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â #Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Attempt to Revoke Moderator Privileges from an Admin or Owner |
|---|
| 462 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â pass |
|---|
| 463 |             elif errcode == '407': #registration required :    User Is Not on Member List |
|---|
| 464 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â #Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
|---|
| 465 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â pass |
|---|
| 466 |             elif errcode == '409': #conflict :   Nick Conflict |
|---|
| 467 |                 self.hub.sendPlugin('WARNING', None, errmsg) |
|---|
| 468 | Â Â Â Â Â Â Â Â Â Â Â Â else: |
|---|
| 469 |                 self.hub.sendPlugin('NOTIFY', self.connexions[con], \ |
|---|
| 470 |                     (prs.getFrom().getStripped(), 'error', errmsg, \ |
|---|
| 471 |                     prs.getFrom().getResource(), prio, keyID, None, None, None, \ |
|---|
| 472 |                     None, None, None)) |
|---|
| 473 | Â Â Â Â # END presenceCB |
|---|
| 474 | |
|---|
| 475 |     def disconnectedCB(self, con): |
|---|
| 476 | Â Â Â Â Â Â Â Â """Called when we are disconnected""" |
|---|
| 477 | Â Â Â Â Â Â Â Â log.debug("disconnectedCB") |
|---|
| 478 |         if self.connexions.has_key(con): |
|---|
| 479 | Â Â Â Â Â Â Â Â Â Â Â Â self.connected[self.connexions[con]]Â =Â 0 |
|---|
| 480 |             self.hub.sendPlugin('STATUS', self.connexions[con], 'offline') |
|---|
| 481 | Â Â Â Â # END disconenctedCB |
|---|
| 482 | |
|---|
| 483 |     def rosterSetCB(self, con, iq_obj): |
|---|
| 484 |         for item in iq_obj.getQueryNode().getChildren(): |
|---|
| 485 |             jid = item.getAttr('jid') |
|---|
| 486 | Â Â Â Â Â Â Â Â Â Â Â Â name =Â item.getAttr('name') |
|---|
| 487 |             sub = item.getAttr('subscription') |
|---|
| 488 |             ask = item.getAttr('ask') |
|---|
| 489 | Â Â Â Â Â Â Â Â Â Â Â Â groups =Â [] |
|---|
| 490 |             for group in item.getTags("group"): |
|---|
| 491 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â groups.append(group.getData()) |
|---|
| 492 |             self.hub.sendPlugin('ROSTER_INFO', self.connexions[con], (jid, name, sub, ask, groups)) |
|---|
| 493 | |
|---|
| 494 |     def connect(self, account): |
|---|
| 495 | Â Â Â Â Â Â Â Â """Connect and authentificate to the Jabber server""" |
|---|
| 496 | Â Â Â Â Â Â Â Â hostname =Â self.cfgParser.tab[account]["hostname"] |
|---|
| 497 | Â Â Â Â Â Â Â Â name =Â self.cfgParser.tab[account]["name"] |
|---|
| 498 | Â Â Â Â Â Â Â Â password =Â self.passwords[account] |
|---|
| 499 | Â Â Â Â Â Â Â Â ressource =Â self.cfgParser.tab[account]["ressource"] |
|---|
| 500 | |
|---|
| 501 | Â Â Â Â Â Â Â Â #create connexion if it doesn't already existe |
|---|
| 502 | Â Â Â Â Â Â Â Â con =Â None |
|---|
| 503 |         for conn in self.connexions: |
|---|
| 504 |             if self.connexions[conn] == account: |
|---|
| 505 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â con =Â conn |
|---|
| 506 |         if not con: |
|---|
| 507 |             if self.cfgParser.tab[account]["use_proxy"]: |
|---|
| 508 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â proxy =Â {"host":self.cfgParser.tab[account]["proxyhost"]} |
|---|
| 509 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â proxy["port"]Â =Â self.cfgParser.tab[account]["proxyport"] |
|---|
| 510 | Â Â Â Â Â Â Â Â Â Â Â Â else: |
|---|
| 511 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â proxy =Â None |
|---|
| 512 |             if self.log: |
|---|
| 513 |                 con = common.jabber.Client(host = hostname, debug = [], \ |
|---|
| 514 |                 log = sys.stderr, connection=common.xmlstream.TCP, port=5222, \ |
|---|
| 515 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â proxy =Â proxy) |
|---|
| 516 | Â Â Â Â Â Â Â Â Â Â Â Â else: |
|---|
| 517 |                 con = common.jabber.Client(host = hostname, debug = [], log = None,\ |
|---|
| 518 |                 connection=common.xmlstream.TCP, port=5222, proxy = proxy) |
|---|
| 519 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â #debug = [common.jabber.DBG_ALWAYS], log = sys.stderr, \ |
|---|
| 520 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â #connection=common.xmlstream.TCP_SSL, port=5223, proxy = proxy) |
|---|
| 521 | Â Â Â Â Â Â Â Â Â Â Â Â con.setDisconnectHandler(self.disconnectedCB) |
|---|
| 522 |             con.registerHandler('message', self.messageCB) |
|---|
| 523 |             con.registerHandler('presence', self.presenceCB) |
|---|
| 524 | Â Â Â Â Â Â Â Â Â Â Â Â con.registerHandler('iq',self.vCardCB,'result')#common.jabber.NS_VCARD) |
|---|
| 525 |             con.registerHandler('iq',self.rosterSetCB,'set', \ |
|---|
| 526 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â common.jabber.NS_ROSTER) |
|---|
| 527 | Â Â Â Â Â Â Â Â try: |
|---|
| 528 | Â Â Â Â Â Â Â Â Â Â Â Â con.connect() |
|---|
| 529 |         except IOError, e: |
|---|
| 530 |             log.debug("Couldn't connect to %s %s" % (hostname, e)) |
|---|
| 531 |             self.hub.sendPlugin('STATUS', account, 'offline') |
|---|
| 532 |             self.hub.sendPlugin('WARNING', None, _("Couldn't connect to %s") \ |
|---|
| 533 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â %Â hostname) |
|---|
| 534 |             return 0 |
|---|
| 535 |         except common.xmlstream.socket.error, e: |
|---|
| 536 |             log.debug("Couldn't connect to %s %s" % (hostname, e)) |
|---|
| 537 |             self.hub.sendPlugin('STATUS', account, 'offline') |
|---|
| 538 | Â Â Â Â Â Â Â Â Â Â Â |
|---|