Пример #1
0
/*************************************************************************
 *
 * hu_XMLLoad( inResourceName, inResourceExtension )
 *
 * Purpose: Load a resource( XML ) file into a CFPropertyListRef
 *
 * Inputs: inResourceName		- name of the resource file
 *			inResourceExtension - extension of the resource file
 *
 * Returns: CFPropertyListRef - the data
 */
static CFPropertyListRef hu_XMLLoad(CFStringRef inResourceName, CFStringRef inResourceExtension) {
	CFURLRef resFileCFURLRef;
	CFPropertyListRef tCFPropertyListRef = NULL;
	
	// check the main (application) bundle
	resFileCFURLRef = CFBundleCopyResourceURL(CFBundleGetMainBundle(), inResourceName, inResourceExtension, NULL);
	
	if ( !resFileCFURLRef ) {
		// check this specific (HID_Utilities framework) bundle
		CFBundleRef tCFBundleRef = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.HID_Utilities"));
		if ( tCFBundleRef ) {
			resFileCFURLRef = CFBundleCopyResourceURL( tCFBundleRef, inResourceName, inResourceExtension, NULL );
		}
	}
	if ( !resFileCFURLRef ) {
		// check bundles already loaded or otherwise known to the current process
		CFArrayRef tCFArrayRef = CFBundleGetAllBundles();
		CFIndex idx, cnt = CFArrayGetCount(tCFArrayRef);
		for ( idx = 0; idx < cnt; idx++ ) {
			CFBundleRef tCFBundleRef = (CFBundleRef) CFArrayGetValueAtIndex(tCFArrayRef, idx) ;
			if ( tCFBundleRef ) {
				resFileCFURLRef = CFBundleCopyResourceURL( tCFBundleRef, inResourceName, inResourceExtension, NULL );
				if ( resFileCFURLRef ) {
					break;
				}
			}
		}
	}
	if ( resFileCFURLRef ) {
		tCFPropertyListRef = hu_LoadFromXMLFile(resFileCFURLRef);
		CFRelease(resFileCFURLRef);
	}
	
	return (tCFPropertyListRef);
}   // hu_XMLLoad
Пример #2
0
RemoteVSTClient::RemoteVSTClient(CFBundleRef bundle, audioMasterCallback theMaster, AEffect *theEffect, bool showGUI) :
    RemotePluginClient(theMaster, theEffect)
{
	m_bundle = bundle;
	m_audioMaster = theMaster;
	pid_t child;

	SInt32 errorCode;
	CFDataRef data;
	CFURLRef configUrl = CFBundleCopyResourceURL(bundle, CFSTR("config"), CFSTR("plist"), NULL);
	if (configUrl == 0) {
		return;
	}
	CFURLCreateDataAndPropertiesFromResource(kCFAllocatorDefault, configUrl, &data, NULL, NULL, &errorCode);
	m_props = (CFDictionaryRef) CFPropertyListCreateFromXMLData( kCFAllocatorDefault, data, kCFPropertyListImmutable, NULL);

	std::string dllName(CFStringGetCStringPtr(get_path_prop(CFSTR("plugin-name")), NULL));
    std::string arg = dllName + "," + getFileIdentifiers();
    if (showGUI) arg = "-g " + arg;
	const char *argStr = arg.c_str();

	CFURLRef server_url = CFBundleCopyResourceURL(m_bundle, CFSTR("dssi-vst-server.exe"), CFSTR("so"), NULL);
	if (server_url != NULL) {
		CFStringRef server_path = CFURLCopyFileSystemPath(server_url, kCFURLPOSIXPathStyle);
		if (server_path != NULL) {
			const char *c_server_path = CFStringGetCStringPtr(server_path, NULL);
			CFStringRef wine_path =  (CFStringRef) CFDictionaryGetValue(m_props, CFSTR("wine-path"));
			if (wine_path != NULL) {
				const char *c_wine_path = CFStringGetCStringPtr(wine_path, NULL);	
				std::cerr << "RemoteVSTClient: executing " << c_server_path << "\n";
				// if no dispaly environment guess...
				// setenv("DISPLAY", ":0", 0);
				setenv("DYLD_FALLBACK_LIBRARY_PATH", "/usr/X11/lib:/usr/lib", 0);
				if ((child = fork()) < 0) {
					cleanup();
					throw((std::string)"Fork failed");
				} else if (child == 0) { // child process
					if (execlp(c_wine_path, "wine", c_server_path, argStr, NULL)) {
						perror("Exec failed");
						exit(1);
					}
				}
				syncStartup();
				return;
			}
		}
	}
	cleanup();
	throw((std::string)"Failed to find dssi-vst-server executable");
	return;
 }
