diff options
author | VMiklos <vmiklos@frugalware.org> | 2007-09-04 00:22:55 +0200 |
---|---|---|
committer | VMiklos <vmiklos@frugalware.org> | 2007-09-04 00:22:55 +0200 |
commit | 761367025bcb4a711f07715a91076769a3297531 (patch) | |
tree | bb0ab099d44587c12ebc1c833f09215d47236b8d | |
parent | 02a531b69a273c4ead692d18b24b3d7c953996e6 (diff) |
handle the case when the input is a multiline message
-rw-r--r-- | skype/skype.c | 4 | ||||
-rw-r--r-- | skype/skyped.py | 18 |
2 files changed, 17 insertions, 5 deletions
diff --git a/skype/skype.c b/skype/skype.c index 2d4e8676..7dfd3a26 100644 --- a/skype/skype.c +++ b/skype/skype.c @@ -260,6 +260,7 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c * it, then we can later use it * when we got the message's * body. */ + g_free(sd->handle); sd->handle = g_strdup_printf("%s@skype.com", info); } else if(!strncmp(info, "BODY ", 5)) @@ -269,8 +270,6 @@ static gboolean skype_read_callback( gpointer data, gint fd, b_input_condition c { /* New body, we have everything to use imcb_buddy_msg() now! */ imcb_buddy_msg(ic, sd->handle, info, 0, 0); - g_free(sd->handle); - sd->handle = NULL; } } } @@ -379,6 +378,7 @@ static void skype_logout( struct im_connection *ic ) g_free(buf); g_free(sd->username); + g_free(sd->handle); g_free(sd); ic->proto_data = NULL; } diff --git a/skype/skyped.py b/skype/skyped.py index 6d56cf82..186d38cc 100644 --- a/skype/skyped.py +++ b/skype/skyped.py @@ -52,7 +52,8 @@ def input_handler(fd, io_condition): input = fd.recv(1024) for i in input.split("\n"): if i: - fd.send((skype.send(i.strip()) + "\n").encode(locale.getdefaultlocale()[1])) + for j in skype.send(i.strip()): + fd.send((j + "\n").encode(locale.getdefaultlocale()[1])) return True def server(host, port): @@ -84,7 +85,7 @@ class SkypeApi(dbus.service.Object): sys.exit("Can't find any Skype instance. Are you sure you have started Skype?") reply = self.send('NAME ' + CLIENT_NAME) - if reply != 'OK': + if reply[0] != 'OK': sys.exit('Could not bind to Skype client') reply = self.send('PROTOCOL 5') @@ -116,7 +117,18 @@ class SkypeApi(dbus.service.Object): except LookupError: pass mainloop.quit() - dprint('<< ' + reply) + if "\n" in reply: + # crappy skype prefixes only the first line for + # multiline messages so we need to do so for the other + # lines, too. this is something like: + # 'CHATMESSAGE id BODY first line\nsecond line' -> + # 'CHATMESSAGE id BODY first line\nCHATMESSAGE id BODY second line' + prefix = " ".join(reply.split(" ")[:3]) + reply = ["%s %s" % (prefix, i) for i in " ".join(reply.split(" ")[3:]).split("\n")] + else: + reply = [reply] + for i in reply: + dprint('<< ' + i) return reply class Options: |