Changes in / [e4f5ca8:12f500f]


Ignore:
Location:
protocols
Files:
8 added
2 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • protocols/skype/HACKING

    re4f5ca8 r12f500f  
    18184) irssi
    1919
     20
    2021== Tests
    2122
    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:
     23The plugin is tested with a mocked IRC client and a mocked skyped.
     24
     25=== Requirements
     26
     27Python pexpect module is required to run the tests.
     28
     29To run tests with bitlbee built in a development tree and not (the one)
     30installed in the system (e.g. /usr), make sure to specify --plugindir= option to
     31./configure script during the build process:
     32
     33bitlbee% ./configure --skype=1 --plugindir="$(realpath .)"
     34
     35Otherwise bitlbee will try to load skype.so (among other things) from /usr/lib,
     36which is probably not what you want to test, or produce "Unknown protocol"
     37error.
     38
     39=== Running
     40
     41Tests can be run by running test.py script in this ("protocols/skype")
     42directory.
     43
     44For more control over how/which tests are being run from there, use "python -m
     45unittest" command:
     46
     47bitlbee/protocols/skype% python -m unittest test
     48bitlbee/protocols/skype% python -m unittest -f test
     49bitlbee/protocols/skype% python -m unittest test.Test.testMsg
     50
     51If bitlbee crashes during tests with SIGSEGV (segmentation fault), it's likely
     52that there is some problem with skype.c plugin.
     53To get a backtrace of such crash, use:
     54
     55bitlbee/protocols/skype% ATTACH_GDB=true python -m unittest test.Test.testMsg
     56
     57Example shows running "testMsg" test with gdb attached to bitlbee, which will
     58produce full backtrace in "t/gdb-<pid>.log" files (see pid in pexpect error
     59output of the test).
     60
     61=== Adding new tests
     62
     63To add a new test, the following steps are necessary:
    2464
    25651) Add a new -skyped.mock file: just do the test manually, copy&paste the
  • protocols/skype/skype.c

    re4f5ca8 r12f500f  
    2929#define SKYPE_DEFAULT_SERVER "localhost"
    3030#define SKYPE_DEFAULT_PORT "2727"
    31 #define IRC_LINE_SIZE 1024
     31#define IRC_LINE_SIZE 16384
    3232#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
    3333
     
    194194{
    195195        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",
    197197                bla->handle);
    198198        g_free(bla->handle);
     
    203203{
    204204        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",
    206206                bla->handle);
    207207        g_free(bla->handle);
     
    226226{
    227227        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",
    229229                bla->handle);
    230230        g_free(bla->handle);
     
    235235{
    236236        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",
    238238                bla->handle);
    239239        g_free(bla->handle);
     
    918918                        /* Number of users changed in this group, query its type to see
    919919                         * 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);
    921921                        return;
    922922                }
     
    927927
    928928                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);
    930930                        g_free(sd->pending_user);
    931931                        sd->pending_user = NULL;
     
    935935        } else if (!strcmp(info, "TYPE CUSTOM_GROUP"))
    936936                /* 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);
    938938}
    939939
     
    11471147        /* Read the whole data. */
    11481148        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        }
    11491156        if (st > 0) {
    11501157                buf[st] = '\0';
     
    13381345        struct im_connection *ic = acc->ic;
    13391346
    1340         skype_printf(ic, "SET PROFILE FULLNAME %s", value);
     1347        skype_printf(ic, "SET PROFILE FULLNAME %s\n", value);
    13411348        return value;
    13421349}
     
    13471354        struct im_connection *ic = acc->ic;
    13481355
    1349         skype_printf(ic, "SET PROFILE MOOD_TEXT %s", value);
     1356        skype_printf(ic, "SET PROFILE MOOD_TEXT %s\n", value);
    13501357        return value;
    13511358}
     
    13561363        struct im_connection *ic = acc->ic;
    13571364
    1358         skype_printf(ic, "GET PROFILE PSTN_BALANCE");
     1365        skype_printf(ic, "GET PROFILE PSTN_BALANCE\n");
    13591366        return value;
    13601367}
     
    13671374        if (ptr)
    13681375                *ptr = '\0';
    1369         skype_printf(ic, "CALL %s", nick);
     1376        skype_printf(ic, "CALL %s\n", nick);
    13701377        g_free(nick);
    13711378}
     
    13761383
    13771384        if (sd->call_id) {
    1378                 skype_printf(ic, "SET CALL %s STATUS FINISHED",
     1385                skype_printf(ic, "SET CALL %s STATUS FINISHED\n",
    13791386                                sd->call_id);
    13801387                g_free(sd->call_id);
     
    14161423                        /* No such group, we need to create it, then have to
    14171424                         * add the user once it's created. */
    1418                         skype_printf(ic, "CREATE GROUP %s", group);
     1425                        skype_printf(ic, "CREATE GROUP %s\n", group);
    14191426                        sd->pending_user = g_strdup(nick);
    14201427                } 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);
    14221429                }
    14231430        }
     
    15231530}
    15241531
    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 
    15301532static void skype_init(account_t *acc)
    15311533{
     
    15841586
    15851587        if (ret == NULL) {
    1586                 static const struct buddy_action ba[3] = {
     1588                static const struct buddy_action ba[2] = {
    15871589                        {"CALL", "Initiate a call" },
    15881590                        {"HANGUP", "Hang up a call" },
    15891591                };
    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));
    15921596        }
    15931597
     
    16201624        ret->buddy_msg = skype_buddy_msg;
    16211625        ret->get_info = skype_get_info;
    1622         ret->set_my_name = skype_set_my_name;
    16231626        ret->away_states = skype_away_states;
    16241627        ret->set_away = skype_set_away;
  • protocols/skype/skyped.py

    re4f5ca8 r12f500f  
    11#!/usr/bin/env python2.7
    2 # 
     2#
    33#   skyped.py
    4 # 
     4#
    55#   Copyright (c) 2007-2013 by Miklos Vajna <vmiklos@vmiklos.hu>
    66#
     
    99#   the Free Software Foundation; either version 2 of the License, or
    1010#   (at your option) any later version.
    11 # 
     11#
    1212#   This program is distributed in the hope that it will be useful,
    1313#   but WITHOUT ANY WARRANTY; without even the implied warranty of
    1414#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1515#   GNU General Public License for more details.
    16 # 
     16#
    1717#   You should have received a copy of the GNU General Public License
    1818#   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,
    2020#   USA.
    2121#
     
    2424import os
    2525import signal
    26 import locale
    2726import time
    2827import socket
    29 import getopt
    3028import Skype4Py
    3129import hashlib
     
    5452        if options.conn:
    5553                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
    6160        sys.exit("Exiting.")
    6261
     
    125124        return True
    126125
    127 def send(sock, txt):
    128         global options
    129         from time import sleep
    130         count = 1
    131         done = False
     126def send(sock, txt, tries=10):
     127        global options
    132128        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))
    142134                        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
    145139                        if wait_for_lock(options.lock, 3, 10, "socket send"):
    146140                                try:
    147                                          if options.conn: sock.send(txt)
     141                                         if options.conn: sock.sendall(txt)
    148142                                         options.lock.release()
    149                                          done = True
    150                                 except Exception, s:
     143                                except socket.error as s:
    151144                                        options.lock.release()
    152                                         count += 1
    153145                                        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:
    156150                        if options.conn:
    157151                                options.conn.close()
     
    208202                        keyfile=options.config.sslkey,
    209203                        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
    213211        if hasattr(options.conn, 'handshake'):
    214212                try:
     
    281279                sock = open(mock)
    282280                self.lines = sock.readlines()
    283        
     281
    284282        def SendCommand(self, c):
    285283                pass
     
    310308class SkypeApi:
    311309        def __init__(self, mock):
     310                global options
    312311                if not mock:
    313312                        self.skype = Skype4Py.Skype()
    314313                        self.skype.OnNotify = self.recv
    315                         self.skype.Client.Start()
     314                        if not options.dont_start_skype:
     315                                self.skype.Client.Start()
    316316                else:
    317317                        self.skype = MockedSkype(mock)
     
    380380                        dprint("Warning, sending '%s' failed (%s)." % (e, s))
    381381
    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 settings
    386                 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.syscfgpath
    389                 self.daemon = True
    390                 self.debug = False
    391                 self.help = False
    392                 self.host = "0.0.0.0"
    393                 self.log = None
    394                 self.port = None
    395                 self.version = False
    396                 # well, this is a bit hackish. we store the socket of the last connected client
    397                 # here and notify it. maybe later notify all connected clients?
    398                 self.conn = None
    399                 # this will be read first by the input handler
    400                 self.buf = None
    401                 self.mock = None
    402 
    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 messages
    412         -h      --help          this help
    413         -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 background
    416         -p      --port          set the tcp port (default: %s)
    417         -v      --version       display version information""" % (self.cfgpath, self.host, self.port)
    418                 sys.exit(ret)
    419382
    420383def serverloop(options, skype):
     
    459422                                options.last_bitlbee_pong = now
    460423
    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
     425def 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:
    489456                print "skyped %s" % __version__
    490457                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
    496470        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
    502477        # hack: we have to parse the parameters first to locate the
    503478        # config file but the -p option should overwrite the value from
    504479        # the config file
    505480        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])
    507482                if not options.port:
    508483                        options.port = options.config.port
     
    510485                pass
    511486        if not options.port:
    512                 options.port = 2727
    513         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:
    515490                pid = os.fork()
    516491                if pid == 0:
     
    540515                        options.lock = threading.Lock()
    541516                        server(options.host, options.port, skype)
     517
     518
     519if __name__ == '__main__': main()
  • protocols/skype/skyped.txt

    re4f5ca8 r12f500f  
    7575        Don't run as daemon in the background
    7676
     77-s, --dont-start-skype::
     78        Assume that skype is running independently, don't try to start/stop it.
     79
    7780-p, --port::
    7881        Set the tcp port (default: 2727)
  • protocols/skype/t/add-yes-bitlbee.mock

    re4f5ca8 r12f500f  
    55<< PRIVMSG &bitlbee :account add skype alice foo
    66<< 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
    98>> :bob!bob@skype.com JOIN :&bitlbee
  • protocols/skype/t/add-yes-skyped.mock

    re4f5ca8 r12f500f  
    99>> GET USER echo123 ONLINESTATUS
    1010<< 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
    1513<< USER bob ISAUTHORIZED TRUE
    1614<< USER bob ISBLOCKED FALSE
     15<< USER bob BUDDYSTATUS 2
     16<< USER bob ONLINESTATUS OFFLINE
     17<< USER bob FULLNAME skype test203
    1718<< USER bob BUDDYSTATUS 3
    1819<< USER bob ONLINESTATUS OFFLINE
    1920<< USER bob ONLINESTATUS ONLINE
    2021<< USER bob TIMEZONE 90000
    21 << USER bob FULLNAME Miklos V
    22 << USER bob LANGUAGE hu Hungarian
    23 << USER bob COUNTRY hu Hungary
  • protocols/skype/test.py

    re4f5ca8 r12f500f  
    99import hashlib
    1010
     11def 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()
     18def 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
    1139class 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()
    1940        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],
    2245                                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()
    3974
    4075        def setUp(self):
     
    4479                        pass
    4580                os.makedirs("t/bitlbee")
    46 
    47                 try:
    48                         shutil.rmtree("t/skyped")
    49                 except OSError:
    50                         pass
    51                 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 
    6581
    6682        def testMsg(self):
     
    7288        def testInfo(self):
    7389                self.mock("info")
    74        
     90
    7591        def testCall(self):
    7692                self.mock("call")
    77        
     93
    7894        def testCallFailed(self):
    7995                self.mock("call-failed")
    80        
     96
    8197        def testAddYes(self):
    8298                self.mock("add-yes")
    8399
    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")
    86105
    87106        def testGroupchatInvited(self):
     
    90109        def testGroupchatInvite(self):
    91110                self.mock("groupchat-invite")
    92        
     111
    93112        def testCalledYes(self):
    94113                self.mock("called-yes")
     
    103122                self.mock("group-read")
    104123
     124        def testCtcpHelp(self):
     125                self.mock("ctcp-help")
     126
     127        def testSetMoodText(self):
     128                self.mock("set-mood-text")
     129
    105130if __name__ == '__main__':
     131        setupSkyped()
    106132        unittest.main()
  • protocols/twitter/twitter.c

    re4f5ca8 r12f500f  
    468468        }
    469469        return (0);
    470 }
    471 
    472 /**
    473  *
    474  */
    475 static void twitter_set_my_name(struct im_connection *ic, char *info)
    476 {
    477470}
    478471
     
    734727        ret->buddy_msg = twitter_buddy_msg;
    735728        ret->get_info = twitter_get_info;
    736         ret->set_my_name = twitter_set_my_name;
    737729        ret->add_buddy = twitter_add_buddy;
    738730        ret->remove_buddy = twitter_remove_buddy;
Note: See TracChangeset for help on using the changeset viewer.