Ejemplo n.º 1
0
def WMEnable(name=None):
    if name is None:
        name = os.path.splitext(os.path.basename(sys.argv[0]))[0]
    if isinstance(name, unicode):
        name = name.encode('utf-8')
    if not hasattr(objc, 'loadBundleFunctions'):
        return False
    bndl = NSBundle.bundleWithPath_(objc.pathForFramework('/System/Library/Frameworks/ApplicationServices.framework'))
    if bndl is None:
        print >>sys.stderr, 'ApplicationServices missing'
        return False
    d = {}
    app = NSApplication.sharedApplication()
    objc.loadBundleFunctions(bndl, d, FUNCTIONS)
    for (fn, sig) in FUNCTIONS:
        if fn not in d:
            print >>sys.stderr, 'Missing', fn
            return False
    err, psn = d['GetCurrentProcess']()
    if err:
        print >>sys.stderr, 'GetCurrentProcess', (err, psn)
        return False
    err = d['CPSSetProcessName'](psn, name)
    if err:
        print >>sys.stderr, 'CPSSetProcessName', (err, psn)
        return False
    err = d['CPSEnableForegroundOperation'](psn)
    if err:
        print >>sys.stderr, 'CPSEnableForegroundOperation', (err, psn)
        return False
    err = d['SetFrontProcess'](psn)
    if err:
        print >>sys.stderr, 'SetFrontProcess', (err, psn)
        return False
    return True
Ejemplo n.º 2
0
def WMEnable(name=None):
    if name is None:
        name = os.path.splitext(os.path.basename(sys.argv[0]))[0]
    if isinstance(name, six.unicode):
        name = name.encode("utf-8")
    if not hasattr(objc, "loadBundleFunctions"):
        return False
    bndl = NSBundle.bundleWithPath_(objc.pathForFramework("/System/Library/Frameworks/ApplicationServices.framework"))
    if bndl is None:
        print("ApplicationServices missing", file=sys.stderr)
        return False
    d = {}
    app = NSApplication.sharedApplication()
    objc.loadBundleFunctions(bndl, d, FUNCTIONS)
    for (fn, sig) in FUNCTIONS:
        if fn not in d:
            print("Missing", fn, file=sys.stderr)
            return False
    err, psn = d["GetCurrentProcess"]()
    if err:
        print("GetCurrentProcess", (err, psn), file=sys.stderr)
        return False
    err = d["CPSSetProcessName"](psn, name)
    if err:
        print("CPSSetProcessName", (err, psn), file=sys.stderr)
        return False
    err = d["CPSEnableForegroundOperation"](psn)
    if err:
        print("CPSEnableForegroundOperation", (err, psn))
        return False
    err = d["SetFrontProcess"](psn)
    if err:
        print("SetFrontProcess", (err, psn))
        return False
    return True
Ejemplo n.º 3
0
def WMEnable(name="Python"):
    if isinstance(name, unicode):
        name = name.encode("utf8")
    mainBundle = NSBundle.mainBundle()
    bPath = os.path.split(os.path.split(os.path.split(sys.executable)[0])[0])[0]
    if mainBundle.bundlePath() == bPath:
        return True
    bndl = NSBundle.bundleWithPath_(objc.pathForFramework("/System/Library/Frameworks/ApplicationServices.framework"))
    if bndl is None:
        print >>sys.stderr, "ApplicationServices missing"
        return False
    d = {}
    objc.loadBundleFunctions(bndl, d, FUNCTIONS)
    for (fn, sig) in FUNCTIONS:
        if fn not in d:
            print >>sys.stderr, "Missing", fn
            return False
    err, psn = d["GetCurrentProcess"]()
    if err:
        print >>sys.stderr, "GetCurrentProcess", (err, psn)
        return False
    err = d["CPSSetProcessName"](psn, name)
    if err:
        print >>sys.stderr, "CPSSetProcessName", (err, psn)
        return False
    err = d["CPSEnableForegroundOperation"](psn)
    if err:
        # print >>sys.stderr, 'CPSEnableForegroundOperation', (err, psn)
        return False
    err = d["SetFrontProcess"](psn)
    if err:
        print >>sys.stderr, "SetFrontProcess", (err, psn)
        return False
    return True
Ejemplo n.º 4
0
def WMEnable(name='Python'):
    if isinstance(name, unicode):
        name = name.encode('utf8')
    mainBundle = NSBundle.mainBundle()
    bPath = os.path.split(os.path.split(os.path.split(sys.executable)[0])[0])[0]
    if mainBundle.bundlePath() == bPath:
        return True
    bndl = NSBundle.bundleWithPath_(objc.pathForFramework('/System/Library/Frameworks/ApplicationServices.framework'))
    if bndl is None:
        print('ApplicationServices missing', file=sys.stderr)
        return False
    d = {}
    objc.loadBundleFunctions(bndl, d, FUNCTIONS)
    for (fn, sig) in FUNCTIONS:
        if fn not in d:
            print('Missing', fn, file=sys.stderr)
            return False
    err, psn = d['GetCurrentProcess']()
    if err:
        print('GetCurrentProcess', (err, psn), file=sys.stderr)
        return False
    err = d['CPSSetProcessName'](psn, name)
    if err:
        print('CPSSetProcessName', (err, psn), file=sys.stderr)
        return False
    err = d['CPSEnableForegroundOperation'](psn)
    if err:
        #print >>sys.stderr, 'CPSEnableForegroundOperation', (err, psn)
        return False
    err = d['SetFrontProcess'](psn)
    if err:
        print('SetFrontProcess', (err, psn), file=sys.stderr)
        return False
    return True
Ejemplo n.º 5
0
    def init(self):
        self = super(Growler, self).init()
        self.name = "UpShot"
        objc.loadBundle(
            "GrowlApplicationBridge",
            globals(),
            bundle_path=objc.pathForFramework(os.path.join(NSBundle.mainBundle().resourcePath(), "Growl.framework")),
        )

        self._growl = GrowlApplicationBridge
        self._growl.setGrowlDelegate_(self)
        self._callback = lambda ctx: None
        return self
Ejemplo n.º 6
0
def _load(g=globals()):
    import objc
    from Foundation import NSBundle
    OSErr = objc._C_SHT
    def S(*args):
        return ''.join(args)

    FUNCTIONS = [
        (u'LSGetApplicationForInfo', 'sII@Io^{FSRef=[80C]}o^@'),
    ]

    bndl = NSBundle.bundleWithPath_(objc.pathForFramework('/System/Library/Frameworks/ApplicationServices.framework'))
    objc.loadBundleFunctions(bndl, g, FUNCTIONS)
Ejemplo n.º 7
0
def toggleBluetooth():
    bundle = objc.loadBundle('IOBluetooth', globals(), bundle_path=objc.pathForFramework('/System/Library/Frameworks/IOBluetooth.framework'))
    if not bundle:
        alfred.exit('Toggle Bluetooth fail. initFrameworkWrapper error')
    fs = [('IOBluetoothPreferenceGetControllerPowerState', 'oI'),('IOBluetoothPreferenceSetControllerPowerState','vI')]
    ds = {}
    objc.loadBundleFunctions(bundle, ds, fs)
    for (name, handle) in fs:
        if not name in ds:
            alfred.exit('Toggle Bluetooth fail. failed to load: {}'.format(name))
    if ds['IOBluetoothPreferenceGetControllerPowerState']() == 1:
        ds['IOBluetoothPreferenceSetControllerPowerState'](0)
        alfred.exit('Bluetooth Disabled.')
    else:
        ds['IOBluetoothPreferenceSetControllerPowerState'](1)
        alfred.exit('Bluetooth Enable.')
