Package Skype4Py :: Module skype
[frames] | no frames]

Source Code for Module Skype4Py.skype

   1  '''Main Skype interface. 
   2  ''' 
   3   
   4  from API import ICommand, _ISkypeAPI 
   5  from errors import * 
   6  from enums import * 
   7  from utils import * 
   8  from conversion import * 
   9  from client import * 
  10  from user import * 
  11  from call import * 
  12  from profile import * 
  13  from settings import * 
  14  from chat import * 
  15  from application import * 
  16  from voicemail import * 
  17  from sms import * 
  18  from filetransfer import * 
  19  import threading 
  20   
  21   
22 -class ISkype(EventHandlingBase):
23 '''The main class which you have to instatinate to get access to Skype client. 24 25 1. Usage. 26 27 You should access this class using the alias at the package level:: 28 29 import Skype4Py 30 31 skype = Skype4Py.Skype() 32 33 For possible constructor arguments, read the L{ISkype.__init__} description. 34 35 2. Events. 36 37 This class provides events. 38 39 The events names and their arguments lists can be found in L{ISkypeEvents} class. 40 41 The usage of events is described in L{EventHandlingBase} class which is a superclass of 42 this class. Follow the link for more information. 43 44 @newfield option: Option, Options 45 46 @ivar OnNotify: Event handler for L{ISkypeEvents.Notify} event. See L{EventHandlingBase} for more information on events. 47 @type OnNotify: callable 48 49 @ivar OnCommand: Event handler for L{ISkypeEvents.Command} event. See L{EventHandlingBase} for more information on events. 50 @type OnCommand: callable 51 52 @ivar OnReply: Event handler for L{ISkypeEvents.Reply} event. See L{EventHandlingBase} for more information on events. 53 @type OnReply: callable 54 55 @ivar OnError: Event handler for L{ISkypeEvents.Error} event. See L{EventHandlingBase} for more information on events. 56 @type OnError: callable 57 58 @ivar OnAttachmentStatus: Event handler for L{ISkypeEvents.AttachmentStatus} event. See L{EventHandlingBase} for more information on events. 59 @type OnAttachmentStatus: callable 60 61 @ivar OnConnectionStatus: Event handler for L{ISkypeEvents.ConnectionStatus} event. See L{EventHandlingBase} for more information on events. 62 @type OnConnectionStatus: callable 63 64 @ivar OnUserStatus: Event handler for L{ISkypeEvents.UserStatus} event. See L{EventHandlingBase} for more information on events. 65 @type OnUserStatus: callable 66 67 @ivar OnOnlineStatus: Event handler for L{ISkypeEvents.OnlineStatus} event. See L{EventHandlingBase} for more information on events. 68 @type OnOnlineStatus: callable 69 70 @ivar OnCallStatus: Event handler for L{ISkypeEvents.CallStatus} event. See L{EventHandlingBase} for more information on events. 71 @type OnCallStatus: callable 72 73 @ivar OnCallHistory: Event handler for L{ISkypeEvents.CallHistory} event. See L{EventHandlingBase} for more information on events. 74 @type OnCallHistory: callable 75 76 @ivar OnMute: Event handler for L{ISkypeEvents.Mute} event. See L{EventHandlingBase} for more information on events. 77 @type OnMute: callable 78 79 @ivar OnMessageStatus: Event handler for L{ISkypeEvents.MessageStatus} event. See L{EventHandlingBase} for more information on events. 80 @type OnMessageStatus: callable 81 82 @ivar OnMessageHistory: Event handler for L{ISkypeEvents.MessageHistory} event. See L{EventHandlingBase} for more information on events. 83 @type OnMessageHistory: callable 84 85 @ivar OnAutoAway: Event handler for L{ISkypeEvents.AutoAway} event. See L{EventHandlingBase} for more information on events. 86 @type OnAutoAway: callable 87 88 @ivar OnCallDtmfReceived: Event handler for L{ISkypeEvents.CallDtmfReceived} event. See L{EventHandlingBase} for more information on events. 89 @type OnCallDtmfReceived: callable 90 91 @ivar OnVoicemailStatus: Event handler for L{ISkypeEvents.VoicemailStatus} event. See L{EventHandlingBase} for more information on events. 92 @type OnVoicemailStatus: callable 93 94 @ivar OnApplicationConnecting: Event handler for L{ISkypeEvents.ApplicationConnecting} event. See L{EventHandlingBase} for more information on events. 95 @type OnApplicationConnecting: callable 96 97 @ivar OnApplicationStreams: Event handler for L{ISkypeEvents.ApplicationStreams} event. See L{EventHandlingBase} for more information on events. 98 @type OnApplicationStreams: callable 99 100 @ivar OnApplicationDatagram: Event handler for L{ISkypeEvents.ApplicationDatagram} event. See L{EventHandlingBase} for more information on events. 101 @type OnApplicationDatagram: callable 102 103 @ivar OnApplicationSending: Event handler for L{ISkypeEvents.ApplicationSending} event. See L{EventHandlingBase} for more information on events. 104 @type OnApplicationSending: callable 105 106 @ivar OnApplicationReceiving: Event handler for L{ISkypeEvents.ApplicationReceiving} event. See L{EventHandlingBase} for more information on events. 107 @type OnApplicationReceiving: callable 108 109 @ivar OnContactsFocused: Event handler for L{ISkypeEvents.ContactsFocused} event. See L{EventHandlingBase} for more information on events. 110 @type OnContactsFocused: callable 111 112 @ivar OnGroupVisible: Event handler for L{ISkypeEvents.GroupVisible} event. See L{EventHandlingBase} for more information on events. 113 @type OnGroupVisible: callable 114 115 @ivar OnGroupExpanded: Event handler for L{ISkypeEvents.GroupExpanded} event. See L{EventHandlingBase} for more information on events. 116 @type OnGroupExpanded: callable 117 118 @ivar OnGroupUsers: Event handler for L{ISkypeEvents.GroupUsers} event. See L{EventHandlingBase} for more information on events. 119 @type OnGroupUsers: callable 120 121 @ivar OnGroupDeleted: Event handler for L{ISkypeEvents.GroupDeleted} event. See L{EventHandlingBase} for more information on events. 122 @type OnGroupDeleted: callable 123 124 @ivar OnUserMood: Event handler for L{ISkypeEvents.UserMood} event. See L{EventHandlingBase} for more information on events. 125 @type OnUserMood: callable 126 127 @ivar OnSmsMessageStatusChanged: Event handler for L{ISkypeEvents.SmsMessageStatusChanged} event. See L{EventHandlingBase} for more information on events. 128 @type OnSmsMessageStatusChanged: callable 129 130 @ivar OnSmsTargetStatusChanged: Event handler for L{ISkypeEvents.SmsTargetStatusChanged} event. See L{EventHandlingBase} for more information on events. 131 @type OnSmsTargetStatusChanged: callable 132 133 @ivar OnCallInputStatusChanged: Event handler for L{ISkypeEvents.CallInputStatusChanged} event. See L{EventHandlingBase} for more information on events. 134 @type OnCallInputStatusChanged: callable 135 136 @ivar OnAsyncSearchUsersFinished: Event handler for L{ISkypeEvents.AsyncSearchUsersFinished} event. See L{EventHandlingBase} for more information on events. 137 @type OnAsyncSearchUsersFinished: callable 138 139 @ivar OnCallSeenStatusChanged: Event handler for L{ISkypeEvents.CallSeenStatusChanged} event. See L{EventHandlingBase} for more information on events. 140 @type OnCallSeenStatusChanged: callable 141 142 @ivar OnPluginEventClicked: Event handler for L{ISkypeEvents.PluginEventClicked} event. See L{EventHandlingBase} for more information on events. 143 @type OnPluginEventClicked: callable 144 145 @ivar OnPluginMenuItemClicked: Event handler for L{ISkypeEvents.PluginMenuItemClicked} event. See L{EventHandlingBase} for more information on events. 146 @type OnPluginMenuItemClicked: callable 147 148 @ivar OnWallpaperChanged: Event handler for L{ISkypeEvents.WallpaperChanged} event. See L{EventHandlingBase} for more information on events. 149 @type OnWallpaperChanged: callable 150 151 @ivar OnFileTransferStatusChanged: Event handler for L{ISkypeEvents.FileTransferStatusChanged} event. See L{EventHandlingBase} for more information on events. 152 @type OnFileTransferStatusChanged: callable 153 154 @ivar OnCallTransferStatusChanged: Event handler for L{ISkypeEvents.CallTransferStatusChanged} event. See L{EventHandlingBase} for more information on events. 155 @type OnCallTransferStatusChanged: callable 156 157 @ivar OnChatMembersChanged: Event handler for L{ISkypeEvents.ChatMembersChanged} event. See L{EventHandlingBase} for more information on events. 158 @type OnChatMembersChanged: callable 159 160 @ivar OnChatMemberRoleChanged: Event handler for L{ISkypeEvents.ChatMemberRoleChanged} event. See L{EventHandlingBase} for more information on events. 161 @type OnChatMemberRoleChanged: callable 162 163 @ivar OnCallVideoReceiveStatusChanged: Event handler for L{ISkypeEvents.CallVideoReceiveStatusChanged} event. See L{EventHandlingBase} for more information on events. 164 @type OnCallVideoReceiveStatusChanged: callable 165 166 @ivar OnCallVideoSendStatusChanged: Event handler for L{ISkypeEvents.CallVideoSendStatusChanged} event. See L{EventHandlingBase} for more information on events. 167 @type OnCallVideoSendStatusChanged: callable 168 169 @ivar OnCallVideoStatusChanged: Event handler for L{ISkypeEvents.CallVideoStatusChanged} event. See L{EventHandlingBase} for more information on events. 170 @type OnCallVideoStatusChanged: callable 171 172 @ivar OnChatWindowState: Event handler for L{ISkypeEvents.ChatWindowState} event. See L{EventHandlingBase} for more information on events. 173 @type OnChatWindowState: callable 174 175 @ivar OnClientWindowState: Event handler for L{ISkypeEvents.ClientWindowState} event. See L{EventHandlingBase} for more information on events. 176 @type OnClientWindowState: callable 177 ''' 178
179 - def __init__(self, Events=None, **Options):
180 '''Initializes the object. 181 182 @param Events: An optional object with event handlers. See L{EventHandlingBase} for more information on events. 183 @type Events: object 184 @param Options: Addtional options for the low-level API handler. For supported options, go to L{Skype4Py.API} 185 subpackage and select your platform. 186 @type Options: kwargs 187 ''' 188 EventHandlingBase.__init__(self) 189 if Events: 190 self._SetEventHandlerObj(Events) 191 192 self._API = _ISkypeAPI(self._Handler, Options) 193 194 self._Cache = True 195 self.ResetCache() 196 197 self._Timeout = 30000 198 199 self._Convert = IConversion(self) 200 self._Client = IClient(self) 201 self._Settings = ISettings(self) 202 self._Profile = IProfile(self)
203
204 - def __del__(self):
205 '''Frees all resources. 206 ''' 207 if hasattr(self, '_API'): 208 self._API.Close()
209
210 - def _Handler(self, mode, arg):
211 # low-level API callback 212 if mode == 'rece_api': 213 self._CallEventHandler('Notify', arg) 214 a, b = chop(arg) 215 ObjectType = None 216 # if..elif handling cache and most event handlers 217 if a in ('CALL', 'USER', 'GROUP', 'CHAT', 'CHATMESSAGE', 'CHATMEMBER', 'VOICEMAIL', 'APPLICATION', 'SMS', 'FILETRANSFER'): 218 ObjectType, ObjectId, PropName, Value = [a] + chop(b, 2) 219 self._CacheDict[str(ObjectType), str(ObjectId), str(PropName)] = Value 220 if ObjectType == 'USER': 221 o = IUser(ObjectId, self) 222 if PropName == 'ONLINESTATUS': 223 self._CallEventHandler('OnlineStatus', o, Value) 224 elif PropName == 'MOOD_TEXT' or PropName == 'RICH_MOOD_TEXT': 225 self._CallEventHandler('UserMood', o, Value) 226 elif PropName == 'RECEIVEDAUTHREQUEST': 227 self._CallEventHandler('UserAuthorizationRequestReceived', o) 228 elif ObjectType == 'CALL': 229 o = ICall(ObjectId, self) 230 if PropName == 'STATUS': 231 self._CallEventHandler('CallStatus', o, Value) 232 elif PropName == 'SEEN': 233 self._CallEventHandler('CallSeenStatusChanged', o, Value == 'TRUE') 234 elif PropName == 'VAA_INPUT_STATUS': 235 self._CallEventHandler('CallInputStatusChanged', o, Value == 'TRUE') 236 elif PropName == 'TRANSFER_STATUS': 237 self._CallEventHandler('CallTransferStatusChanged', o, Value) 238 elif PropName == 'DTMF': 239 self._CallEventHandler('CallDtmfReceived', o, Value) 240 elif PropName == 'VIDEO_STATUS': 241 self._CallEventHandler('CallVideoStatusChanged', o, Value) 242 elif PropName == 'VIDEO_SEND_STATUS': 243 self._CallEventHandler('CallVideoSendStatusChanged', o, Value) 244 elif PropName == 'VIDEO_RECEIVE_STATUS': 245 self._CallEventHandler('CallVideoReceiveStatusChanged', o, Value) 246 elif ObjectType == 'CHAT': 247 o = IChat(ObjectId, self) 248 if PropName == 'MEMBERS': 249 self._CallEventHandler('ChatMembersChanged', o, tuple([IUser(x, self) for x in esplit(Value)])) 250 if PropName in ('OPENED', 'CLOSED'): 251 self._CallEventHandler('ChatWindowState', o, PropName == 'OPENED') 252 elif ObjectType == 'CHATMEMBER': 253 o = IChatMember(ObjectId, self) 254 if PropName == 'ROLE': 255 self._CallEventHandler('ChatMemberRoleChanged', o, Value) 256 elif ObjectType == 'CHATMESSAGE': 257 o = IChatMessage(ObjectId, self) 258 if PropName == 'STATUS': 259 self._CallEventHandler('MessageStatus', o, Value) 260 elif ObjectType == 'APPLICATION': 261 o = IApplication(ObjectId, self) 262 if PropName == 'CONNECTING': 263 self._CallEventHandler('ApplicationConnecting', o, tuple([IUser(x, self) for x in esplit(Value)])) 264 elif PropName == 'STREAMS': 265 self._CallEventHandler('ApplicationStreams', o, tuple([IApplicationStream(x, o) for x in esplit(Value)])) 266 elif PropName == 'DATAGRAM': 267 handle, text = chop(Value) 268 self._CallEventHandler('ApplicationDatagram', o, IApplicationStream(handle, o), text) 269 elif PropName == 'SENDING': 270 self._CallEventHandler('ApplicationSending', o, tuple([IApplicationStream(x.split('=')[0], o) for x in esplit(Value)])) 271 elif PropName == 'RECEIVED': 272 self._CallEventHandler('ApplicationReceiving', o, tuple([IApplicationStream(x.split('=')[0], o) for x in esplit(Value)])) 273 elif ObjectType == 'GROUP': 274 o = IGroup(ObjectId, self) 275 if PropName == 'VISIBLE': 276 self._CallEventHandler('GroupVisible', o, Value == 'TRUE') 277 elif PropName == 'EXPANDED': 278 self._CallEventHandler('GroupExpanded', o, Value == 'TRUE') 279 elif PropName == 'USERS': 280 self._CallEventHandler('GroupUsers', o, tuple([IUser(x, self) for x in esplit(Value, ', ')])) 281 elif ObjectType == 'SMS': 282 o = ISmsMessage(ObjectId, self) 283 if PropName == 'STATUS': 284 self._CallEventHandler('SmsMessageStatusChanged', o, Value) 285 elif PropName == 'TARGET_STATUSES': 286 for t in esplit(Value, ', '): 287 number, status = t.split('=') 288 self._CallEventHandler('SmsTargetStatusChanged', ISmsTarget((number, o)), status) 289 elif ObjectType == 'FILETRANSFER': 290 o = IFileTransfer(ObjectId, self) 291 if PropName == 'STATUS': 292 self._CallEventHandler('FileTransferStatusChanged', o, Value) 293 elif ObjectType == 'VOICEMAIL': 294 o = IVoicemail(ObjectId, self) 295 if PropName == 'STATUS': 296 self._CallEventHandler('VoicemailStatus', o, Value) 297 elif a in ('PROFILE', 'PRIVILEGE'): 298 ObjectType, ObjectId, PropName, Value = [a, ''] + chop(b) 299 self._CacheDict[str(ObjectType), str(ObjectId), str(PropName)] = Value 300 elif a in ('CURRENTUSERHANDLE', 'USERSTATUS', 'CONNSTATUS', 'PREDICTIVE_DIALER_COUNTRY', 'SILENT_MODE', 'AUDIO_IN', 'AUDIO_OUT', 'RINGER', 'MUTE', 'AUTOAWAY', 'WINDOWSTATE'): 301 ObjectType, ObjectId, PropName, Value = [a, '', '', b] 302 self._CacheDict[str(ObjectType), str(ObjectId), str(PropName)] = Value 303 if ObjectType == 'MUTE': 304 self._CallEventHandler('Mute', Value == 'TRUE') 305 elif ObjectType == 'CONNSTATUS': 306 self._CallEventHandler('ConnectionStatus', Value) 307 elif ObjectType == 'USERSTATUS': 308 self._CallEventHandler('UserStatus', Value) 309 elif ObjectType == 'AUTOAWAY': 310 self._CallEventHandler('AutoAway', Value == 'ON') 311 elif ObjectType == 'WINDOWSTATE': 312 self._CallEventHandler('ClientWindowState', Value) 313 elif ObjectType == 'SILENT_MODE': 314 self._CallEventHandler('SilentModeStatusChanged', Value == 'ON') 315 elif a == 'CALLHISTORYCHANGED': 316 self._CallEventHandler('CallHistory') 317 elif a == 'IMHISTORYCHANGED': 318 self._CallEventHandler('MessageHistory', u'') 319 elif a == 'CONTACTS': 320 PropName, Value = chop(b) 321 if PropName == 'FOCUSED': 322 self._CallEventHandler('ContactsFocused', Value) 323 elif a == 'DELETED': 324 PropName, Value = chop(b) 325 if PropName == 'GROUP': 326 self._CallEventHandler('GroupDeleted', int(Value)) 327 elif a == 'EVENT': 328 ObjectId, PropName, Value = chop(b, 2) 329 if PropName == 'CLICKED': 330 self._CallEventHandler('PluginEventClicked', IPluginEvent(ObjectId, self)) 331 elif a == 'MENU_ITEM': 332 ObjectId, PropName, Value = chop(b, 2) 333 if PropName == 'CLICKED': 334 i = Value.rfind('CONTEXT ') 335 if i >= 0: 336 context = chop(Value[i+8:])[0] 337 users = () 338 context_id = u'' 339 if context in (pluginContextContact, pluginContextCall, pluginContextChat): 340 users = tuple([IUser(x, self) for x in esplit(Value[:i-1], ', ')]) 341 if context in (pluginContextCall, pluginContextChat): 342 j = Value.rfind('CONTEXT_ID ') 343 if j >= 0: 344 context_id = chop(Value[j+11:])[0] 345 self._CallEventHandler('PluginMenuItemClicked', IPluginMenuItem(ObjectId, self), users, context, context_id) 346 elif a == 'WALLPAPER': 347 self._CallEventHandler('WallpaperChanged', b) 348 elif mode == 'rece': 349 self._CallEventHandler('Reply', arg) 350 elif mode == 'send': 351 self._CallEventHandler('Command', arg) 352 elif mode == 'attach': 353 self._CallEventHandler('AttachmentStatus', arg) 354 if arg == apiAttachRefused: 355 raise ISkypeAPIError('Skype connection refused')
356
357 - def _DoCommand(self, com, reply=''):
358 command = ICommand(-1, com, reply, True, self.Timeout) 359 self.SendCommand(command) 360 a, b = chop(command.Reply) 361 if a == 'ERROR': 362 errnum, errstr = chop(b) 363 self._CallEventHandler('Error', command, int(errnum), errstr) 364 raise ISkypeError(int(errnum), errstr) 365 if not command.Reply.startswith(command.Expected): 366 raise ISkypeError(0, 'Unexpected reply from Skype, got [%s], expected [%s]' % \ 367 (command.Reply, command.Expected)) 368 return command.Reply
369
370 - def _Property(self, ObjectType, ObjectId, PropName, Set=None, Cache=True):
371 h = (str(ObjectType), str(ObjectId), str(PropName)) 372 arg = ('%s %s %s' % h).split() 373 while '' in arg: 374 arg.remove('') 375 jarg = ' '.join(arg) 376 if Set == None: # Get 377 if Cache and self._Cache and h in self._CacheDict: 378 return self._CacheDict[h] 379 Value = self._DoCommand('GET %s' % jarg, jarg) 380 while arg: 381 try: 382 a, b = chop(Value) 383 except ValueError: 384 break 385 if a.lower() != arg[0].lower(): 386 break 387 del arg[0] 388 Value = b 389 if Cache and self._Cache: 390 self._CacheDict[h] = Value 391 return Value 392 else: # Set 393 Value = unicode(Set) 394 self._DoCommand('SET %s %s' % (jarg, Value), jarg) 395 if Cache and self._Cache: 396 self._CacheDict[h] = Value
397
398 - def _Alter(self, ObjectType, ObjectId, AlterName, Args=None, Reply=None):
399 com = 'ALTER %s %s %s' % (str(ObjectType), str(ObjectId), str(AlterName)) 400 if Reply == None: 401 Reply = com 402 if Args != None: 403 com = '%s %s' % (com, Args) 404 reply = self._DoCommand(com, Reply) 405 arg = com.split() 406 while arg: 407 try: 408 a, b = chop(reply) 409 except ValueError: 410 break 411 if a.lower() != arg[0].lower(): 412 break 413 del arg[0] 414 reply = b 415 return reply
416
417 - def _Search(self, ObjectType, Args=None):
418 com = 'SEARCH %s' % ObjectType 419 if Args != None: 420 com = '%s %s' % (com, Args) 421 return tuple(esplit(chop(self._DoCommand(com))[-1], ', '))
422
423 - def ApiSecurityContextEnabled(self, Context):
424 '''Queries if an API security context for Internet Explorer is enabled. 425 426 @param Context: API security context to check. 427 @type Context: unicode 428 @return: True if the API security for the given context is enabled, False elsewhere. 429 @rtype: bool 430 431 @warning: This functionality isn't supported by Skype4Py. 432 ''' 433 self._API.ApiSecurityContextEnabled(Context)
434
435 - def Application(self, Name):
436 '''Queries an application object. 437 438 @param Name: Application name. 439 @type Name: unicode 440 @return: The application object. 441 @rtype: L{IApplication} 442 ''' 443 return IApplication(Name, self)
444
445 - def _AsyncSearchUsersReplyHandler(self, Command):
446 if Command in self._AsyncSearchUsersCommands: 447 self._AsyncSearchUsersCommands.remove(Command) 448 self._CallEventHandler('AsyncSearchUsersFinished', Command.Id, 449 tuple([IUser(x, self) for x in esplit(chop(Command.Reply)[-1], ', ')])) 450 if len(self._AsyncSearchUsersCommands) == 0: 451 self.UnregisterEventHandler('Reply', self._AsyncSearchUsersReplyHandler) 452 del self._AsyncSearchUsersCommands
453
454 - def AsyncSearchUsers(self, Target):
455 '''Asynchronously searches for Skype users. 456 457 @param Target: Search target (name or email address). 458 @type Target: unicode 459 @return: A search identifier. It will be passed along with the results to the 460 L{ISkypeEvents.AsyncSearchUsersFinished} event after the search is completed. 461 @rtype: int 462 ''' 463 if not hasattr(self, '_AsyncSearchUsersCommands'): 464 self._AsyncSearchUsersCommands = [] 465 self.RegisterEventHandler('Reply', self._AsyncSearchUsersReplyHandler) 466 Command = ICommand(-1, 'SEARCH USERS %s' % Target, 'USERS', False, self.Timeout) 467 self._AsyncSearchUsersCommands.append(Command) 468 self.SendCommand(Command) 469 # return pCookie - search identifier 470 return Command.Id
471
472 - def Attach(self, Protocol=5, Wait=True):
473 '''Establishes a connection to Skype. 474 475 @param Protocol: Minimal Skype protocol version. 476 @type Protocol: int 477 @param Wait: If set to False, blocks forever until the connection is established. 478 Otherwise, timeouts after the L{Timeout}. 479 @type Wait: bool 480 ''' 481 try: 482 self._API.Protocol = Protocol 483 self._API.Attach(self.Timeout, Wait) 484 except ISkypeAPIError: 485 self.ResetCache() 486 raise
487
488 - def Call(self, Id=0):
489 '''Queries a call object. 490 491 @param Id: Call identifier. 492 @type Id: int 493 @return: Call object. 494 @rtype: L{ICall} 495 ''' 496 o = ICall(Id, self) 497 o.Status 498 return o
499
500 - def Calls(self, Target=''):
501 '''Queries calls in call history. 502 503 @param Target: Call target. 504 @type Target: unicode 505 @return: Call objects. 506 @rtype: tuple of L{ICall} 507 ''' 508 return tuple([ICall(x, self) for x in self._Search('CALLS', Target)])
509
510 - def __ChangeUserStatus_UserStatus_Handler(self, status):
511 if status.upper() == self.__ChangeUserStatus_Val: 512 self.__ChangeUserStatus_Event.set()
513
514 - def ChangeUserStatus(self, Val):
515 '''Changes the online status for the current user. 516 517 @param Val: New online status for the user. 518 @type Val: L{User status<enums.cusUnknown>} 519 520 @note: This function waits until the online status changes. Alternatively, use 521 the L{CurrentUserStatus} property to perform an immediate change of status. 522 ''' 523 if self.CurrentUserStatus.upper() == Val.upper(): 524 return 525 self.__ChangeUserStatus_Event = threading.Event() 526 self.__ChangeUserStatus_Val = Val.upper() 527 self.RegisterEventHandler('UserStatus', self.__ChangeUserStatus_UserStatus_Handler) 528 self.CurrentUserStatus = Val 529 self.__ChangeUserStatus_Event.wait() 530 self.UnregisterEventHandler('UserStatus', self.__ChangeUserStatus_UserStatus_Handler) 531 del self.__ChangeUserStatus_Event, self.__ChangeUserStatus_Val
532
533 - def Chat(self, Name=''):
534 '''Queries a chat object. 535 536 @param Name: Chat name. 537 @type Name: unicode 538 @return: A chat object. 539 @rtype: L{IChat} 540 ''' 541 o = IChat(Name, self) 542 o.Status 543 return o
544
545 - def ClearCallHistory(self, Username='ALL', Type=chsAllCalls):
546 '''Clears the call history. 547 548 @param Username: Skypename of the user. A special value of 'ALL' means that entries of all users should 549 be removed. 550 @type Username: unicode 551 @param Type: Call type. 552 @type Type: L{Call type<enums.cltUnknown>} 553 ''' 554 self._DoCommand('CLEAR CALLHISTORY %s %s' % (str(Type), Username))
555
556 - def ClearChatHistory(self):
557 '''Clears the chat history. 558 ''' 559 self._DoCommand('CLEAR CHATHISTORY')
560
561 - def ClearVoicemailHistory(self):
562 '''Clears the voicemail history. 563 ''' 564 self._DoCommand('CLEAR VOICEMAILHISTORY')
565
566 - def Command(self, Command, Reply=u'', Block=False, Timeout=30000, Id=-1):
567 '''Creates an API command object. 568 569 @param Command: Command string. 570 @type Command: unicode 571 @param Reply: Expected reply. By default any reply is accepted (except errors 572 which raise an L{ISkypeError} exception). 573 @type Reply: unicode 574 @param Block: If set to True, L{SendCommand} method waits for a response from Skype API before returning. 575 @type Block: bool 576 @param Timeout: Timeout in milliseconds. Used if Block=True. 577 @type Timeout: int 578 @param Id: Command Id. The default (-1) means it will be assigned automatically as soon as the command is sent. 579 @type Id: int 580 @return: A command object. 581 @rtype: L{ICommand} 582 @see: L{SendCommand} 583 ''' 584 return ICommand(Id, Command, Reply, Block, Timeout)
585
586 - def Conference(self, Id=0):
587 '''Queries a call conference object. 588 589 @param Id: Conference Id. 590 @type Id: int 591 @return: A conference object. 592 @rtype: L{IConference} 593 ''' 594 o = IConference(Id, self) 595 if Id <= 0 or not o.Calls: 596 raise ISkypeError(0, 'Unknown conference') 597 return o
598
599 - def CreateChatUsingBlob(self, Blob):
600 '''Returns existing or joins a new chat using given blob. 601 602 @param Blob: A blob indentifying the chat. 603 @type Blob: unicode 604 @return: A chat object 605 @rtype: L{IChat} 606 ''' 607 return IChat(chop(self._DoCommand('CHAT CREATEUSINGBLOB %s' % Blob), 2)[1], self)
608
609 - def CreateChatWith(self, *Usernames):
610 '''Creates a chat with one or more users. 611 612 @param Usernames: One or more strings with the Skypenames of the users. 613 @type Usernames: unicode 614 @return: A chat object 615 @rtype: L{IChat} 616 @see: L{IChat.AddMembers} 617 ''' 618 return IChat(chop(self._DoCommand('CHAT CREATE %s' % ', '.join(Usernames)), 2)[1], self)
619
620 - def CreateGroup(self, GroupName):
621 '''Creates a custom contact group. 622 623 @param GroupName: Group name. 624 @type GroupName: unicode 625 @return: A group object. 626 @rtype: L{IGroup} 627 @see: L{DeleteGroup} 628 ''' 629 groups = self.CustomGroups 630 self._DoCommand('CREATE GROUP %s' % GroupName) 631 for g in self.CustomGroups: 632 if g not in groups and g.DisplayName == GroupName: 633 return g 634 raise ISkypeError(0, 'Group creating failed')
635
636 - def CreateSms(self, MessageType, *TargetNumbers):
637 '''Creates an SMS message. 638 639 @param MessageType: Message type. 640 @type MessageType: L{SMS message type<enums.smsMessageTypeUnknown>} 641 @param TargetNumbers: One or more target SMS numbers. 642 @type TargetNumbers: unicode 643 @return: An sms message object. 644 @rtype: L{ISmsMessage} 645 ''' 646 return ISmsMessage(chop(self._DoCommand('CREATE SMS %s %s' % (MessageType, ', '.join(TargetNumbers))), 2)[1], self)
647
648 - def DeleteGroup(self, GroupId):
649 '''Deletes a custom contact group. 650 651 Users in the contact group are moved to the All Contacts (hardwired) contact group. 652 653 @param GroupId: Group identifier. Get it from L{IGroup.Id}. 654 @type GroupId: int 655 @see: L{CreateGroup} 656 ''' 657 self._DoCommand('DELETE GROUP %s' % GroupId)
658
659 - def EnableApiSecurityContext(self, Context):
660 '''Enables an API security context for Internet Explorer scripts. 661 662 @param Context: combination of API security context values. 663 @type Context: unicode 664 @warning: This functionality isn't supported by Skype4Py. 665 ''' 666 self._API.EnableApiSecurityContext(Context)
667
668 - def FindChatUsingBlob(self, Blob):
669 '''Returns existing chat using given blob. 670 671 @param Blob: A blob indentifying the chat. 672 @type Blob: unicode 673 @return: A chat object 674 @rtype: L{IChat} 675 ''' 676 return IChat(chop(self._DoCommand('CHAT FINDUSINGBLOB %s' % Blob), 2)[1], self)
677
678 - def Greeting(self, Username=''):
679 '''Queries the greeting used as voicemail. 680 681 @param Username: Skypename of the user. 682 @type Username: unicode 683 @return: A voicemail object. 684 @rtype: L{IVoicemail} 685 ''' 686 for v in self.Voicemails: 687 if Username and v.PartnerHandle != Username: 688 continue 689 if v.Type in (vmtDefaultGreeting, vmtCustomGreeting): 690 return v
691
692 - def Message(self, Id=0):
693 '''Queries a chat message object. 694 695 @param Id: Message Id. 696 @type Id: int 697 @return: A chat message object. 698 @rtype: L{IChatMessage} 699 ''' 700 o = IChatMessage(Id, self) 701 o.Status 702 return o
703
704 - def Messages(self, Target=''):
705 '''Queries chat messages which were sent/received by the user. 706 707 @param Target: Message sender. 708 @type Target: unicode 709 @return: Chat message objects. 710 @rtype: tuple of L{IChatMessage} 711 ''' 712 return tuple([IChatMessage(x, self) for x in self._Search('CHATMESSAGES', Target)])
713
714 - def PlaceCall(self, *Targets):
715 '''Places a call to a single user or creates a conference call. 716 717 @param Targets: One or more call targets. If multiple targets are specified, a conference 718 call is created. The call target can be a Skypename, phone number, or speed dial code. 719 @type Targets: unicode 720 @return: A call object. 721 @rtype: L{ICall} 722 ''' 723 calls = self.ActiveCalls 724 reply = self._DoCommand('CALL %s' % ', '.join(Targets)) 725 # Skype for Windows returns the call status which gives us the call Id; 726 if reply.startswith('CALL '): 727 return ICall(chop(reply, 2)[1], self) 728 # On linux we get 'OK' as reply so we search for the new call on 729 # list of active calls. 730 for c in self.ActiveCalls: 731 if c not in calls: 732 return c 733 raise ISkypeError(0, 'Placing call failed')
734
735 - def Privilege(self, Name):
736 '''Queries the Skype services (privileges) enabled for the Skype client. 737 738 @param Name: Privilege name, currently one of 'SKYPEOUT', 'SKYPEIN', 'VOICEMAIL'. 739 @type Name: unicode 740 @return: True if the priviledge is available, False otherwise. 741 @rtype: bool 742 ''' 743 return self._Property('PRIVILEGE', '', Name.upper()) == 'TRUE'
744
745 - def Profile(self, Property, Set=None):
746 '''Queries/sets user profile properties. 747 748 @param Property: Property name, currently one of 'PSTN_BALANCE', 'PSTN_BALANCE_CURRENCY', 749 'FULLNAME', 'BIRTHDAY', 'SEX', 'LANGUAGES', 'COUNTRY', 'PROVINCE', 'CITY', 'PHONE_HOME', 750 'PHONE_OFFICE', 'PHONE_MOBILE', 'HOMEPAGE', 'ABOUT'. 751 @type Property: unicode 752 @param Set: Value the property should be set to or None if the value should be queried. 753 @type Set: unicode or None 754 @return: Property value if Set=None, None otherwise. 755 @rtype: unicode or None 756 ''' 757 return self._Property('PROFILE', '', Property, Set)
758
759 - def Property(self, ObjectType, ObjectId, PropName, Set=None):
760 '''Queries/sets the properties of an object. 761 762 @param ObjectType: Object type, currently one of 'USER', 'CALL', 'CHAT', 'CHATMESSAGE', 'VOICEMAIL'. 763 @type ObjectType: unicode 764 @param ObjectId: Object Id, depends on the object type 765 @type ObjectId: unicode 766 @param PropName: Name of the property you want to access. 767 @type PropName: unicode 768 @param Set: Value the property should be set to or None if the value should be queried. 769 @type Set: unicode or None 770 @return: Property value if Set=None, None otherwise. 771 @rtype: unicode or None 772 ''' 773 return self._Property(ObjectType, ObjectId, PropName, Set)
774
775 - def ResetCache(self):
776 '''Deletes all command cache entries. 777 778 This method clears the Skype4Py's internal command cache which means that all objects will forget 779 their property values and querying them will trigger a code to get them from Skype client (and 780 cache them again). 781 ''' 782 self._CacheDict = {}
783
784 - def SearchForUsers(self, Target):
785 '''Searches for users. 786 787 @param Target: Search target (name or email address). 788 @type Target: unicode 789 @return: Found users. 790 @rtype: tuple of L{IUser} 791 ''' 792 return tuple([IUser(x, self) for x in self._Search('USERS', Target)])
793
794 - def SendCommand(self, Command):
795 '''Sends an API command. 796 797 @param Command: Command to send. Use L{Command} method to create a command. 798 @type Command: L{ICommand} 799 ''' 800 try: 801 self._API.SendCommand(Command) 802 except ISkypeAPIError: 803 self.ResetCache() 804 raise
805
806 - def SendMessage(self, Username, Text):
807 '''Sends a chat message. 808 809 @param Username: Skypename of the user. 810 @type Username: unicode 811 @param Text: Body of the message. 812 @type Text: unicode 813 @return: A chat message object. 814 @rtype: L{IChatMessage} 815 ''' 816 return self.CreateChatWith(Username).SendMessage(Text)
817
818 - def SendSms(self, *TargetNumbers, **Properties):
819 '''Creates and sends an SMS message. 820 821 @param TargetNumbers: One or more target SMS numbers. 822 @type TargetNumbers: unicode 823 @param Properties: Message properties. Properties available are same as L{ISmsMessage} object properties. 824 @type Properties: kwargs 825 @return: An sms message object. The message is already sent at this point. 826 @rtype: L{ISmsMessage} 827 ''' 828 sms = self.CreateSms(smsMessageTypeOutgoing, *TargetNumbers) 829 for prop, value in Properties.items(): 830 if hasattr(sms, prop): 831 setattr(sms, prop, value) 832 else: 833 raise TypeError('Unknown property: %s' % prop) 834 sms.Send() 835 return sms
836
837 - def SendVoicemail(self, Username):
838 '''Sends a voicemail to a specified user. 839 840 @param Username: Skypename of the user. 841 @type Username: unicode 842 @return: A voicemail object. 843 @rtype: L{IVoicemail} 844 ''' 845 if self._API.Protocol >= 6: 846 self._DoCommand('CALLVOICEMAIL %s' % Username) 847 else: 848 self._DoCommand('VOICEMAIL %s' % Username)
849
850 - def User(self, Username=''):
851 '''Queries a user object. 852 853 @param Username: Skypename of the user. 854 @type Username: unicode 855 @return: A user object. 856 @rtype: L{IUser} 857 ''' 858 o = IUser(Username, self) 859 o.OnlineStatus 860 return o
861
862 - def Variable(self, Name, Set=None):
863 '''Queries/sets Skype general parameters. 864 865 @param Name: Variable name. 866 @type Name: unicode 867 @param Set: Value the variable should be set to or None if the value should be queried. 868 @type Set: unicode or None 869 @return: Variable value if Set=None, None otherwise. 870 @rtype: unicode or None 871 ''' 872 return self._Property(Name, '', '', Set)
873
874 - def Voicemail(self, Id):
875 '''Queries the voicemail object. 876 877 @param Id: Voicemail Id. 878 @type Id: int 879 @return: A voicemail object. 880 @rtype: L{IVoicemail} 881 ''' 882 o = IVoicemail(Id, self) 883 o.Type 884 return o
885
886 - def _GetActiveCalls(self):
887 return tuple([ICall(x, self) for x in self._Search('ACTIVECALLS')])
888 889 ActiveCalls = property(_GetActiveCalls, 890 doc='''Queries a list of active calls. 891 892 @type: tuple of L{ICall} 893 ''') 894
895 - def _GetActiveChats(self):
896 return tuple([IChat(x, self) for x in self._Search('ACTIVECHATS')])
897 898 ActiveChats = property(_GetActiveChats, 899 doc='''Queries a list of active chats. 900 901 @type: tuple of L{IChat} 902 ''') 903
904 - def _GetActiveFileTransfers(self):
905 return tuple([IFileTransfer(x, self) for x in self._Search('ACTIVEFILETRANSFERS')])
906 907 ActiveFileTransfers = property(_GetActiveFileTransfers, 908 doc='''Queries currently active file transfers. 909 910 @type: tuple of L{IFileTransfer} 911 ''') 912
913 - def _GetApiDebugLevel(self):
914 return self._API.DebugLevel
915
916 - def _SetApiDebugLevel(self, value):
917 self._API.SetDebugLevel(int(value))
918 919 ApiDebugLevel = property(_GetApiDebugLevel, _SetApiDebugLevel, 920 doc='''Queries/sets the debug level of the underlying API. Currently there are 921 only two levels, 0 which means no debug information and 1 which means that the 922 commands sent to / received from the Skype client are printed to the sys.stderr. 923 924 @type: int 925 ''') 926
927 - def _GetApiWrapperVersion(self):
928 from Skype4Py import __version__ 929 return unicode(__version__)
930 931 ApiWrapperVersion = property(_GetApiWrapperVersion, 932 doc='''Returns Skype4Py version. 933 934 @type: unicode 935 ''') 936
937 - def _GetAttachmentStatus(self):
938 return self._API.AttachmentStatus
939 940 AttachmentStatus = property(_GetAttachmentStatus, 941 doc='''Queries the attachment status of the Skype client. 942 943 @type: L{Attachment status<enums.apiAttachUnknown>} 944 ''') 945
946 - def _GetBookmarkedChats(self):
947 return tuple([IChat(x, self) for x in self._Search('BOOKMARKEDCHATS')])
948 949 BookmarkedChats = property(_GetBookmarkedChats, 950 doc='''Queries a list of bookmarked chats. 951 952 @type: tuple of L{IChat} 953 ''') 954
955 - def _GetCache(self):
956 return self._Cache
957
958 - def _SetCache(self, value):
959 self._Cache = bool(value)
960 961 Cache = property(_GetCache, _SetCache, 962 doc='''Queries/sets the status of internal cache. The internal API cache is used 963 to cache Skype object properties and global parameters. 964 965 @type: bool 966 ''') 967
968 - def _GetChats(self):
969 return tuple([IChat(x, self) for x in self._Search('CHATS')])
970 971 Chats = property(_GetChats, 972 doc='''Queries a list of chats. 973 974 @type: tuple of L{IChat} 975 ''') 976
977 - def _GetClient(self):
978 return self._Client
979 980 Client = property(_GetClient, 981 doc='''Queries the user interface control object. 982 983 @type: L{IClient} 984 ''') 985
986 - def _GetCommandId(self):
987 return True
988
989 - def _SetCommandId(self, value):
990 pass
991 992 CommandId = property(_GetCommandId, _SetCommandId, 993 doc='''Queries/sets the status of automatic command identifiers. 994 995 Type: bool 996 Note: Currently it is always True. 997 998 @type: bool 999 ''') 1000
1001 - def _GetConferences(self):
1002 confs = [] 1003 for c in self.Calls(): 1004 cid = c.ConferenceId 1005 if cid > 0 and cid not in [x.Id for x in confs]: 1006 confs.append(IConference(cid, self)) 1007 return tuple(confs)
1008 1009 Conferences = property(_GetConferences, 1010 doc='''Queries a list of call conferences. 1011 1012 @type: tuple of L{IConference} 1013 ''') 1014
1015 - def _GetConnectionStatus(self):
1016 return self.Variable('CONNSTATUS')
1017 1018 ConnectionStatus = property(_GetConnectionStatus, 1019 doc='''Queries the connection status of the Skype client. 1020 1021 @type: L{Connection status<enums.conUnknown>} 1022 ''') 1023
1024 - def _GetConvert(self):
1025 return self._Convert
1026 1027 Convert = property(_GetConvert, 1028 doc='''Queries the conversion object. 1029 1030 @type: L{IConversion} 1031 ''') 1032
1033 - def _GetCurrentUser(self):
1034 return IUser(self.CurrentUserHandle, self)
1035 1036 CurrentUser = property(_GetCurrentUser, 1037 doc='''Queries the current user object. 1038 1039 @type: L{IUser} 1040 ''') 1041
1042 - def _GetCurrentUserHandle(self):
1043 return self.Variable('CURRENTUSERHANDLE')
1044 1045 CurrentUserHandle = property(_GetCurrentUserHandle, 1046 doc='''Queries the Skypename of the current user. 1047 1048 @type: unicode 1049 ''') 1050
1051 - def _GetCurrentUserProfile(self):
1052 return self._Profile
1053 1054 CurrentUserProfile = property(_GetCurrentUserProfile, 1055 doc='''Queries the user profile object. 1056 1057 @type: L{IProfile} 1058 ''') 1059
1060 - def _GetCurrentUserStatus(self):
1061 return self.Variable('USERSTATUS')
1062
1063 - def _SetCurrentUserStatus(self, value):
1064 self.Variable('USERSTATUS', str(value))
1065 1066 CurrentUserStatus = property(_GetCurrentUserStatus, _SetCurrentUserStatus, 1067 doc='''Queries/sets the online status of the current user. 1068 1069 @type: L{Online status<enums.olsUnknown>} 1070 ''') 1071
1072 - def _GetCustomGroups(self):
1073 return tuple([IGroup(x, self) for x in self._Search('GROUPS', 'CUSTOM')])
1074 1075 CustomGroups = property(_GetCustomGroups, 1076 doc='''Queries the list of custom contact groups. Custom groups are contact groups defined by the user. 1077 1078 @type: tuple of L{IGroup} 1079 ''') 1080
1081 - def _GetFileTransfers(self):
1082 return tuple([IFileTransfer(x, self) for x in self._Search('FILETRANSFERS')])
1083 1084 FileTransfers = property(_GetFileTransfers, 1085 doc='''Queries all file transfers. 1086 1087 @type: tuple of L{IFileTransfer} 1088 ''') 1089
1090 - def _GetFocusedContacts(self):
1091 # we have to use _DoCommand() directly because for unknown reason the API returns 1092 # "CONTACTS FOCUSED" instead of "CONTACTS_FOCUSED" (note the space instead of "_") 1093 return tuple([IUser(x, self) for x in esplit(chop(self._DoCommand('GET CONTACTS_FOCUSED', 'CONTACTS FOCUSED'), 2)[-1])])
1094 1095 FocusedContacts = property(_GetFocusedContacts, 1096 doc='''Queries a list of contacts selected in the contacts list. 1097 1098 @type: tuple of L{IUser} 1099 ''') 1100
1101 - def _SetFriendlyName(self, FriendlyName):
1102 self._API.SetFriendlyName(unicode(FriendlyName))
1103 1104 FriendlyName = property(fset=_SetFriendlyName, 1105 doc='''Sets a "friendly" name for an application. 1106 1107 @type: unicode 1108 ''') 1109
1110 - def _GetFriends(self):
1111 return tuple([IUser(x, self) for x in self._Search('FRIENDS')])
1112 1113 Friends = property(_GetFriends, 1114 doc='''Queries the users in a contact list. 1115 1116 @type: tuple of L{IUser} 1117 ''') 1118
1119 - def _GetGroups(self):
1120 return tuple([IGroup(x, self) for x in self._Search('GROUPS', 'ALL')])
1121 1122 Groups = property(_GetGroups, 1123 doc='''Queries the list of all contact groups. 1124 1125 @type: tuple of L{IGroup} 1126 ''') 1127
1128 - def _GetHardwiredGroups(self):
1129 return tuple([IGroup(x, self) for x in self._Search('GROUPS', 'HARDWIRED')])
1130 1131 HardwiredGroups = property(_GetHardwiredGroups, 1132 doc='''Queries the list of hardwired contact groups. Hardwired groups are "smart" contact groups, 1133 defined by Skype, that cannot be removed. 1134 1135 @type: tuple of L{IGroup} 1136 ''') 1137
1138 - def _GetMissedCalls(self):
1139 return tuple([ICall(x, self) for x in self._Search('MISSEDCALLS')])
1140 1141 MissedCalls = property(_GetMissedCalls, 1142 doc='''Queries a list of missed calls. 1143 1144 @type: tuple of L{ICall} 1145 ''') 1146
1147 - def _GetMissedChats(self):
1148 return tuple([IChat(x, self) for x in self._Search('MISSEDCHATS')])
1149 1150 MissedChats = property(_GetMissedChats, 1151 doc='''Queries a list of missed chats. 1152 1153 @type: tuple of L{IChat} 1154 ''') 1155
1156 - def _GetMissedMessages(self):
1157 return tuple([IChatMessage(x, self) for x in self._Search('MISSEDCHATMESSAGES')])
1158 1159 MissedMessages = property(_GetMissedMessages, 1160 doc='''Queries a list of missed chat messages. 1161 1162 @type: L{IChatMessage} 1163 ''') 1164
1165 - def _GetMissedSmss(self):
1166 return tuple([ISmsMessage(x, self) for x in self._Search('MISSEDSMSS')])
1167 1168 MissedSmss = property(_GetMissedSmss, 1169 doc='''Requests a list of all missed SMS messages. 1170 1171 @type: tuple of L{ISmsMessage} 1172 ''') 1173
1174 - def _GetMissedVoicemails(self):
1175 return tuple([IVoicemail(x, self) for x in self._Search('MISSEDVOICEMAILS')])
1176 1177 MissedVoicemails = property(_GetMissedVoicemails, 1178 doc='''Requests a list of missed voicemails. 1179 1180 @type: L{IVoicemail} 1181 ''') 1182
1183 - def _GetMute(self):
1184 return self.Variable('MUTE') == 'ON'
1185
1186 - def _SetMute(self, value):
1187 self.Variable('MUTE', cndexp(value, 'ON', 'OFF'))
1188 1189 Mute = property(_GetMute, _SetMute, 1190 doc='''Queries/sets the mute status of the Skype client. 1191 1192 Type: bool 1193 Note: This value can be set only when there is an active call. 1194 1195 @type: bool 1196 ''') 1197
1199 return self.Variable('PREDICTIVE_DIALER_COUNTRY')
1200 1201 PredictiveDialerCountry = property(_GetPredictiveDialerCountry, 1202 doc='''Returns predictive dialer coutry code. 1203 1204 @type: unicode 1205 ''') 1206
1207 - def _GetProtocol(self):
1208 return self._API.Protocol
1209
1210 - def _SetProtocol(self, value):
1211 self._DoCommand('PROTOCOL %s' % value) 1212 self._API.Protocol = int(value)
1213 1214 Protocol = property(_GetProtocol, _SetProtocol, 1215 doc='''Queries/sets the protocol version used by the Skype client. 1216 1217 @type: int 1218 ''') 1219
1220 - def _GetRecentChats(self):
1221 return tuple([IChat(x, self) for x in self._Search('RECENTCHATS')])
1222 1223 RecentChats = property(_GetRecentChats, 1224 doc='''Queries a list of recent chats. 1225 1226 @type: tuple of L{IChat} 1227 ''') 1228
1229 - def _GetSettings(self):
1230 return self._Settings
1231 1232 Settings = property(_GetSettings, 1233 doc='''Queries the settings for Skype general parameters. 1234 1235 @type: L{ISettings} 1236 ''') 1237
1238 - def _GetSilentMode(self):
1239 return self._Property('SILENT_MODE', '', '', Cache=False) == 'ON'
1240
1241 - def _SetSilentMode(self, value):
1242 self._Property('SILENT_MODE', '', '', cndexp(value, 'ON', 'OFF'), Cache=False)
1243 1244 SilentMode = property(_GetSilentMode, _SetSilentMode, 1245 doc='''Returns/sets Skype silent mode status. 1246 1247 @type: bool 1248 ''') 1249
1250 - def _GetSmss(self):
1251 return tuple([ISmsMessage(x, self) for x in self._Search('SMSS')])
1252 1253 Smss = property(_GetSmss, 1254 doc='''Requests a list of all SMS messages. 1255 1256 @type: tuple of L{ISmsMessage} 1257 ''') 1258
1259 - def _GetTimeout(self):
1260 return self._Timeout
1261
1262 - def _SetTimeout(self, value):
1263 self._Timeout = int(value)
1264 1265 Timeout = property(_GetTimeout, _SetTimeout, 1266 doc='''Queries/sets the wait timeout value in milliseconds. This timeout value applies to every 1267 command sent to the Skype API. If a response is not received during the timeout period, an 1268 L{ISkypeAPIError} exception is raised. 1269 1270 @type: int 1271 ''') 1272
1274 return tuple([IUser(x, self) for x in self._Search('USERSWAITINGMYAUTHORIZATION')])
1275 1276 UsersWaitingAuthorization = property(_GetUsersWaitingAuthorization, 1277 doc='''Queries the list of users waiting for authorization. 1278 1279 @type: tuple of L{IUser} 1280 ''') 1281
1282 - def _GetVersion(self):
1283 return self.Variable('SKYPEVERSION')
1284 1285 Version = property(_GetVersion, 1286 doc='''Queries the application version of the Skype client. 1287 1288 @type: unicode 1289 ''') 1290
1291 - def _GetVoicemails(self):
1292 return tuple([IVoicemail(x, self) for x in self._Search('VOICEMAILS')])
1293 1294 Voicemails = property(_GetVoicemails, 1295 doc='''Queries a list of voicemails. 1296 1297 @type: L{IVoicemail} 1298 ''')
1299 1300
1301 -class ISkypeEvents(object):
1302 '''Events defined in L{ISkype}. 1303 1304 See L{EventHandlingBase} for more information on events. 1305 ''' 1306
1307 - def ApplicationConnecting(self, App, Users):
1308 '''This event is triggered when list of users connecting to an application changes. 1309 1310 @param App: Application object. 1311 @type App: L{IApplication} 1312 @param Users: Connecting users. 1313 @type Users: tuple of L{IUser} 1314 '''
1315
1316 - def ApplicationDatagram(self, App, Stream, Text):
1317 '''This event is caused by the arrival of an application datagram. 1318 1319 @param App: Application object. 1320 @type App: L{IApplication} 1321 @param Stream: Application stream that received the datagram. 1322 @type Stream: L{IApplicationStream} 1323 @param Text: The datagram text. 1324 @type Text: unicode 1325 '''
1326
1327 - def ApplicationReceiving(self, App, Streams):
1328 '''This event is triggered when list of application receiving streams changes. 1329 1330 @param App: Application object. 1331 @type App: L{IApplication} 1332 @param Streams: Application receiving streams. 1333 @type Streams: tuple of L{IApplicationStream} 1334 '''
1335
1336 - def ApplicationSending(self, App, Streams):
1337 '''This event is triggered when list of application sending streams changes. 1338 1339 @param App: Application object. 1340 @type App: L{IApplication} 1341 @param Streams: Application sending streams. 1342 @type Streams: tuple of L{IApplicationStream} 1343 '''
1344
1345 - def ApplicationStreams(self, App, Streams):
1346 '''This event is triggered when list of application streams changes. 1347 1348 @param App: Application object. 1349 @type App: L{IApplication} 1350 @param Streams: Application streams. 1351 @type Streams: tuple of L{IApplicationStream} 1352 '''
1353
1354 - def AsyncSearchUsersFinished(self, Cookie, Users):
1355 '''This event occurs when an asynchronous search is completed. 1356 1357 @param Cookie: Search identifier as returned by L{ISkype.AsyncSearchUsers}. 1358 @type Cookie: int 1359 @param Users: Found users. 1360 @type Users: tuple of L{IUser} 1361 @see: L{ISkype.AsyncSearchUsers} 1362 '''
1363
1364 - def AttachmentStatus(self, Status):
1365 '''This event is caused by a change in the status of an attachment to the Skype API. 1366 1367 @param Status: New attachment status. 1368 @type Status: L{Attachment status<enums.apiAttachUnknown>} 1369 '''
1370
1371 - def AutoAway(self, Automatic):
1372 '''This event is caused by a change of auto away status. 1373 1374 @param Automatic: New auto away status. 1375 @type Automatic: bool 1376 '''
1377
1378 - def CallDtmfReceived(self, Call, Code):
1379 '''This event is caused by a call DTMF event. 1380 1381 @param Call: Call object. 1382 @type Call: L{ICall} 1383 @param Code: Received DTMF code. 1384 @type Code: unicode 1385 '''
1386
1387 - def CallHistory(self):
1388 '''This event is caused by a change in call history. 1389 '''
1390
1391 - def CallInputStatusChanged(self, Call, Active):
1392 '''This event is caused by a change in the Call voice input status change. 1393 1394 @param Call: Call object. 1395 @type Call: L{ICall} 1396 @param Active: New voice input status (active when True). 1397 @type Active: bool 1398 '''
1399
1400 - def CallSeenStatusChanged(self, Call, Seen):
1401 '''This event occurs when the seen status of a call changes. 1402 1403 @param Call: Call object. 1404 @type Call: L{ICall} 1405 @param Seen: True if call was seen. 1406 @type Seen: bool 1407 @see: L{ICall.Seen} 1408 '''
1409
1410 - def CallStatus(self, Call, Status):
1411 '''This event is caused by a change in call status. 1412 1413 @param Call: Call object. 1414 @type Call: L{ICall} 1415 @param Status: New status of the call. 1416 @type Status: L{Call status<enums.clsUnknown>} 1417 '''
1418
1419 - def CallTransferStatusChanged(self, Call, Status):
1420 '''This event occurs when a call transfer status changes. 1421 1422 @param Call: Call object. 1423 @type Call: L{ICall} 1424 @param Status: New status of the call transfer. 1425 @type Status: L{Call status<enums.clsUnknown>} 1426 '''
1427
1428 - def CallVideoReceiveStatusChanged(self, Call, Status):
1429 '''This event occurs when a call video receive status changes. 1430 1431 @param Call: Call object. 1432 @type Call: L{ICall} 1433 @param Status: New video receive status of the call. 1434 @type Status: L{Call video send status<enums.vssUnknown>} 1435 '''
1436
1437 - def CallVideoSendStatusChanged(self, Call, Status):
1438 '''This event occurs when a call video send status changes. 1439 1440 @param Call: Call object. 1441 @type Call: L{ICall} 1442 @param Status: New video send status of the call. 1443 @type Status: L{Call video send status<enums.vssUnknown>} 1444 '''
1445
1446 - def CallVideoStatusChanged(self, Call, Status):
1447 '''This event occurs when a call video status changes. 1448 1449 @param Call: Call object. 1450 @type Call: L{ICall} 1451 @param Status: New video status of the call. 1452 @type Status: L{Call video status<enums.cvsUnknown>} 1453 '''
1454
1455 - def ChatMemberRoleChanged(self, Member, Role):
1456 '''This event occurs when a chat member role changes. 1457 1458 @param Member: Chat member object. 1459 @type Member: L{IChatMember} 1460 @param Role: New member role. 1461 @type Role: L{Chat member role<enums.chatMemberRoleUnknown>} 1462 '''
1463
1464 - def ChatMembersChanged(self, Chat, Members):
1465 '''This event occurs when a list of chat members change. 1466 1467 @param Chat: Chat object. 1468 @type Chat: L{IChat} 1469 @param Members: Chat members. 1470 @type Members: tuple of L{IUser} 1471 '''
1472
1473 - def ChatWindowState(self, Chat, State):
1474 '''This event occurs when chat window is opened or closed. 1475 1476 @param Chat: Chat object. 1477 @type Chat: L{IChat} 1478 @param State: True if the window was opened or False if closed. 1479 @type State: bool 1480 '''
1481
1482 - def ClientWindowState(self, State):
1483 '''This event occurs when the state of the client window changes. 1484 1485 @param State: New window state. 1486 @type State: L{Window state<enums.wndUnknown>} 1487 '''
1488
1489 - def Command(self, Command):
1490 '''This event is triggered when a command is sent to the Skype API. 1491 1492 @param Command: Command object. 1493 @type Command: L{ICommand} 1494 '''
1495
1496 - def ConnectionStatus(self, Status):
1497 '''This event is caused by a connection status change. 1498 1499 @param Status: New connection status. 1500 @type Status: L{Connection status<enums.conUnknown>} 1501 '''
1502
1503 - def ContactsFocused(self, Username):
1504 '''This event is caused by a change in contacts focus. 1505 1506 @param Username: Name of the user that was focused or empty string if focus was lost. 1507 @type Username: unicode 1508 '''
1509
1510 - def Error(self, Command, Number, Description):
1511 '''This event is triggered when an error occurs during execution of an API command. 1512 1513 @param Command: Command object that caused the error. 1514 @type Command: L{ICommand} 1515 @param Number: Error number returned by the Skype API. 1516 @type Number: int 1517 @param Description: Description of the error. 1518 @type Description: unicode 1519 '''
1520
1521 - def FileTransferStatusChanged(self, Transfer, Status):
1522 '''This event occurs when a file transfer status changes. 1523 1524 @param Transfer: File transfer object. 1525 @type Transfer: L{IFileTransfer} 1526 @param Status: New status of the file transfer. 1527 @type Status: L{File transfer status<enums.fileTransferStatusNew>} 1528 '''
1529
1530 - def GroupDeleted(self, GroupId):
1531 '''This event is caused by a user deleting a custom contact group. 1532 1533 @param GroupId: Id of the deleted group. 1534 @type GroupId: int 1535 '''
1536
1537 - def GroupExpanded(self, Group, Expanded):
1538 '''This event is caused by a user expanding or collapsing a group in the contacts tab. 1539 1540 @param Group: Group object. 1541 @type Group: L{IGroup} 1542 @param Expanded: Tells if the group is expanded (True) or collapsed (False). 1543 @type Expanded: bool 1544 '''
1545
1546 - def GroupUsers(self, Group, Users):
1547 '''This event is caused by a change in a contact group members. 1548 1549 @param Group: Group object. 1550 @type Group: L{IGroup} 1551 @param Users: Group members. 1552 @type Users: tuple of L{IUser} 1553 '''
1554
1555 - def GroupVisible(self, Group, Visible):
1556 '''This event is caused by a user hiding/showing a group in the contacts tab. 1557 1558 @param Group: Group object. 1559 @type Group: L{IGroup} 1560 @param Visible: Tells if the group is visible or not. 1561 @type Visible: bool 1562 '''
1563
1564 - def MessageHistory(self, Username):
1565 '''This event is caused by a change in message history. 1566 1567 @param Username: Name of the user whose message history changed. 1568 @type Username: unicode 1569 '''
1570
1571 - def MessageStatus(self, Message, Status):
1572 '''This event is caused by a change in chat message status. 1573 1574 @param Message: Chat message object. 1575 @type Message: L{IChatMessage} 1576 @param Status: New status of the chat message. 1577 @type Status: L{Chat message status<enums.cmsUnknown>} 1578 '''
1579
1580 - def Mute(self, Mute):
1581 '''This event is caused by a change in mute status. 1582 1583 @param Mute: New mute status. 1584 @type Mute: bool 1585 '''
1586
1587 - def Notify(self, Notification):
1588 '''This event is triggered whenever Skype client sends a notification. 1589 1590 @param Notification: Notification string. 1591 @type Notification: unicode 1592 @note: Use this event only if there is no dedicated one. 1593 '''
1594
1595 - def OnlineStatus(self, User, Status):
1596 '''This event is caused by a change in the online status of a user. 1597 1598 @param User: User object. 1599 @type User: L{IUser} 1600 @param Status: New online status of the user. 1601 @type Status: L{Online status<enums.olsUnknown>} 1602 '''
1603
1604 - def PluginEventClicked(self, Event):
1605 '''This event occurs when a user clicks on a plug-in event. 1606 1607 @param Event: Plugin event object. 1608 @type Event: L{IPluginEvent} 1609 '''
1610
1611 - def PluginMenuItemClicked(self, MenuItem, Users, PluginContext, ContextId):
1612 '''This event occurs when a user clicks on a plug-in menu item. 1613 1614 @param MenuItem: Menu item object. 1615 @type MenuItem: L{IPluginMenuItem} 1616 @param Users: Users this item refers to. 1617 @type Users: tuple of L{IUser} 1618 @param PluginContext: Plug-in context. 1619 @type PluginContext: unicode 1620 @param ContextId: Context Id. 1621 @type ContextId: unicode 1622 @see: L{IPluginMenuItem} 1623 '''
1624
1625 - def Reply(self, Command):
1626 '''This event is triggered when the API replies to a command object. 1627 1628 @param Command: Command object. 1629 @type Command: L{ICommand} 1630 '''
1631
1632 - def SilentModeStatusChanged(self, Silent):
1633 '''This event occurs when a silent mode is switched off. 1634 1635 @param Silent: Skype client silent status. 1636 @type Silent: bool 1637 '''
1638
1639 - def SmsMessageStatusChanged(self, Message, Status):
1640 '''This event is caused by a change in the SMS message status. 1641 1642 @param Message: SMS message object. 1643 @type Message: L{ISmsMessage} 1644 @param Status: New status of the SMS message. 1645 @type Status: L{SMS message status<enums.smsMessageStatusUnknown>} 1646 '''
1647
1648 - def SmsTargetStatusChanged(self, Target, Status):
1649 '''This event is caused by a change in the SMS target status. 1650 1651 @param Target: SMS target object. 1652 @type Target: L{ISmsTarget} 1653 @param Status: New status of the SMS target. 1654 @type Status: L{SMS target status<enums.smsTargetStatusUnknown>} 1655 '''
1656
1657 - def UserAuthorizationRequestReceived(self, User):
1658 '''This event occurs when user sends you an authorization request. 1659 1660 @param User: User object. 1661 @type User: L{IUser} 1662 '''
1663
1664 - def UserMood(self, User, MoodText):
1665 '''This event is caused by a change in the mood text of the user. 1666 1667 @param User: User object. 1668 @type User: L{IUser} 1669 @param MoodText: New mood text. 1670 @type MoodText: unicode 1671 '''
1672
1673 - def UserStatus(self, Status):
1674 '''This event is caused by a user status change. 1675 1676 @param Status: New user status. 1677 @type Status: L{User status<enums.cusUnknown>} 1678 '''
1679
1680 - def VoicemailStatus(self, Mail, Status):
1681 '''This event is caused by a change in voicemail status. 1682 1683 @param Mail: Voicemail object. 1684 @type Mail: L{IVoicemail} 1685 @param Status: New status of the voicemail. 1686 @type Status: L{Voicemail status<enums.vmsUnknown>} 1687 '''
1688
1689 - def WallpaperChanged(self, Path):
1690 '''This event occurs when client wallpaper changes. 1691 1692 @param Path: Path to new wallpaper bitmap. 1693 @type Path: unicode 1694 '''
1695 1696 1697 ISkype._AddEvents(ISkypeEvents) 1698