Пример #3
0
// ---------------------------------------------------------------------------
// A PLACER DANS STYLEMGR
// ------------
bool bMacMapType::make_style(){
_bTrace_("bMacMapType::make_style",false);
char		path[PATH_MAX];
CFURLRef	url;
	switch(_kind){
		case kBaseKindPoint:
			url=CFBundleCopyResourceURL(CFBundleGetMainBundle(),CFSTR("default_point_style"),CFSTR("xml"),NULL);
			break;
		case kBaseKindPolyline:
			url=CFBundleCopyResourceURL(CFBundleGetMainBundle(),CFSTR("default_line_style"),CFSTR("xml"),NULL);
			break;
		case kBaseKindText:
			url=CFBundleCopyResourceURL(CFBundleGetMainBundle(),CFSTR("default_text_style"),CFSTR("xml"),NULL);
			break;
		case kBaseKindPolygon:
			url=CFBundleCopyResourceURL(CFBundleGetMainBundle(),CFSTR("default_surf_style"),CFSTR("xml"),NULL);
			break;
		case kBaseKindRaster:
			url=CFBundleCopyResourceURL(CFBundleGetMainBundle(),CFSTR("default_raster_style"),CFSTR("xml"),NULL);
			break;
		default:
_te_("bad type kind "+_kind);
			return(false);
			break;
	}	
	if(!url){
_te_("url == NULL");
		return(false);
	}
	
CFStringRef	cfs=CFURLCopyFileSystemPath(url,kCFURLPOSIXPathStyle);
	CFRelease(url);
	CFStringGetCString(cfs,path,PATH_MAX,kCFStringEncodingMacRoman);
	CFRelease(cfs);

void*		buffer;
int			sz;
bStdFile	stl(path,"r");
	if(stl.status()){
_te_("stl.status()="+stl.status());
		return(false);
	}
	
	stl.mount((char**)&buffer,&sz);
	_bse.set_param("styles","default.xml",buffer,sz);
	free(buffer);
	
	return(true);
}
Пример #4
0
static string getFrameworkFromBundle()
{
	// Attempt to locate the Firebird.framework bundle
	CFBundleRef fbFramework = CFBundleGetBundleWithIdentifier(CFSTR(DARWIN_FRAMEWORK_ID));
	if (fbFramework)
	{
		CFURLRef msgFileUrl = CFBundleCopyResourceURL(fbFramework,
			CFSTR(DARWIN_GEN_DIR), NULL, NULL);
		if (msgFileUrl)
		{
			CFStringRef	msgFilePath = CFURLCopyFileSystemPath(msgFileUrl,
				kCFURLPOSIXPathStyle);
			if (msgFilePath)
			{
				char file_buff[MAXPATHLEN];
				if (CFStringGetCString(msgFilePath, file_buff, MAXPATHLEN,
					kCFStringEncodingMacRoman))
				{
					string dir = file_buff;
					dir += PathUtils::dir_sep;
					return dir;
				}
			}
		}
	}

	// No luck
	return "";
}
Пример #5
0
static FILE* ios_open_from_bundle(const char path[], const char* perm) {
    // Get a reference to the main bundle
    CFBundleRef mainBundle = CFBundleGetMainBundle();

    // Get a reference to the file's URL
    CFStringRef pathRef = CFStringCreateWithCString(NULL, path, kCFStringEncodingUTF8);
    CFURLRef imageURL = CFBundleCopyResourceURL(mainBundle, pathRef, NULL, NULL);
    CFRelease(pathRef);
    if (!imageURL) {
        return nullptr;
    }

    // Convert the URL reference into a string reference
    CFStringRef imagePath = CFURLCopyFileSystemPath(imageURL, kCFURLPOSIXPathStyle);
    CFRelease(imageURL);

    // Get the system encoding method
    CFStringEncoding encodingMethod = CFStringGetSystemEncoding();

    // Convert the string reference into a C string
    const char *finalPath = CFStringGetCStringPtr(imagePath, encodingMethod);
    FILE* fileHandle = fopen(finalPath, perm);
    CFRelease(imagePath);
    return fileHandle;
}
Пример #6
0
	FILE* fopen (const char *filename, const char *mode) {
		
		#ifdef HX_MACOS
		FILE *result = ::fopen (filename, "rb");
		if (!result) {
			CFStringRef str = CFStringCreateWithCString (NULL, filename, kCFStringEncodingUTF8);
			CFURLRef path = CFBundleCopyResourceURL (CFBundleGetMainBundle (), str, NULL, NULL);
			CFRelease (str);
			if (path) {
				str = CFURLCopyPath (path);
				CFIndex maxSize = CFStringGetMaximumSizeForEncoding (CFStringGetLength (str), kCFStringEncodingUTF8);
				char *buffer = (char *)malloc (maxSize);
				if (CFStringGetCString (str, buffer, maxSize, kCFStringEncodingUTF8)) {
					result = ::fopen (buffer,"rb");
					free (buffer);
				}
				CFRelease (str);
				CFRelease (path);
			}
		}
		return result;
		#else
		return ::fopen (filename, mode);
		#endif
		
	}