Ejemplo n.º 8
0
def WMEnable(name='Python'):
    if isinstance(name, unicode):
        name = name.encode('utf8')
    mainBundle = NSBundle.mainBundle()
    bPath = os.path.split(os.path.split(os.path.split(
        sys.executable)[0])[0])[0]
    if mainBundle.bundlePath() == bPath:
        return True
    bndl = NSBundle.bundleWithPath_(
        objc.pathForFramework(
            '/System/Library/Frameworks/ApplicationServices.framework'))
    if bndl is None:
        print >> sys.stderr, 'ApplicationServices missing'
        return False
    d = {}
    objc.loadBundleFunctions(bndl, d, FUNCTIONS)
    for (fn, sig) in FUNCTIONS:
        if fn not in d:
            print >> sys.stderr, 'Missing', fn
            return False
    err, psn = d['GetCurrentProcess']()
    if err:
        print >> sys.stderr, 'GetCurrentProcess', (err, psn)
        return False
    err = d['CPSSetProcessName'](psn, name)
    if err:
        print >> sys.stderr, 'CPSSetProcessName', (err, psn)
        return False
    err = d['CPSEnableForegroundOperation'](psn)
    if err:
        print >> sys.stderr, 'CPSEnableForegroundOperation', (err, psn)
        return False
    err = d['SetFrontProcess'](psn)
    if err:
        print >> sys.stderr, 'SetFrontProcess', (err, psn)
        return False
    return True
Ejemplo n.º 9
0
def WMEnable(name="Python"):
    if not isinstance(name, bytes):
        name = name.encode("utf8")
    mainBundle = NSBundle.mainBundle()
    bPath = os.path.split(os.path.split(os.path.split(
        sys.executable)[0])[0])[0]
    if mainBundle.bundlePath() == bPath:
        return True
    bndl = NSBundle.bundleWithPath_(
        objc.pathForFramework(
            "/System/Library/Frameworks/ApplicationServices.framework"))
    if bndl is None:
        print >> sys.stderr, "ApplicationServices missing"
        return False
    d = {}
    objc.loadBundleFunctions(bndl, d, FUNCTIONS)
    for (fn, sig) in FUNCTIONS:
        if fn not in d:
            print >> sys.stderr, "Missing", fn
            return False
    err, psn = d["GetCurrentProcess"](None)
    if err:
        print >> sys.stderr, "GetCurrentProcess", (err, psn)
        return False
    err = d["CPSSetProcessName"](psn, name)
    if err:
        print >> sys.stderr, "CPSSetProcessName", (err, psn)
        return False
    err = d["CPSEnableForegroundOperation"](psn)
    if err:
        print >> sys.stderr, "CPSEnableForegroundOperation", (err, psn)
        return False
    err = d["SetFrontProcess"](psn)
    if err:
        print >> sys.stderr, "SetFrontProcess", (err, psn)
        return False
    return True
Ejemplo n.º 10
0
def WMEnable(name=None):
    if name is None:
        name = os.path.splitext(os.path.basename(sys.argv[0]))[0]
    if isinstance(name, unicode):
        name = name.encode('utf-8')
    if not hasattr(objc, 'loadBundleFunctions'):
        return False
    bndl = NSBundle.bundleWithPath_(
        objc.pathForFramework(
            '/System/Library/Frameworks/ApplicationServices.framework'))
    if bndl is None:
        print >> sys.stderr, 'ApplicationServices missing'
        return False
    d = {}
    app = NSApplication.sharedApplication()
    objc.loadBundleFunctions(bndl, d, FUNCTIONS)
    for (fn, sig) in FUNCTIONS:
        if fn not in d:
            print >> sys.stderr, 'Missing', fn
            return False
    err, psn = d['GetCurrentProcess']()
    if err:
        print >> sys.stderr, 'GetCurrentProcess', (err, psn)
        return False
    err = d['CPSSetProcessName'](psn, name)
    if err:
        print >> sys.stderr, 'CPSSetProcessName', (err, psn)
        return False
    err = d['CPSEnableForegroundOperation'](psn)
    if err:
        print >> sys.stderr, 'CPSEnableForegroundOperation', (err, psn)
        return False
    err = d['SetFrontProcess'](psn)
    if err:
        print >> sys.stderr, 'SetFrontProcess', (err, psn)
        return False
    return True
Ejemplo n.º 11
0
This module does not contain docstrings for the wrapped code, check Apple's
documentation for details on how to use these functions and classes.
"""

import sys
import objc
import Foundation

from CoreData import _metadata
from CoreData._CoreData import *
import CoreData._convenience

sys.modules["CoreData"] = objc.ObjCLazyModule(
    "CoreData",
    "com.apple.CoreData",
    objc.pathForFramework("/System/Library/Frameworks/CoreData.framework"),
    _metadata.__dict__,
    None,
    {
        "__doc__": __doc__,
        "__path__": __path__,
        "__loader__": globals().get("__loader__", None),
        "objc": objc,
    },
    (Foundation,),
)

import sys

del sys.modules["CoreData._metadata"]
Ejemplo n.º 12
0
'''
Python mapping for the ImageKit framework.

This module does not contain docstrings for the wrapped code, check Apple's
documentation for details on how to use these functions and classes. 
'''

import objc as _objc
from AppKit import *
from Foundation import *
#from Quartz.QuartzCore import *

__bundle__ = _objc.initFrameworkWrapper("ImageKit",
    frameworkIdentifier="com.apple.imageKit",
    frameworkPath=_objc.pathForFramework(
        "/System/Library/Frameworks/Quartz.framework/Frameworks/ImageKit.framework"),
    frameworkResourceName="Quartz.ImageKit",
    globals=globals())
Ejemplo n.º 13
0
import getopt
import os
import sys
import traceback
import uuid
import xml.parsers.expat
"""
OpenDirectory.framework
"""

import objc as _objc

__bundle__ = _objc.initFrameworkWrapper(
    "OpenDirectory",
    frameworkIdentifier="com.apple.OpenDirectory",
    frameworkPath=_objc.pathForFramework(
        "/System/Library/Frameworks/OpenDirectory.framework"),
    globals=globals())

# DS attributes we need
kDSStdRecordTypeUsers = "dsRecTypeStandard:Users"
kDSStdRecordTypeGroups = "dsRecTypeStandard:Groups"
kDSStdRecordTypePlaces = "dsRecTypeStandard:Places"
kDSStdRecordTypeResources = "dsRecTypeStandard:Resources"

kDS1AttrGeneratedUID = "dsAttrTypeStandard:GeneratedUID"
kDSNAttrRecordName = "dsAttrTypeStandard:RecordName"

eDSExact = 0x2001

sys_root = "/Applications/Server.app/Contents/ServerRoot"
os.environ["PATH"] = "%s/usr/bin:%s" % (sys_root, os.environ["PATH"])
Ejemplo n.º 14
0
Python mapping for the WebKit framework.

This module does not contain docstrings for the wrapped code, check Apple's
documentation for details on how to use these functions and classes.
"""
import sys

