Skip to content

Commit

Permalink
Manually merged changes from https://github.com/stigkj/Skype4Py
Browse files Browse the repository at this point in the history
  • Loading branch information
miohtama committed Jan 30, 2013
1 parent 65851cd commit d5ba2ba
Show file tree
Hide file tree
Showing 17 changed files with 88 additions and 117 deletions.
6 changes: 3 additions & 3 deletions Skype4Py/__init__.py
Expand Up @@ -85,12 +85,12 @@
a ``SkypeApiError`` name, the second one uses ``SkypeAPIError``. Other names including properties,
methods, arguments, variables and module names use lowercase letters with underscores.
.. _Skype4COM: http://developer.skype.com/accessories/skype4com
.. _Skype4COM: https://developer.skype.com/Docs/Skype4COM
.. |copy| unicode:: U+000A9
:author: Arkadiusz Wahlig <arkadiusz.wahlig@gmail.com>
:requires: Python 2.4 up until but not including 3.0.
:see: The Skype4Py website: https://github.com/awahlig/skype4py
:see: The Skype4Py website: https://developer.skype.com/wiki/Skype4Py
:license: BSD License (see the accompanying LICENSE file for more information)
:copyright: |copy| 2007-2009 Arkadiusz Wahlig
"""
Expand All @@ -105,7 +105,7 @@
import logging


__version__ = '1.0.32.1'
__version__ = '1.0.32.0'
"""The version of Skype4Py."""


Expand Down
11 changes: 11 additions & 0 deletions Skype4Py/api/darwin.py
Expand Up @@ -297,6 +297,17 @@ def __init__(self, opts):
self.center = CFDistributedNotificationCenter()
self.is_available = False
self.client_id = -1
self.thread_started = False

def start(self):
"""
Start the thread associated with this API object.
Ensure that the call is made no more than once,
to avoid raising a RuntimeError.
"""
if not self.thread_started:
super(SkypeAPI, self).start()
self.thread_started = True

def run(self):
self.logger.info('thread started')
Expand Down
13 changes: 9 additions & 4 deletions Skype4Py/api/posix_dbus.py
Expand Up @@ -42,6 +42,7 @@ def method(*args, **kwargs):
return lambda *args, **kwargs: None
else:
import dbus
import dbus.glib
import dbus.service
from dbus.mainloop.glib import DBusGMainLoop
import gobject
Expand All @@ -67,17 +68,23 @@ def __init__(self, opts):
self.logger = logging.getLogger('Skype4Py.api.posix_dbus.SkypeAPI')
SkypeAPIBase.__init__(self)
self.run_main_loop = opts.pop('RunMainLoop', True)
system_bus = opts.pop('UseSystemBus', False)
finalize_opts(opts)
self.skype_in = self.skype_out = self.dbus_name_owner_watch = None

# initialize glib multithreading support
gobject.threads_init()
dbus.glib.threads_init()

# dbus-python calls object.__init__() with arguments passed to SessionBus(),
# this throws a warning on newer Python versions; here we suppress it
warnings.simplefilter('ignore')
try:
self.bus = dbus.SessionBus(mainloop=DBusGMainLoop())
if system_bus:
bus = dbus.SystemBus
else:
bus = dbus.SessionBus
self.bus = bus(mainloop=DBusGMainLoop())
finally:
warnings.simplefilter('default')

Expand Down Expand Up @@ -176,9 +183,7 @@ def startup(self, minimized, nosplash):
import os
if os.fork() == 0: # we're child
os.setsid()
# a second empy argument should be added or an error would be raised by
# python-dbus starting method
os.execlp('skype','')
os.execlp('skype', 'skype')

def shutdown(self):
import os
Expand Down
2 changes: 1 addition & 1 deletion Skype4Py/api/posix_x11.py
Expand Up @@ -400,7 +400,7 @@ def startup(self, minimized, nosplash):
if not self.is_running():
if os.fork() == 0: # we're the child
os.setsid()
os.execlp('skype')
os.execlp('skype', 'skype')

def shutdown(self):
from signal import SIGINT
Expand Down
2 changes: 0 additions & 2 deletions Skype4Py/application.py
Expand Up @@ -249,6 +249,4 @@ def _GetPartnerHandle(self):


class ApplicationStreamCollection(CachedCollection):
"""Container for `ApplicationStream` objects.
"""
_CachedType = ApplicationStream
6 changes: 0 additions & 6 deletions Skype4Py/call.py
Expand Up @@ -564,8 +564,6 @@ def _GetVmDuration(self):


class CallCollection(CachedCollection):
"""Container for `Call` objects.
"""
_CachedType = Call


Expand Down Expand Up @@ -647,8 +645,6 @@ def _GetIdx(self):


class ParticipantCollection(CachedCollection):
"""Container for `Participant` objects.
"""
_CachedType = Participant


Expand Down Expand Up @@ -710,6 +706,4 @@ def _GetId(self):


class ConferenceCollection(CachedCollection):
"""Container for `Conference` objects.
"""
_CachedType = Conference
6 changes: 0 additions & 6 deletions Skype4Py/chat.py
Expand Up @@ -403,8 +403,6 @@ def _GetType(self):


class ChatCollection(CachedCollection):
"""Container for `Chat` objects.
"""
_CachedType = Chat


Expand Down Expand Up @@ -602,8 +600,6 @@ def _GetUsers(self):


class ChatMessageCollection(CachedCollection):
"""Container for `ChatMessage` objects.
"""
_CachedType = ChatMessage


Expand Down Expand Up @@ -686,6 +682,4 @@ def _SetRole(self, Value):


class ChatMemberCollection(CachedCollection):
"""Container for `ChatMember` objects.
"""
_CachedType = ChatMember
44 changes: 22 additions & 22 deletions Skype4Py/client.py
Expand Up @@ -45,7 +45,7 @@ def CreateEvent(self, EventId, Caption, Hint):
"""Creates a custom event displayed in Skype client's events pane.
:Parameters:
EventId : str
EventId : unicode
Unique identifier for the event.
Caption : unicode
Caption text.
Expand All @@ -55,7 +55,7 @@ def CreateEvent(self, EventId, Caption, Hint):
:return: Event object.
:rtype: `PluginEvent`
"""
self._Skype._DoCommand('CREATE EVENT %s CAPTION %s HINT %s' % (str(EventId),
self._Skype._DoCommand('CREATE EVENT %s CAPTION %s HINT %s' % (tounicode(EventId),
quote(tounicode(Caption)), quote(tounicode(Hint))))
return PluginEvent(self._Skype, EventId)

Expand All @@ -64,7 +64,7 @@ def CreateMenuItem(self, MenuItemId, PluginContext, CaptionText, HintText=u'', I
"""Creates custom menu item in Skype client's "Do More" menus.
:Parameters:
MenuItemId : str
MenuItemId : unicode
Unique identifier for the menu item.
PluginContext : `enums`.pluginContext*
Menu item context. Allows to choose in which client windows will the menu item appear.
Expand All @@ -85,7 +85,7 @@ def CreateMenuItem(self, MenuItemId, PluginContext, CaptionText, HintText=u'', I
:return: Menu item object.
:rtype: `PluginMenuItem`
"""
cmd = 'CREATE MENU_ITEM %s CONTEXT %s CAPTION %s ENABLED %s' % (str(MenuItemId), PluginContext,
cmd = 'CREATE MENU_ITEM %s CONTEXT %s CAPTION %s ENABLED %s' % (tounicode(MenuItemId), PluginContext,
quote(tounicode(CaptionText)), cndexp(Enabled, 'true', 'false'))
if HintText:
cmd += ' HINT %s' % quote(tounicode(HintText))
Expand All @@ -96,9 +96,7 @@ def CreateMenuItem(self, MenuItemId, PluginContext, CaptionText, HintText=u'', I
if PluginContext == pluginContextContact:
cmd += ' CONTACT_TYPE_FILTER %s' % ContactType
self._Skype._DoCommand(cmd)
item = PluginMenuItem(self._Skype, MenuItemId)
item._SetupProps(CaptionText, HintText, Enabled)
return item
return PluginMenuItem(self._Skype, MenuItemId, CaptionText, HintText, Enabled)

def Focus(self):
"""Brings the client window into focus.
Expand Down Expand Up @@ -212,7 +210,7 @@ def OpenOptionsDialog(self, Page=''):
Page : str
Page name to open.
:see: See http://developer.skype.com/public-api-reference#COMMAND_OPEN_OPTIONS for known Page values.
:see: See https://developer.skype.com/Docs/ApiDoc/OPEN_OPTIONS for known Page values.
"""
self.OpenDialog('OPTIONS', Page)

Expand Down Expand Up @@ -316,35 +314,37 @@ def _SetWindowState(self, Value):
""")