Пример #7
0
void UnloadBundle(CFBundleRef theBundle)
{
	/*get bundle resource and convert from xml to propertylist struct so we can look for revdontunload attribute and not unload- necessary for external
	that interface with Cocoa*/
	Boolean dontunload = False;
	CFPropertyListRef tCFPropertyListRef = NULL;
	short resrefnum = CFBundleOpenBundleResourceMap (theBundle );
	CFURLRef resFileCFURLRef = CFBundleCopyResourceURL(theBundle,CFSTR("revinfo"),CFSTR("plist"),NULL);
	CFDataRef resCFDataRef;
	if (resFileCFURLRef && CFURLCreateDataAndPropertiesFromResource(kCFAllocatorDefault,resFileCFURLRef,&resCFDataRef,nil,nil,nil))
	{
		if (resCFDataRef)
		{
			CFStringRef errorString;
			tCFPropertyListRef = CFPropertyListCreateFromXMLData(kCFAllocatorDefault,resCFDataRef,kCFPropertyListImmutable,&errorString);
			CFRelease(resCFDataRef);
		}
	}
	if (tCFPropertyListRef)
	{
		if (CFDictionaryGetValueIfPresent((CFDictionaryRef)tCFPropertyListRef,CFSTR("revdontunload"),NULL))
			dontunload = True;
	}
	if (resFileCFURLRef)
		CFRelease(resFileCFURLRef);
	CFBundleCloseBundleResourceMap (theBundle,resrefnum);
	if (theBundle && !dontunload)
	{
		CFBundleUnloadExecutable(theBundle);
		CFRelease(theBundle);
	}
}
Пример #8
0
// ---------------------------------
// Load the element strings from the given resource (XML) file into a CFPropertyListRef
static CFPropertyListRef xml_load(const CFStringRef pResourceName,const CFStringRef pResourceExtension)
{
	CFPropertyListRef tCFPropertyListRef = NULL;
	CFURLRef resFileCFURLRef = CFBundleCopyResourceURL(CFBundleGetMainBundle(), pResourceName, pResourceExtension, NULL);

	if (NULL != resFileCFURLRef)
	{
		CFDataRef resCFDataRef;

		if (CFURLCreateDataAndPropertiesFromResource(kCFAllocatorDefault, resFileCFURLRef, &resCFDataRef, nil, nil, nil))
		{
			if (NULL != resCFDataRef)
			{
				CFStringRef errorString;

				tCFPropertyListRef = CFPropertyListCreateFromXMLData(kCFAllocatorDefault, resCFDataRef, kCFPropertyListImmutable, &errorString);
				if (NULL == tCFPropertyListRef)
					CFShow(errorString);
				CFRelease(resCFDataRef);
			}
		}
		CFRelease(resFileCFURLRef);
	}
	return tCFPropertyListRef;
}
Пример #9
0
static CFPropertyListRef getPropertyList()
{
  CFDataRef       xmlData;
  CFStringRef error;
  CFPropertyListRef propertyList;
  CFBundleRef appBundle;
  CFURLRef myRef;

  // locate the starter's bundle:
  appBundle = CFBundleGetMainBundle();
  
  // get a URL for the named resource
  myRef = CFBundleCopyResourceURL(appBundle, CFSTR(RSRCNAME), 
				  NULL, NULL);
  if (myRef == NULL) {
    return NULL;
  }
  
  // Load the XML data using its URL.
  CFURLCreateDataAndPropertiesFromResource(kCFAllocatorDefault, myRef, 
					   &xmlData, NULL, NULL, NULL);

  // convert to a Property List
  propertyList = CFPropertyListCreateFromXMLData(kCFAllocatorDefault, xmlData, 
						 kCFPropertyListImmutable, 
						 &error);
  if (error != NULL) {
    return NULL;
  }

  return propertyList;
}
Пример #10
0
char const* path_to_file(CFStringRef file, CFStringRef extension)
{
    // Get a reference to the main bundle
    CFBundleRef mainBundle = CFBundleGetMainBundle();
    
    if (mainBundle == NULL) {
        return NULL;
    }
    
    // Get a reference to the file's URL
    CFURLRef imageURL = CFBundleCopyResourceURL(mainBundle,
                                                file,
                                                extension,
                                                NULL);
    
    if (imageURL == NULL) {
        return NULL;
    }
    
    // Convert the URL reference into a string reference
    CFStringRef imagePath = CFURLCopyFileSystemPath(imageURL,
                                                    kCFURLPOSIXPathStyle);
    
    // Get the system encoding method
    CFStringEncoding encodingMethod = CFStringGetSystemEncoding();
    
    // Convert the string reference into a C string
    const char *path = CFStringGetCStringPtr(imagePath, encodingMethod);
    return path;
}
Пример #11
0
//----------------------------------------------------------------------------//
const char* CEGuiBaseApplication::getDataPathPrefix() const
{
    static char dataPathPrefix[PATH_MAX];

#ifdef __APPLE__
    CFURLRef datafilesURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(),
                                                    CFSTR("datafiles"),
                                                    0, 0);
    CFURLGetFileSystemRepresentation(datafilesURL, true,
                                     reinterpret_cast<UInt8*>(dataPathPrefix),
                                     PATH_MAX);
    CFRelease(datafilesURL);
#else
    char* envDataPath = 0;

    // get data path from environment var
    envDataPath = getenv(DATAPATH_VAR_NAME);

    // set data path prefix / base directory.  This will
    // be either from an environment variable, or from
    // a compiled in default based on original configure
    // options
    if (envDataPath != 0)
        strcpy(dataPathPrefix, envDataPath);
    else
        strcpy(dataPathPrefix, CEGUI_SAMPLE_DATAPATH);