import Foundation
import objc
from WebKit import _metadata
from WebKit import _WebKit

objc.addConvenienceForBasicSequence("WebScriptObject", True)

sys.modules["WebKit"] = mod = objc.ObjCLazyModule(
    "WebKit",
    "com.apple.WebKit",
    objc.pathForFramework("/System/Library/Frameworks/WebKit.framework"),
    _metadata.__dict__,
    None,
    {
        "__doc__": __doc__,
        "objc": objc,
        "__path__": __path__,
        "__loader__": globals().get("__loader__", None),
    },
    (_WebKit, Foundation),
)

del sys.modules["WebKit._metadata"]
Ejemplo n.º 15
0
Python mapping for the JavaScriptCore framework.

This module does not contain docstrings for the wrapped code, check Apple's
documentation for details on how to use these functions and classes.
"""
import sys

import CoreFoundation
import JavaScriptCore._util
import objc
from JavaScriptCore import _metadata

sys.modules["JavaScriptCore"] = mod = objc.ObjCLazyModule(
    "JavaScriptCore",
    "com.apple.JavaScriptCore",
    objc.pathForFramework(
        "/System/Library/Frameworks/JavaScriptCore.framework"),
    _metadata.__dict__,
    None,
    {
        "__doc__": __doc__,
        "objc": objc,
        "__path__": __path__,
        "__loader__": globals().get("__loader__", None),
    },
    (CoreFoundation, ),
)

del sys.modules["JavaScriptCore._metadata"]

mod.autoreleasing = JavaScriptCore._util.autoreleasing
Ejemplo n.º 16
0
from miro import app
from miro import prefs
from miro import player
from miro import iso639
from miro.plat import utils
from miro.plat import bundle
from miro.plat import qtcomp
from miro.plat import script_codes
from miro.plat.frontends.widgets import threads
from miro.plat.frontends.widgets.helpers import NotificationForwarder
from miro.util import copy_subtitle_file

###############################################################################

qt_framework = pathForFramework("QuickTime.framework")
qt_bundle = NSBundle.bundleWithPath_(qt_framework)
loadBundleFunctions(qt_bundle, globals(), (('GetMediaLanguage', 's^^{}'),))

###############################################################################

def register_components():
    bundlePath = bundle.getBundlePath()
    componentsDirectoryPath = os.path.join(bundlePath, 'Contents', 'Components')
    components = glob.glob(os.path.join(componentsDirectoryPath, '*.component'))
    for component in components:
        cmpName = os.path.basename(component)
        stdloc1 = os.path.join(os.path.sep, "Library", "Quicktime", cmpName)
        stdloc2 = os.path.join(os.path.sep, "Library", "Audio", "Plug-Ins",
                               "Components", cmpName)
        if not os.path.exists(stdloc1) and not os.path.exists(stdloc2):
Ejemplo n.º 17
0
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
import threading

import objc

from ..config import TIMEOUT_SEC
from ..interfaces import GattService, GattCharacteristic, GattDescriptor

from .objc_helpers import cbuuid_to_uuid
from .provider import device_list, characteristic_list, descriptor_list


# Load CoreBluetooth bundle.
objc.loadBundle("CoreBluetooth", globals(),
    bundle_path=objc.pathForFramework(u'/System/Library/Frameworks/IOBluetooth.framework/Versions/A/Frameworks/CoreBluetooth.framework'))


class CoreBluetoothGattService(GattService):
    """CoreBluetooth GATT service object."""

    def __init__(self, service):
        """Create an instance of the GATT service from the provided CoreBluetooth
        CBService instance.
        """
        self._service = service

    @property
    def uuid(self):
        """Return the UUID of this GATT service."""
        return cbuuid_to_uuid(self._service.UUID())
Ejemplo n.º 18
0
import objc

from CoreFoundation import CFUUIDCreateFromString
from Foundation import NSBundle


bndl = NSBundle.bundleWithPath_(objc.pathForFramework('/System/Library/Frameworks/ApplicationServices.framework/'
                                                      'Versions/A/Frameworks/HIServices.framework/'
                                                      'Versions/A/HIServices'))
objc.loadBundleFunctions(bndl, globals(), [
    (u'DesktopPictureCopyDisplayForSpace', b'^{__CFDictionary=}Ii^{__CFString=}'),
    (u'DesktopPictureSetDisplayForSpace', b'vI^{__CFDictionary=}ii^{__CFString=}'),
])
bndl = NSBundle.bundleWithPath_(objc.pathForFramework('/System/Library/Frameworks/CoreGraphics.framework/Versions/A/'
                                                      'CoreGraphics'))
objc.loadBundleFunctions(bndl, globals(), [
    (u'_CGSDefaultConnection', b'i'),
    (u'CGSCopyManagedDisplaySpaces', b'^{__CFArray=}i', '', {'retval': {'already_retained': True}}),
    (u'CGMainDisplayID', b'I'),
    (u'CGSGetDisplayForUUID', b'I^{__CFUUID=}'),
])


class OSXSpace(object):
    def __init__(self, uuid, display_uuid, managed_space_id, id64, type, wsid):
        self.uuid = uuid
        self.display_uuid = display_uuid
        self.managed_space_id = managed_space_id
        self.id64 = id64
        self.type = type
        self.wsid = wsid
Ejemplo n.º 19
0
# Copyright (C) 2009 Johan Rydberg <*****@*****.**>

import objc
from Foundation import *

objc.loadBundle(
    "ScopeBar", globals(), 
    bundle_path=objc.pathForFramework("/System/Library/Frameworks/ScopeBar.framework")
    #bundle_identifier="com.mattgemmell.ScopeBar",
    #bundle_path="/System/Library/Frameworks/ScopeBar.framework"
    )


MGScopeBarDataSource = objc.informal_protocol(
    "MGScopeBarDataSource",
    [
        objc.selector(
            None,
            selector="numberOfGroupsInScopeBar:",
            signature="i@:@",
            isRequired=1,
            ),
        objc.selector(
            None,
            selector="scopeBar:itemIdentifiersForGroup:",
            signature="@@:@i",
            isRequired=1,
            ),
        objc.selector(
            None,
            selector="scopeBar:labelForGroup:",
Ejemplo n.º 20
0
'''
Python mapping for the PubSub framework.

This module does not contain docstrings for the wrapped code, check Apple's
documentation for details on how to use these functions and classes.
'''
import sys

import Foundation
import objc
from PubSub import _metadata

sys.modules['PubSub'] = mod = objc.ObjCLazyModule('PubSub',
    "com.apple.PubSub",
    objc.pathForFramework("/System/Library/Frameworks/PubSub.framework"),
    _metadata.__dict__, None, {
       '__doc__': __doc__,
       '__path__': __path__,
       '__loader__': globals().get('__loader__', None),
       'objc': objc,
    }, ( Foundation,))

import sys
del sys.modules['PubSub._metadata']
Ejemplo n.º 21
0

def CFSocketStreamSOCKSGetErrorSubdomain(err):
    return (err.error >> 16) & 0xFFFF


frameworkPath = "/System/Library/Frameworks/CFNetwork.framework"
if not os.path.exists(frameworkPath):
    frameworkPath = (
        "/System/Library/Frameworks/CoreServices.framework/Frameworks/CFNetwork.framework"
    )

sys.modules["CFNetwork"] = mod = objc.ObjCLazyModule(
    "CFNetwork",
    "com.apple.CFNetwork",
    objc.pathForFramework(frameworkPath),
    _metadata.__dict__,
    None,
    {
        "__doc__":
        __doc__,
        "objc":
        objc,
        "__path__":
        __path__,
        "__loader__":
        globals().get("__loader__", None),
        "CFSocketStreamSOCKSGetError":
        CFSocketStreamSOCKSGetError,
        "CFSocketStreamSOCKSGetErrorSubdomain":
        CFSocketStreamSOCKSGetErrorSubdomain,
Ejemplo n.º 22
0
'''
Python mapping for the InstantMessage framework.

This module does not contain docstrings for the wrapped code, check Apple's
documentation for details on how to use these functions and classes.
'''
import sys
import objc
import Foundation
import Quartz

from InstantMessage import _metadata

sys.modules['InstantMessage'] = mod = objc.ObjCLazyModule('InstantMessage',
    "com.apple.IMFramework",
    objc.pathForFramework("/System/Library/Frameworks/InstantMessage.framework"),
    _metadata.__dict__, None, {
       '__doc__': __doc__,
       '__path__': __path__,
       '__loader__': globals().get('__loader__', None),
       'objc': objc,
    }, ( Foundation, Quartz,))

import sys
del sys.modules['InstantMessage._metadata']
Ejemplo n.º 23
0
'''
Python mapping for the SystemConfiguration framework.

This module does not contain docstrings for the wrapped code, check Apple's
documentation for details on how to use these functions and classes.
'''
import sys

import Foundation
import SystemConfiguration._manual
import objc
from SystemConfiguration import _metadata

sys.modules['SystemConfiguration'] = mod = objc.ObjCLazyModule(
    'SystemConfiguration', "com.apple.SystemConfiguration",
    objc.pathForFramework(
        "/System/Library/Frameworks/SystemConfiguration.framework"),
    _metadata.__dict__, None, {
        '__doc__': __doc__,
        '__path__': __path__,
        '__loader__': globals().get('__loader__', None),
        'objc': objc,
    }, (
        Foundation,
        SystemConfiguration._manual,
    ))

import sys
del sys.modules['SystemConfiguration._metadata']

import SystemConfiguration._manual as m
for nm in dir(m):
Ejemplo n.º 24
0
'''
Python mapping for the SyncServices framework.

This module does not contain docstrings for the wrapped code, check Apple's
documentation for details on how to use these functions and classes. 
'''

import objc as _objc
from CoreData import *

__bundle__ = _objc.initFrameworkWrapper("SyncServices",
    frameworkIdentifier="com.apple.syncservices",
    frameworkPath=_objc.pathForFramework(
        "/System/Library/Frameworks/SyncServices.framework"),
    globals=globals())
Ejemplo n.º 25
0
'''
import objc, sys
import os
import Foundation

from LaunchServices import _metadata

if os.path.exists('/System/Library/Frameworks/ApplicationServices.framework/Frameworks/LaunchServices.framework'):
    framework = '/System/Library/Frameworks/ApplicationServices.framework/Frameworks/LaunchServices.framework'
else:
    framework = '/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework'

sys.modules['LaunchServices'] = mod = objc.ObjCLazyModule(
    "LaunchServices",
    "com.apple.LaunchServices",
    objc.pathForFramework(framework),
    _metadata.__dict__, None, {
    '__doc__': __doc__,
    'objc': objc,
    '__path__': __path__,
    '__loader__': globals().get('__loader__', None),
    }, (Foundation,))

import sys
del sys.modules['LaunchServices._metadata']


# Load an undocumented, yet announced function. This function was announced
# in TN2029 (http://developer.apple.com/technotes/tn/tn2029.html)
#objc.loadBundleFunctions(
#        __bundle__, mod.__dict__,
				('LSSharedFileListInsertItemURL',       '^{OpaqueLSSharedFileListItemRef=}^{OpaqueLSSharedFileListRef=}^{OpaqueLSSharedFileListItemRef=}^{__CFString=}^{OpaqueIconRef=}^{__CFURL=}^{__CFDictionary=}^{__CFArray=}'),
				('kLSSharedFileListItemBeforeFirst',    '^{OpaqueLSSharedFileListItemRef=}'),]
	loadBundleFunctions(SFL_bundle, globals(), functions)
else:
	from LaunchServices import kLSSharedFileListItemBeforeFirst, LSSharedFileListCreate, LSSharedFileListCopySnapshot, LSSharedFileListItemCopyDisplayName, LSSharedFileListItemResolve, LSSharedFileListItemMove, LSSharedFileListItemRemove, LSSharedFileListRemoveAllItems, LSSharedFileListInsertItemURL

# Shoutout to Mike Lynn for the mount_share function below, allowing for the scripting of mounting network shares.
# See his blog post for more details: http://michaellynn.github.io/2015/08/08/learn-you-a-better-pyobjc-bridgesupport-signature/
class attrdict(dict): 
	__getattr__ = dict.__getitem__
	__setattr__ = dict.__setitem__

NetFS = attrdict()
# Can cheat and provide 'None' for the identifier, it'll just use frameworkPath instead
# scan_classes=False means only add the contents of this Framework
NetFS_bundle = initFrameworkWrapper('NetFS', frameworkIdentifier=None, frameworkPath=pathForFramework('NetFS.framework'), globals=NetFS, scan_classes=False)

def mount_share(share_path):
	# Mounts a share at /Volumes, returns the mount point or raises an error
	sh_url = CFURLCreateWithString(None, share_path, None)
	# Set UI to reduced interaction
	open_options  = {NetFS.kNAUIOptionKey: NetFS.kNAUIOptionNoUI}
	# Allow mounting sub-directories of root shares
	mount_options = {NetFS.kNetFSAllowSubMountsKey: True}
	# Mount!
	result, output = NetFS.NetFSMountURLSync(sh_url, None, None, None, open_options, mount_options, None)
	# Check if it worked
	if result != 0:
		 raise Exception('Error mounting url "%s": %s' % (share_path, output))
	# Return the mountpath
	return str(output[0])
Ejemplo n.º 27
0
    from Cython.Distutils import build_ext
    install_requires.append('cython')
except ImportError:
    from distutils.command.build_ext import build_ext
    if platform != 'android':
        print('\n\nYou need Cython to compile Pyjnius.\n\n')
        raise
    files = [fn[:-3] + 'c' for fn in files if fn.endswith('pyx')]

if platform == 'android':
    # for android, we use SDL...
    libraries = ['sdl', 'log']
    library_dirs = ['libs/' + environ['ARCH']]
elif platform == 'darwin':
    import objc
    framework = objc.pathForFramework('JavaVM.framework')
    if not framework:
        raise Exception('You must install Java on your Mac OS X distro')
    extra_link_args = ['-framework', 'JavaVM']
    include_dirs = [join(framework, 'Versions/A/Headers')]
else:
    import subprocess
    # otherwise, we need to search the JDK_HOME
    jdk_home = environ.get('JDK_HOME')
    if not jdk_home:
        if platform == 'win32':
            env_var = environ.get('JAVA_HOME')
            if env_var and 'jdk' in env_var:
                jdk_home = env_var

                # Remove /bin if it's appended to JAVA_HOME
Ejemplo n.º 28
0
'''
Python mapping for the SystemConfiguration framework.

This module does not contain docstrings for the wrapped code, check Apple's
documentation for details on how to use these functions and classes.
'''
import sys
import objc
import Foundation
import SystemConfiguration._manual

from SystemConfiguration import _metadata

sys.modules['SystemConfiguration'] = mod = objc.ObjCLazyModule('SystemConfiguration',
    "com.apple.SystemConfiguration",
    objc.pathForFramework("/System/Library/Frameworks/SystemConfiguration.framework"),
    _metadata.__dict__, None, {
       '__doc__': __doc__,
       '__path__': __path__,
       '__loader__': globals().get('__loader__', None),
       'objc': objc,
    }, ( Foundation, SystemConfiguration._manual,))

import sys
del sys.modules['SystemConfiguration._metadata']

import SystemConfiguration._manual as m
for nm in dir(m):
    setattr(mod, nm, getattr(m, nm))

mod.SCBondInterfaceRef = mod.SCNetworkInterfaceRef
Ejemplo n.º 29
0
This module does not contain docstrings for the wrapped code, check Apple's
documentation for details on how to use these functions and classes.
"""

