ILauncherProfileRef FLauncherProfileManager::AddNewProfile() { // find a unique name for the profile. int32 ProfileIndex = SavedProfiles.Num(); FString ProfileName = FString::Printf(TEXT("New Profile %d"), ProfileIndex); for (int32 Index = 0; Index < SavedProfiles.Num(); ++Index) { if (SavedProfiles[Index]->GetName() == ProfileName) { ProfileName = FString::Printf(TEXT("New Profile %d"), ++ProfileIndex); Index = -1; continue; } } // create and add the profile ILauncherProfileRef NewProfile = MakeShareable(new FLauncherProfile(AsShared(), FGuid::NewGuid(), ProfileName)); AddProfile(NewProfile); SaveProfile(NewProfile); return NewProfile; }
//Reload bool Profiles::Reload () { Err fErr (m_Err, L"Reload"); if (m_sDirectory.empty ()) { return fErr.Set (L"Profilesystem is not initialized"); } std::vector<wstring> lsFiles; if (!ListFiles (m_sDirectory, &lsFiles)) { return fErr.Set (L"Could not list the profiles"); } m_lProfiles.clear (); for (unsigned int i = 0; i != lsFiles.size (); i++) { if (!AddProfile (lsFiles.at (i))) { return false; } } return true; }//Reload
void BluetoothProfileController::AddProfileWithServiceClass( BluetoothServiceClass aClass) { BluetoothProfileManagerBase* profile; switch (aClass) { case BluetoothServiceClass::HANDSFREE: case BluetoothServiceClass::HEADSET: profile = BluetoothHfpManager::Get(); break; case BluetoothServiceClass::A2DP: profile = BluetoothA2dpManager::Get(); break; case BluetoothServiceClass::AVRCP: profile = BluetoothAvrcpManager::Get(); break; case BluetoothServiceClass::HID: profile = BluetoothHidManager::Get(); break; default: DispatchReplyError(mRunnable, NS_LITERAL_STRING(ERR_UNKNOWN_PROFILE)); mCallback(); return; } AddProfile(profile); }
void FLauncherProfileManager::LoadProfiles( ) { TArray<FString> ProfileFileNames; IFileManager::Get().FindFiles(ProfileFileNames, *(GetProfileFolder() / TEXT("*.ulp")), true, false); for (TArray<FString>::TConstIterator It(ProfileFileNames); It; ++It) { FString ProfileFilePath = GetProfileFolder() / *It; FArchive* ProfileFileReader = IFileManager::Get().CreateFileReader(*ProfileFilePath); if (ProfileFileReader != nullptr) { ILauncherProfilePtr LoadedProfile = LoadProfile(*ProfileFileReader); delete ProfileFileReader; if (LoadedProfile.IsValid()) { AddProfile(LoadedProfile.ToSharedRef()); } else { IFileManager::Get().Delete(*ProfileFilePath); } } } }
void BluetoothProfileController::SetupProfiles(bool aAssignServiceClass) { MOZ_ASSERT(NS_IsMainThread()); /** * When a service class is assigned, only its corresponding profile is put * into array. */ if (aAssignServiceClass) { AddProfileWithServiceClass(mTarget.service); return; } // For a disconnect request, all connected profiles are put into array. if (!mConnect) { AddProfile(BluetoothHidManager::Get(), true); AddProfile(BluetoothOppManager::Get(), true); AddProfile(BluetoothA2dpManager::Get(), true); AddProfile(BluetoothHfpManager::Get(), true); return; } /** * For a connect request, put multiple profiles into array and connect to * all of them sequencely. */ bool hasAudio = HAS_AUDIO(mTarget.cod); bool hasObjectTransfer = HAS_OBJECT_TRANSFER(mTarget.cod); bool hasRendering = HAS_RENDERING(mTarget.cod); bool isPeripheral = IS_PERIPHERAL(mTarget.cod); NS_ENSURE_TRUE_VOID(hasAudio || hasObjectTransfer || hasRendering || isPeripheral); /** * Connect to HFP/HSP first. Then, connect A2DP if Rendering bit is set. * It's almost impossible to send file to a remote device which is an Audio * device or a Rendering device, so we won't connect OPP in that case. */ if (hasAudio) { AddProfile(BluetoothHfpManager::Get()); } if (hasRendering) { AddProfile(BluetoothA2dpManager::Get()); } if (hasObjectTransfer && !hasAudio && !hasRendering) { AddProfile(BluetoothOppManager::Get()); } if (isPeripheral) { AddProfile(BluetoothHidManager::Get()); } }
//------------------------------------------------------------------------ //! Switches to a new active configuration profile //! //! @param strProfile Name of the new profile //------------------------------------------------------------------------ void CViewConfigSectionProfiles::SetActiveProfile(const CString& strProfile) { // Make the new strProfile the active ones WriteSetting(m_ViewName, _T("ActiveProfile"), strProfile); m_CurrentSection = JoinSectionName(m_ViewName, strProfile); if (strProfile.IsEmpty()) return; AddProfile(strProfile); }
void OBSBasic::on_actionRenameProfile_triggered() { std::string curDir = config_get_string(App()->GlobalConfig(), "Basic", "ProfileDir"); std::string curName = config_get_string(App()->GlobalConfig(), "Basic", "Profile"); /* Duplicate and delete in case there are any issues in the process */ bool success = AddProfile(false, Str("RenameProfile.Title"), Str("AddProfile.Text"), curName.c_str()); if (success) { DeleteProfile(curName.c_str(), curDir.c_str()); RefreshProfiles(); } }
void CuDlgDomPropStaticProfile::RefreshDisplay() { UpdateData (FALSE); // Mandatory! // Exclusively use member variables of m_Data for display refresh int cnt; int size; m_cListCtrl.DeleteAllItems(); size = m_Data.m_uaStaticProfile.GetCount(); ASSERT (size > 0); for (cnt = 0; cnt < size; cnt++) AddProfile(m_Data.m_uaStaticProfile[cnt]); }
void ProfilesNameValue::Load(const char* nameFile) { FILE* f = fopen( nameFile, "r" ); if( f == 0 ) return; int state = 0; char buf[256], buf2[256]; int c; int pos = 0; bool stop = false; while( (c = fgetc(f)) >= 0 && !stop ) { if( c == '\n' || c == '{' || c == '}' || c == '=' ) { if( pos > 0 ) { switch( state ) { case 0: //имя профиля AddProfile(buf); state = 1; break; case 1: //имя strcpy( buf2, buf ); state = 2; break; case 2: //значение AddNameValue( buf2, buf ); state = 1; break; } pos = 0; } if( c == '}' ) state = 0; } else { if( ((c != ' ' && c != '\t') || pos > 0) && pos < sizeof(buf) - 1 ) { buf[pos] = c; buf[pos + 1] = 0; pos++; } } } fclose(f); }
void CVCDlg::OnCategorySelChanged() { m_profileComboBox.DeleteAllItems(); int nCurSel = m_deviceComboBox.GetCurSel(); if(nCurSel >= 0) { ProfileNode* pParent = (ProfileNode*)m_deviceComboBox.GetItemDataPtr(nCurSel); int nChildCount = ((pParent == NULL) ? 0 : pParent->GetChildCount()); for(int i = 0; i < nChildCount; i++) { ProfileNode* pProfile = (ProfileNode*)pParent->GetChild(i); AddProfile(pProfile, NULL); } if(nChildCount > 0) { m_profileComboBox.SetCurSel(0); OnProfileSelChanged(); } } }
void BluetoothProfileController::SetupProfiles(bool aAssignServiceClass) { MOZ_ASSERT(NS_IsMainThread()); /** * When a service class is assigned, only its corresponding profile is put * into array. */ if (aAssignServiceClass) { AddProfileWithServiceClass(mTarget.service); return; } // For a disconnect request, all connected profiles are put into array. if (!mConnect) { AddProfile(BluetoothHidManager::Get(), true); AddProfile(BluetoothA2dpManager::Get(), true); AddProfile(BluetoothHfpManager::Get(), true); return; } /** * For a connect request, put multiple profiles into array and connect to * all of them sequencely. */ bool hasAudio = HAS_AUDIO(mTarget.cod); bool hasRendering = HAS_RENDERING(mTarget.cod); bool isPeripheral = IS_PERIPHERAL(mTarget.cod); NS_ENSURE_TRUE_VOID(hasAudio || hasRendering || isPeripheral); /** * Connect to HFP/HSP first. Then, connect A2DP if Rendering bit is set. */ if (hasAudio) { AddProfile(BluetoothHfpManager::Get()); } if (hasRendering) { AddProfile(BluetoothA2dpManager::Get()); } if (isPeripheral) { AddProfile(BluetoothHidManager::Get()); } }
ReplaceString *ReplaceList::AddString(wchar_t *old, wchar_t *rep, wchar_t *profile) { int i = AddProfile(profile); return lists[i].AddString(old, rep); }
void OBSBasic::on_actionDupProfile_triggered() { AddProfile(false, Str("AddProfile.Title"), Str("AddProfile.Text")); }
void OBSBasic::on_actionNewProfile_triggered() { AddProfile(true, Str("AddProfile.Title"), Str("AddProfile.Text")); }
void BluetoothProfileController::SetupProfiles(bool aAssignServiceClass) { MOZ_ASSERT(NS_IsMainThread()); /** * When a service class is assigned, only its corresponding profile is put * into array. */ if (aAssignServiceClass) { AddProfileWithServiceClass(mTarget.service); return; } // For a disconnect request, all connected profiles are put into array. if (!mConnect) { AddProfile(BluetoothHidManager::Get(), true); AddProfile(BluetoothAvrcpManager::Get(), true); AddProfile(BluetoothA2dpManager::Get(), true); AddProfile(BluetoothHfpManager::Get(), true); return; } /** * For a connect request, put multiple profiles into array and connect to * all of them sequencely. */ bool hasAudio = HAS_AUDIO(mTarget.cod); bool hasRendering = HAS_RENDERING(mTarget.cod); bool isPeripheral = IS_PERIPHERAL(mTarget.cod); bool isRemoteControl = IS_REMOTE_CONTROL(mTarget.cod); bool isKeyboard = IS_KEYBOARD(mTarget.cod); bool isPointingDevice = IS_POINTING_DEVICE(mTarget.cod); bool isInvalid = IS_INVALID(mTarget.cod); // The value of CoD is invalid. Since the device didn't declare its class of // device properly, we assume the device may support all of these profiles. // Note the invalid CoD from bluedroid callback usually results from // NFC-triggered direct pairing for no EIR query records. if (isInvalid) { AddProfile(BluetoothHfpManager::Get()); AddProfile(BluetoothA2dpManager::Get()); AddProfile(BluetoothAvrcpManager::Get()); // register after A2DP return; } NS_ENSURE_TRUE_VOID(hasAudio || hasRendering || isPeripheral); // Audio bit should be set if remote device supports HFP/HSP. if (hasAudio) { AddProfile(BluetoothHfpManager::Get()); } // Rendering bit should be set if remote device supports A2DP. // A device which supports AVRCP should claim that it's a peripheral and it's // a remote control. if (hasRendering || (isPeripheral && isRemoteControl)) { AddProfile(BluetoothA2dpManager::Get()); AddProfile(BluetoothAvrcpManager::Get()); // register after A2DP } // A device which supports HID should claim that it's a peripheral and it's // either a keyboard, a pointing device, or both. if (isPeripheral && (isKeyboard || isPointingDevice)) { AddProfile(BluetoothHidManager::Get()); } }
//InitProfilesScreen bool Menu::InitProfilesScreen (Screen *pScreen) { Err fErr (m_Err, L"InitProfilesScreen"); if (pScreen == NULL) { return fErr.Set (sERR_ARGUMENTS); } wstring sMenuProfiles, sList, sEdit, sDelete, sCreate, sCreateName, sStandard; if (!m_pLanguage->Get (L"ProfilesTitle", &sMenuProfiles) || !m_pLanguage->Get (L"ProfilesList", &sList) || !m_pLanguage->Get (L"ProfilesEdit", &sEdit) || !m_pLanguage->Get (L"ProfilesDelete", &sDelete) || !m_pLanguage->Get (L"ProfilesCreate", &sCreate) || !m_pLanguage->Get (L"ProfilesCreateName", &sCreateName) || !m_pLanguage->Get (L"ProfileStandard", &sStandard)) { return false; } if (!pScreen->Init (&m_Err, m_pProfiles, m_pWindow, sMenuProfiles)) { return false; } std::vector<Profile> *plProfiles; if (!m_pProfiles->GetList (&plProfiles)) { return false; } if (plProfiles->size () == 0 && !AddProfile (sStandard)) { return false; } std::vector<wstring> lsProfileList; for (unsigned int i = 0; i != plProfiles->size (); i++) { wstring sName; if (!m_pProfiles->GetName (i, &sName)) { return false; } lsProfileList.push_back (sName); } if (!pScreen->AddButton (sEdit, Vector2f (100, 190), eProfilesButtonEdit) || !pScreen->AddList (sList, Vector2f (350, 220), lsProfileList, 0, eProfilesListChoice) || !pScreen->AddButton (sDelete, Vector2f (100, 250), eProfilesButtonDelete) || !pScreen->AddButton (sCreate, Vector2f (100, 400), eProfilesButtonCreate) || !pScreen->AddEditbox (sCreateName, Vector2f (350, 400), 300, eProfilesEditCreateName) || !pScreen->AddButton (m_sAbort, Vector2f (700, 600), eProfilesButtonAbort)) { return false; } return true; }//InitProfilesScreen
KRProfileSys::KRProfileSys(TStringList* Dat) { enum load { none, crits, main, profiles, priorities }; load state = none; Crits = KRCritSys(); std::vector<int>P; for (int i = 0; i < Dat->Count; i++) { if (Dat->Strings[i] == "[Crits]") state = crits; if (Dat->Strings[i] == "[Main]") state = main; if (Dat->Strings[i] == "[Profiles]") state = profiles; if (Dat->Strings[i] == "[Priorities]") state = priorities; if (Dat->Names[i] == "name") { KRProfile *Profile; switch (state) { case none: break; case crits: Crits.AddCrit(KRCrit(Dat->ValueFromIndex[i], Dat->ValueFromIndex[i + 1].ToInt())); break; case main: Profile = new KRProfile(Dat->ValueFromIndex[i], Crits); for (int j = 0; j < Crits.GetSize(); j++) Profile->ChangeCrit(j, Dat->ValueFromIndex[i + j + 1].ToInt()); if (Dat->ValueFromIndex[i] == "Worst") { Profile->ChangeCoeff(0.0); Worst = Profile; } if (Dat->ValueFromIndex[i] == "Best") { Profile->ChangeCoeff(1.0); Best = Profile; } if (Dat->ValueFromIndex[i] == "A25") { Profile->ChangeCoeff(0.25); A25 = Profile; } if (Dat->ValueFromIndex[i] == "A50") { Profile->ChangeCoeff(0.50); A50 = Profile; } if (Dat->ValueFromIndex[i] == "A75") { Profile->ChangeCoeff(0.75); A75 = Profile; } if (Dat->ValueFromIndex[i] == "AEQ") { Profile->ChangeCoeff(0.0); AEQ = Profile; } break; case profiles: Profile = new KRProfile(Dat->ValueFromIndex[i], Crits); for (int j = 0; j < Crits.GetSize(); j++) Profile->ChangeCrit(j, Dat->ValueFromIndex[i + j + 1].ToInt()); AddProfile(Profile); break; case priorities: for (int j = 0; j < Crits.GetSize(); j++) P.push_back(Dat->ValueFromIndex[i + j + 1].ToInt()); Crits.SetPrority(P); break; default: break; } } } /* Crits = KRCritSys(); Crits.AddCrit(KRCrit("Время решения", 1)); Crits.AddCrit(KRCrit("Точность", 0)); Crits.AddCrit(KRCrit("Устойчивость", 0)); Crits.AddCrit(KRCrit("Память", 1)); KRProfile* Worst = new KRProfile("Худ", Crits); int CW[] = {500, 20, 0, 256}; Worst->SetCrits(CW); KRProfile* Best = new KRProfile("Луд", Crits); int CB[] = {1, 100, 1, 2}; Best->SetCrits(CB); Profiles = KRProfileSys(Worst, Best, Crits); KRProfile* Prof1 = new KRProfile("МВГ", Crits); int C[] = {40, 100, 1, 16}; Prof1->SetCrits(C); Profiles.AddProfile(Prof1); KRProfile* Prof2 = new KRProfile("ГА", Crits); int C2[] = {8, 85, 1, 32}; Prof2->SetCrits(C2); Profiles.AddProfile(Prof2); KRProfile* Prof3 = new KRProfile("МБС", Crits); int C3[] = {20, 70, 0, 64}; Prof3->SetCrits(C3); Profiles.AddProfile(Prof3); KRProfile* Prof4 = new KRProfile("Пере", Crits); int C4[] = {120, 100, 1, 128}; Prof4->SetCrits(C4); Profiles.AddProfile(Prof4); */ }
void FLauncherProfileManager::LoadProfiles( ) { TArray<FString> ProfileFileNames; //load and move legacy profiles { IFileManager::Get().FindFilesRecursive(ProfileFileNames, *GetLegacyProfileFolder(), TEXT("*.ulp"), true, false); for (TArray<FString>::TConstIterator It(ProfileFileNames); It; ++It) { FString ProfileFilePath = *It; FArchive* ProfileFileReader = IFileManager::Get().CreateFileReader(*ProfileFilePath); if (ProfileFileReader != nullptr) { ILauncherProfilePtr LoadedProfile = LoadProfile(*ProfileFileReader); delete ProfileFileReader; //re-save profile to new location if (LoadedProfile.IsValid()) { SaveProfile(LoadedProfile.ToSharedRef()); } //delete legacy profile. IFileManager::Get().Delete(*ProfileFilePath); } } } //load and re-save legacy profiles { IFileManager::Get().FindFilesRecursive(ProfileFileNames, *FLauncherProfile::GetProfileFolder(), TEXT("*.ulp"), true, false); for (TArray<FString>::TConstIterator It(ProfileFileNames); It; ++It) { FString ProfileFilePath = *It; FArchive* ProfileFileReader = IFileManager::Get().CreateFileReader(*ProfileFilePath); if (ProfileFileReader != nullptr) { ILauncherProfilePtr LoadedProfile = LoadProfile(*ProfileFileReader); delete ProfileFileReader; //re-save profile to the new format if (LoadedProfile.IsValid()) { if (ProfileFilePath.Contains("NotForLicensees")) { LoadedProfile->SetNotForLicensees(); } SaveJSONProfile(LoadedProfile.ToSharedRef()); } //delete legacy profile. IFileManager::Get().Delete(*ProfileFilePath); } } } ProfileFileNames.Reset(); IFileManager::Get().FindFilesRecursive(ProfileFileNames, *FLauncherProfile::GetProfileFolder(), TEXT("*.ulp2"), true, false); for (TArray<FString>::TConstIterator It(ProfileFileNames); It; ++It) { FString ProfileFilePath = *It; ILauncherProfilePtr LoadedProfile = LoadJSONProfile(*ProfileFilePath); if (LoadedProfile.IsValid()) { if (ProfileFilePath.Contains("NotForLicensees")) { LoadedProfile->SetNotForLicensees(); } AddProfile(LoadedProfile.ToSharedRef()); } else { IFileManager::Get().Delete(*ProfileFilePath); } } }
//ManageProfileScreens bool Menu::ManageProfileScreens () { Err fErr (m_Err, L"ManageProfileScreens"); Screen Overview; if (!InitProfilesScreen (&Overview)) { return false; } unsigned int nAction; do { if (!Overview.Run ()) { return false; } if (Overview.IsQuit ()) { m_bClose = true; break; } if (!Overview.GetSelectId (&nAction)) { return false; } wstring sName; if (!Overview.Get (eProfilesListChoice, &sName)) { return false; } switch (nAction) { case (eProfilesButtonEdit): { bool bModified; if (!RunEditProfile (sName, &bModified)) { return false; } if (bModified && !m_pProfiles->Reload ()) { return false; } } break; case (eProfilesButtonCreate): { wstring sName; if (!Overview.Get (eProfilesEditCreateName, &sName)) { return false; } if (sName.empty ()) { fErr.Set (L"The given profile name is empty"); } if (!AddProfile (sName) || !InitProfilesScreen (&Overview)) { return false; } } break; case (eProfilesButtonDelete): if (!m_pProfiles->DeleteProfile (sName) || !InitProfilesScreen (&Overview)) { return false; } break; } if (!Overview.Reset ()) { return false; } } while (!m_bClose && nAction != eProfilesButtonAbort); return true; }//ManageProfileScreens
bool mainFrame::ReadConfig() { if(!m_pFnConfig) return false; //Configuration path not configured wxString sGroup, sTmp; long lCookie; //Populate map of MCU types unsigned int nMcuIndex = 0; while(AddDeviceType(wxAvr::GetMcuNames(nMcuIndex++))); wxLogMessage("%d MCU core types supported", nMcuIndex - 1); if(0 == m_mDevices.size()) return false; //No supported device types //Populate map of profiles wxConfig* pConfig = new wxConfig("wxSimAVRGui", "riban", m_pFnConfig->GetPath() + "/profile.cfg"); bool bMore = pConfig->GetFirstGroup(sGroup, lCookie); while(bMore) { wxString sName, sDeviceType, sDescription; long lFrequency; pConfig->Read(sGroup + "/device", &sDeviceType, wxEmptyString); pConfig->Read(sGroup + "/description", &sDescription, wxEmptyString); pConfig->Read(sGroup + "/frequency", &lFrequency, 0l); if(!AddProfile(sGroup, sDeviceType, lFrequency, sDescription)) wxLogError("Configuration error: Bad configuration of profile [%s]", sGroup.c_str()); bMore = pConfig->GetNextGroup(sGroup, lCookie); } delete pConfig; //Read application configuration pConfig = new wxConfig("wxSimAVRGui", "riban", m_pFnConfig->GetPath() + ("/config.cfg")); pConfig->Read("/state/mcu", &m_sDeviceType, "test"); if(m_sDeviceType.IsEmpty()) { std::map<long,wxString>::iterator it = m_mDevices.begin(); m_sDeviceType = it->second; //This exists because it is specifically created above if m_pDeviceType is empty wxLogMessage("MCU device type not configured - using first defined (%s)", m_sDeviceType); } pConfig->Read("/state/frequency", &m_lFrequency); if(pConfig->Read("/state/firmware", &sTmp)) m_pFnFirmware = new wxFileName(sTmp); if(pConfig->Read("/state/ihex", &sTmp)) m_pFnHex = new wxFileName(sTmp); pConfig->Read("/state/serial", &m_bSerialEnabled, false); pConfig->Read("/state/vcdfile", &sTmp, "wxSimAVR.vcd"); m_pFnVcd = new wxFileName(sTmp); pConfig->Read("/state/vcd", &m_bVcdEnabled, false); m_pMenuitemSerial->Check(m_bSerialEnabled); m_pMenuitemVcd->Check(m_bVcdEnabled); int nWidth = 600; int nHeight = 400; int nX = 10; int nY = 10; long lTmp; bool bTmp; if(pConfig->Read(wxT("/Layout/Width"), &lTmp)) nWidth = lTmp; if(pConfig->Read(wxT("/Layout/Height"), &lTmp)) nHeight = lTmp; if(pConfig->Read(wxT("/Layout/PosX"), &lTmp)) nX = lTmp; if(pConfig->Read(wxT("/Layout/PosY"), &lTmp)) nY = lTmp; if(pConfig->Read(wxT("/Layout/Maximised"), &bTmp)) Maximize(bTmp); SetSize(nWidth, nHeight); //Check saved location is visible bool bCanSee = false; for(unsigned int nDisplay = 0; nDisplay < wxDisplay::GetCount(); nDisplay++) { bCanSee |= wxDisplay(nDisplay).GetGeometry().Intersects(wxRect(nX, nY, nWidth, nHeight)); } if(bCanSee) Move(nX, nY); //AUI manager perspective (layout management) wxString sPerspective; if(pConfig->Read("/Layout/Perspective", &sPerspective, wxEmptyString)) m_pAuiManager->LoadPerspective(sPerspective); m_pMenuitemToolbarControl->Check(m_pAuiManager->GetPane("ToolbarControl").IsShown()); m_pMenuitemToolbarFile->Check(m_pAuiManager->GetPane("ToolbarFile").IsShown()); bTmp = false; pConfig->Read(wxT("/Log/File"), &bTmp, false); EnableLogToFile(bTmp); pConfig->Read(wxT("/Log/Verbose"), &bTmp, false); wxLog::SetVerbose(bTmp); m_pMenuitemLogVerbose->Check(bTmp); delete pConfig; return true; }