class PluginEvent(Cached):
class PluginEvent(object):
"""Represents an event displayed in Skype client's events pane.
"""
_ValidateHandle = str

def __init__(self, Skype, Id):
self._Skype = Skype
self._Id = tounicode(Id)

def __repr__(self):
return '<%s with Id=%s>' % (object.__repr__(self)[1:-1], repr(self.Id))

def Delete(self):
"""Deletes the event from the events pane in the Skype client.
"""
self._Owner._DoCommand('DELETE EVENT %s' % self.Id, 'DELETE EVENT')
self._Skype._DoCommand('DELETE EVENT %s' % self.Id)

def _GetId(self):
return self._Handle
return self._Id

Id = property(_GetId,
doc="""Unique event Id.
:type: str
:type: unicode
""")


class PluginMenuItem(Cached):
class PluginMenuItem(object):
"""Represents a menu item displayed in Skype client's "Do More" menus.
"""
_ValidateHandle = str

def _SetupProps(self, Caption, Hint, Enabled):
def __init__(self, Skype, Id, Caption, Hint, Enabled):
self._Skype = Skype
self._Id = tounicode(Id)
self._CacheDict = {}
self._CacheDict['CAPTION'] = tounicode(Caption)
self._CacheDict['HINT'] = tounicode(Hint)
Expand All @@ -356,13 +356,13 @@ def __repr__(self):
def _Property(self, PropName, Set=None):
if Set is None:
return self._CacheDict[PropName]
self._Owner._Property('MENU_ITEM', self.Id, PropName, Set)
self._Skype._Property('MENU_ITEM', self.Id, PropName, Set)
self._CacheDict[PropName] = unicode(Set)