import sys

import Foundation
import objc
from . import _metadata
from . import _AutomaticAssessmentConfiguration

sys.modules["AutomaticAssessmentConfiguration"] = mod = objc.ObjCLazyModule(
    "AutomaticAssessmentConfiguration",
    "com.apple.AutomaticAssessmentConfiguration",
    objc.pathForFramework(
        "/System/Library/Frameworks/AutomaticAssessmentConfiguration.framework"
    ),
    _metadata.__dict__,
    None,
    {
        "__doc__": __doc__,
        "objc": objc,
        "__path__": __path__,
        "__loader__": globals().get("__loader__", None),
    },
    (_AutomaticAssessmentConfiguration, Foundation),
)

del sys.modules["AutomaticAssessmentConfiguration._metadata"]
Ejemplo n.º 30
0
'''
Python mapping for the ScriptingBridge framework.

This module does not contain docstrings for the wrapped code, check Apple's
documentation for details on how to use these functions and classes.
'''
import sys
import objc
import Foundation

from ScriptingBridge import _metadata
from ScriptingBridge._ScriptingBridge import *

sys.modules['ScriptingBridge'] = mod = objc.ObjCLazyModule('ScriptingBridge',
    "com.apple.ScriptingBridge",
    objc.pathForFramework("/System/Library/Frameworks/ScriptingBridge.framework"),
    _metadata.__dict__, None, {
       '__doc__': __doc__,
       '__path__': __path__,
       'objc': objc,
    }, ( Foundation,))

