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

Source Code for Module Skype4Py.client

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