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 AsyncSearchUsers(self, Target):
446 '''Asynchronously searches for Skype users. 447 448 @param Target: Search target (name or email address). 449 @type Target: unicode 450 @return: A search identifier. It will be passed along with the results to the 451 L{ISkypeEvents.AsyncSearchUsersFinished} event after the search is completed. 452 @rtype: int 453 ''' 454 def reply_handler(command): 455 if command.Command.startswith('SEARCH USERS'): 456 self._CallEventHandler('AsyncSearchUsersFinished', command.Id, tuple(IUser(x, self) for x in esplit(chop(command.Reply)[-1], ', '))) 457 self.UnregisterEventHandler('Reply', reply_handler)
458 command = ICommand(-1, 'SEARCH USERS %s' % Target, 'USERS', False, self.Timeout) 459 self.RegisterEventHandler('Reply', reply_handler) 460 self.SendCommand(command) 461 # return pCookie - search identifier 462 return command.Id
463
464 - def Attach(self, Protocol=5, Wait=True):
465 '''Establishes a connection to Skype. 466 467 @param Protocol: Minimal Skype protocol version. 468 @type Protocol: int 469 @param Wait: If set to False, blocks forever until the connection is established. 470 Otherwise, timeouts after the L{Timeout}. 471 @type Wait: bool 472 ''' 473 try: 474 self._API.Protocol = Protocol 475 self._API.Attach(self.Timeout, Wait) 476 except ISkypeAPIError: 477 self.ResetCache() 478 raise
479
480 - def Call(self, Id=0):
481 '''Queries a call object. 482 483 @param Id: Call identifier. 484 @type Id: int 485 @return: Call object. 486 @rtype: L{ICall} 487 ''' 488 o = ICall(Id, self) 489 o.Status 490 return o
491
492 - def Calls(self, Target=''):
493 '''Queries calls in call history. 494 495 @param Target: Call target. 496 @type Target: unicode 497 @return: Call objects. 498 @rtype: tuple of L{ICall} 499 ''' 500 return tuple(ICall(x, self) for x in self._Search('CALLS', Target))
501
502 - def ChangeUserStatus(self, Val):
503 '''Changes the online status for the current user. 504 505 @param Val: New online status for the user. 506 @type Val: L{User status<enums.cusUnknown>} 507 508 @note: This function waits until the online status changes. Alternatively, use 509 the L{CurrentUserStatus} property to perform an immediate change of status. 510 ''' 511 if self.CurrentUserStatus.upper() == Val.upper(): 512 return 513 event = threading.Event() 514 def userstatus_handler(status): 515 if status.upper() == Val.upper(): 516 event.set()
517 self.RegisterEventHandler('UserStatus', userstatus_handler) 518 self.CurrentUserStatus = Val 519 event.wait() 520 self.UnregisterEventHandler('UserStatus', userstatus_handler) 521
522 - def Chat(self, Name=''):
523 '''Queries a chat object. 524 525 @param Name: Chat name. 526 @type Name: unicode 527 @return: A chat object. 528 @rtype: L{IChat} 529 ''' 530 o = IChat(Name, self) 531 o.Status 532 return o
533
534 - def ClearCallHistory(self, Username='ALL', Type=chsAllCalls):
535 '''Clears the call history. 536 537 @param Username: Skypename of the user. A special value of 'ALL' means that entries of all users should 538 be removed. 539 @type Username: unicode 540 @param Type: Call type. 541 @type Type: L{Call type<enums.cltUnknown>} 542 ''' 543 self._DoCommand('CLEAR CALLHISTORY %s %s' % (str(Type), Username))
544
545 - def ClearChatHistory(self):
546 '''Clears the chat history. 547 ''' 548 self._DoCommand('CLEAR CHATHISTORY')
549
550 - def ClearVoicemailHistory(self):
551 '''Clears the voicemail history. 552 ''' 553 self._DoCommand('CLEAR VOICEMAILHISTORY')
554
555 - def Command(self, Command, Reply=u'', Block=False, Timeout=30000, Id=-1):
556 '''Creates an API command object. 557 558 @param Command: Command string. 559 @type Command: unicode 560 @param Reply: Expected reply. By default any reply is accepted (except errors 561 which raise an L{ISkypeError} exception). 562 @type Reply: unicode 563 @param Block: If set to True, L{SendCommand} method waits for a response from Skype API before returning. 564 @type Block: bool 565 @param Timeout: Timeout in milliseconds. Used if Block=True. 566 @type Timeout: int 567 @param Id: Command Id. The default (-1) means it will be assigned automatically as soon as the command is sent. 568 @type Id: int 569 @return: A command object. 570 @rtype: L{ICommand} 571 @see: L{SendCommand} 572 ''' 573 return ICommand(Id, Command, Reply, Block, Timeout)
574
575 - def Conference(self, Id=0):
576 '''Queries a call conference object. 577 578 @param Id: Conference Id. 579 @type Id: int 580 @return: A conference object. 581 @rtype: L{IConference} 582 ''' 583 o = IConference(Id, self) 584 if Id <= 0 or not o.Calls: 585 raise ISkypeError(0, 'Unknown conference') 586 return o
587
588 - def CreateChatUsingBlob(self, Blob):
589 '''Returns existing or joins a new chat using given blob. 590 591 @param Blob: A blob indentifying the chat. 592 @type Blob: unicode 593 @return: A chat object 594 @rtype: L{IChat} 595 ''' 596 return IChat(chop(self._DoCommand('CHAT CREATEUSINGBLOB %s' % Blob), 2)[1], self)
597
598 - def CreateChatWith(self, *Usernames):
599 '''Creates a chat with one or more users. 600 601 @param Usernames: One or more strings with the Skypenames of the users. 602 @type Usernames: unicode 603 @return: A chat object 604 @rtype: L{IChat} 605 @see: L{IChat.AddMembers} 606 ''' 607 return IChat(chop(self._DoCommand('CHAT CREATE %s' % ', '.join(Usernames)), 2)[1], self)
608
609 - def CreateGroup(self, GroupName):
610 '''Creates a custom contact group. 611 612 @param GroupName: Group name. 613 @type GroupName: unicode 614 @return: A group object. 615 @rtype: L{IGroup} 616 @see: L{DeleteGroup} 617 ''' 618 groups = self.CustomGroups 619 self._DoCommand('CREATE GROUP %s' % GroupName) 620 for g in self.CustomGroups: 621 if g not in groups and g.DisplayName == GroupName: 622 return g 623 raise ISkypeError(0, 'Group creating failed')
624
625 - def CreateSms(self, MessageType, *TargetNumbers):
626 '''Creates an SMS message. 627 628 @param MessageType: Message type. 629 @type MessageType: L{SMS message type<enums.smsMessageTypeUnknown>} 630 @param TargetNumbers: One or more target SMS numbers. 631 @type TargetNumbers: unicode 632 @return: An sms message object. 633 @rtype: L{ISmsMessage} 634 ''' 635 return ISmsMessage(chop(self._DoCommand('CREATE SMS %s %s' % (MessageType, ', '.join(TargetNumbers))), 2)[1], self)
636
637 - def DeleteGroup(self, GroupId):
638 '''Deletes a custom contact group. 639 640 Users in the contact group are moved to the All Contacts (hardwired) contact group. 641 642 @param GroupId: Group identifier. Get it from L{IGroup.Id}. 643 @type GroupId: int 644 @see: L{CreateGroup} 645 ''' 646 self._DoCommand('DELETE GROUP %s' % GroupId)
647
648 - def EnableApiSecurityContext(self, Context):
649 '''Enables an API security context for Internet Explorer scripts. 650 651 @param Context: combination of API security context values. 652 @type Context: unicode 653 @warning: This functionality isn't supported by Skype4Py. 654 ''' 655 self._API.EnableApiSecurityContext(Context)
656
657 - def FindChatUsingBlob(self, Blob):
658 '''Returns existing chat using given blob. 659 660 @param Blob: A blob indentifying the chat. 661 @type Blob: unicode 662 @return: A chat object 663 @rtype: L{IChat} 664 ''' 665 return IChat(chop(self._DoCommand('CHAT FINDUSINGBLOB %s' % Blob), 2)[1], self)
666
667 - def Greeting(self, Username=''):
668 '''Queries the greeting used as voicemail. 669 670 @param Username: Skypename of the user. 671 @type Username: unicode 672 @return: A voicemail object. 673 @rtype: L{IVoicemail} 674 ''' 675 for v in self.Voicemails: 676 if Username and v.PartnerHandle != Username: 677 continue 678 if v.Type in (vmtDefaultGreeting, vmtCustomGreeting): 679 return v
680
681 - def Message(self, Id=0):
682 '''Queries a chat message object. 683 684 @param Id: Message Id. 685 @type Id: int 686 @return: A chat message object. 687 @rtype: L{IChatMessage} 688 ''' 689 o = IChatMessage(Id, self) 690 o.Status 691 return o
692
693 - def Messages(self, Target=''):
694 '''Queries chat messages which were sent/received by the user. 695 696 @param Target: Message sender. 697 @type Target: unicode 698 @return: Chat message objects. 699 @rtype: tuple of L{IChatMessage} 700 ''' 701 return tuple(IChatMessage(x, self) for x in self._Search('CHATMESSAGES', Target))
702
703 - def PlaceCall(self, *Targets):
704 '''Places a call to a single user or creates a conference call. 705 706 @param Targets: One or more call targets. If multiple targets are specified, a conference 707 call is created. The call target can be a Skypename, phone number, or speed dial code. 708 @type Targets: unicode 709 @return: A call object. 710 @rtype: L{ICall} 711 ''' 712 calls = self.ActiveCalls 713 reply = self._DoCommand('CALL %s' % ', '.join(Targets)) 714 # Skype for Windows returns the call status which gives us the call Id; 715 if reply.startswith('CALL '): 716 return ICall(chop(reply, 2)[1], self) 717 # On linux we get 'OK' as reply so we search for the new call on 718 # list of active calls. 719 for c in self.ActiveCalls: 720 if c not in calls: 721 return c 722 raise ISkypeError(0, 'Placing call failed')
723
724 - def Privilege(self, Name):
725 '''Queries the Skype services (privileges) enabled for the Skype client. 726 727 @param Name: Privilege name, currently one of 'SKYPEOUT', 'SKYPEIN', 'VOICEMAIL'. 728 @type Name: unicode 729 @return: True if the priviledge is available, False otherwise. 730 @rtype: bool 731 ''' 732 return self._Property('PRIVILEGE', '', Name.upper()) == 'TRUE'
733
734 - def Profile(self, Property, Set=None):
735 '''Queries/sets user profile properties. 736 737 @param Property: Property name, currently one of 'PSTN_BALANCE', 'PSTN_BALANCE_CURRENCY', 738 'FULLNAME', 'BIRTHDAY', 'SEX', 'LANGUAGES', 'COUNTRY', 'PROVINCE', 'CITY', 'PHONE_HOME', 739 'PHONE_OFFICE', 'PHONE_MOBILE', 'HOMEPAGE', 'ABOUT'. 740 @type Property: unicode 741 @param Set: Value the property should be set to or None if the value should be queried. 742 @type Set: unicode or None 743 @return: Property value if Set=None, None otherwise. 744 @rtype: unicode or None 745 ''' 746 return self._Property('PROFILE', '', Property, Set)
747
748 - def Property(self, ObjectType, ObjectId, PropName, Set=None):
749 '''Queries/sets the properties of an object. 750 751 @param ObjectType: Object type, currently one of 'USER', 'CALL', 'CHAT', 'CHATMESSAGE', 'VOICEMAIL'. 752 @type ObjectType: unicode 753 @param ObjectId: Object Id, depends on the object type 754 @type ObjectId: unicode 755 @param PropName: Name of the property you want to access. 756 @type PropName: unicode 757 @param Set: Value the property should be set to or None if the value should be queried. 758 @type Set: unicode or None 759 @return: Property value if Set=None, None otherwise. 760 @rtype: unicode or None 761 ''' 762 return self._Property(ObjectType, ObjectId, PropName, Set)
763
764 - def ResetCache(self):
765 '''Deletes all command cache entries. 766 767 This method clears the Skype4Py's internal command cache which means that all objects will forget 768 their property values and querying them will trigger a code to get them from Skype client (and 769 cache them again). 770 ''' 771 self._CacheDict = {}
772
773 - def SearchForUsers(self, Target):
774 '''Searches for users. 775 776 @param Target: Search target (name or email address). 777 @type Target: unicode 778 @return: Found users. 779 @rtype: tuple of L{IUser} 780 ''' 781 return tuple(IUser(x, self) for x in self._Search('USERS', Target))
782
783 - def SendCommand(self, Command):
784 '''Sends an API command. 785 786 @param Command: Command to send. Use L{Command} method to create a command. 787 @type Command: L{ICommand} 788 ''' 789 try: 790 self._API.SendCommand(Command) 791 except ISkypeAPIError: 792 self.ResetCache() 793 raise
794
795 - def SendMessage(self, Username, Text):
796 '''Sends a chat message. 797 798 @param Username: Skypename of the user. 799 @type Username: unicode 800 @param Text: Body of the message. 801 @type Text: unicode 802 @return: A chat message object. 803 @rtype: L{IChatMessage} 804 ''' 805 return self.CreateChatWith(Username).SendMessage(Text)
806
807 - def SendSms(self, *TargetNumbers, **Properties):
808 '''Creates and sends an SMS message. 809 810 @param TargetNumbers: One or more target SMS numbers. 811 @type TargetNumbers: unicode 812 @param Properties: Message properties. Properties available are same as L{ISmsMessage} object properties. 813 @type Properties: kwargs 814 @return: An sms message object. The message is already sent at this point. 815 @rtype: L{ISmsMessage} 816 ''' 817 sms = self.CreateSms(smsMessageTypeOutgoing, *TargetNumbers) 818 for prop, value in Properties.items(): 819 if hasattr(sms, prop): 820 setattr(sms, prop, value) 821 else: 822 raise TypeError('Unknown property: %s' % prop) 823 sms.Send() 824 return sms
825
826 - def SendVoicemail(self, Username):
827 '''Sends a voicemail to a specified user. 828 829 @param Username: Skypename of the user. 830 @type Username: unicode 831 @return: A voicemail object. 832 @rtype: L{IVoicemail} 833 ''' 834 if self._API.Protocol >= 6: 835 self._DoCommand('CALLVOICEMAIL %s' % Username) 836 else: 837 self._DoCommand('VOICEMAIL %s' % Username)
838
839 - def User(self, Username=''):
840 '''Queries a user object. 841 842 @param Username: Skypename of the user. 843 @type Username: unicode 844 @return: A user object. 845 @rtype: L{IUser} 846 ''' 847 o = IUser(Username, self) 848 o.OnlineStatus 849 return o
850
851 - def Variable(self, Name, Set=None):
852 '''Queries/sets Skype general parameters. 853 854 @param Name: Variable name. 855 @type Name: unicode 856 @param Set: Value the variable should be set to or None if the value should be queried. 857 @type Set: unicode or None 858 @return: Variable value if Set=None, None otherwise. 859 @rtype: unicode or None 860 ''' 861 return self._Property(Name, '', '', Set)
862
863 - def Voicemail(self, Id):
864 '''Queries the voicemail object. 865 866 @param Id: Voicemail Id. 867 @type Id: int 868 @return: A voicemail object. 869 @rtype: L{IVoicemail} 870 ''' 871 o = IVoicemail(Id, self) 872 o.Type 873 return o
874
875 - def _GetActiveCalls(self):
876 return tuple(ICall(x, self) for x in self._Search('ACTIVECALLS'))
877 878 ActiveCalls = property(_GetActiveCalls, 879 doc='''Queries a list of active calls. 880 881 @type: tuple of L{ICall} 882 ''') 883
884 - def _GetActiveChats(self):
885 return tuple(IChat(x, self) for x in self._Search('ACTIVECHATS'))
886 887 ActiveChats = property(_GetActiveChats, 888 doc='''Queries a list of active chats. 889 890 @type: tuple of L{IChat} 891 ''') 892
893 - def _GetActiveFileTransfers(self):
894 return tuple(IFileTransfer(x, self) for x in self._Search('ACTIVEFILETRANSFERS'))
895 896 ActiveFileTransfers = property(_GetActiveFileTransfers, 897 doc='''Queries currently active file transfers. 898 899 @type: tuple of L{IFileTransfer} 900 ''') 901
902 - def _GetApiDebugLevel(self):
903 return self._API.DebugLevel
904
905 - def _SetApiDebugLevel(self, value):
906 self._API.SetDebugLevel(int(value))
907 908 ApiDebugLevel = property(_GetApiDebugLevel, _SetApiDebugLevel, 909 doc='''Queries/sets the debug level of the underlying API. Currently there are 910 only two levels, 0 which means no debug information and 1 which means that the 911 commands sent to / received from the Skype client are printed to the sys.stderr. 912 913 @type: int 914 ''') 915
916 - def _GetApiWrapperVersion(self):
917 from Skype4Py import __version__ 918 return unicode(__version__)
919 920 ApiWrapperVersion = property(_GetApiWrapperVersion, 921 doc='''Returns Skype4Py version. 922 923 @type: unicode 924 ''') 925
926 - def _GetAttachmentStatus(self):
927 return self._API.AttachmentStatus
928 929 AttachmentStatus = property(_GetAttachmentStatus, 930 doc='''Queries the attachment status of the Skype client. 931 932 @type: L{Attachment status<enums.apiAttachUnknown>} 933 ''') 934
935 - def _GetBookmarkedChats(self):
936 return tuple(IChat(x, self) for x in self._Search('BOOKMARKEDCHATS'))
937 938 BookmarkedChats = property(_GetBookmarkedChats, 939 doc='''Queries a list of bookmarked chats. 940 941 @type: tuple of L{IChat} 942 ''') 943
944 - def _GetCache(self):
945 return self._Cache
946
947 - def _SetCache(self, value):
948 self._Cache = bool(value)
949 950 Cache = property(_GetCache, _SetCache, 951 doc='''Queries/sets the status of internal cache. The internal API cache is used 952 to cache Skype object properties and global parameters. 953 954 @type: bool 955 ''') 956
957 - def _GetChats(self):
958 return tuple(IChat(x, self) for x in self._Search('CHATS'))
959 960 Chats = property(_GetChats, 961 doc='''Queries a list of chats. 962 963 @type: tuple of L{IChat} 964 ''') 965
966 - def _GetClient(self):
967 return self._Client
968 969 Client = property(_GetClient, 970 doc='''Queries the user interface control object. 971 972 @type: L{IClient} 973 ''') 974
975 - def _GetCommandId(self):
976 return True
977
978 - def _SetCommandId(self, value):
979 pass
980 981 CommandId = property(_GetCommandId, _SetCommandId, 982 doc='''Queries/sets the status of automatic command identifiers. 983 984 Type: bool 985 Note: Currently it is always True. 986 987 @type: bool 988 ''') 989
990 - def _GetConferences(self):
991 confs = [] 992 for c in self.Calls(): 993 cid = c.ConferenceId 994 if cid > 0 and cid not in [x.Id for x in confs]: 995 confs.append(IConference(cid, self)) 996 return tuple(confs)
997 998 Conferences = property(_GetConferences, 999 doc='''Queries a list of call conferences. 1000 1001 @type: tuple of L{IConference} 1002 ''') 1003
1004 - def _GetConnectionStatus(self):
1005 return self.Variable('CONNSTATUS')
1006 1007 ConnectionStatus = property(_GetConnectionStatus, 1008 doc='''Queries the connection status of the Skype client. 1009 1010 @type: L{Connection status<enums.conUnknown>} 1011 ''') 1012
1013 - def _GetConvert(self):
1014 return self._Convert
1015 1016 Convert = property(_GetConvert, 1017 doc='''Queries the conversion object. 1018 1019 @type: L{IConversion} 1020 ''') 1021
1022 - def _GetCurrentUser(self):
1023 return IUser(self.CurrentUserHandle, self)
1024 1025 CurrentUser = property(_GetCurrentUser, 1026 doc='''Queries the current user object. 1027 1028 @type: L{IUser} 1029 ''') 1030
1031 - def _GetCurrentUserHandle(self):
1032 return self.Variable('CURRENTUSERHANDLE')
1033 1034 CurrentUserHandle = property(_GetCurrentUserHandle, 1035 doc='''Queries the Skypename of the current user. 1036 1037 @type: unicode 1038 ''') 1039
1040 - def _GetCurrentUserProfile(self):
1041 return self._Profile
1042 1043 CurrentUserProfile = property(_GetCurrentUserProfile, 1044 doc='''Queries the user profile object. 1045 1046 @type: L{IProfile} 1047 ''') 1048
1049 - def _GetCurrentUserStatus(self):
1050 return self.Variable('USERSTATUS')
1051
1052 - def _SetCurrentUserStatus(self, value):
1053 self.Variable('USERSTATUS', str(value))
1054 1055 CurrentUserStatus = property(_GetCurrentUserStatus, _SetCurrentUserStatus, 1056 doc='''Queries/sets the online status of the current user. 1057 1058 @type: L{Online status<enums.olsUnknown>} 1059 ''') 1060
1061 - def _GetCustomGroups(self):
1062 return tuple(IGroup(x, self) for x in self._Search('GROUPS', 'CUSTOM'))
1063 1064 CustomGroups = property(_GetCustomGroups, 1065 doc='''Queries the list of custom contact groups. Custom groups are contact groups defined by the user. 1066 1067 @type: tuple of L{IGroup} 1068 ''') 1069
1070 - def _GetFileTransfers(self):
1071 return tuple(IFileTransfer(x, self) for x in self._Search('FILETRANSFERS'))
1072 1073 FileTransfers = property(_GetFileTransfers, 1074 doc='''Queries all file transfers. 1075 1076 @type: tuple of L{IFileTransfer} 1077 ''') 1078
1079 - def _GetFocusedContacts(self):
1080 # we have to use _DoCommand() directly because for unknown reason the API returns 1081 # "CONTACTS FOCUSED" instead of "CONTACTS_FOCUSED" (note the space instead of "_") 1082 return tuple(IUser(x, self) for x in esplit(chop(self._DoCommand('GET CONTACTS_FOCUSED', 'CONTACTS FOCUSED'), 2)[-1]))
1083 1084 FocusedContacts = property(_GetFocusedContacts, 1085 doc='''Queries a list of contacts selected in the contacts list. 1086 1087 @type: tuple of L{IUser} 1088 ''') 1089
1090 - def _SetFriendlyName(self, FriendlyName):
1091 self._API.SetFriendlyName(FriendlyName)
1092 1093 FriendlyName = property(fset=_SetFriendlyName, 1094 doc='''Sets a "friendly" name for an application. 1095 1096 @type: unicode 1097 ''') 1098
1099 - def _GetFriends(self):
1100 return tuple(IUser(x, self) for x in self._Search('FRIENDS'))
1101 1102 Friends = property(_GetFriends, 1103 doc='''Queries the users in a contact list. 1104 1105 @type: tuple of L{IUser} 1106 ''') 1107
1108 - def _GetGroups(self):
1109 return tuple(IGroup(x, self) for x in self._Search('GROUPS', 'ALL'))
1110 1111 Groups = property(_GetGroups, 1112 doc='''Queries the list of all contact groups. 1113 1114 @type: tuple of L{IGroup} 1115 ''') 1116
1117 - def _GetHardwiredGroups(self):
1118 return tuple(IGroup(x, self) for x in self._Search('GROUPS', 'HARDWIRED'))
1119 1120 HardwiredGroups = property(_GetHardwiredGroups, 1121 doc='''Queries the list of hardwired contact groups. Hardwired groups are "smart" contact groups, 1122 defined by Skype, that cannot be removed. 1123 1124 @type: tuple of L{IGroup} 1125 ''') 1126
1127 - def _GetMissedCalls(self):
1128 return tuple(ICall(x, self) for x in self._Search('MISSEDCALLS'))
1129 1130 MissedCalls = property(_GetMissedCalls, 1131 doc='''Queries a list of missed calls. 1132 1133 @type: tuple of L{ICall} 1134 ''') 1135
1136 - def _GetMissedChats(self):
1137 return tuple(IChat(x, self) for x in self._Search('MISSEDCHATS'))
1138 1139 MissedChats = property(_GetMissedChats, 1140 doc='''Queries a list of missed chats. 1141 1142 @type: tuple of L{IChat} 1143 ''') 1144
1145 - def _GetMissedMessages(self):
1146 return tuple(IChatMessage(x, self) for x in self._Search('MISSEDCHATMESSAGES'))
1147 1148 MissedMessages = property(_GetMissedMessages, 1149 doc='''Queries a list of missed chat messages. 1150 1151 @type: L{IChatMessage} 1152 ''') 1153
1154 - def _GetMissedSmss(self):
1155 return tuple(ISmsMessage(x, self) for x in self._Search('MISSEDSMSS'))
1156 1157 MissedSmss = property(_GetMissedSmss, 1158 doc='''Requests a list of all missed SMS messages. 1159 1160 @type: tuple of L{ISmsMessage} 1161 ''') 1162
1163 - def _GetMissedVoicemails(self):
1164 return tuple(IVoicemail(x, self) for x in self._Search('MISSEDVOICEMAILS'))
1165 1166 MissedVoicemails = property(_GetMissedVoicemails, 1167 doc='''Requests a list of missed voicemails. 1168 1169 @type: L{IVoicemail} 1170 ''') 1171
1172 - def _GetMute(self):
1173 return self.Variable('MUTE') == 'ON'
1174
1175 - def _SetMute(self, value):
1176 self.Variable('MUTE', cndexp(value, 'ON', 'OFF'))
1177 1178 Mute = property(_GetMute, _SetMute, 1179 doc='''Queries/sets the mute status of the Skype client. 1180 1181 Type: bool 1182 Note: This value can be set only when there is an active call. 1183 1184 @type: bool 1185 ''') 1186
1187 - def _GetPredictiveDialerCountry(self):
1188 return self.Variable('PREDICTIVE_DIALER_COUNTRY')
1189 1190 PredictiveDialerCountry = property(_GetPredictiveDialerCountry, 1191 doc='''Returns predictive dialer coutry code. 1192 1193 @type: unicode 1194 ''') 1195
1196 - def _GetProtocol(self):
1197 return self._API.Protocol
1198
1199 - def _SetProtocol(self, value):
1200 self._DoCommand('PROTOCOL %s' % value) 1201 self._API.Protocol = int(value)
1202 1203 Protocol = property(_GetProtocol, _SetProtocol, 1204 doc='''Queries/sets the protocol version used by the Skype client. 1205 1206 @type: int 1207 ''') 1208
1209 - def _GetRecentChats(self):
1210 return tuple(IChat(x, self) for x in self._Search('RECENTCHATS'))
1211 1212 RecentChats = property(_GetRecentChats, 1213 doc='''Queries a list of recent chats. 1214 1215 @type: tuple of L{IChat} 1216 ''') 1217
1218 - def _GetSettings(self):
1219 return self._Settings
1220 1221 Settings = property(_GetSettings, 1222 doc='''Queries the settings for Skype general parameters. 1223 1224 @type: L{ISettings} 1225 ''') 1226
1227 - def _GetSilentMode(self):
1228 return self._Property('SILENT_MODE', '', '', Cache=False) == 'ON'
1229
1230 - def _SetSilentMode(self, value):
1231 self._Property('SILENT_MODE', '', '', cndexp(value, 'ON', 'OFF'), Cache=False)
1232 1233 SilentMode = property(_GetSilentMode, _SetSilentMode, 1234 doc='''Returns/sets Skype silent mode status. 1235 1236 @type: bool 1237 ''') 1238
1239 - def _GetSmss(self):
1240 return tuple(ISmsMessage(x, self) for x in self._Search('SMSS'))
1241 1242 Smss = property(_GetSmss, 1243 doc='''Requests a list of all SMS messages. 1244 1245 @type: tuple of L{ISmsMessage} 1246 ''') 1247
1248 - def _GetTimeout(self):
1249 return self._Timeout
1250
1251 - def _SetTimeout(self, value):
1252 self._Timeout = int(value)
1253 1254 Timeout = property(_GetTimeout, _SetTimeout, 1255 doc='''Queries/sets the wait timeout value in milliseconds. This timeout value applies to every 1256 command sent to the Skype API. If a response is not received during the timeout period, an 1257 L{ISkypeAPIError} exception is raised. 1258 1259 @type: int 1260 ''') 1261
1262 - def _GetUsersWaitingAuthorization(self):
1263 return tuple(IUser(x, self) for x in self._Search('USERSWAITINGMYAUTHORIZATION'))
1264 1265 UsersWaitingAuthorization = property(_GetUsersWaitingAuthorization, 1266 doc='''Queries the list of users waiting for authorization. 1267 1268 @type: tuple of L{IUser} 1269 ''') 1270
1271 - def _GetVersion(self):
1272 return self.Variable('SKYPEVERSION')
1273 1274 Version = property(_GetVersion, 1275 doc='''Queries the application version of the Skype client. 1276 1277 @type: unicode 1278 ''') 1279
1280 - def _GetVoicemails(self):
1281 return tuple(IVoicemail(x, self) for x in self._Search('VOICEMAILS'))
1282 1283 Voicemails = property(_GetVoicemails, 1284 doc='''Queries a list of voicemails. 1285 1286 @type: L{IVoicemail} 1287 ''') 1288 1289
1290 -class ISkypeEvents(object):
1291 '''Events defined in L{ISkype}. 1292 1293 See L{EventHandlingBase} for more information on events. 1294 ''' 1295
1296 - def ApplicationConnecting(self, App, Users):
1297 '''This event is triggered when list of users connecting to an application changes. 1298 1299 @param App: Application object. 1300 @type App: L{IApplication} 1301 @param Users: Connecting users. 1302 @type Users: tuple of L{IUser} 1303 '''
1304
1305 - def ApplicationDatagram(self, App, Stream, Text):
1306 '''This event is caused by the arrival of an application datagram. 1307 1308 @param App: Application object. 1309 @type App: L{IApplication} 1310 @param Stream: Application stream that received the datagram. 1311 @type Stream: L{IApplicationStream} 1312 @param Text: The datagram text. 1313 @type Text: unicode 1314 '''
1315
1316 - def ApplicationReceiving(self, App, Streams):
1317 '''This event is triggered when list of application receiving streams changes. 1318 1319 @param App: Application object. 1320 @type App: L{IApplication} 1321 @param Streams: Application receiving streams. 1322 @type Streams: tuple of L{IApplicationStream} 1323 '''
1324
1325 - def ApplicationSending(self, App, Streams):
1326 '''This event is triggered when list of application sending streams changes. 1327 1328 @param App: Application object. 1329 @type App: L{IApplication} 1330 @param Streams: Application sending streams. 1331 @type Streams: tuple of L{IApplicationStream} 1332 '''
1333
1334 - def ApplicationStreams(self, App, Streams):
1335 '''This event is triggered when list of application streams changes. 1336 1337 @param App: Application object. 1338 @type App: L{IApplication} 1339 @param Streams: Application streams. 1340 @type Streams: tuple of L{IApplicationStream} 1341 '''
1342
1343 - def AsyncSearchUsersFinished(self, Cookie, Users):
1344 '''This event occurs when an asynchronous search is completed. 1345 1346 @param Cookie: Search identifier as returned by L{ISkype.AsyncSearchUsers}. 1347 @type Cookie: int 1348 @param Users: Found users. 1349 @type Users: tuple of L{IUser} 1350 @see: L{ISkype.AsyncSearchUsers} 1351 '''
1352
1353 - def AttachmentStatus(self, Status):
1354 '''This event is caused by a change in the status of an attachment to the Skype API. 1355 1356 @param Status: New attachment status. 1357 @type Status: L{Attachment status<enums.apiAttachUnknown>} 1358 '''
1359
1360 - def AutoAway(self, Automatic):
1361 '''This event is caused by a change of auto away status. 1362 1363 @param Automatic: New auto away status. 1364 @type Automatic: bool 1365 '''
1366
1367 - def CallDtmfReceived(self, Call, Code):
1368 '''This event is caused by a call DTMF event. 1369 1370 @param Call: Call object. 1371 @type Call: L{ICall} 1372 @param Code: Received DTMF code. 1373 @type Code: unicode 1374 '''
1375
1376 - def CallHistory(self):
1377 '''This event is caused by a change in call history. 1378 '''
1379
1380 - def CallInputStatusChanged(self, Call, Active):
1381 '''This event is caused by a change in the Call voice input status change. 1382 1383 @param Call: Call object. 1384 @type Call: L{ICall} 1385 @param Active: New voice input status (active when True). 1386 @type Active: bool 1387 '''
1388
1389 - def CallSeenStatusChanged(self, Call, Seen):
1390 '''This event occurs when the seen status of a call changes. 1391 1392 @param Call: Call object. 1393 @type Call: L{ICall} 1394 @param Seen: True if call was seen. 1395 @type Seen: bool 1396 @see: L{ICall.Seen} 1397 '''
1398
1399 - def CallStatus(self, Call, Status):
1400 '''This event is caused by a change in call status. 1401 1402 @param Call: Call object. 1403 @type Call: L{ICall} 1404 @param Status: New status of the call. 1405 @type Status: L{Call status<enums.clsUnknown>} 1406 '''
1407
1408 - def CallTransferStatusChanged(self, Call, Status):
1409 '''This event occurs when a call transfer status changes. 1410 1411 @param Call: Call object. 1412 @type Call: L{ICall} 1413 @param Status: New status of the call transfer. 1414 @type Status: L{Call status<enums.clsUnknown>} 1415 '''
1416
1417 - def CallVideoReceiveStatusChanged(self, Call, Status):
1418 '''This event occurs when a call video receive status changes. 1419 1420 @param Call: Call object. 1421 @type Call: L{ICall} 1422 @param Status: New video receive status of the call. 1423 @type Status: L{Call video send status<enums.vssUnknown>} 1424 '''
1425
1426 - def CallVideoSendStatusChanged(self, Call, Status):
1427 '''This event occurs when a call video send status changes. 1428 1429 @param Call: Call object. 1430 @type Call: L{ICall} 1431 @param Status: New video send status of the call. 1432 @type Status: L{Call video send status<enums.vssUnknown>} 1433 '''
1434
1435 - def CallVideoStatusChanged(self, Call, Status):
1436 '''This event occurs when a call video status changes. 1437 1438 @param Call: Call object. 1439 @type Call: L{ICall} 1440 @param Status: New video status of the call. 1441 @type Status: L{Call video status<enums.cvsUnknown>} 1442 '''
1443
1444 - def ChatMemberRoleChanged(self, Member, Role):
1445 '''This event occurs when a chat member role changes. 1446 1447 @param Member: Chat member object. 1448 @type Member: L{IChatMember} 1449 @param Role: New member role. 1450 @type Role: L{Chat member role<enums.chatMemberRoleUnknown>} 1451 '''
1452
1453 - def ChatMembersChanged(self, Chat, Members):
1454 '''This event occurs when a list of chat members change. 1455 1456 @param Chat: Chat object. 1457 @type Chat: L{IChat} 1458 @param Members: Chat members. 1459 @type Members: tuple of L{IUser} 1460 '''
1461
1462 - def ChatWindowState(self, Chat, State):
1463 '''This event occurs when chat window is opened or closed. 1464 1465 @param Chat: Chat object. 1466 @type Chat: L{IChat} 1467 @param State: True if the window was opened or False if closed. 1468 @type State: bool 1469 '''
1470
1471 - def ClientWindowState(self, State):
1472 '''This event occurs when the state of the client window changes. 1473 1474 @param State: New window state. 1475 @type State: L{Window state<enums.wndUnknown>} 1476 '''
1477
1478 - def Command(self, Command):
1479 '''This event is triggered when a command is sent to the Skype API. 1480 1481 @param Command: Command object. 1482 @type Command: L{ICommand} 1483 '''
1484
1485 - def ConnectionStatus(self, Status):
1486 '''This event is caused by a connection status change. 1487 1488 @param Status: New connection status. 1489 @type Status: L{Connection status<enums.conUnknown>} 1490 '''
1491
1492 - def ContactsFocused(self, Username):
1493 '''This event is caused by a change in contacts focus. 1494 1495 @param Username: Name of the user that was focused or empty string if focus was lost. 1496 @type Username: unicode 1497 '''
1498
1499 - def Error(self, Command, Number, Description):
1500 '''This event is triggered when an error occurs during execution of an API command. 1501 1502 @param Command: Command object that caused the error. 1503 @type Command: L{ICommand} 1504 @param Number: Error number returned by the Skype API. 1505 @type Number: int 1506 @param Description: Description of the error. 1507 @type Description: unicode 1508 '''
1509
1510 - def FileTransferStatusChanged(self, Transfer, Status):
1511 '''This event occurs when a file transfer status changes. 1512 1513 @param Transfer: File transfer object. 1514 @type Transfer: L{IFileTransfer} 1515 @param Status: New status of the file transfer. 1516 @type Status: L{File transfer status<enums.fileTransferStatusNew>} 1517 '''
1518
1519 - def GroupDeleted(self, GroupId):
1520 '''This event is caused by a user deleting a custom contact group. 1521 1522 @param GroupId: Id of the deleted group. 1523 @type GroupId: int 1524 '''
1525
1526 - def GroupExpanded(self, Group, Expanded):
1527 '''This event is caused by a user expanding or collapsing a group in the contacts tab. 1528 1529 @param Group: Group object. 1530 @type Group: L{IGroup} 1531 @param Expanded: Tells if the group is expanded (True) or collapsed (False). 1532 @type Expanded: bool 1533 '''
1534
1535 - def GroupUsers(self, Group, Users):
1536 '''This event is caused by a change in a contact group members. 1537 1538 @param Group: Group object. 1539 @type Group: L{IGroup} 1540 @param Users: Group members. 1541 @type Users: tuple of L{IUser} 1542 '''
1543
1544 - def GroupVisible(self, Group, Visible):
1545 '''This event is caused by a user hiding/showing a group in the contacts tab. 1546 1547 @param Group: Group object. 1548 @type Group: L{IGroup} 1549 @param Visible: Tells if the group is visible or not. 1550 @type Visible: bool 1551 '''
1552
1553 - def MessageHistory(self, Username):
1554 '''This event is caused by a change in message history. 1555 1556 @param Username: Name of the user whose message history changed. 1557 @type Username: unicode 1558 '''
1559
1560 - def MessageStatus(self, Message, Status):
1561 '''This event is caused by a change in chat message status. 1562 1563 @param Message: Chat message object. 1564 @type Message: L{IChatMessage} 1565 @param Status: New status of the chat message. 1566 @type Status: L{Chat message status<enums.cmsUnknown>} 1567 '''
1568
1569 - def Mute(self, Mute):
1570 '''This event is caused by a change in mute status. 1571 1572 @param Mute: New mute status. 1573 @type Mute: bool 1574 '''
1575
1576 - def Notify(self, Notification):
1577 '''This event is triggered whenever Skype client sends a notification. 1578 1579 @param Notification: Notification string. 1580 @type Notification: unicode 1581 @note: Use this event only if there is no dedicated one. 1582 '''
1583
1584 - def OnlineStatus(self, User, Status):
1585 '''This event is caused by a change in the online status of a user. 1586 1587 @param User: User object. 1588 @type User: L{IUser} 1589 @param Status: New online status of the user. 1590 @type Status: L{Online status<enums.olsUnknown>} 1591 '''
1592
1593 - def PluginEventClicked(self, Event):
1594 '''This event occurs when a user clicks on a plug-in event. 1595 1596 @param Event: Plugin event object. 1597 @type Event: L{IPluginEvent} 1598 '''
1599
1600 - def PluginMenuItemClicked(self, MenuItem, Users, PluginContext, ContextId):
1601 '''This event occurs when a user clicks on a plug-in menu item. 1602 1603 @param MenuItem: Menu item object. 1604 @type MenuItem: L{IPluginMenuItem} 1605 @param Users: Users this item refers to. 1606 @type Users: tuple of L{IUser} 1607 @param PluginContext: Plug-in context. 1608 @type PluginContext: unicode 1609 @param ContextId: Context Id. 1610 @type ContextId: unicode 1611 @see: L{IPluginMenuItem} 1612 '''
1613
1614 - def Reply(self, Command):
1615 '''This event is triggered when the API replies to a command object. 1616 1617 @param Command: Command object. 1618 @type Command: L{ICommand} 1619 '''
1620
1621 - def SilentModeStatusChanged(self, Silent):
1622 '''This event occurs when a silent mode is switched off. 1623 1624 @param Silent: Skype client silent status. 1625 @type Silent: bool 1626 '''
1627
1628 - def SmsMessageStatusChanged(self, Message, Status):
1629 '''This event is caused by a change in the SMS message status. 1630 1631 @param Message: SMS message object. 1632 @type Message: L{ISmsMessage} 1633 @param Status: New status of the SMS message. 1634 @type Status: L{SMS message status<enums.smsMessageStatusUnknown>} 1635 '''
1636
1637 - def SmsTargetStatusChanged(self, Target, Status):
1638 '''This event is caused by a change in the SMS target status. 1639 1640 @param Target: SMS target object. 1641 @type Target: L{ISmsTarget} 1642 @param Status: New status of the SMS target. 1643 @type Status: L{SMS target status<enums.smsTargetStatusUnknown>} 1644 '''
1645
1646 - def UserAuthorizationRequestReceived(self, User):
1647 '''This event occurs when user sends you an authorization request. 1648 1649 @param User: User object. 1650 @type User: L{IUser} 1651 '''
1652
1653 - def UserMood(self, User, MoodText):
1654 '''This event is caused by a change in the mood text of the user. 1655 1656 @param User: User object. 1657 @type User: L{IUser} 1658 @param MoodText: New mood text. 1659 @type MoodText: unicode 1660 '''
1661
1662 - def UserStatus(self, Status):
1663 '''This event is caused by a user status change. 1664 1665 @param Status: New user status. 1666 @type Status: L{User status<enums.cusUnknown>} 1667 '''
1668
1669 - def VoicemailStatus(self, Mail, Status):
1670 '''This event is caused by a change in voicemail status. 1671 1672 @param Mail: Voicemail object. 1673 @type Mail: L{IVoicemail} 1674 @param Status: New status of the voicemail. 1675 @type Status: L{Voicemail status<enums.vmsUnknown>} 1676 '''
1677
1678 - def WallpaperChanged(self, Path):
1679 '''This event occurs when client wallpaper changes. 1680 1681 @param Path: Path to new wallpaper bitmap. 1682 @type Path: unicode 1683 '''
1684 1685 1686 ISkype._AddEvents(ISkypeEvents) 1687