# Override the default behaviour of the bridge to ensure that we
# make the minimal amount of AppleScript calls.
import objc
objc.addConvenienceForClass('SBElementArray', [
    ('__iter__', lambda self: iter(self.objectEnumerator())),
])
Ejemplo n.º 31
0
'''
Python mapping for the ImageIO framework.

This module does not contain docstrings for the wrapped code, check Apple's
documentation for details on how to use these functions and classes.
'''
import sys
import objc
import Quartz.CoreGraphics

from Quartz.ImageIO import _metadata

sys.modules['Quartz.ImageIO'] = mod = objc.ObjCLazyModule(
    'Quartz.ImageIO', "com.apple.ImageIO.framework",
    objc.pathForFramework(
        "/System/Library/Frameworks/ApplicationServices.framework/Frameworks/ImageIO.framework"
    ), _metadata.__dict__, None, {
        '__doc__': __doc__,
        '__path__': __path__,
        'objc': objc,
    }, (Quartz.CoreGraphics, ))
Ejemplo n.º 32
0
'''
Python mapping for the InstallerPlugins framework.

This module does not contain docstrings for the wrapped code, check Apple's
documentation for details on how to use these functions and classes.
'''
import sys
import objc
import AppKit

from InstallerPlugins import _metadata

sys.modules['InstallerPlugins'] = mod = objc.ObjCLazyModule('InstallerPlugins',
    "com.apple.InstallerPlugins",
    objc.pathForFramework("/System/Library/Frameworks/InstallerPlugins.framework"),
    _metadata.__dict__, None, {
       '__doc__': __doc__,
       '__path__': __path__,
       'objc': objc,
    }, ( AppKit,))
Ejemplo n.º 33
0
This module does not contain docstrings for the wrapped code, check Apple's
documentation for details on how to use these functions and classes.
'''
import sys
import objc
import CoreFoundation
import Foundation

from Quartz.CoreGraphics import _metadata
from Quartz.CoreGraphics._inlines import _inline_list_


sys.modules['Quartz.CoreGraphics'] = mod = objc.ObjCLazyModule('Quartz.CoreGraphics',
    "com.apple.CoreGraphics",
    objc.pathForFramework("/System/Library/Frameworks/ApplicationServices.framework/Frameworks/CoreGraphics.framework"),
    _metadata.__dict__, _inline_list_, {
       '__doc__': __doc__,
       '__path__': __path__,
       'objc': objc,
    }, ( CoreFoundation,))


def _load(mod):
    import Quartz
    Quartz.CoreGraphics = mod

    # XXX: CGFLOAT_MIN is a #define for FLT_MIN or DBL_MIN, which isn't detected properly
    # by the metadata script.
    import sys
Ejemplo n.º 34
0
'''
Python mapping for the QuartzCore framework.

This module does not contain docstrings for the wrapped code, check Apple's
documentation for details on how to use these functions and classes.
'''
import sys
import objc
import Foundation

from Quartz.QuartzFilters import _metadata

sys.modules['Quartz.QuartzFilters'] = mod = objc.ObjCLazyModule('Quartz.QuartzFilters',
    "com.apple.quartzfilters",
    objc.pathForFramework("/System/Library/Frameworks/Quartz.framework/Frameworks/QuartzFilters.framework"),
    _metadata.__dict__, None, {
       '__doc__': __doc__,
       '__path__': __path__,
       'objc': objc,
    }, ( Foundation,))
Ejemplo n.º 35
0
This module does not contain docstrings for the wrapped code, check Apple's
documentation for details on how to use these functions and classes.
"""
import sys

import CoreFoundation
import objc
from Quartz.CoreGraphics import _metadata
from Quartz.CoreGraphics._inlines import _inline_list_

sys.modules["Quartz.CoreGraphics"] = mod = objc.ObjCLazyModule(
    "Quartz.CoreGraphics",
    "com.apple.CoreGraphics",
    objc.pathForFramework(
        "/System/Library/Frameworks/ApplicationServices.framework/Frameworks/CoreGraphics.framework"  # noqa: B950
    ),
    _metadata.__dict__,
    _inline_list_,
    {
        "__doc__": __doc__,
        "__path__": __path__,
        "__loader__": globals().get("__loader__", None),
        "objc": objc,
    },
    (CoreFoundation, ),
)

del sys.modules["Quartz.CoreGraphics._metadata"]

Ejemplo n.º 36
0
#    WiiRow, a WiiRemote frontend for FrontRow and stuff
#
#    Copyright (C) 2009 Christian L. Jacobsen
#
#    This file is part of WiiRow
#
#    Cloninator is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    Cloninator is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with Cloninator; if not, write to the Free Software
#    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

# Load the framework relative to the executable in the .app bundle
import objc
objc.loadBundle("EyeTunes", globals(),
    bundle_path=objc.pathForFramework(
    u'@executable_path@/../../Frameworks/EyeTunes.framework'))

# vim:ts=4:sw=4:et:
Ejemplo n.º 37
0
"""
Python mapping for the AppKit framework.

This module does not contain docstrings for the wrapped code, check Apple's
documentation for details on how to use these functions and classes. 
"""

import objc as _objc
from Foundation import *

from AppKit._inlines import _inline_list_

__bundle__ = _objc.initFrameworkWrapper(
    "AppKit",
    frameworkIdentifier="com.apple.AppKit",
    frameworkPath=_objc.pathForFramework("/System/Library/Frameworks/AppKit.framework"),
    globals=globals(),
    inlineTab=_inline_list_,
)

# NSApp is a global variable that can be changed in ObjC,
# somewhat emulate that (it is *not* possible to assign to
# NSApp in Python)
from AppKit._nsapp import NSApp

# Import some manually maintained helper code:
from AppKit._appmain import *
from AppKit._nsbezierpath import *
from AppKit._nsfont import *
from AppKit._nsquickdrawview import *
from AppKit._nsbezierpath import *
Ejemplo n.º 38
0
'''
Python mapping for the SearchKit framework.