#endif

    return dataPathPrefix;
}
Пример #12
0
int CreateScene() {

    CFURLRef balls_dat_url = CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("balls"), CFSTR("dat"),NULL);
    char filename[1024];
    CFURLGetFileSystemRepresentation(balls_dat_url, true, (UInt8*)filename, (CFIndex)sizeof(filename));
    CFRelease(balls_dat_url);

    global_scene = rt_newscene();
    rt_initialize();

    if ( readmodel(filename, global_scene) != 0 ) {
        rt_finalize();
        return -1;
    }

    // need these early for create_graphics_window() so grab these here...
    scenedef *scene = (scenedef *) global_scene;

    get_screen_resolution(&global_xsize, &global_ysize);

    // scene->hres and scene->vres should be equal to screen resolution
    scene->hres = global_xwinsize = global_xsize;
    scene->vres = global_ywinsize = global_ysize;
    return 0;
}
Пример #13
0
Файл: bs.c Проект: MSch/MacRuby
static inline const char *
_bs_main_bundle_bs_path(void)
{
  static bool done = false;
  static char *path = NULL;
  /* XXX not thread-safe */
  if (!done) {
    CFBundleRef bundle;

    done = true;
    bundle = CFBundleGetMainBundle();
    if (bundle != NULL) {
      CFURLRef url;

      url = CFBundleCopyResourceURL(bundle, CFSTR("BridgeSupport"), 
                                    NULL, NULL);
      if (url != NULL) {
        CFStringRef str = CFURLCopyPath(url);
        path = (char *)malloc(sizeof(char) * PATH_MAX);
	ASSERT_ALLOC(path);
        CFStringGetFileSystemRepresentation(str, path, PATH_MAX);
        CFRelease(str);
        CFRelease(url);
      }
    }
  }
  return path;
}
Пример #14
0
inline SQLite3StatementRef SQLite3StatementCreateWithBundleResource(SQLite3ConnectionRef connection, CFBundleRef bundle, CFStringRef type, CFStringRef name, CFStringRef subdir) {
  SQLite3StatementRef statement = NULL;
  if (connection) {
    SInt32 errorCode = 0;
    CFDictionaryRef properties = NULL;
    CFDataRef data = NULL;
    CFURLRef url = CFBundleCopyResourceURL(bundle, name, type, subdir);
    if (url) {
      if (CFURLCreateDataAndPropertiesFromResource(connection->allocator, url, &data, &properties, NULL, &errorCode)) {
        CFStringRef sql = CFStringCreateWithBytes(connection->allocator, CFDataGetBytePtr(data), CFDataGetLength(data), kCFStringEncodingUTF8, 0);
        if (sql) {
          statement = SQLite3StatementCreate(connection, sql);
          CFRelease(sql);
        }
        CFRelease(data);
        if (properties)
          CFRelease(properties);
      } else {
        // TODO: Error
      }
      CFRelease(url);
    }
  }
  return statement;
}
Пример #15
0
static	CGImageRef	GetThePoofImage()
{
	CGDataProviderRef	provider;
	CFStringRef 		fileName	= NULL;
	CGImageRef			image		= NULL;
	CFURLRef			 url		= NULL;
	CFBundleRef 		appBundle	= CFBundleGetMainBundle();
	
	if ( appBundle == NULL )	goto Bail;

	fileName = CFStringCreateWithCString( NULL, "ToolbarPoof.png", kCFStringEncodingASCII );	//	ToolbarPoof.png is in our Resources directory within the bundle
	if ( fileName == NULL )	goto Bail;

	url = CFBundleCopyResourceURL( appBundle, fileName, NULL, NULL );
	if ( url == NULL ) goto Bail;
	
	provider	= CGDataProviderCreateWithURL( url );

	image	= CGImageCreateWithPNGDataProvider( provider, NULL, false,  kCGRenderingIntentDefault );
	
	CGDataProviderRelease( provider );

Bail:
	if ( fileName != NULL )	CFRelease( fileName );
	if ( url != NULL )	CFRelease( url );
	return( image );
}
Пример #16
0
void SC_StandAloneInfo::SC_StandAloneInfoInit() {
	char relDir[PATH_MAX];
	CFStringEncoding encoding = kCFStringEncodingASCII;
	if(!haveCheckedBundleStatus) {
		haveCheckedBundleStatus = true;
		CFURLRef enablerURL = CFBundleCopyResourceURL (
			CFBundleGetMainBundle(),
			CFSTR("SCClassLibrary"),
			NULL,
			NULL
		);
		if ( enablerURL ) {
			// If sclang or SuperCollider binary is run within the .app bundle,
			// this is how we find the Resources path.
			CFStringRef rawPath = CFURLCopyFileSystemPath(enablerURL, kCFURLPOSIXPathStyle);
			rawPath = CFStringCreateWithFormat(NULL, NULL, CFSTR("%@/.."), rawPath);
			CFStringGetCString(rawPath, relDir, PATH_MAX, encoding);
		} else {
			// when sclang is run from a symlink, the resource URL above will not be found,
			// so we need to find the path of the executable.
			uint32_t bufsize = PATH_MAX, *bufsizep = &bufsize;
			if(_NSGetExecutablePath(relDir, bufsizep)==0) {
				realpath(relDir, dirPath); // resolve symlink
				char *dir = dirname(dirPath);
				strcpy(dirPath, dir);
				return;
			} else {
				// in case it failed, fall back to current directory
				getcwd(dirPath, PATH_MAX);
			}
		}
		realpath(relDir, dirPath);
	}
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//	ÇPROJECTNAMEÈ::GetProperty
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ComponentResult		ÇPROJECTNAMEÈ::GetProperty(	AudioUnitPropertyID inID,
                                                        AudioUnitScope 		inScope,
                                                        AudioUnitElement 	inElement,
                                                        void *			outData )
{
if (inScope == kAudioUnitScope_Global) {
		switch (inID) {
			case kAudioUnitProperty_CocoaUI:
			{
				// Look for a resource in the main bundle by name and type.
				CFBundleRef bundle = CFBundleGetBundleWithIdentifier( CFSTR("com.Demo.audiounit.ÇPROJECTNAMEÈ") );
				
				if (bundle == NULL) return fnfErr;
                
				CFURLRef bundleURL = CFBundleCopyResourceURL( bundle, 
                    CFSTR("CocoaViewFactory"), 
                    CFSTR("bundle"), 
                    NULL);
                
                if (bundleURL == NULL) return fnfErr;
                
				CFStringRef className = CFSTR("CocoaViewFactory");
				AudioUnitCocoaViewInfo cocoaInfo = { bundleURL, className };
				*((AudioUnitCocoaViewInfo *)outData) = cocoaInfo;
				
				return noErr;
		}
	  }
	}

	return AUEffectBase::GetProperty (inID, inScope, inElement, outData);
}
Пример #18
0
    CFBundleRef mac_loadExeBundle(const char *name) 
    {
        CFBundleRef baseBundle = CFBundleGetBundleWithIdentifier(CFSTR("org.demi3d.Demi"));
        CFBundleRef mainBundle = CFBundleGetMainBundle();
        CFStringRef nameRef = CFStringCreateWithCString(NULL, name, kCFStringEncodingASCII);
        CFURLRef bundleURL = 0; //URL of bundle to load
        CFBundleRef bundle = 0; //bundle to load

        //cut off .bundle if present
        if (CFStringHasSuffix(nameRef, CFSTR(".bundle"))) 
        {
            CFStringRef nameTempRef = nameRef;
            int end = CFStringGetLength(nameTempRef) - CFStringGetLength(CFSTR(".bundle"));
            nameRef = CFStringCreateWithSubstring(NULL, nameTempRef, CFRangeMake(0, end));
            CFRelease(nameTempRef);
        }

        //assume relative to Resources/ directory of Main bundle
        bundleURL = CFBundleCopyResourceURL(mainBundle, nameRef, CFSTR("bundle"), NULL);
        if (bundleURL)
        {
            bundle = CFBundleCreate(NULL, bundleURL);
            CFRelease(bundleURL);
        }

        //otherwise, try Resources/ directory of Ogre Framework bundle
        if (!bundle) 
        {
            bundleURL = CFBundleCopyResourceURL(baseBundle, nameRef, CFSTR("bundle"), NULL);
            if (bundleURL)
            {
                bundle = CFBundleCreate(NULL, bundleURL);
                CFRelease(bundleURL);
            }
        }
        CFRelease(nameRef);

        if (bundle)
        {
            if (CFBundleLoadExecutable(bundle)) 
                return bundle;
            else
                CFRelease(bundle);
        }

        return 0;
    }
Пример #19
0
// add an HIImageViewRef to the parentView
HIViewRef
AddImage( HIViewRef parentView )
{
	OSStatus status = paramErr;
	HIViewRef cgImageView = NULL;
	CGImageRef cgImage = NULL;
	CGDataProviderRef cgImageProvider = NULL;
	HILayoutInfo layoutInfo; 
	CFBundleRef theAppBundle = NULL;
	CFStringRef imageFileName = NULL;
	CFURLRef imageURL = NULL;
	
	HIRect parentFrame;
	
	theAppBundle = CFBundleGetMainBundle(); 
	imageFileName = CFStringCreateWithCString( NULL /*allocator*/, "rainbowpark.jpg", kCFStringEncodingASCII ); 
	imageURL = CFBundleCopyResourceURL( theAppBundle, imageFileName, NULL, NULL );

	cgImageProvider = CGDataProviderCreateWithURL(imageURL);
	
	require( cgImageProvider != NULL, FAIL );
	cgImage = CGImageCreateWithJPEGDataProvider( cgImageProvider, NULL, false, kCGRenderingIntentDefault );
	
	require( cgImage != NULL, FAIL );
	
	CGDataProviderRelease( cgImageProvider );
	CFRelease( imageFileName );
	
	HIImageViewCreate( cgImage, &cgImageView );
	CGImageRelease( cgImage);
	
	require( cgImageView != NULL, FAIL );
	
	layoutInfo.binding.left.kind = kHILayoutBindLeft;
	layoutInfo.binding.left.toView = NULL;
	layoutInfo.binding.left.offset = 0.0;
	layoutInfo.binding.top.kind = kHILayoutBindTop;
	layoutInfo.binding.top.toView = NULL;
	layoutInfo.binding.top.offset = 0.0;
	layoutInfo.binding.right.kind = kHILayoutBindRight;
	layoutInfo.binding.right.toView = NULL;
	layoutInfo.binding.right.offset = 0.0;
	layoutInfo.binding.bottom.kind = kHILayoutBindBottom;
	layoutInfo.binding.bottom.toView = NULL;
	layoutInfo.binding.bottom.offset = 0.0;
	verify_noerr( HIViewSetLayoutInfo(cgImageView, &layoutInfo) );
	verify_noerr( HIImageViewSetScaleToFit(cgImageView, true) );
	status = HIViewAddSubview(parentView, cgImageView);
	
	if( status != noErr )
	{
		CFRelease( cgImageView );
		cgImageView = NULL;
	}
	
	FAIL:
	return cgImageView;

}
CFArrayRef copyTrustedAppListFromBundle(CFStringRef bundlePath, CFStringRef trustedAppListFileName)
{
	CFStringRef errorString = nil;
    CFURLRef bundleURL,trustedAppsURL = NULL;
    CFBundleRef secBundle = NULL;
	CFPropertyListRef trustedAppsPlist = NULL;
	CFDataRef xmlDataRef = NULL;
	SInt32 errorCode;
    CFArrayRef trustedAppList = NULL;
	CFMutableStringRef trustedAppListFileNameWithoutExtension = NULL;

    // Make a CFURLRef from the CFString representation of the bundleÕs path.
    bundleURL = CFURLCreateWithFileSystemPath(
        kCFAllocatorDefault,bundlePath,kCFURLPOSIXPathStyle,true);

	CFRange wholeStrRange;

	if (!bundleURL)
        goto xit;

    // Make a bundle instance using the URLRef.
    secBundle = CFBundleCreate(kCFAllocatorDefault,bundleURL);
    if (!secBundle)
        goto xit;

	trustedAppListFileNameWithoutExtension =
		CFStringCreateMutableCopy(NULL,CFStringGetLength(trustedAppListFileName),trustedAppListFileName);
	wholeStrRange = CFStringFind(trustedAppListFileName,CFSTR(".plist"),0);

	CFStringDelete(trustedAppListFileNameWithoutExtension,wholeStrRange);

    // Look for a resource in the bundle by name and type
    trustedAppsURL = CFBundleCopyResourceURL(secBundle,trustedAppListFileNameWithoutExtension,CFSTR("plist"),NULL);
    if (!trustedAppsURL)
        goto xit;

    if ( trustedAppListFileNameWithoutExtension )
		CFRelease(trustedAppListFileNameWithoutExtension);

	if (!CFURLCreateDataAndPropertiesFromResource(kCFAllocatorDefault,trustedAppsURL,&xmlDataRef,NULL,NULL,&errorCode))
        goto xit;

	trustedAppsPlist = CFPropertyListCreateFromXMLData(kCFAllocatorDefault,xmlDataRef,kCFPropertyListImmutable,&errorString);
    trustedAppList = (CFArrayRef)trustedAppsPlist;

xit:
    if (bundleURL)
        CFRelease(bundleURL);
    if (secBundle)
        CFRelease(secBundle);
    if (trustedAppsURL)
        CFRelease(trustedAppsURL);
    if (xmlDataRef)
        CFRelease(xmlDataRef);
    if (errorString)
        CFRelease(errorString);

    return trustedAppList;
}
Пример #21
0
String WebInspectorProxy::inspectorPageURL() const
{
    RetainPtr<CFURLRef> htmlURLRef(AdoptCF, CFBundleCopyResourceURL(webKitBundle(), CFSTR("inspector"), CFSTR("html"), CFSTR("inspector")));
    if (!htmlURLRef)
        return String();

    return String(CFURLGetString(htmlURLRef.get()));
}
Пример #22
0
String WebInspectorProxy::inspectorPageURL() const
{
    RetainPtr<CFURLRef> htmlURLRef(AdoptCF, CFBundleCopyResourceURL(CFBundleGetBundleWithIdentifier(CFSTR("com.apple.WebKit")), CFSTR("inspector"), CFSTR("html"), CFSTR("inspector")));
    if (!htmlURLRef)
        return String();

    return String(CFURLGetString(htmlURLRef.get()));
}
static CFBundleRef LoadRadioEffectComponent()
{
	bool bLoaded = false;
	CFBundleRef Bundle = NULL;

	CFBundleRef MainBundleRef = CFBundleGetMainBundle();
	if( MainBundleRef )
	{
		CFURLRef ComponentURLRef = CFBundleCopyResourceURL( MainBundleRef, CFSTR("RadioEffectUnit"), CFSTR("component"), 0 );
		if( ComponentURLRef )
		{
			Bundle = CFBundleCreate(kCFAllocatorDefault, ComponentURLRef);
			if(Bundle)
			{
				CFArrayRef Components = (CFArrayRef)CFBundleGetValueForInfoDictionaryKey(Bundle, CFSTR("AudioComponents"));
				if ( Components && CFArrayGetCount(Components) )
				{
					CFDictionaryRef ComponentInfo = (CFDictionaryRef)CFArrayGetValueAtIndex(Components, 0);
					CFNumberRef ComponentVersion = (CFNumberRef)CFDictionaryGetValue(ComponentInfo, CFSTR("version"));
					CFStringRef ComponentFactoryFunction = (CFStringRef)CFDictionaryGetValue(ComponentInfo, CFSTR("factoryFunction"));
					if( ComponentVersion && ComponentFactoryFunction )
					{
						int32 Version = 0;
						CFNumberGetValue(ComponentVersion, kCFNumberSInt32Type, &Version);
						
						AudioComponentFactoryFunction Factory = (AudioComponentFactoryFunction)CFBundleGetFunctionPointerForName(Bundle, ComponentFactoryFunction);
						if(Factory)
						{
							//	fill out the AudioComponentDescription
							AudioComponentDescription theDescription;
							theDescription.componentType = kAudioUnitType_Effect;
							theDescription.componentSubType = 'Rdio';
							theDescription.componentManufacturer = 'Epic';
							theDescription.componentFlagsMask = 0;
							
							AudioComponent RadioComponent = AudioComponentFindNext(nullptr, &theDescription);
							if ( !RadioComponent )
							{
								RadioComponent = AudioComponentRegister(&theDescription, CFSTR("Epic Games: RadioEffectUnit"), Version, Factory);
								check(RadioComponent);
							}
							bLoaded = (RadioComponent != NULL);
						}
					}
				}
				if(!bLoaded)
				{
					CFRelease(Bundle);
					Bundle = NULL;
				}
			}

			CFRelease( ComponentURLRef );
		}
	}

	return Bundle;
}
Пример #24
0
Файл: main.c Проект: Deanzou/ppp
/* -----------------------------------------------------------------------------
plugin entry point, called by pppd
----------------------------------------------------------------------------- */
int start(CFBundleRef ref)
{
    CFStringRef 	strref;
    CFURLRef 		urlref;
   
    bundle = ref;
    CFRetain(bundle);
    
    url = CFBundleCopyBundleURL(bundle);

    // hookup our handlers
    old_check_options = the_channel->check_options;
    the_channel->check_options = serial_check_options;
    
    old_connect = the_channel->connect;
    the_channel->connect = serial_connect;
    
    old_process_extra_options = the_channel->process_extra_options;
    the_channel->process_extra_options = serial_process_extra_options;

    add_notifier(&connect_fail_notify, serial_connect_notifier, 0);
    add_notifier(&lcp_lowerdown_notify, serial_lcpdown_notifier, 0);

    cancelstrref = CFBundleCopyLocalizedString(bundle, CFSTR("Cancel"), CFSTR("Cancel"), NULL);
    if (cancelstrref == 0) return 1;
    CFStringGetCString(cancelstrref, (char*)cancelstr, sizeof(cancelstr), kCFStringEncodingUTF8);
    
    icstrref = CFBundleCopyLocalizedString(bundle, CFSTR("Network Connection"), CFSTR("Network Connection"), NULL);
    if (icstrref == 0) return 1;
    CFStringGetCString(icstrref, (char*)icstr, sizeof(icstr), kCFStringEncodingUTF8);
    
    urlref = CFBundleCopyResourceURL(bundle, CFSTR("NetworkConnect.icns"), NULL, NULL);
    if (urlref == 0 || ((strref = CFURLGetString(urlref)) == 0)) {
		if (urlref)
            CFRelease(urlref);
        return 1;
    }
    CFStringGetCString(strref, (char*)iconstr, sizeof(iconstr), kCFStringEncodingUTF8);
	
	iconstrref = CFStringCreateCopy(NULL, strref);
    CFRelease(urlref);

	urlref = CFBundleCopyBuiltInPlugInsURL(bundle);
	if (urlref == 0 || ((CFURLGetFileSystemRepresentation(urlref, TRUE, pathccl, sizeof(pathccl))) == FALSE)) {
		if (urlref)
            CFRelease(urlref);
        return 1;
    }
    strlcat((char*)pathccl, SUFFIX_CCLENGINE, sizeof(pathccl));
    CFRelease(urlref);
    
    // add the socket specific options
    add_options(serial_options);

    return 0;
}
Пример #25
0
// Given an application bundle reference and the name of an icon file
// which is a resource in that bundle, look up the full (posix style)
// path to that icon. Returns the path, or an empty wxString on failure
wxString GetPathForIconFile( CFBundleRef bundle, CFStringRef iconFile )
{
    // If either parameter is NULL there is no hope of success
    if( !bundle || !iconFile )
        return wxEmptyString;

    // Create a range object representing the whole string
    CFRange wholeString;
    wholeString.location = 0;
    wholeString.length = CFStringGetLength( iconFile );

    // Index of the period in the file name for iconFile
    UniCharCount periodIndex;

    // In order to locate the period delimiting the extension,
    // iconFile must be represented as UniChar[]
    {
        // Allocate a buffer and copy in the iconFile string
        UniChar* buffer = new UniChar[ wholeString.length ];
        CFStringGetCharacters( iconFile, wholeString, buffer );

        // Locate the period character
        OSStatus status = LSGetExtensionInfo( wholeString.length, buffer, &periodIndex );

        // Deallocate the buffer
        delete [] buffer;

        // If the period could not be located it will not be possible to get the URL
        if( status != noErr || periodIndex == kLSInvalidExtensionIndex )
            return wxEmptyString;
    }

    // Range representing the name part of iconFile
    CFRange iconNameRange;
    iconNameRange.location = 0;
    iconNameRange.length = periodIndex - 1;

    // Range representing the extension part of iconFile
    CFRange iconExtRange;
    iconExtRange.location = periodIndex;
    iconExtRange.length = wholeString.length - periodIndex;

    // Get the name and extension strings
    wxCFStringRef iconName = CFStringCreateWithSubstring( kCFAllocatorDefault, iconFile, iconNameRange );
    wxCFStringRef iconExt = CFStringCreateWithSubstring( kCFAllocatorDefault, iconFile, iconExtRange );

    // Now it is possible to query the URL for the icon as a resource
    wxCFRef< CFURLRef > iconUrl = wxCFRef< CFURLRef >( CFBundleCopyResourceURL( bundle, iconName, iconExt, NULL ) );

    if( !iconUrl.get() )
        return wxEmptyString;

    // All being well, return the icon path
    return wxCFStringRef( CFURLCopyFileSystemPath( iconUrl, kCFURLPOSIXPathStyle ) ).AsString();
}
Пример #26
0
//-----------------------------------------------------------------------------
bool CGBitmap::load (const CResourceDescription& desc)
{
	if (bits)
		return false;

	bool result = false;
	if (getBundleRef ())
	{
		// find the bitmap in our Bundle.
		// If the resource description is of type integer, it must be in the form of bmp00123.png, where the resource id would be 123.
		// else it just uses the name
		char filename [PATH_MAX];
		if (desc.type == CResourceDescription::kIntegerType)
			sprintf (filename, "bmp%05d", (int32_t)desc.u.id);
		else
			strcpy (filename, desc.u.name);
		CFStringRef cfStr = CFStringCreateWithCString (NULL, filename, kCFStringEncodingUTF8);
		if (cfStr)
		{
			CFURLRef url = NULL;
			if (filename[0] == '/')
				url = CFURLCreateFromFileSystemRepresentation (0, (const UInt8*)filename, strlen (filename), false);
			int32_t i = 0;
			while (url == NULL)
			{
				static CFStringRef resTypes [] = { CFSTR("png"), CFSTR("bmp"), CFSTR("jpg"), CFSTR("pict"), NULL };
				url = CFBundleCopyResourceURL (getBundleRef (), cfStr, desc.type == CResourceDescription::kIntegerType ? resTypes[i] : 0, NULL);
				if (resTypes[++i] == NULL)
					break;
			}
			CFRelease (cfStr);
			if (url)
			{
				CGImageSourceRef source = CGImageSourceCreateWithURL (url, NULL);
				if (source)
				{
					result = loadFromImageSource (source);
					CFRelease (source);
				}
				CFRelease (url);
			}
		}
	}
#if DEBUG
	if (result == false)
	{
		if (desc.type == CResourceDescription::kIntegerType)
			DebugPrint ("*** Bitmap Nr.:%d not found.\n", desc.u.id);
		else
			DebugPrint ("*** Bitmap '%s' not found.\n", desc.u.name);
	}
#endif
	return result;
}
Пример #27
0
// function provides some Mac OS X specific source code to load files from the resources of the application bundle.
char * resPath(char **argv, char* name, char* type ) 
{
	static char resource[1024];
	CFURLRef cfBundleURL = CFBundleCopyResourceURL( CFBundleGetMainBundle(),    
	CFStringCreateWithCString(kCFAllocatorDefault,name, kCFStringEncodingISOLatin1), 
	CFStringCreateWithCString(kCFAllocatorDefault,type,kCFStringEncodingISOLatin1), 
	NULL);
	CFStringGetCString( CFURLCopyPath(cfBundleURL),
		resource,1023,kCFStringEncodingISOLatin1);
   return resource;
}
Пример #28
0
/*
 * QuartzLoadDisplayBundle
 *  Try to load the appropriate bundle containing the back end display code.
 */
Bool QuartzLoadDisplayBundle(
    const char *dpyBundleName)
{
    CFBundleRef mainBundle;
    CFStringRef bundleName;
    CFURLRef    bundleURL;
    CFBundleRef dpyBundle;
    QuartzModeBundleInitPtr bundleInit;

    // Get the main bundle for the application
    mainBundle = CFBundleGetMainBundle();

    // Make CFString from bundle name
    bundleName = CFStringCreateWithCStringNoCopy(kCFAllocatorDefault,
                                                 dpyBundleName,
                                                 kCFStringEncodingASCII,
                                                 kCFAllocatorNull);

    // Look for the appropriate bundle in the main bundle
    bundleURL = CFBundleCopyResourceURL(mainBundle, bundleName,
                                        NULL, NULL);
    if (!bundleURL) {
        ErrorF("Could not find display mode bundle %s.\n", dpyBundleName);
        return FALSE;
    }

    // Make a bundle instance using the URLRef
    dpyBundle = CFBundleCreate(kCFAllocatorDefault, bundleURL);

    if (!CFBundleLoadExecutable(dpyBundle)) {
        ErrorF("Could not load display mode bundle %s.\n", dpyBundleName);
        return FALSE;
    }

    // Lookup the bundle initialization function
    bundleInit = (void *)
            CFBundleGetFunctionPointerForName(dpyBundle,
                                              CFSTR("QuartzModeBundleInit"));
    if (!bundleInit) {
        ErrorF("Could not initialize display mode bundle %s.\n",
               dpyBundleName);
        return FALSE;
    }
    if (!bundleInit())
        return FALSE;

    // Release the CF objects
    CFRelease(bundleName);
    CFRelease(bundleURL);

    return TRUE;
}
Пример #29
0
/*
=================
fs_get_resource_url
=================
*/
CFURLRef fs_get_resource_url (const char *filename)
{
    CFStringRef cffilename;
    CFURLRef    url;

    if (NULL == (cffilename = CFStringCreateWithCString(NULL, fs_get_resource_path(filename), kCFStringEncodingUTF8)))
        return NULL;

    url = CFBundleCopyResourceURL(cg_main_bundle, cffilename, NULL, NULL);
    CFRelease(cffilename);

    return url;
}
Пример #30
0
CFStringRef RemoteVSTClient::get_path_prop(CFStringRef path_name)
{
	CFStringRef path =  (CFStringRef) CFDictionaryGetValue(m_props, path_name);
	if (path == NULL) {
		return NULL;
	}
	CFURLRef fullPath = CFBundleCopyResourceURL(m_bundle, path, CFSTR("dll"), NULL);
	if (!fullPath) {
		return 0;
	}

	return CFURLCopyFileSystemPath(fullPath, kCFURLPOSIXPathStyle);
}