bool GlobalPreferences_save()
{
	String settingsPath = (String)getenv("HOME") + "/Library/Preferences/" + bundleID + ".plist";
	void*dict = ProjLoad_loadAllocatedPlist(settingsPath);
	if(dict==NULL)
	{
		dict = NSMutableDictionary_alloc_init();
	}
	if(dict!=NULL)
	{
		void*sdk = NSString_stringWithUTF8String(defaultSDK);
		NSMutableDictionary_setObjectForKey(dict, sdk, "DefaultSDK");
		
		void*editorFont = NSString_stringWithUTF8String(codeEditorFont);
		NSMutableDictionary_setObjectForKey(dict, editorFont, "EditorFont");
		
		void*editorFontSize = NSNumber_numberWithInt((int)codeEditorFontSize);
		NSMutableDictionary_setObjectForKey(dict, editorFontSize, "EditorFontSize");
		
		void*syntaxHighlighting = NSNumber_numberWithBool(syntaxHighlightingOn);
		NSMutableDictionary_setObjectForKey(dict, syntaxHighlighting, "SyntaxHighlighting");
		
		void*installedAppsArray = NSMutableArray_alloc_init();
		for(int i=0; i<installedApps.size(); i++)
		{
			void*appName = NSString_stringWithUTF8String(installedApps.get(i));
			NSMutableArray_addObject(installedAppsArray, appName);
		}
		NSMutableDictionary_setObjectForKey(dict, installedAppsArray, "InstalledApps");
		id_release(installedAppsArray);
		
		void*latestVersion = NSNumber_numberWithDouble(currentVersion);
		NSMutableDictionary_setObjectForKey(dict, latestVersion, "LatestVersion");
		
		String settingsPath = (String)getenv("HOME") + "/Library/Preferences/" + bundleID + ".plist";
		bool success = ProjLoad_savePlist(dict, settingsPath);
		id_release(dict);
		return success;
	}
	return false;
}
Example #2
0
void CompilerTools_fillInfoPlist(ProjectData_struct*project)
{
	ProjectData& projData = *((ProjectData*)project->data);
	String path = ProjLoad_getSavedProjectsFolder();
	path += (String)'/' + projData.getFolderName() + "/bin/release/";
	ProjectType projType = projData.getProjectType();
	if(projType == PROJECTTYPE_APPLICATION)
	{
		path += projData.getProductName() + ".app/Info.plist";
	}
	else
	{
		return;
	}
	
	String fileContents;
	
	if(FileTools_fileExists(path))
	{
		bool success = FileTools::loadFileIntoString(path, fileContents);
		if(!success)
		{
			return;
		}
		
		CompilerTools_fillProjectVarsInString(fileContents, projData);
		FileTools::writeStringToFile(path, fileContents);
	}
	
	void* infoPlist = ProjLoad_loadAllocatedPlist(path);
	if(infoPlist!=NULL)
	{
		//UIDeviceFamily
		void* uidevicefamily = NSMutableArray_alloc_init();
		ProjectDevice projDevice = projData.getProjectDevice();
		if(projDevice==DEVICE_IPHONE)
		{
			void* num = NSNumber_numberWithInt(1);
			NSMutableArray_addObject(uidevicefamily, num);
		}
		else if(projDevice==DEVICE_IPAD)
		{
			void* num = NSNumber_numberWithInt(2);
			NSMutableArray_addObject(uidevicefamily, num);
		}
		else if(projDevice==DEVICE_ALL)
		{
			void* num = NSNumber_numberWithInt(1);
			NSMutableArray_addObject(uidevicefamily, num);
			num = NSNumber_numberWithInt(2);
			NSMutableArray_addObject(uidevicefamily, num);
		}
		
		if(projDevice!=DEVICE_UNKNOWN)
		{
			NSMutableDictionary_setObjectForKey(infoPlist, uidevicefamily, "UIDeviceFamily");
		}
		id_release(uidevicefamily);
		
		ProjLoad_savePlist(infoPlist, path);
		id_release(infoPlist);
	}
}