This module does not contain docstrings for the wrapped code, check Apple's
documentation for details on how to use these functions and classes. 
'''

import objc as _objc
from CoreFoundation import *

__bundle__ = _objc.initFrameworkWrapper("SearchKit",
    frameworkIdentifier="com.apple.SearchKit",
    frameworkPath=_objc.pathForFramework(
        "/System/Library/Frameworks/CoreServices.framework/Frameworks/SearchKit.framework"),
    globals=globals())

try:
    SKIndexGetTypeID

except NameError:
    # SKIndexGetTypeID is documented, but not actually exported by Leopard. Try to
    # emulate the missing functionality. 
    #
    # See also radar:6525606.
    #
    def workaround():
        from Foundation import NSMutableData, NSAutoreleasePool

        pool = NSAutoreleasePool.alloc().init()
        try:
            rI = SKIndexCreateWithMutableData(NSMutableData.data(),
Ejemplo n.º 39
0
'''
Python mapping for the NotificationCenter framework.

This module does not contain docstrings for the wrapped code, check Apple's
documentation for details on how to use these functions and classes.
'''

import objc
import sys
import Cocoa

from NotificationCenter import _metadata, _NotificationCenter

sys.modules['NotificationCenter'] = mod = objc.ObjCLazyModule(
    "NotificationCenter",
    "com.apple.notificationcenter",
    objc.pathForFramework("/System/Library/Frameworks/NotificationCenter.framework"),
    _metadata.__dict__, None, {
        '__doc__': __doc__,
        'objc': objc,
        '__path__': __path__,
        '__loader__': globals().get('__loader__', None),
    }, (Cocoa, ))

import sys
del sys.modules['NotificationCenter._metadata']
del sys.modules['NotificationCenter._NotificationCenter']
Ejemplo n.º 40
0
classes through PyObjC.
"""

import objc
import os.path

_FRAMEWORK_PATH = u'/Library/Frameworks/LightAquaBlue.framework'
if not os.path.isdir(_FRAMEWORK_PATH):
    raise ImportError("Cannot load LightAquaBlue framework, not found at" + \
        _FRAMEWORK_PATH)

try:
    # mac os 10.5 loads frameworks using bridgesupport metadata
    __bundle__ = objc.initFrameworkWrapper("LightAquaBlue",
            frameworkIdentifier="com.blammit.LightAquaBlue",
            frameworkPath=objc.pathForFramework(_FRAMEWORK_PATH),
            globals=globals())

except AttributeError:
    # earlier versions use loadBundle() and setSignatureForSelector()

    objc.loadBundle("LightAquaBlue", globals(), 
       bundle_path=objc.pathForFramework(_FRAMEWORK_PATH))

    # return int, take (object, object, object, output unsigned char, output int)           
    # i.e. in python: return (int, char, int), take (object, object, object)
    objc.setSignatureForSelector("BBServiceAdvertiser", 
        "addRFCOMMServiceDictionary:withName:UUID:channelID:serviceRecordHandle:",
        "i@0:@@@o^Co^I")
        
    # set to take (6-char array, unsigned char, object)
Ejemplo n.º 41
0
Python mapping for the CoreHaptics framework.

This module does not contain docstrings for the wrapped code, check Apple's
documentation for details on how to use these functions and classes.
"""

import objc
import sys
import Foundation

from CoreHaptics import _metadata

sys.modules["CoreHaptics"] = mod = objc.ObjCLazyModule(
    "CoreHaptics",
    "com.apple.CoreHaptics",
    objc.pathForFramework("/System/Library/Frameworks/CoreHaptics.framework"),
    _metadata.__dict__,
    None,
    {
        "__doc__": __doc__,
        "objc": objc,
        "__path__": __path__,
        "__loader__": globals().get("__loader__", None),
    },
    (Foundation, ),
)

import sys

del sys.modules["CoreHaptics._metadata"]
Ejemplo n.º 42
0
'''
Python mapping for the NetworkExtension framework.

This module does not contain docstrings for the wrapped code, check Apple's
documentation for details on how to use these functions and classes.
'''

import objc
import sys
import Foundation

from NetworkExtension import _metadata, _NetworkExtension

sys.modules['NetworkExtension'] = mod = objc.ObjCLazyModule(
    "NetworkExtension",
    "com.apple.NetworkExtension",
    objc.pathForFramework("/System/Library/Frameworks/NetworkExtension.framework"),
    _metadata.__dict__, None, {
        '__doc__': __doc__,
        'objc': objc,
        '__path__': __path__,
        '__loader__': globals().get('__loader__', None),
    }, (Foundation,))

import sys
del sys.modules['NetworkExtension._metadata']
Ejemplo n.º 43
0
'''
Python mapping for the CoreServices framework.

This module does not contain docstrings for the wrapped code, check Apple's
documentation for details on how to use these functions and classes.

Note that PyObjC only wrappers the non-deprecated parts of the CoreServices
framework.
'''
import sys

import FSEvents
import objc
from CoreServices import CarbonCore
from CoreServices import DictionaryServices
from CoreServices import LaunchServices
from CoreServices import Metadata
from CoreServices import SearchKit

sys.modules['CoreServices'] = mod = objc.ObjCLazyModule(
    'CoreServices', "com.apple.CoreServices",
    objc.pathForFramework("/System/Library/Frameworks/CoreServices.framework"),
    {}, None, {
        '__doc__': __doc__,
        '__path__': __path__,
        '__loader__': globals().get('__loader__', None),
        'objc': objc,
    }, (FSEvents, DictionaryServices, LaunchServices, SearchKit, Metadata,
        CarbonCore))
Ejemplo n.º 44
0
'''
Python mapping for the MediaLibrary framework.

