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

Source Code for Module Skype4Py.client

  1  """Skype client user interface control. 
  2  """ 
  3  __docformat__ = 'restructuredtext en' 
  4   
  5   
  6  import weakref 
  7   
  8  from enums import * 
  9  from errors import SkypeError 
 10  from utils import * 
 11   
 12   
13 -class Client(object):
14 """Represents a Skype client. Access using `skype.Skype.Client`. 15 """ 16
17 - def __init__(self, Skype):
18 """__init__. 19 20 :Parameters: 21 Skype : `Skype` 22 Skype 23 """ 24 self._SkypeRef = weakref.ref(Skype)
25
26 - def ButtonPressed(self, Key):
27 """This command sends a button pressed notification event. 28 29 :Parameters: 30 Key : str 31 Button key [0-9, A-Z, #, \*, UP, DOWN, YES, NO, SKYPE, PAGEUP, PAGEDOWN]. 32 """ 33 self._Skype._DoCommand('BTN_PRESSED %s' % Key)
34
35 - def ButtonReleased(self, Key):
36 """This command sends a button released notification event. 37 38 :Parameters: 39 Key : str 40 Button key [0-9, A-Z, #, \*, UP, DOWN, YES, NO, SKYPE, PAGEUP, PAGEDOWN]. 41 """ 42 self._Skype._DoCommand('BTN_RELEASED %s' % Key)
43
44 - def CreateEvent(self, EventId, Caption, Hint):
45 """Creates a custom event displayed in Skype client's events pane. 46 47 :Parameters: 48 EventId : unicode 49 Unique identifier for the event. 50 Caption : unicode 51 Caption text. 52 Hint : unicode 53 Hint text. Shown when mouse hoovers over the event. 54 55 :return: Event object. 56 :rtype: `PluginEvent` 57 """ 58 self._Skype._DoCommand('CREATE EVENT %s CAPTION %s HINT %s' % (tounicode(EventId), 59 quote(tounicode(Caption)), quote(tounicode(Hint)))) 60 return PluginEvent(self._Skype, EventId)
61
62 - def CreateMenuItem(self, MenuItemId, PluginContext, CaptionText, HintText=u'', IconPath='', Enabled=True, 63 ContactType=pluginContactTypeAll, MultipleContacts=False):
64 """Creates custom menu item in Skype client's "Do More" menus. 65 66 :Parameters: 67 MenuItemId : unicode 68 Unique identifier for the menu item. 69 PluginContext : `enums`.pluginContext* 70 Menu item context. Allows to choose in which client windows will the menu item appear. 71 CaptionText : unicode 72 Caption text. 73 HintText : unicode 74 Hint text (optional). Shown when mouse hoovers over the menu item. 75 IconPath : unicode 76 Path to the icon (optional). 77 Enabled : bool 78 Initial state of the menu item. True by default. 79 ContactType : `enums`.pluginContactType* 80 In case of `enums.pluginContextContact` tells which contacts the menu item should appear 81 for. Defaults to `enums.pluginContactTypeAll`. 82 MultipleContacts : bool 83 Set to True if multiple contacts should be allowed (defaults to False). 84 85 :return: Menu item object. 86 :rtype: `PluginMenuItem` 87 """ 88 cmd = 'CREATE MENU_ITEM %s CONTEXT %s CAPTION %s ENABLED %s' % (tounicode(MenuItemId), PluginContext, 89 quote(tounicode(CaptionText)), cndexp(Enabled, 'true', 'false')) 90 if HintText: 91 cmd += ' HINT %s' % quote(tounicode(HintText)) 92 if IconPath: 93 cmd += ' ICON %s' % quote(path2unicode(IconPath)) 94 if MultipleContacts: 95 cmd += ' ENABLE_MULTIPLE_CONTACTS true' 96 if PluginContext == pluginContextContact: 97 cmd += ' CONTACT_TYPE_FILTER %s' % ContactType 98 self._Skype._DoCommand(cmd) 99 return PluginMenuItem(self._Skype, MenuItemId, CaptionText, HintText, Enabled)
100
101 - def Focus(self):
102 """Brings the client window into focus. 103 """ 104 self._Skype._Api.allow_focus(self._Skype.Timeout) 105 self._Skype._DoCommand('FOCUS')
106
107 - def Minimize(self):
108 """Hides Skype application window. 109 """ 110 self._Skype._DoCommand('MINIMIZE')
111
112 - def OpenAddContactDialog(self, Username=''):
113 """Opens "Add a Contact" dialog. 114 115 :Parameters: 116 Username : str 117 Optional Skypename of the contact. 118 """ 119 self.OpenDialog('ADDAFRIEND', Username)
120
121 - def OpenAuthorizationDialog(self, Username):
122 """Opens authorization dialog. 123 124 :Parameters: 125 Username : str 126 Skypename of the user to authenticate. 127 """ 128 self.OpenDialog('AUTHORIZATION', Username)
129
130 - def OpenBlockedUsersDialog(self):
131 """Opens blocked users dialog. 132 """ 133 self.OpenDialog('BLOCKEDUSERS')
134
135 - def OpenCallHistoryTab(self):
136 """Opens call history tab. 137 """ 138 self.OpenDialog('CALLHISTORY')
139
140 - def OpenConferenceDialog(self):
141 """Opens create conference dialog. 142 """ 143 self.OpenDialog('CONFERENCE')
144
145 - def OpenContactsTab(self):
146 """Opens contacts tab. 147 """ 148 self.OpenDialog('CONTACTS')
149
150 - def OpenDialog(self, Name, *Params):
151 """Open dialog. Use this method to open dialogs added in newer Skype versions if there is no 152 dedicated method in Skype4Py. 153 154 :Parameters: 155 Name : str 156 Dialog name. 157 Params : unicode 158 One or more optional parameters. 159 """ 160 self._Skype._Api.allow_focus(self._Skype.Timeout) 161 params = filter(None, (str(Name),) + Params) 162 self._Skype._DoCommand('OPEN %s' % tounicode(' '.join(params)))
163
164 - def OpenDialpadTab(self):
165 """Opens dial pad tab. 166 """ 167 self.OpenDialog('DIALPAD')
168
169 - def OpenFileTransferDialog(self, Username, Folder):
170 """Opens file transfer dialog. 171 172 :Parameters: 173 Username : str 174 Skypename of the user. 175 Folder : str 176 Path to initial directory. 177 """ 178 self.OpenDialog('FILETRANSFER', Username, 'IN', path2unicode(Folder))
179
180 - def OpenGettingStartedWizard(self):
181 """Opens getting started wizard. 182 """ 183 self.OpenDialog('GETTINGSTARTED')
184
185 - def OpenImportContactsWizard(self):
186 """Opens import contacts wizard. 187 """ 188 self.OpenDialog('IMPORTCONTACTS')
189
190 - def OpenLiveTab(self):
191 """OpenLiveTab. 192 """ 193 self.OpenDialog('LIVETAB')
194
195 - def OpenMessageDialog(self, Username, Text=u''):
196 """Opens "Send an IM Message" dialog. 197 198 :Parameters: 199 Username : str 200 Message target. 201 Text : unicode 202 Message text. 203 """ 204 self.OpenDialog('IM', Username, tounicode(Text))
205
206 - def OpenOptionsDialog(self, Page=''):
207 """Opens options dialog. 208 209 :Parameters: 210 Page : str 211 Page name to open. 212 213 :see: See https://developer.skype.com/Docs/ApiDoc/OPEN_OPTIONS for known Page values. 214 """ 215 self.OpenDialog('OPTIONS', Page)
216
217 - def OpenProfileDialog(self):
218 """Opens current user profile dialog. 219 """ 220 self.OpenDialog('PROFILE')
221
222 - def OpenSearchDialog(self):
223 """Opens search dialog. 224 """ 225 self.OpenDialog('SEARCH')
226
227 - def OpenSendContactsDialog(self, Username=''):
228 """Opens send contacts dialog. 229 230 :Parameters: 231 Username : str 232 Optional Skypename of the user. 233 """ 234 self.OpenDialog('SENDCONTACTS', Username)
235
236 - def OpenSmsDialog(self, SmsId):
237 """Opens SMS window 238 239 :Parameters: 240 SmsId : int 241 SMS message Id. 242 """ 243 self.OpenDialog('SMS', str(SmsId))
244
245 - def OpenUserInfoDialog(self, Username):
246 """Opens user information dialog. 247 248 :Parameters: 249 Username : str 250 Skypename of the user. 251 """ 252 self.OpenDialog('USERINFO', Username)
253
254 - def OpenVideoTestDialog(self):
255 """Opens video test dialog. 256 """ 257 self.OpenDialog('VIDEOTEST')
258
259 - def Shutdown(self):
260 """Closes Skype application. 261 """ 262 self._Skype._Api.shutdown()
263
264 - def Start(self, Minimized=False, Nosplash=False):
265 """Starts Skype application. 266 267 :Parameters: 268 Minimized : bool 269 If True, Skype is started minimized in system tray. 270 Nosplash : bool 271 If True, no splash screen is displayed upon startup. 272 """ 273 self._Skype._Api.startup(Minimized, Nosplash)
274
275 - def _Get_Skype(self):
276 skype = self._SkypeRef() 277 if skype: 278 return skype 279 raise SkypeError('Skype4Py internal error')
280 281 _Skype = property(_Get_Skype) 282
283 - def _GetIsRunning(self):
284 return self._Skype._Api.is_running()
285 286 IsRunning = property(_GetIsRunning, 287 doc="""Tells if Skype client is running. 288 289 :type: bool 290 """) 291
292 - def _GetWallpaper(self):
293 return unicode2path(self._Skype.Variable('WALLPAPER'))
294
295 - def _SetWallpaper(self, Value):
296 self._Skype.Variable('WALLPAPER', path2unicode(Value))
297 298 Wallpaper = property(_GetWallpaper, _SetWallpaper, 299 doc="""Path to client wallpaper bitmap. 300 301 :type: str 302 """) 303
304 - def _GetWindowState(self):
305 return str(self._Skype.Variable('WINDOWSTATE'))
306
307 - def _SetWindowState(self, Value):
308 self._Skype.Variable('WINDOWSTATE', Value)
309 310 WindowState = property(_GetWindowState, _SetWindowState, 311 doc="""Client window state. 312 313 :type: `enums`.wnd* 314 """)
315 316
317 -class PluginEvent(object):
318 """Represents an event displayed in Skype client's events pane. 319 """
320 - def __init__(self, Skype, Id):
321 self._Skype = Skype 322 self._Id = tounicode(Id)
323
324 - def __repr__(self):
325 return '<%s with Id=%s>' % (object.__repr__(self)[1:-1], repr(self.Id))
326
327 - def Delete(self):
328 """Deletes the event from the events pane in the Skype client. 329 """ 330 self._Skype._DoCommand('DELETE EVENT %s' % self.Id)
331
332 - def _GetId(self):
333 return self._Id
334 335 Id = property(_GetId, 336 doc="""Unique event Id. 337 338 :type: unicode 339 """)
340 341
342 -class PluginMenuItem(object):
343 """Represents a menu item displayed in Skype client's "Do More" menus. 344 """
345 - def __init__(self, Skype, Id, Caption, Hint, Enabled):
346 self._Skype = Skype 347 self._Id = tounicode(Id) 348 self._CacheDict = {} 349 self._CacheDict['CAPTION'] = tounicode(Caption) 350 self._CacheDict['HINT'] = tounicode(Hint) 351 self._CacheDict['ENABLED'] = cndexp(Enabled, u'TRUE', u'FALSE')
352
353 - def __repr__(self):
354 return '<%s with Id=%s>' % (object.__repr__(self)[1:-1], repr(self.Id))
355
356 - def _Property(self, PropName, Set=None):
357 if Set is None: 358 return self._CacheDict[PropName] 359 self._Skype._Property('MENU_ITEM', self.Id, PropName, Set) 360 self._CacheDict[PropName] = unicode(Set)
361
362 - def Delete(self):
363 """Removes the menu item from the "Do More" menus. 364 """ 365 self._Skype._DoCommand('DELETE MENU_ITEM %s' % self.Id)
366
367 - def _GetCaption(self):
368 return self._Property('CAPTION')
369
370 - def _SetCaption(self, Value):
371 self._Property('CAPTION', tounicode(Value))
372 373 Caption = property(_GetCaption, _SetCaption, 374 doc="""Menu item caption text. 375 376 :type: unicode 377 """) 378
379 - def _GetEnabled(self):
380 return (self._Property('ENABLED') == 'TRUE')
381
382 - def _SetEnabled(self, Value):
383 self._Property('ENABLED', cndexp(Value, 'TRUE', 'FALSE'))
384 385 Enabled = property(_GetEnabled, _SetEnabled, 386 doc="""Defines whether the menu item is enabled when a user launches Skype. If no value is defined, 387 the menu item will be enabled. 388 389 :type: bool 390 """) 391
392 - def _GetHint(self):
393 return self._Property('HINT')
394
395 - def _SetHint(self, Value):
396 self._Property('HINT', tounicode(Value))
397 398 Hint = property(_GetHint, _SetHint, 399 doc="""Menu item hint text. 400 401 :type: unicode 402 """) 403
404 - def _GetId(self):
405 return self._Id
406 407 Id = property(_GetId, 408 doc="""Unique menu item Id. 409 410 :type: unicode 411 """)
412