Changeset 12f500f
- Timestamp:
- 2013-02-21T13:16:26Z (12 years ago)
- Branches:
- master
- Children:
- 06eef80
- Parents:
- e4f5ca8 (diff), 9754c2f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- protocols
- Files:
-
- 6 added
- 8 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
protocols/skype/HACKING
re4f5ca8 r12f500f 18 18 4) irssi 19 19 20 20 21 == Tests 21 22 22 The plugin is tested with a mocked IRC client and a mocked skyped. To add a new 23 test, the following steps are necessary: 23 The plugin is tested with a mocked IRC client and a mocked skyped. 24 25 === Requirements 26 27 Python pexpect module is required to run the tests. 28 29 To run tests with bitlbee built in a development tree and not (the one) 30 installed in the system (e.g. /usr), make sure to specify --plugindir= option to 31 ./configure script during the build process: 32 33 bitlbee% ./configure --skype=1 --plugindir="$(realpath .)" 34 35 Otherwise bitlbee will try to load skype.so (among other things) from /usr/lib, 36 which is probably not what you want to test, or produce "Unknown protocol" 37 error. 38 39 === Running 40 41 Tests can be run by running test.py script in this ("protocols/skype") 42 directory. 43 44 For more control over how/which tests are being run from there, use "python -m 45 unittest" command: 46 47 bitlbee/protocols/skype% python -m unittest test 48 bitlbee/protocols/skype% python -m unittest -f test 49 bitlbee/protocols/skype% python -m unittest test.Test.testMsg 50 51 If bitlbee crashes during tests with SIGSEGV (segmentation fault), it's likely 52 that there is some problem with skype.c plugin. 53 To get a backtrace of such crash, use: 54 55 bitlbee/protocols/skype% ATTACH_GDB=true python -m unittest test.Test.testMsg 56 57 Example shows running "testMsg" test with gdb attached to bitlbee, which will 58 produce full backtrace in "t/gdb-<pid>.log" files (see pid in pexpect error 59 output of the test). 60 61 === Adding new tests 62 63 To add a new test, the following steps are necessary: 24 64 25 65 1) Add a new -skyped.mock file: just do the test manually, copy&paste the -
protocols/skype/skype.c
re4f5ca8 r12f500f 29 29 #define SKYPE_DEFAULT_SERVER "localhost" 30 30 #define SKYPE_DEFAULT_PORT "2727" 31 #define IRC_LINE_SIZE 1 02431 #define IRC_LINE_SIZE 16384 32 32 #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) 33 33 … … 194 194 { 195 195 struct skype_buddy_ask_data *bla = data; 196 skype_printf(bla->ic, "SET USER %s ISAUTHORIZED TRUE ",196 skype_printf(bla->ic, "SET USER %s ISAUTHORIZED TRUE\n", 197 197 bla->handle); 198 198 g_free(bla->handle); … … 203 203 { 204 204 struct skype_buddy_ask_data *bla = data; 205 skype_printf(bla->ic, "SET USER %s ISAUTHORIZED FALSE ",205 skype_printf(bla->ic, "SET USER %s ISAUTHORIZED FALSE\n", 206 206 bla->handle); 207 207 g_free(bla->handle); … … 226 226 { 227 227 struct skype_buddy_ask_data *bla = data; 228 skype_printf(bla->ic, "SET CALL %s STATUS INPROGRESS ",228 skype_printf(bla->ic, "SET CALL %s STATUS INPROGRESS\n", 229 229 bla->handle); 230 230 g_free(bla->handle); … … 235 235 { 236 236 struct skype_buddy_ask_data *bla = data; 237 skype_printf(bla->ic, "SET CALL %s STATUS FINISHED ",237 skype_printf(bla->ic, "SET CALL %s STATUS FINISHED\n", 238 238 bla->handle); 239 239 g_free(bla->handle); … … 918 918 /* Number of users changed in this group, query its type to see 919 919 * if it's a custom one we should care about. */ 920 skype_printf(ic, "GET GROUP %s TYPE ", id);920 skype_printf(ic, "GET GROUP %s TYPE\n", id); 921 921 return; 922 922 } … … 927 927 928 928 if (sg) { 929 skype_printf(ic, "ALTER GROUP %d ADDUSER %s ", sg->id, sd->pending_user);929 skype_printf(ic, "ALTER GROUP %d ADDUSER %s\n", sg->id, sd->pending_user); 930 930 g_free(sd->pending_user); 931 931 sd->pending_user = NULL; … … 935 935 } else if (!strcmp(info, "TYPE CUSTOM_GROUP")) 936 936 /* This one is interesting, query its users. */ 937 skype_printf(ic, "GET GROUP %s USERS ", id);937 skype_printf(ic, "GET GROUP %s USERS\n", id); 938 938 } 939 939 … … 1147 1147 /* Read the whole data. */ 1148 1148 st = ssl_read(sd->ssl, buf, sizeof(buf)); 1149 if (st >= IRC_LINE_SIZE-1) { 1150 /* As we don't buffer incoming data, if IRC_LINE_SIZE amount of bytes 1151 * were received, there's a good chance last message was truncated 1152 * and the next recv() will yield garbage. */ 1153 imcb_error(ic, "Unable to handle incoming data from skyped"); 1154 st = 0; 1155 } 1149 1156 if (st > 0) { 1150 1157 buf[st] = '\0'; … … 1338 1345 struct im_connection *ic = acc->ic; 1339 1346 1340 skype_printf(ic, "SET PROFILE FULLNAME %s ", value);1347 skype_printf(ic, "SET PROFILE FULLNAME %s\n", value); 1341 1348 return value; 1342 1349 } … … 1347 1354 struct im_connection *ic = acc->ic; 1348 1355 1349 skype_printf(ic, "SET PROFILE MOOD_TEXT %s ", value);1356 skype_printf(ic, "SET PROFILE MOOD_TEXT %s\n", value); 1350 1357 return value; 1351 1358 } … … 1356 1363 struct im_connection *ic = acc->ic; 1357 1364 1358 skype_printf(ic, "GET PROFILE PSTN_BALANCE ");1365 skype_printf(ic, "GET PROFILE PSTN_BALANCE\n"); 1359 1366 return value; 1360 1367 } … … 1367 1374 if (ptr) 1368 1375 *ptr = '\0'; 1369 skype_printf(ic, "CALL %s ", nick);1376 skype_printf(ic, "CALL %s\n", nick); 1370 1377 g_free(nick); 1371 1378 } … … 1376 1383 1377 1384 if (sd->call_id) { 1378 skype_printf(ic, "SET CALL %s STATUS FINISHED ",1385 skype_printf(ic, "SET CALL %s STATUS FINISHED\n", 1379 1386 sd->call_id); 1380 1387 g_free(sd->call_id); … … 1416 1423 /* No such group, we need to create it, then have to 1417 1424 * add the user once it's created. */ 1418 skype_printf(ic, "CREATE GROUP %s ", group);1425 skype_printf(ic, "CREATE GROUP %s\n", group); 1419 1426 sd->pending_user = g_strdup(nick); 1420 1427 } else { 1421 skype_printf(ic, "ALTER GROUP %d ADDUSER %s ", sg->id, nick);1428 skype_printf(ic, "ALTER GROUP %d ADDUSER %s\n", sg->id, nick); 1422 1429 } 1423 1430 } … … 1523 1530 } 1524 1531 1525 static void skype_set_my_name(struct im_connection *ic, char *info)1526 {1527 skype_set_display_name(set_find(&ic->acc->set, "display_name"), info);1528 }1529 1530 1532 static void skype_init(account_t *acc) 1531 1533 { … … 1584 1586 1585 1587 if (ret == NULL) { 1586 static const struct buddy_action ba[ 3] = {1588 static const struct buddy_action ba[2] = { 1587 1589 {"CALL", "Initiate a call" }, 1588 1590 {"HANGUP", "Hang up a call" }, 1589 1591 }; 1590 1591 ret = g_list_prepend(ret, (void *) ba + 0); 1592 int i; 1593 1594 for (i = 0; i < ARRAY_SIZE(ba); i++) 1595 ret = g_list_prepend(ret, (void *)(ba + i)); 1592 1596 } 1593 1597 … … 1620 1624 ret->buddy_msg = skype_buddy_msg; 1621 1625 ret->get_info = skype_get_info; 1622 ret->set_my_name = skype_set_my_name;1623 1626 ret->away_states = skype_away_states; 1624 1627 ret->set_away = skype_set_away; -
protocols/skype/skyped.py
re4f5ca8 r12f500f 1 1 #!/usr/bin/env python2.7 2 # 2 # 3 3 # skyped.py 4 # 4 # 5 5 # Copyright (c) 2007-2013 by Miklos Vajna <vmiklos@vmiklos.hu> 6 6 # … … 9 9 # the Free Software Foundation; either version 2 of the License, or 10 10 # (at your option) any later version. 11 # 11 # 12 12 # This program is distributed in the hope that it will be useful, 13 13 # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 15 # GNU General Public License for more details. 16 # 16 # 17 17 # You should have received a copy of the GNU General Public License 18 18 # along with this program; if not, write to the Free Software 19 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 19 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 20 20 # USA. 21 21 # … … 24 24 import os 25 25 import signal 26 import locale27 26 import time 28 27 import socket 29 import getopt30 28 import Skype4Py 31 29 import hashlib … … 54 52 if options.conn: 55 53 options.conn.close() 56 # shut down client if it's running 57 try: 58 skype.skype.Client.Shutdown() 59 except NameError: 60 pass 54 if not options.dont_start_skype: 55 # shut down client if it's running 56 try: 57 skype.skype.Client.Shutdown() 58 except NameError: 59 pass 61 60 sys.exit("Exiting.") 62 61 … … 125 124 return True 126 125 127 def send(sock, txt): 128 global options 129 from time import sleep 130 count = 1 131 done = False 126 def send(sock, txt, tries=10): 127 global options 132 128 if hasgobject: 133 while (not done) and (count < 10): 134 try: 135 sock.send(txt) 136 done = True 137 except Exception, s: 138 count += 1 139 dprint("Warning, sending '%s' failed (%s). count=%d" % (txt, s, count)) 140 sleep(1) 141 if not done: 129 if not options.conn: return 130 try: 131 sock.sendall(txt) 132 except socket.error as s: 133 dprint("Warning, sending '%s' failed (%s)." % (txt, s)) 142 134 options.conn.close() 143 else: 144 while (not done) and (count < 10) and options.conn: 135 options.conn = False 136 else: 137 for attempt in xrange(1, tries+1): 138 if not options.conn: break 145 139 if wait_for_lock(options.lock, 3, 10, "socket send"): 146 140 try: 147 if options.conn: sock.send (txt)141 if options.conn: sock.sendall(txt) 148 142 options.lock.release() 149 done = True 150 except Exception, s: 143 except socket.error as s: 151 144 options.lock.release() 152 count += 1153 145 dprint("Warning, sending '%s' failed (%s). count=%d" % (txt, s, count)) 154 sleep(1) 155 if not done: 146 time.sleep(1) 147 else: 148 break 149 else: 156 150 if options.conn: 157 151 options.conn.close() … … 208 202 keyfile=options.config.sslkey, 209 203 ssl_version=ssl.PROTOCOL_TLSv1) 210 except ssl.SSLError: 211 dprint("Warning, SSL init failed, did you create your certificate?") 212 return False 204 except (ssl.SSLError, socket.error) as err: 205 if isinstance(err, ssl.SSLError): 206 dprint("Warning, SSL init failed, did you create your certificate?") 207 return False 208 else: 209 dprint('Warning, SSL init failed') 210 return True 213 211 if hasattr(options.conn, 'handshake'): 214 212 try: … … 281 279 sock = open(mock) 282 280 self.lines = sock.readlines() 283 281 284 282 def SendCommand(self, c): 285 283 pass … … 310 308 class SkypeApi: 311 309 def __init__(self, mock): 310 global options 312 311 if not mock: 313 312 self.skype = Skype4Py.Skype() 314 313 self.skype.OnNotify = self.recv 315 self.skype.Client.Start() 314 if not options.dont_start_skype: 315 self.skype.Client.Start() 316 316 else: 317 317 self.skype = MockedSkype(mock) … … 380 380 dprint("Warning, sending '%s' failed (%s)." % (e, s)) 381 381 382 class Options:383 def __init__(self):384 self.cfgpath = os.path.join(os.environ['HOME'], ".skyped", "skyped.conf")385 # fall back to system-wide settings386 self.syscfgpath = "/usr/local/etc/skyped/skyped.conf"387 if os.path.exists(self.syscfgpath) and not os.path.exists(self.cfgpath):388 self.cfgpath = self.syscfgpath389 self.daemon = True390 self.debug = False391 self.help = False392 self.host = "0.0.0.0"393 self.log = None394 self.port = None395 self.version = False396 # well, this is a bit hackish. we store the socket of the last connected client397 # here and notify it. maybe later notify all connected clients?398 self.conn = None399 # this will be read first by the input handler400 self.buf = None401 self.mock = None402 403 404 def usage(self, ret):405 print """Usage: skyped [OPTION]...406 407 skyped is a daemon that acts as a tcp server on top of a Skype instance.408 409 Options:410 -c --config path to configuration file (default: %s)411 -d --debug enable debug messages412 -h --help this help413 -H --host set the tcp host, supports IPv4 and IPv6 (default: %s)414 -l --log set the log file in background mode (default: none)415 -n --nofork don't run as daemon in the background416 -p --port set the tcp port (default: %s)417 -v --version display version information""" % (self.cfgpath, self.host, self.port)418 sys.exit(ret)419 382 420 383 def serverloop(options, skype): … … 459 422 options.last_bitlbee_pong = now 460 423 461 if __name__=='__main__': 462 options = Options() 463 try: 464 opts, args = getopt.getopt(sys.argv[1:], "c:dhH:l:m:np:v", ["config=", "debug", "help", "host=", "log=", "mock=", "nofork", "port=", "version"]) 465 except getopt.GetoptError: 466 options.usage(1) 467 for opt, arg in opts: 468 if opt in ("-c", "--config"): 469 options.cfgpath = arg 470 elif opt in ("-d", "--debug"): 471 options.debug = True 472 elif opt in ("-h", "--help"): 473 options.help = True 474 elif opt in ("-H", "--host"): 475 options.host = arg 476 elif opt in ("-l", "--log"): 477 options.log = arg 478 elif opt in ("-m", "--mock"): 479 options.mock = arg 480 elif opt in ("-n", "--nofork"): 481 options.daemon = False 482 elif opt in ("-p", "--port"): 483 options.port = int(arg) 484 elif opt in ("-v", "--version"): 485 options.version = True 486 if options.help: 487 options.usage(0) 488 elif options.version: 424 425 def main(args=None): 426 global options 427 global skype 428 429 cfgpath = os.path.join(os.environ['HOME'], ".skyped", "skyped.conf") 430 syscfgpath = "/usr/local/etc/skyped/skyped.conf" 431 if not os.path.exists(cfgpath) and os.path.exists(syscfgpath): 432 cfgpath = syscfgpath # fall back to system-wide settings 433 port = 2727 434 435 import argparse 436 parser = argparse.ArgumentParser() 437 parser.add_argument('-c', '--config', 438 metavar='path', default=cfgpath, 439 help='path to configuration file (default: %(default)s)') 440 parser.add_argument('-H', '--host', default='0.0.0.0', 441 help='set the tcp host, supports IPv4 and IPv6 (default: %(default)s)') 442 parser.add_argument('-p', '--port', type=int, 443 help='set the tcp port (default: %(default)s)') 444 parser.add_argument('-l', '--log', metavar='path', 445 help='set the log file in background mode (default: none)') 446 parser.add_argument('-v', '--version', action='store_true', help='display version information') 447 parser.add_argument('-n', '--nofork', 448 action='store_true', help="don't run as daemon in the background") 449 parser.add_argument('-s', '--dont-start-skype', action='store_true', 450 help="assume that skype is running independently, don't try to start/stop it") 451 parser.add_argument('-m', '--mock', help='fake interactions with skype (only useful for tests)') 452 parser.add_argument('-d', '--debug', action='store_true', help='enable debug messages') 453 options = parser.parse_args(sys.argv[1:] if args is None else args) 454 455 if options.version: 489 456 print "skyped %s" % __version__ 490 457 sys.exit(0) 491 # parse our config 492 if not os.path.exists(options.cfgpath): 493 print "Can't find configuration file at '%s'." % options.cfgpath 494 print "Use the -c option to specify an alternate one." 495 sys.exit(1) 458 459 # well, this is a bit hackish. we store the socket of the last connected client 460 # here and notify it. maybe later notify all connected clients? 461 options.conn = None 462 # this will be read first by the input handler 463 options.buf = None 464 465 if not os.path.exists(options.config): 466 parser.error(( "Can't find configuration file at '%s'." 467 "Use the -c option to specify an alternate one." )% options.config) 468 469 cfgpath = options.config 496 470 options.config = ConfigParser() 497 options.config.read(options.cfgpath) 498 options.config.username = options.config.get('skyped', 'username').split('#')[0] 499 options.config.password = options.config.get('skyped', 'password').split('#')[0] 500 options.config.sslkey = os.path.expanduser(options.config.get('skyped', 'key').split('#')[0]) 501 options.config.sslcert = os.path.expanduser(options.config.get('skyped', 'cert').split('#')[0]) 471 options.config.read(cfgpath) 472 options.config.username = options.config.get('skyped', 'username').split('#', 1)[0] 473 options.config.password = options.config.get('skyped', 'password').split('#', 1)[0] 474 options.config.sslkey = os.path.expanduser(options.config.get('skyped', 'key').split('#', 1)[0]) 475 options.config.sslcert = os.path.expanduser(options.config.get('skyped', 'cert').split('#', 1)[0]) 476 502 477 # hack: we have to parse the parameters first to locate the 503 478 # config file but the -p option should overwrite the value from 504 479 # the config file 505 480 try: 506 options.config.port = int(options.config.get('skyped', 'port').split('#' )[0])481 options.config.port = int(options.config.get('skyped', 'port').split('#', 1)[0]) 507 482 if not options.port: 508 483 options.port = options.config.port … … 510 485 pass 511 486 if not options.port: 512 options.port = 2727513 dprint("Parsing config file '%s' done, username is '%s'." % ( options.cfgpath, options.config.username))514 if options.daemon:487 options.port = port 488 dprint("Parsing config file '%s' done, username is '%s'." % (cfgpath, options.config.username)) 489 if not options.nofork: 515 490 pid = os.fork() 516 491 if pid == 0: … … 540 515 options.lock = threading.Lock() 541 516 server(options.host, options.port, skype) 517 518 519 if __name__ == '__main__': main() -
protocols/skype/skyped.txt
re4f5ca8 r12f500f 75 75 Don't run as daemon in the background 76 76 77 -s, --dont-start-skype:: 78 Assume that skype is running independently, don't try to start/stop it. 79 77 80 -p, --port:: 78 81 Set the tcp port (default: 2727) -
protocols/skype/t/add-yes-bitlbee.mock
re4f5ca8 r12f500f 5 5 << PRIVMSG &bitlbee :account add skype alice foo 6 6 << PRIVMSG &bitlbee :account skype on 7 >> PRIVMSG &bitlbee :skype - New request: The user bob wants to add you 8 << PRIVMSG &bitlbee :yes 7 << PRIVMSG &bitlbee :add skype bob 9 8 >> :bob!bob@skype.com JOIN :&bitlbee -
protocols/skype/t/add-yes-skyped.mock
re4f5ca8 r12f500f 9 9 >> GET USER echo123 ONLINESTATUS 10 10 << USER echo123 ONLINESTATUS ONLINE 11 << USER bob RECEIVEDAUTHREQUEST Please allow me to see when you are online 12 >> SET USER bob ISAUTHORIZED TRUE 13 << USER bob ISAUTHORIZED TRUE 14 << USER bob RECEIVEDAUTHREQUEST 11 >> SET USER bob BUDDYSTATUS 2 Please authorize me 12 << USER bob BUDDYSTATUS 2 15 13 << USER bob ISAUTHORIZED TRUE 16 14 << USER bob ISBLOCKED FALSE 15 << USER bob BUDDYSTATUS 2 16 << USER bob ONLINESTATUS OFFLINE 17 << USER bob FULLNAME skype test203 17 18 << USER bob BUDDYSTATUS 3 18 19 << USER bob ONLINESTATUS OFFLINE 19 20 << USER bob ONLINESTATUS ONLINE 20 21 << USER bob TIMEZONE 90000 21 << USER bob FULLNAME Miklos V22 << USER bob LANGUAGE hu Hungarian23 << USER bob COUNTRY hu Hungary -
protocols/skype/test.py
re4f5ca8 r12f500f 9 9 import hashlib 10 10 11 def openssl(args): 12 with open(os.devnull, "w") as devnull: 13 proc = subprocess.Popen(['openssl'] + args, stdin=subprocess.PIPE, stderr=devnull) 14 for i in range(6): 15 proc.stdin.write("\n") 16 proc.stdin.close() 17 proc.communicate() 18 def setupSkyped(): 19 try: 20 shutil.rmtree("t/skyped") 21 except OSError: 22 pass 23 os.makedirs("t/skyped") 24 cwd = os.getcwd() 25 os.chdir("t/skyped") 26 try: 27 shutil.copyfile("../../skyped.cnf", "skyped.cnf") 28 openssl(['req', '-new', '-x509', '-days', '365', '-nodes', '-config', 'skyped.cnf', '-out', 'skyped.cert.pem', '-keyout', 'skyped.key.pem']) 29 with open("skyped.conf", "w") as sock: 30 sock.write("[skyped]\n") 31 sock.write("username = alice\n") 32 sock.write("password = %s\n" % hashlib.sha1("foo").hexdigest()) 33 sock.write("cert = %s/skyped.cert.pem\n" % os.getcwd()) 34 sock.write("key = %s/skyped.key.pem\n" % os.getcwd()) 35 sock.write("port = 2727\n") 36 finally: 37 os.chdir(cwd) 38 11 39 class Test(unittest.TestCase): 12 def openssl(self, args):13 with open(os.devnull, "w") as devnull:14 proc = subprocess.Popen(['openssl'] + args, stdin=subprocess.PIPE, stderr=devnull)15 for i in range(6):16 proc.stdin.write("\n")17 proc.stdin.close()18 proc.communicate()19 40 def mock(self, name): 20 skyped_log = open("t/skyped.log", "w") 21 skyped = subprocess.Popen([sys.executable, "skyped.py", "-c", "t/skyped/skyped.conf", "-n", "-d", "-m", "t/%s-skyped.mock" % name], 41 with open("t/skyped.log", "w") as skyped_log,\ 42 open("t/pexpect.log", "w") as pexpect_log: 43 skyped = subprocess.Popen([sys.executable, "skyped.py", 44 "-c", "t/skyped/skyped.conf", "-n", "-d", "-m", "t/%s-skyped.mock" % name], 22 45 stdout=skyped_log, stderr=subprocess.STDOUT) 23 24 try: 25 bitlbee = pexpect.spawn('../../bitlbee', ['-d', 't/bitlbee']) 26 bitlbee_mock = open("t/%s-bitlbee.mock" % name) 27 for i in bitlbee_mock.readlines(): 28 line = i.strip() 29 if line.startswith(">> "): 30 bitlbee.expect_exact(line[3:], timeout=10) 31 elif line.startswith("<< "): 32 bitlbee.sendline(line[3:]) 33 bitlbee_mock.close() 34 bitlbee.close() 35 finally: 36 skyped.terminate() 37 skyped.communicate() 38 skyped_log.close() 46 try: 47 bitlbee = pexpect.spawn('../../bitlbee', ['-d', 't/bitlbee'], logfile=pexpect_log) 48 if os.environ.get('ATTACH_GDB'): 49 subprocess.Popen(['gdb', '-batch-silent', 50 '-ex', 'set logging overwrite on', 51 '-ex', 'set logging file t/gdb-%s.log' % bitlbee.pid, 52 '-ex', 'set logging on', 53 '-ex', 'handle all pass nostop noprint', 54 '-ex', 'handle SIGSEGV pass stop print', 55 '-ex', 'set pagination 0', 56 '-ex', 'continue', 57 '-ex', 'backtrace full', 58 '-ex', 'info registers', 59 '-ex', 'thread apply all backtrace', 60 '-ex', 'quit', 61 '../../bitlbee', str(bitlbee.pid) ]) 62 bitlbee_mock = open("t/%s-bitlbee.mock" % name) 63 for i in bitlbee_mock.readlines(): 64 line = i.strip() 65 if line.startswith(">> "): 66 bitlbee.expect_exact(line[3:], timeout=10) 67 elif line.startswith("<< "): 68 bitlbee.sendline(line[3:]) 69 bitlbee_mock.close() 70 bitlbee.close() 71 finally: 72 skyped.terminate() 73 skyped.communicate() 39 74 40 75 def setUp(self): … … 44 79 pass 45 80 os.makedirs("t/bitlbee") 46 47 try:48 shutil.rmtree("t/skyped")49 except OSError:50 pass51 os.makedirs("t/skyped")52 cwd = os.getcwd()53 os.chdir("t/skyped")54 shutil.copyfile("../../skyped.cnf", "skyped.cnf")55 self.openssl(['req', '-new', '-x509', '-days', '365', '-nodes', '-config', 'skyped.cnf', '-out', 'skyped.cert.pem', '-keyout', 'skyped.key.pem'])56 with open("skyped.conf", "w") as sock:57 sock.write("[skyped]\n")58 sock.write("username = alice\n")59 sock.write("password = %s\n" % hashlib.sha1("foo").hexdigest())60 sock.write("cert = %s/skyped.cert.pem\n" % os.getcwd())61 sock.write("key = %s/skyped.key.pem\n" % os.getcwd())62 sock.write("port = 2727\n")63 os.chdir(cwd)64 65 81 66 82 def testMsg(self): … … 72 88 def testInfo(self): 73 89 self.mock("info") 74 90 75 91 def testCall(self): 76 92 self.mock("call") 77 93 78 94 def testCallFailed(self): 79 95 self.mock("call-failed") 80 96 81 97 def testAddYes(self): 82 98 self.mock("add-yes") 83 99 84 def testAddNo(self): 85 self.mock("add-no") 100 def testAddedYes(self): 101 self.mock("added-yes") 102 103 def testAddedNo(self): 104 self.mock("added-no") 86 105 87 106 def testGroupchatInvited(self): … … 90 109 def testGroupchatInvite(self): 91 110 self.mock("groupchat-invite") 92 111 93 112 def testCalledYes(self): 94 113 self.mock("called-yes") … … 103 122 self.mock("group-read") 104 123 124 def testCtcpHelp(self): 125 self.mock("ctcp-help") 126 127 def testSetMoodText(self): 128 self.mock("set-mood-text") 129 105 130 if __name__ == '__main__': 131 setupSkyped() 106 132 unittest.main() -
protocols/twitter/twitter.c
re4f5ca8 r12f500f 468 468 } 469 469 return (0); 470 }471 472 /**473 *474 */475 static void twitter_set_my_name(struct im_connection *ic, char *info)476 {477 470 } 478 471 … … 734 727 ret->buddy_msg = twitter_buddy_msg; 735 728 ret->get_info = twitter_get_info; 736 ret->set_my_name = twitter_set_my_name;737 729 ret->add_buddy = twitter_add_buddy; 738 730 ret->remove_buddy = twitter_remove_buddy;
Note: See TracChangeset
for help on using the changeset viewer.