This module does not contain docstrings for the wrapped code, check Apple's
documentation for details on how to use these functions and classes.
'''

import sys

import Cocoa
import Quartz
import objc
from MediaLibrary import _metadata

sys.modules['MediaLibrary'] = mod = objc.ObjCLazyModule(
    "MediaLibrary", "com.apple.MediaLibrary",
    objc.pathForFramework("/System/Library/Frameworks/MediaLibrary.framework"),
    _metadata.__dict__, None, {
        '__doc__': __doc__,
        'objc': objc,
        '__path__': __path__,
        '__loader__': globals().get('__loader__', None),
    }, (Cocoa, Quartz))

import sys
del sys.modules['MediaLibrary._metadata']
Ejemplo n.º 45
0
'''
Python mapping for the QuartzComposer framework.

This module does not contain docstrings for the wrapped code, check Apple's
documentation for details on how to use these functions and classes.
'''
import sys
import objc
import Quartz.CoreGraphics
import Foundation

from Quartz.QuartzComposer import _metadata

sys.modules['Quartz.QuartzComposer'] = mod = objc.ObjCLazyModule(
    'Quartz.QuartzComposer', "com.apple.QuartzComposer",
    objc.pathForFramework(
        "/System/Library/Frameworks/Quartz.framework/Frameworks/QuartzComposer.framework"
    ), _metadata.__dict__, None, {
        '__doc__': __doc__,
        '__path__': __path__,
        '__loader__': globals().get('__loader__', None),
        'objc': objc,
    }, (
        Quartz.CoreGraphics,
        Foundation,
    ))

import sys
del sys.modules['Quartz.QuartzComposer._metadata']
Ejemplo n.º 46
0
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
import logging
import threading
import time

import objc

from ..config import TIMEOUT_SEC
from ..interfaces import Adapter
from ..platform import get_provider


# Load IOBluetooth functions for controlling bluetooth power state.
objc.loadBundleFunctions(
    objc.loadBundle("IOBluetooth", globals(), bundle_path=objc.pathForFramework(u'/System/Library/Frameworks/IOBluetooth.framework')),
    globals(),
    [('IOBluetoothPreferenceGetControllerPowerState', b'oI'),('IOBluetoothPreferenceSetControllerPowerState', b'vI')]
)

logger = logging.getLogger(__name__)


class CoreBluetoothAdapter(Adapter):
    """CoreBluetooth BLE network adapter.  Note that CoreBluetooth has no
    concept of individual BLE adapters so any instance of this class will just
    interact with BLE globally.
    """

    def __init__(self):
        """Create an instance of the bluetooth adapter from the provided bluez
Ejemplo n.º 47
0
import socket
import Queue
import hci

from pwn import *

from core import InternalBlue

import objc
import binascii
import os
filepath = os.path.dirname(os.path.abspath(__file__))

objc.initFrameworkWrapper("IOBluetoothExtended",
    frameworkIdentifier="de.tu-darmstadt.seemoo.IOBluetoothExtended",
    frameworkPath=objc.pathForFramework(filepath+"/../macos-framework/IOBluetoothExtended.framework"),
    globals=globals())

class macOSCore(InternalBlue):
    NSNotificationCenter = objc.lookUpClass('NSNotificationCenter')

    def __init__(self, queue_size=1000, btsnooplog_filename='btsnoop.log', log_level='info', fix_binutils='True', data_directory="."):
        super(macOSCore, self).__init__(queue_size, btsnooplog_filename, log_level, fix_binutils, data_directory=".")
        self.doublecheck = False
        self.iobe = None

    def device_list(self):
        """
        Get a list of connected devices
        """
Ejemplo n.º 48
0
'''
Python mapping for the GameplayKit framework.

This module does not contain docstrings for the wrapped code, check Apple's
documentation for details on how to use these functions and classes.
'''

import sys

import Cocoa
import SpriteKit
import objc
from GameplayKit import _metadata
from GameplayKit._GameplayKit import *

sys.modules['GameplayKit'] = mod = objc.ObjCLazyModule(
    "GameplayKit", "com.apple.GameplayKit",
    objc.pathForFramework("/System/Library/Frameworks/GameplayKit.framework"),
    _metadata.__dict__, None, {
        '__doc__': __doc__,
        'objc': objc,
        '__path__': __path__,
        '__loader__': globals().get('__loader__', None),
    }, (Cocoa, SpriteKit))

import sys
del sys.modules['GameplayKit._metadata']
Ejemplo n.º 49
0
'''
Python mapping for the AddressBook framework.

This module does not contain docstrings for the wrapped code, check Apple's
documentation for details on how to use these functions and classes.
'''

import sys

import Cocoa
import objc
from MediaAccessibility import _metadata

sys.modules['MediaAccessibility'] = mod = objc.ObjCLazyModule(
    "MediaAccessibility", "com.apple.MediaAccessibility",
    objc.pathForFramework(
        "/System/Library/Frameworks/MediaAccessibility.framework"),
    _metadata.__dict__, None, {
        '__doc__': __doc__,
        'objc': objc,
        '__path__': __path__,
        '__loader__': globals().get('__loader__', None),
    }, (Cocoa, ))

import sys
del sys.modules['MediaAccessibility._metadata']
Ejemplo n.º 50
0
    from Cython.Distutils import build_ext
except ImportError:
    from distutils.command.build_ext import build_ext
    if platform != 'android':
        print('\n\nWarning: You need Cython to compile Pyjnius.\n\n')
    files = [fn[:-3] + 'c' for fn in files if fn.endswith('pyx')]

if platform == 'android':
    # for android, we use SDL...
    libraries = ['sdl', 'log']
    library_dirs = ['libs/' + environ['ARCH']]
elif platform == 'darwin':

    try:
        import objc
        framework = objc.pathForFramework('JavaVM.framework')
        if not framework:
            raise Exception('You must install Java on your Mac OS X distro')
        extra_link_args = ['-framework', 'JavaVM']
        include_dirs = [join(framework, 'Versions/A/Headers')]
    except ImportError:
        import subprocess
        java_home = subprocess.check_output('/usr/libexec/java_home').strip()
        print(java_home)
        library_dirs = [join(java_home, 'jre', 'lib', 'server')]
        libraries = ['jvm']
        extra_link_args = ['-Wl,-rpath', library_dirs[0]]
        include_dirs = [
            join(java_home, 'include'),
            join(java_home, 'include', 'darwin')
        ]
Ejemplo n.º 51
0
    <arg type='^I'/>
    <retval type='I'/>
  </function>
  <function name='IORegisterForSystemPower'>
    <arg type='^v'/>
    <arg type='^^{IONotificationPort}'/>
    <arg function_pointer='true' type='^?'>
      <arg type='^v'/>
      <arg type='I'/>
      <arg type='I'/>
      <arg type='^v'/>
      <retval type='v'/>
    </arg>
    <arg type='^I'/>
    <retval type='I'/>
  </function>
</signatures>
"""

# __bundle__ = objc.initFrameworkWrapper("IOKit",
#                                        frameworkIdentifier="com.apple.framework.IOKit",
#                                        frameworkPath=objc.pathForFramework("/System/Library/Frameworks/IOKit.framework"),
#                                        globals=globals())

__bundle__ = objc.parseBridgeSupport(
    GEN_BRIDGE_METADATA,
    globals(),
    objc.pathForFramework("/System/Library/Frameworks/IOKit.framework"))

objc.loadBundleFunctions(__bundle__, globals(), [("IOPMAssertionCreateWithName", b"i@I@o^I")])
Ejemplo n.º 52
0
"""
Python mapping for the ShazamKit framework.

This module does not contain docstrings for the wrapped code, check Apple's
documentation for details on how to use these functions and classes.
"""

import sys

import Cocoa
import objc
from . import _metadata

sys.modules["ShazamKit"] = mod = objc.ObjCLazyModule(
    "ShazamKit",
    "com.apple.ShazamKit",
    objc.pathForFramework("/System/Library/Frameworks/ShazamKit.framework"),
    _metadata.__dict__,
    None,
    {
        "__doc__": __doc__,
        "objc": objc,
        "__path__": __path__,
        "__loader__": globals().get("__loader__", None),
    },
    (Cocoa, ),
)

del sys.modules["ShazamKit._metadata"]
Ejemplo n.º 53
0
'''
Python mapping for the SearchKit framework.