def Delete(self):
"""Removes the menu item from the "Do More" menus.
"""
self._Owner._DoCommand('DELETE MENU_ITEM %s' % self.Id, 'DELETE MENU_ITEM')
self._Skype._DoCommand('DELETE MENU_ITEM %s' % self.Id)

def _GetCaption(self):
return self._Property('CAPTION')
Expand Down Expand Up @@ -402,10 +402,10 @@ def _SetHint(self, Value):
""")

def _GetId(self):
return self._Handle
return self._Id

Id = property(_GetId,
doc="""Unique menu item Id.
:type: str
:type: unicode
""")
2 changes: 1 addition & 1 deletion Skype4Py/errors.py
Expand Up @@ -37,7 +37,7 @@ class SkypeError(Exception):
| 1 | (unicode) Error description. |
+-------+------------------------------+
:see: http://developer.skype.com/public-api-reference#ERRORS for more information about
:see: https://developer.skype.com/Docs/ApiDoc/Error_codes for more information about
Skype error codes. Additionally an **error code 0** can be raised by Skype4Py
itself.
"""
Expand Down
2 changes: 0 additions & 2 deletions Skype4Py/filetransfer.py
Expand Up @@ -161,6 +161,4 @@ def _GetType(self):


class FileTransferCollection(CachedCollection):
"""Container for `FileTransfer` objects.
"""
_CachedType = FileTransfer
2 changes: 1 addition & 1 deletion Skype4Py/profile.py
Expand Up @@ -299,7 +299,7 @@ def _SetRichMoodText(self, Value):
:type: unicode
:see: http://developer.skype.com/public-api-reference#COMMAND_SET_PROFILE_RICH_MOOD_TEXT
:see: https://developer.skype.com/Docs/ApiDoc/SET_PROFILE_RICH_MOOD_TEXT
""")

def _GetSex(self):
Expand Down
6 changes: 0 additions & 6 deletions Skype4Py/sms.py
Expand Up @@ -233,8 +233,6 @@ def _GetType(self):


class SmsMessageCollection(CachedCollection):
"""Container for `SmsMessage` objects.
"""
_CachedType = SmsMessage


Expand Down Expand Up @@ -287,8 +285,6 @@ def _GetText(self):


class SmsChunkCollection(CachedCollection):
"""Container for `SmsChunk` objects.
"""
_CachedType = SmsChunk


Expand Down Expand Up @@ -332,6 +328,4 @@ def _GetStatus(self):


class SmsTargetCollection(CachedCollection):
"""Container for `SmsTarget` objects.
"""
_CachedType = SmsTarget
6 changes: 1 addition & 5 deletions Skype4Py/user.py
Expand Up @@ -368,7 +368,7 @@ def _GetRichMoodText(self):
:type: unicode
:see: http://developer.skype.com/public-api-reference#COMMAND_SET_PROFILE_RICH_MOOD_TEXT
:see: https://developer.skype.com/Docs/ApiDoc/SET_PROFILE_RICH_MOOD_TEXT
""")

def _GetSex(self):
Expand Down Expand Up @@ -403,8 +403,6 @@ def _GetTimezone(self):


class UserCollection(CachedCollection):
"""Container for `User` objects.
"""
_CachedType = User


Expand Down Expand Up @@ -536,6 +534,4 @@ def _GetUsers(self):


class GroupCollection(CachedCollection):
"""Container for `Group` objects.
"""
_CachedType = Group

0 comments on commit d5ba2ba

Please sign in to comment.