1 '''
2 Low-level Skype API definitions.
3
4 This module imports one of the:
5 - L{Skype4Py.API.darwin}
6 - L{Skype4Py.API.posix}
7 - L{Skype4Py.API.windows}
8 submodules based on the platform.
9 '''
10
11 import sys
12 import threading
13 from Skype4Py.utils import *
14 from Skype4Py.enums import *
15 from Skype4Py.errors import ISkypeAPIError
16
17
19 '''Represents an API command. Use L{ISkype.Command<skype.ISkype.Command>} to instatinate.
20
21 To send a command to Skype, use L{ISkype.SendCommand<skype.ISkype.SendCommand>}.
22 '''
23
24 - def __init__(self, Id, Command, Expected=u'', Blocking=False, Timeout=30000):
25 '''Use L{ISkype.Command<skype.ISkype.Command>} to instatinate the object instead.
26 '''
27
28 self.Blocking = Blocking
29 '''If set to True, L{ISkype.SendCommand<skype.ISkype.SendCommand>} will block until the reply is received.
30 @type: bool'''
31
32 self.Command = unicode(Command)
33 '''Command string.
34 @type: unicode'''
35
36 self.Expected = unicode(Expected)
37 '''Expected reply.
38 @type: unicode'''
39
40 self.Id = Id
41 '''Command Id.
42 @type: int'''
43
44 self.Reply = u''
45 '''Reply after the command has been sent and Skype has replied.
46 @type: unicode'''
47
48 self.Timeout = Timeout
49 '''Timeout in milliseconds if Blocking=True.
50 @type: int'''
51
53 return '<%s with Id=%s, Command=%s, Blocking=%s, Reply=%s>' % \
54 (object.__repr__(self)[1:-1], self.Id, repr(self.Command), self.Blocking, repr(self.Reply))
55
56
68
71
73 for h in self.Handlers:
74 if h() == Handler:
75 return
76 self.Handlers.append(WeakCallableRef(Handler))
77
79 self.Handlers = filter(lambda x: x(), self.Handlers)
80
82 self.UpdateHandlers()
83 return len(self.Handlers)
84
86 for h in self.Handlers:
87 f = h()
88 if f:
89 f(mode, arg)
90
102
104 self.CommandsLock.acquire()
105 try:
106 Command = self.Commands[Id]
107 del self.Commands[Id]
108 except KeyError:
109 Command = None
110 self.CommandsLock.release()
111 return Command
112
115
117 self.DebugLevel = Level
118
120 if self.DebugLevel >= kwargs.get('Level', 1):
121 print >>sys.stderr, 'Skype4Py/API', ' '.join(('%s',) * len(args)) % args
122
125
131
132 - def Attach(self, Timeout=30000, Wait=True):
133 self._NotImplemented()
134
136 self._NotImplemented()
137
138 - def Start(self, Minimized=False, Nosplash=False):
139 self._NotImplemented()
140
142 self._NotImplemented()
143
145 self._NotImplemented()
146
148 self._NotImplemented()
149
150 - def EnableApiSecurityContext(self, Context):
151 self._NotImplemented()
152
153
154
155 if sys.platform[:3] == 'win':
156 from windows import _ISkypeAPI
157 elif sys.platform == 'darwin':
158 from darwin import _ISkypeAPI
159 else:
160 from posix import _ISkypeAPI
161