This module does not contain docstrings for the wrapped code, check Apple's
documentation for details on how to use these functions and classes. 
'''

import objc as _objc
from CoreFoundation import *

__bundle__ = _objc.initFrameworkWrapper(
    "SearchKit",
    frameworkIdentifier="com.apple.SearchKit",
    frameworkPath=_objc.pathForFramework(
        "/System/Library/Frameworks/CoreServices.framework/Frameworks/SearchKit.framework"
    ),
    globals=globals())

try:
    SKIndexGetTypeID
    SKDocumentRef

except NameError:
    # SKIndexGetTypeID is documented, but not actually exported by Leopard. Try to
    # emulate the missing functionality.
    #
    # See also radar:6525606.
    #
    def workaround():
        from Foundation import NSMutableData, NSAutoreleasePool
Ejemplo n.º 54
0
Python mapping for the ScreenSaver framework.

This module does not contain docstrings for the wrapped code, check Apple's
documentation for details on how to use these functions and classes.
"""
import sys
import objc
import AppKit

from ScreenSaver import _metadata
from ScreenSaver._inlines import _inline_list_

sys.modules["ScreenSaver"] = mod = objc.ObjCLazyModule(
    "ScreenSaver",
    "com.apple.ScreenSaver",
    objc.pathForFramework("/System/Library/Frameworks/ScreenSaver.framework"),
    _metadata.__dict__,
    _inline_list_,
    {
        "__doc__": __doc__,
        "__path__": __path__,
        "__loader__": globals().get("__loader__", None),
        "objc": objc,
    },
    (AppKit, ),
)

import sys

del sys.modules["ScreenSaver._metadata"]
Ejemplo n.º 55
0
'''
Python mapping for the Message framework.

This module does not contain docstrings for the wrapped code, check Apple's
documentation for details on how to use these functions and classes.
'''
import sys
import objc
import Foundation

from Message import _metadata

sys.modules['Message'] = mod = objc.ObjCLazyModule(
    'Message', "com.apple.MessageFramework",
    objc.pathForFramework("/System/Library/Frameworks/Message.framework"),
    _metadata.__dict__, None, {
        '__doc__': __doc__,
        '__path__': __path__,
        '__loader__': globals().get('__loader__', None),
        'objc': objc,
    }, (Foundation, ))

import sys
del sys.modules['Message._metadata']
Ejemplo n.º 56
0
'''
Python mapping for the CoreAudioKit framework.

This module does not contain docstrings for the wrapped code, check Apple's
documentation for details on how to use these functions and classes.
'''

import objc
import sys
import Foundation

from CoreAudioKit import _metadata
import CoreAudio

sys.modules['CoreAudioKit'] = mod = objc.ObjCLazyModule(
    "CoreAudio",
    "com.apple.CoreAudioKit",
    objc.pathForFramework("/System/Library/Frameworks/CoreAudioKit.framework"),
    _metadata.__dict__, None, {
        '__doc__': __doc__,
        'objc': objc,
        '__path__': __path__,
        '__loader__': globals().get('__loader__', None),
    }, (CoreAudio, Foundation,))

import sys
del sys.modules['CoreAudioKit._metadata']
Ejemplo n.º 57
0
'''
Python mapping for the CalendarStore framework.

This module does not contain docstrings for the wrapped code, check Apple's
documentation for details on how to use these functions and classes.
'''

import sys

import Foundation
import objc
from CalendarStore import _metadata

sys.modules['CalendarStore'] = objc.ObjCLazyModule(
    "CalendarStore", "com.apple.CalendarStore",
    objc.pathForFramework(
        "/System/Library/Frameworks/CalendarStore.framework"),
    _metadata.__dict__, None, {
        '__doc__': __doc__,
        '__path__': __path__,
        'objc': objc,
        '__loader__': globals().get('__loader__', None),
    }, (Foundation, ))

import sys
del sys.modules['CalendarStore._metadata']
Ejemplo n.º 58
0
import Quartz
import objc
import os

dirname, filename = os.path.split(os.path.abspath(__file__))
path = dirname + '/objc/Key.framework'

bundle = objc.loadBundle("Key", globals(), bundle_path=objc.pathForFramework(path))

class Keyboard:

    @staticmethod
    def press(code):
        keyEvent = Quartz.CGEventCreateKeyboardEvent(None, Key.getKeyCode_(code), True)
        Quartz.CGEventPost(Quartz.kCGHIDEventTap, keyEvent)
        
    @staticmethod
    def release(code):
        keyEvent = Quartz.CGEventCreateKeyboardEvent(None, Key.getKeyCode_(code), False)
        Quartz.CGEventPost(Quartz.kCGHIDEventTap, keyEvent)


    @staticmethod
    def key(character):
        return Key.getKeyCode_(character)
Ejemplo n.º 59
0
This module does not contain docstrings for the wrapped code, check Apple's
documentation for details on how to use these functions and classes.
"""

import sys

import Cocoa
import LocalAuthentication
import objc
from . import _metadata

sys.modules["LocalAuthenticationUIView"] = mod = objc.ObjCLazyModule(
    "LocalAuthenticationUIView",
    "com.apple.LocalAuthenticationUIView",
    objc.pathForFramework(
        "/System/Library/Frameworks/LocalAuthenticationUIView.framework"),
    _metadata.__dict__,
    None,
    {
        "__doc__": __doc__,
        "objc": objc,
        "__path__": __path__,
        "__loader__": globals().get("__loader__", None),
    },
    (
        LocalAuthentication,
        Cocoa,
    ),
)

del sys.modules["LocalAuthenticationUIView._metadata"]
Ejemplo n.º 60
0
'''
Python mapping for the IOSurface framework.

This module does not contain docstrings for the wrapped code, check Apple's
documentation for details on how to use these functions and classes.
'''

import objc
import sys
import Foundation

from IOSurface import _metadata

sys.modules['IOSurface'] = mod = objc.ObjCLazyModule(
    "IOSurface",
    "com.apple.IOSurface",
    objc.pathForFramework("/System/Library/Frameworks/IOSurface.framework"),
    _metadata.__dict__, None, {
        '__doc__': __doc__,
        'objc': objc,
        '__path__': __path__,
        '__loader__': globals().get('__loader__', None),
    }, (Foundation,))

import sys
del sys.modules['IOSurface._metadata']