Changeset f932b65 for skype


Ignore:
Timestamp:
2007-08-20T18:56:46Z (17 years ago)
Author:
VMiklos <vmiklos@…>
Branches:
master
Children:
565982f
Parents:
62bb4e4
Message:

skyped: some cleanup, no encoding is needed when sending messages

File:
1 edited

Legend:

Unmodified
Added
Removed
  • skype/skyped.py

    r62bb4e4 rf932b65  
    1515CLIENT_NAME = 'SkypeApiPythonShell'
    1616
    17 local_encoding = locale.getdefaultlocale()[1]
    18 need_conv = (local_encoding != 'utf-8')
    19 
    2017# well, this is a bit hackish. we store the socket of the last connected client
    2118# here and notify it. maybe later notify all connected clients?
    2219conn = None
    23 
    24 def utf8_decode(utf8_str):
    25         if need_conv:
    26                 return utf8_str.decode('utf-8').encode(local_encoding, 'replace')
    27         else:
    28                 return utf8_str
    29 
    30 def utf8_encode(local_str):
    31         if need_conv:
    32                 return local_str.decode(local_encoding).encode('utf-8')
    33         else:
    34                 return local_str
    3520
    3621def sig_handler(signum, frame):
     
    4126        for i in input.split("\n"):
    4227                if i:
    43                         fd.send(skype.send(i.strip()) + "\n")
     28                        fd.send((skype.send(i.strip()) + "\n").encode(locale.getdefaultlocale()[1]))
    4429        return True
    4530
     
    8166        def Notify(self, msg_text):
    8267                global conn
    83                 text = utf8_decode(msg_text)
    84                 dprint('<< ' + text)
     68                dprint('<< ' + msg_text)
    8569                if conn:
    8670                        conn.send(msg_text + "\n")
     
    9276                dprint('>> ' + msg_text)
    9377                try:
    94                         reply = utf8_decode(self.skype_api.Invoke(utf8_encode(msg_text)))
     78                        reply = self.skype_api.Invoke(msg_text)
    9579                except dbus.exceptions.DBusException, s:
    9680                        reply = str(s)
Note: See TracChangeset for help on using the changeset viewer.