示例#1
0
        internal static void parseFile(string filePath, ProvisioningProfile profile)
        {
            var   provisioningFileContents = File.ReadAllText(filePath);
            Match matchUUID = Regex.Match(provisioningFileContents, s_PatternUUID, RegexOptions.Singleline);

            if (matchUUID.Success)
            {
                profile.UUID = matchUUID.Groups[1].Value;
            }

            Match matchCertificate = Regex.Match(provisioningFileContents, s_PatternDeveloperCertificates,
                                                 RegexOptions.Singleline);

            if (matchCertificate.Success)
            {
                string value = matchCertificate.Groups[1].Value;
                string decodedCertificate = Encoding.UTF8.GetString(Convert.FromBase64String(value));

                if (decodedCertificate.Contains(s_DistributionPattern))
                {
                    profile.type = ProvisioningProfileType.Distribution;
                }
                else
                {
                    profile.type = ProvisioningProfileType.Development;
                }
            }
        }
示例#2
0
        internal static ProvisioningProfile ParseProvisioningProfileAtPath(string pathToFile)
        {
            ProvisioningProfile profile = new ProvisioningProfile();

            parseFile(pathToFile, profile);
            return(profile);
        }
        internal static bool GetProvisioningProfileId(string filePath, out ProvisioningProfile provisioningProfile)
        {
            ProvisioningProfile profile = ProvisioningProfile.ParseProvisioningProfileAtPath(filePath);

            provisioningProfile = profile;
            return(profile.UUID != null);
        }
        internal static ProvisioningProfile Browse(string path)
        {
            var msg = "Select the Provising Profile used for Manual Signing";

            var defaultFolder = path;

            if (InternalEditorUtility.inBatchMode)
            {
                return(null);
            }

            ProvisioningProfile provisioningProfile = null;

            do
            {
                path = EditorUtility.OpenFilePanel(msg, defaultFolder, "mobileprovision");

                // user pressed cancel?
                if (path.Length == 0)
                {
                    return(null);
                }
            }while (!GetProvisioningProfileId(path, out provisioningProfile));

            return(provisioningProfile);
        }
        internal static void ShowProvisioningProfileUIWithProperty(GUIContent titleWithToolTip, ProvisioningProfile profile, SerializedProperty profileIDProp, SerializedProperty profileTypeProp)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Label(titleWithToolTip, EditorStyles.label);

            Rect       controlRect = EditorGUILayout.GetControlRect(false, 0);
            GUIContent labelID     = EditorGUIUtility.TrTextContent("Profile ID:");

            EditorGUI.BeginProperty(controlRect, labelID, profileIDProp);

            if (GUILayout.Button("Browse", EditorStyles.miniButton))
            {
                ProvisioningProfile provisioningProfile = Browse("");
                if (provisioningProfile != null && !string.IsNullOrEmpty(provisioningProfile.UUID))
                {
                    profile = provisioningProfile;
                    profileIDProp.stringValue = profile.UUID;
                    profileTypeProp.intValue  = (int)profile.type;
                    profileIDProp.serializedObject.ApplyModifiedProperties();
                    profileTypeProp.serializedObject.ApplyModifiedProperties();
                    GUI.FocusControl("");
                }
                GUIUtility.ExitGUI();
            }

            EditorGUI.EndProperty();
            GUILayout.EndHorizontal();

            EditorGUI.BeginChangeCheck();
            EditorGUI.indentLevel++;

            EditorGUI.BeginProperty(controlRect, labelID, profileIDProp);
            profile.UUID = EditorGUILayout.TextField(labelID, profile.UUID);
            EditorGUI.EndProperty();

            GUIContent labelType = EditorGUIUtility.TrTextContent("Profile Type:");

            EditorGUI.BeginProperty(controlRect, labelType, profileTypeProp);
            profile.type = (ProvisioningProfileType)EditorGUILayout.EnumPopup(labelType, profile.type);
            EditorGUI.EndProperty();

            if (EditorGUI.EndChangeCheck())
            {
                profileIDProp.stringValue = profile.UUID;
                profileTypeProp.intValue  = (int)profile.type;
            }

            EditorGUI.indentLevel--;
        }
        internal static void ShowProvisioningProfileUIWithCallback(GUIContent titleWithToolTip, ProvisioningProfile profile, ProvisioningProfileChangedDelegate callback)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Label(titleWithToolTip, EditorStyles.label);

            if (GUILayout.Button("Browse", EditorStyles.miniButton))
            {
                ProvisioningProfile provisioningProfile = Browse("");
                if (provisioningProfile != null && !string.IsNullOrEmpty(provisioningProfile.UUID))
                {
                    profile = provisioningProfile;
                    callback(profile);

                    GUI.FocusControl("");
                }
                GUIUtility.ExitGUI();
            }

            GUILayout.EndHorizontal();

            EditorGUI.BeginChangeCheck();
            EditorGUI.indentLevel++;

            GUIContent labelID   = EditorGUIUtility.TrTextContent("Profile ID:");
            GUIContent labelType = EditorGUIUtility.TrTextContent("Profile Type:");

            profile.UUID = EditorGUILayout.TextField(labelID, profile.UUID);
            profile.type = (ProvisioningProfileType)EditorGUILayout.EnumPopup(labelType, profile.type);

            if (EditorGUI.EndChangeCheck())
            {
                callback(profile);
            }

            EditorGUI.indentLevel--;
        }