Example #1
0
bool CTrayMenu::OnMenu(CPopupMenuItem * pMenu, CItemBase * pItem)
{
	BOOL bDisconected = !g_hTM;
	EFunctionalityLevel nLicLevel = (EFunctionalityLevel)g_hGui->m_LicInfo.m_dwFuncLevel;
	
	PR_TRACE((g_root, prtIMPORTANT, "gui\tGUI::Tray activate status: conected=%u, functionalitylevel=%u (0 = Unknown, 1 = NoFeatures, 2 = OnlyUpdates, 3 = FunctionWithoutUpdates, 4 = FullFunctionality)", !bDisconected, nLicLevel));

	CItemBase * pTaskTpl = pMenu->GetItem(ITEMID_RUNNINGTASK);
	if( pTaskTpl && pTaskTpl->m_pParent )
	{
		for(DWORD i = 0; i < g_pProduct->GetChildrenCount(); i++)
		{
			CProfile * pProfile = g_pProduct->GetChild(i);
			
			bool bUser;
			if( !pProfile->IsScan(bUser) && pProfile->m_sType != AVP_TASK_UPDATER )
				continue;
			if( !IS_TASK_IN_PROGRESS(pProfile->m_nState) )
				continue;
			
			LPCSTR strProfileName = pProfile->m_sName.c_str(cCP_TCHAR);
			if( pMenu->GetItem(strProfileName) )
				continue;
			
			if( CItemBase * pTask = pTaskTpl->m_pParent->CloneItem(pTaskTpl, strProfileName, true) )
			{
				pTaskTpl->m_pParent->MoveItem(pTaskTpl, pTask);
				pTask->Show(true);
			}
		}
	}

	RefreshStatistics();

	if (bDisconected)
	{
		pMenu->Enable("KAV",                 false);
		pMenu->Enable("Settings",            false);
		pMenu->Enable("Activate",            false);
	}
	if (bDisconected || (nLicLevel != eflFullFunctionality && nLicLevel != eflFunctionWithoutUpdates))
	{
		pMenu->Enable(ITEMID_DISABLEPROTECT, false);
		pMenu->Enable("ScanCustom",          false);
	}

	CProfile * pUpdater  = g_pProduct->GetProfile(AVP_PROFILE_UPDATER);
	if (pUpdater)
		pMenu->Enable(ITEMID_UPDATER, !bDisconected && (nLicLevel == eflFullFunctionality || nLicLevel == eflOnlyUpdates || (pUpdater->m_nState & STATE_FLAG_ACTIVE)));
	else
		pMenu->Show(ITEMID_UPDATER, false);

	CProfile * pFullScan = g_pProduct->GetProfile(AVP_PROFILE_FULLSCAN);
	if (pFullScan)
		pMenu->Enable(ITEMID_SCAN_MY_COMPUTER, !bDisconected && (nLicLevel == eflFullFunctionality || nLicLevel == eflFunctionWithoutUpdates || (pFullScan->m_nState & STATE_FLAG_ACTIVE)));
	else
		pMenu->Show(ITEMID_SCAN_MY_COMPUTER, false);

	return true;
}
Example #2
0
BOOL    CAddDeviceDialog::OnInit() {

    CProfile * pcpThis = m_pcpasBoss->Profile();

    m_hwndList   = GetDlgItem(m_hwnd, DeviceListControl);
    m_hwndButton = GetDlgItem(m_hwnd, AddDeviceButton);

    //  This must not list associated (tentatively) devices, per the spec

    for (unsigned uDevice = 0; uDevice < pcpThis->DeviceCount(); uDevice++) {
        for (unsigned u = 0; u < m_pcpasBoss->AssociationCount(); u++)
            if  (uDevice == m_pcpasBoss->Association(u))
                break;
        if  (u < m_pcpasBoss->AssociationCount())
            continue;   //  Don't insert this one...

        LRESULT idItem = SendMessage(m_hwndList, LB_ADDSTRING, (WPARAM)0,
            (LPARAM) pcpThis->DisplayName(uDevice));
        SendMessage(m_hwndList, LB_SETITEMDATA, idItem, (LPARAM) uDevice);
    }

    if  (SendMessage(m_hwndList, LB_GETCOUNT, 0, 0))
        SendMessage(m_hwndList, LB_SETCURSEL, 0, 0);

    EnableWindow(m_hwndButton, -1 !=
        SendMessage(m_hwndList, LB_GETCURSEL, 0, 0));

    return  TRUE;
}
JSONRPC_STATUS CProfilesOperations::LoadProfile(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
{
  CStdString profilename = parameterObject["profile"].asString();
  int index = CProfilesManager::Get().GetProfileIndex(profilename);
  
  if (index < 0)
    return InvalidParams;

	// Init prompt
	bool bPrompt = false;
	bPrompt = parameterObject["prompt"].asBoolean();
    
	bool bCanceled;
  bool bLoadProfile(false);

  if (CProfilesManager::Get().GetMasterProfile().getLockMode() == LOCK_MODE_EVERYONE ||            // Password not needed
      (bPrompt && g_passwordManager.IsProfileLockUnlocked(index, bCanceled, bPrompt)))  // Password needed and user asked to enter it
    bLoadProfile = true;
	else if (!bCanceled && parameterObject.isMember("password"))  // Password needed and user provided it
	{
    const CVariant &passwordObject = parameterObject["password"];
	  CStdString strToVerify;  // Holds user saved password hash
		if (index == 0)
		  strToVerify = CProfilesManager::Get().GetMasterProfile().getLockCode();
		else
		{
	    CProfile *profile = CProfilesManager::Get().GetProfile(index);
		  strToVerify = profile->getLockCode();
		}

		CStdString password = passwordObject["value"].asString();
		
		// Create password hash from the provided password if md5 is not used
    CStdString md5pword2;
    CStdString encryption = passwordObject["encryption"].asString();
    if (encryption.Equals("none"))
		{
			XBMC::XBMC_MD5 md5state;
			md5state.append(password);
			md5state.getDigest(md5pword2);
		}
		else if (encryption.Equals("md5"))
			md5pword2 = password;

		// Verify profided password
    if (strToVerify.Equals(md5pword2))
		  bLoadProfile = true;
	}

  if (bLoadProfile)
  {
    CApplicationMessenger::Get().LoadProfile(index);
    return ACK;
  }
  return InvalidParams;
}
Example #4
0
/**
 * Copy Constructor
 */
CProfile::CProfile(const CProfile& _pf): m_initialised(false) {
	unsigned long i, max_i = _pf.get_plot_cnt()-1;

	if (_pf.m_initialised) {
		init(_pf.get_plot_pos(0), _pf.get_plot_pos(max_i), max_i);

		for (i = 0; i <= max_i; i++) {
			plot(_pf.get_plot_val(i));
		}
	}
}
Example #5
0
UINT CRefresher::GetRefreshSetting(RefreshParam& rp)
{
	UINT	uRet	= 0;
	CProfile	prof;
	if((uRet = prof.LoadProfile(SYS_CONFIG_POS)) != 0)
		return uRet;
	if((uRet = prof.GetProfileStringW(REFRESH_SETTING,SERVER_IP,rp.strIp) != 0))
		return uRet;
	if((uRet = prof.GetProfileIntW(REFRESH_SETTING,SERVER_PORT,rp.iPort) != 0))
		return uRet;
	if((uRet = prof.GetProfileStringW(REFRESH_SETTING,SEND_MSG,rp.strMsg) != 0))
		return uRet;
	return uRet;
}
Example #6
0
bool CGUIPassword::SetMasterLockMode(bool bDetails)
{
  CProfile* profile = CProfilesManager::Get().GetProfile(0);
  if (profile)
  {
    CProfile::CLock locks = profile->GetLocks();
    if (CGUIDialogLockSettings::ShowAndGetLock(locks, 12360, true, bDetails))
    {
      profile->SetLocks(locks);
      return true;
    }
  }
  return false;
}
Example #7
0
void CSettings::AddProfile(const CProfile &profile)
{
    //data integrity check - covers off migration from old profiles.xml, incrementing of the m_nextIdProfile,and bad data coming in
    m_nextIdProfile = max(m_nextIdProfile, profile.getId() + 1);

    m_vecProfiles.push_back(profile);
}
Example #8
0
BOOL WriteIntFromInI(const CString strSection, const CString strEntry,const int intvalue)
{
	if(g_profile.WriteProfileInt(strSection,strEntry,intvalue,GetInIFileName()))
		return TRUE;
	else
		return FALSE;
}
Example #9
0
bool CAddToAntidialExcludes::OnOk()
{
	if( !CDialogBindingT<>::OnOk() )
		return false;

	CProfile * pProfile = g_pProduct->GetProfile(AVP_PROFILE_ANTIDIAL);
	if( !pProfile || !pProfile->settings() || !pProfile->settings()->isBasedOn(cAntiDialSettings::eIID) )
		return false;

	((cAntiDialSettings *)pProfile->settings())->m_vAllowPhoneNumbersList.push_back(m_ExclItem);
	if( PR_FAIL(pProfile->SaveSettings()) )
		return false;

	m_pAskAction->m_nResultAction = m_pAskAction->m_nExcludeAction;
	((CDialogItem *)Item()->m_pParent)->Close();
	return true;
}
Example #10
0
BOOL WritestrToInI(CString pare_node,CString child_node,CString strvalue)
{

	if(g_profile.WriteProfileString(pare_node,child_node,strvalue,GetInIFileName()))
		return TRUE;
	else
		return FALSE;
}
Example #11
0
void CProfilesManager::AddProfile(const CProfile &profile)
{
  CSingleLock lock(m_critical);
  // data integrity check - covers off migration from old profiles.xml,
  // incrementing of the m_nextIdProfile,and bad data coming in
  m_nextProfileId = max(m_nextProfileId, profile.getId() + 1);

  m_profiles.push_back(profile);
}
Example #12
0
bool CMailWasherDlg::OnOk()
{
	m_MwSett = *(cGuiMailwasherSettings*)&m_Mw;
	if( !m_MwSett.m_bShowMailwasher )
	{
		CProfile *pAs = g_pProduct->GetProfile(AVP_PROFILE_ANTISPAM);
		if( pAs )
		{
			cAsBwList *pAsUserSett = (cAsBwList *)pAs->settings_user(NULL, cAsBwList::eIID);
			if( pAsUserSett )
			{
				pAsUserSett->m_bShowMailwasher = cFALSE;
				pAs->SaveSettings();
			}
		}
	}
	
	return OnCanClose(true);
}
Example #13
0
bool CGUIPassword::IsProfileLockUnlocked(int iProfile, bool& bCanceled, bool prompt)
{
  if (g_passwordManager.bMasterUser)
    return true;
  int iProfileToCheck=iProfile;
  if (iProfile == -1)
    iProfileToCheck = CProfilesManager::Get().GetCurrentProfileIndex();
  if (iProfileToCheck == 0)
    return IsMasterLockUnlocked(prompt,bCanceled);
  else
  {
    CProfile *profile = CProfilesManager::Get().GetProfile(iProfileToCheck);
    if (!profile)
      return false;

    if (!prompt)
      return (profile->getLockMode() == LOCK_MODE_EVERYONE);

    if (profile->getDate().empty() &&
       (CProfilesManager::Get().GetMasterProfile().getLockMode() == LOCK_MODE_EVERYONE ||
        profile->getLockMode() == LOCK_MODE_EVERYONE))
    {
      // user hasn't set a password and this is the first time they've used this account
      // so prompt for password/settings
      if (CGUIDialogProfileSettings::ShowForProfile(iProfileToCheck, true))
        return true;
    }
    else
       if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE)
        return CheckLock(profile->getLockMode(),profile->getLockCode(),20095,bCanceled);
  }

  return true;
}
Example #14
0
void CGUIDialogBoxeeShare::OnInitWindow()
{
  CGUIWindow::OnInitWindow();

  m_strText = GetDefaultShareText();
  
  // Send the item to the special container to allow skin access
  CFileItemPtr itemPtr(new CFileItem(m_item));
  CGUIMessage winmsg(GUI_MSG_LABEL_ADD, GetID(), HIDDEN_CONTAINER, 0, 0, itemPtr);
  g_windowManager.SendMessage(winmsg);
  
  CGUIEditControl* editControl = (CGUIEditControl*)GetControl(EDIT_CONTROL);
  if (editControl)
  {
    editControl->SetLabel2(m_strText);
    CGUIWindow* activeWindow = g_windowManager.GetWindow(g_windowManager.GetActiveWindow());
    if (activeWindow)
    {
      CStdString leftToInput = BOXEE::BXUtils::IntToString(editControl->GetMaxInputSize() - (int)editControl->GetLabel2().size());
      activeWindow->SetProperty(LEFT_TO_INPUT_SIZE,leftToInput);
    }
  }

  // Set the user profile thumb - start
  CProfile profile = g_settings.m_vecProfiles[g_settings.m_iLastLoadedProfileIndex];

  CFileItemPtr item(new CFileItem(profile.getName()));
  CStdString strLabel;

  if (profile.getDate().IsEmpty())
    strLabel = g_localizeStrings.Get(20113);
  else
    strLabel.Format(g_localizeStrings.Get(20112),profile.getDate());

  item->SetLabel2(strLabel);
  item->SetThumbnailImage(profile.getThumb());
  item->SetCachedPictureThumb();
  if (profile.getThumb().IsEmpty() || profile.getThumb().Equals("-"))
    item->SetThumbnailImage("unknown-user.png");

  item->SetLabelPreformated(true);

  CGUIMessage winmsg2(GUI_MSG_LABEL_ADD, GetID(), USER_INFO_CONTAINER, 0, 0, item);
  g_windowManager.SendMessage(winmsg2);

  UpdateShareDialog();

  SET_CONTROL_FOCUS(SHARE_BTN,0);
}
Example #15
0
CString  ReadstrFromInI(CString pare_node,CString child_node,CString default_value)
{
	return g_profile.GetProfileString(pare_node,child_node,default_value,GetInIFileName());
}
Example #16
0
bool CGUIDialogProfileSettings::ShowForProfile(unsigned int iProfile, bool firstLogin)
{
  CProfilesManager &profileManager = CServiceBroker::GetProfileManager();

  if (firstLogin && iProfile > profileManager.GetNumberOfProfiles())
    return false;

  CGUIDialogProfileSettings *dialog = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIDialogProfileSettings>(WINDOW_DIALOG_PROFILE_SETTINGS);
  if (dialog == NULL)
    return false;

  dialog->m_needsSaving = false;
  dialog->m_isDefault = iProfile == 0;
  dialog->m_showDetails = !firstLogin;

  const CProfile *profile = profileManager.GetProfile(iProfile);
  if (profile == NULL)
  {
    dialog->m_name.clear();
    dialog->m_dbMode = 2;
    dialog->m_sourcesMode = 2;
    dialog->m_locks = CProfile::CLock();

    bool bLock = profileManager.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser;
    dialog->m_locks.addonManager = bLock;
    dialog->m_locks.settings = (bLock) ? LOCK_LEVEL::ALL : LOCK_LEVEL::NONE;
    dialog->m_locks.files = bLock;

    dialog->m_directory.clear();
    dialog->m_thumb.clear();

    // prompt for a name
    std::string profileName;
    if (!CGUIKeyboardFactory::ShowAndGetInput(profileName, CVariant{g_localizeStrings.Get(20093)}, false) || profileName.empty())
      return false;
    dialog->m_name = profileName;

    // create a default path
    std::string defaultDir = URIUtils::AddFileToFolder("profiles", CUtil::MakeLegalFileName(dialog->m_name));
    URIUtils::AddSlashAtEnd(defaultDir);
    XFILE::CDirectory::Create(URIUtils::AddFileToFolder("special://masterprofile/", defaultDir));

    // prompt for the user to change it if they want
    std::string userDir = defaultDir;
    if (GetProfilePath(userDir, false)) // can't be the master user
    {
      if (!URIUtils::PathHasParent(userDir, defaultDir)) // user chose a different folder
        XFILE::CDirectory::Remove(URIUtils::AddFileToFolder("special://masterprofile/", defaultDir));
    }
    dialog->m_directory = userDir;
    dialog->m_needsSaving = true;
  }
  else
  {
    dialog->m_name = profile->getName();
    dialog->m_thumb = profile->getThumb();
    dialog->m_directory = profile->getDirectory();
    dialog->m_dbMode = profile->canWriteDatabases() ? 0 : 1;
    if (profile->hasDatabases())
      dialog->m_dbMode += 2;
    dialog->m_sourcesMode = profile->canWriteSources() ? 0 : 1;
    if (profile->hasSources())
      dialog->m_sourcesMode += 2;

    dialog->m_locks = profile->GetLocks();
  }

  dialog->Open();
  if (dialog->m_needsSaving)
  {
    if (iProfile >= profileManager.GetNumberOfProfiles())
    {
      if (dialog->m_name.empty() || dialog->m_directory.empty())
        return false;

      /*std::string strLabel;
      strLabel.Format(g_localizeStrings.Get(20047),dialog->m_strName);
      if (!CGUIDialogYesNo::ShowAndGetInput(20058, strLabel, dialog->m_strDirectory, ""))
      {
        CDirectory::Remove(URIUtils::AddFileToFolder(profileManager.GetUserDataFolder(), dialog->m_strDirectory));
        return false;
      }*/

      // check for old profile settings
      CProfile profile(dialog->m_directory, dialog->m_name, profileManager.GetNextProfileId());
      profileManager.AddProfile(profile);
      bool exists = XFILE::CFile::Exists(URIUtils::AddFileToFolder("special://masterprofile/", dialog->m_directory, "guisettings.xml"));

      if (exists && !CGUIDialogYesNo::ShowAndGetInput(CVariant{20058}, CVariant{20104}))
        exists = false;

      if (!exists)
      {
        // copy masterprofile guisettings to new profile guisettings
        // If the user selects 'start fresh', do nothing as a fresh
        // guisettings.xml will be created on first profile use.
        if (CGUIDialogYesNo::ShowAndGetInput(CVariant{20058}, CVariant{20048}, CVariant{""}, CVariant{""}, CVariant{20044}, CVariant{20064}))
        {
          XFILE::CFile::Copy(URIUtils::AddFileToFolder("special://masterprofile/", "guisettings.xml"),
                              URIUtils::AddFileToFolder("special://masterprofile/", dialog->m_directory, "guisettings.xml"));
        }
      }

      exists = XFILE::CFile::Exists(URIUtils::AddFileToFolder("special://masterprofile/", dialog->m_directory, "sources.xml"));
      if (exists && !CGUIDialogYesNo::ShowAndGetInput(CVariant{20058}, CVariant{20106}))
        exists = false;

      if (!exists)
      {
        if ((dialog->m_sourcesMode & 2) == 2)
          // prompt user to copy masterprofile's sources.xml file
          // If 'start fresh' (no) is selected, do nothing.
          if (CGUIDialogYesNo::ShowAndGetInput(CVariant{20058}, CVariant{20071}, CVariant{""}, CVariant{""}, CVariant{20044}, CVariant{20064}))
          {
            XFILE::CFile::Copy(URIUtils::AddFileToFolder("special://masterprofile/", "sources.xml"),
                                URIUtils::AddFileToFolder("special://masterprofile/", dialog->m_directory, "sources.xml"));
          }
      }
    }

    /*if (!dialog->m_bIsNewUser)
      if (!CGUIDialogYesNo::ShowAndGetInput(20067, 20103))
        return false;*/

    CProfile *profile = profileManager.GetProfile(iProfile);
    assert(profile);
    profile->setName(dialog->m_name);
    profile->setDirectory(dialog->m_directory);
    profile->setThumb(dialog->m_thumb);
    profile->setWriteDatabases(!((dialog->m_dbMode & 1) == 1));
    profile->setWriteSources(!((dialog->m_sourcesMode & 1) == 1));
    profile->setDatabases((dialog->m_dbMode & 2) == 2);
    profile->setSources((dialog->m_sourcesMode & 2) == 2);
    profile->SetLocks(dialog->m_locks);
    profileManager.Save();

    return true;
  }

  return dialog->m_needsSaving;
}
Example #17
0
UINT32 ReadIntFromInI(const CString strSection, const CString strEntry,const int iDefault)
{
	return g_profile.GetProfileInt(strSection, strEntry,iDefault,GetInIFileName());
}
bool CGUIDialogProfileSettings::ShowForProfile(unsigned int iProfile, bool firstLogin)
{
  CGUIDialogProfileSettings *dialog = (CGUIDialogProfileSettings *)g_windowManager.GetWindow(WINDOW_DIALOG_PROFILE_SETTINGS);
  if (!dialog) return false;
  if (iProfile == 0)
    dialog->m_bIsDefault = true;
  else
    dialog->m_bIsDefault = false;
  if (firstLogin && iProfile > CProfilesManager::Get().GetNumberOfProfiles())
    return false;

  dialog->m_bNeedSave = false;
  dialog->m_bShowDetails = !firstLogin;
  dialog->SetProperty("heading", g_localizeStrings.Get(firstLogin ? 20255 : 20067));

  const CProfile *profile = CProfilesManager::Get().GetProfile(iProfile);

  if (!profile)
  { // defaults
    dialog->m_strName.Empty();
    dialog->m_iDbMode = 2;
    dialog->m_iSourcesMode = 2;
    dialog->m_locks = CProfile::CLock();

    bool bLock = CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser;
    dialog->m_locks.addonManager = bLock;
    dialog->m_locks.settings = (bLock) ? LOCK_LEVEL::ALL : LOCK_LEVEL::NONE;
    dialog->m_locks.files = bLock;

    dialog->m_strDirectory.Empty();
    dialog->m_strThumb.Empty();
    // prompt for a name
    if (!CGUIKeyboardFactory::ShowAndGetInput(dialog->m_strName,g_localizeStrings.Get(20093),false) || dialog->m_strName.IsEmpty())
      return false;
    // create a default path
    CStdString defaultDir = URIUtils::AddFileToFolder("profiles",CUtil::MakeLegalFileName(dialog->m_strName));
    URIUtils::AddSlashAtEnd(defaultDir);
    CDirectory::Create(URIUtils::AddFileToFolder("special://masterprofile/", defaultDir));
    // prompt for the user to change it if they want
    CStdString userDir = defaultDir;
    if (dialog->OnProfilePath(userDir, false)) // can't be the master user
    {
      if (userDir.Left(defaultDir.GetLength()) != defaultDir) // user chose a different folder
        CDirectory::Remove(URIUtils::AddFileToFolder("special://masterprofile/", defaultDir));
    }
    dialog->m_strDirectory = userDir;
    dialog->m_bNeedSave = true;
  }
  else
  {
    dialog->m_strName = profile->getName();
    dialog->m_strThumb = profile->getThumb();
    dialog->m_strDirectory = profile->getDirectory();
    dialog->m_iDbMode = profile->canWriteDatabases()?0:1;
    dialog->m_iSourcesMode = profile->canWriteSources()?0:1;
    if (profile->hasDatabases())
      dialog->m_iDbMode += 2;
    if (profile->hasSources())
      dialog->m_iSourcesMode += 2;

    dialog->m_locks = profile->GetLocks();
  }
  dialog->DoModal();
  if (dialog->m_bNeedSave)
  {
    if (iProfile >= CProfilesManager::Get().GetNumberOfProfiles())
    {
      if (dialog->m_strName.IsEmpty() || dialog->m_strDirectory.IsEmpty())
        return false;
      /*CStdString strLabel;
      strLabel.Format(g_localizeStrings.Get(20047),dialog->m_strName);
      if (!CGUIDialogYesNo::ShowAndGetInput(g_localizeStrings.Get(20058),strLabel,dialog->m_strDirectory,""))
      {
        CDirectory::Remove(URIUtils::AddFileToFolder(CProfilesManager::Get().GetUserDataFolder(), dialog->m_strDirectory));
        return false;
      }*/

      // check for old profile settings
      CProfile profile(dialog->m_strDirectory, dialog->m_strName, CProfilesManager::Get().GetNextProfileId());
      CProfilesManager::Get().AddProfile(profile);
      bool bExists = CFile::Exists(URIUtils::AddFileToFolder("special://masterprofile/",
                                                          dialog->m_strDirectory+"/guisettings.xml"));

      if (bExists)
        if (!CGUIDialogYesNo::ShowAndGetInput(20058,20104,20105,20022))
          bExists = false;

      if (!bExists)
      {
        // save new profile guisettings
        if (CGUIDialogYesNo::ShowAndGetInput(20058,20048,20102,20022,20044,20064))
        {
          CFile::Cache(URIUtils::AddFileToFolder("special://masterprofile/","guisettings.xml"),
                       URIUtils::AddFileToFolder("special://masterprofile/",
                                              dialog->m_strDirectory+"/guisettings.xml"));
        }
        else
        {
          // create some new settings
          CStdString path = URIUtils::AddFileToFolder("special://masterprofile/", dialog->m_strDirectory);
          path = URIUtils::AddFileToFolder(path, "guisettings.xml");

          CSettings settings;
          settings.Initialize();
          settings.Save(path);
        }
      }

      bExists = CFile::Exists(URIUtils::AddFileToFolder("special://masterprofile/",
                                                     dialog->m_strDirectory+"/sources.xml"));
      if (bExists)
        if (!CGUIDialogYesNo::ShowAndGetInput(20058,20106,20105,20022))
          bExists = false;

      if (!bExists)
      {
        if ((dialog->m_iSourcesMode & 2) == 2)
          if (CGUIDialogYesNo::ShowAndGetInput(20058,20071,20102,20022,20044,20064))
          {
            CFile::Cache(URIUtils::AddFileToFolder("special://masterprofile/","sources.xml"),
                         URIUtils::AddFileToFolder("special://masterprofile/",
                         dialog->m_strDirectory+"/sources.xml"));
          }
      }
    }

    /*if (!dialog->m_bIsNewUser)
      if (!CGUIDialogYesNo::ShowAndGetInput(20067,20103,20022,20022))
        return false;*/

    CProfile *profile = CProfilesManager::Get().GetProfile(iProfile);
    assert(profile);
    profile->setName(dialog->m_strName);
    profile->setDirectory(dialog->m_strDirectory);
    profile->setThumb(dialog->m_strThumb);
    profile->setWriteDatabases(!((dialog->m_iDbMode & 1) == 1));
    profile->setWriteSources(!((dialog->m_iSourcesMode & 1) == 1));
    profile->setDatabases((dialog->m_iDbMode & 2) == 2);
    profile->setSources((dialog->m_iSourcesMode & 2) == 2);
    profile->SetLocks(dialog->m_locks);

    CProfilesManager::Get().Save();
    return true;
  }

  return !dialog->m_bNeedSave;
}
Example #19
0
void InheritRtpSettings(CProfile* pProfiles, pxnode pnCfg, bool& bCustom)
{
	bCustom = false;

	assert(pProfiles && pnCfg);
	if (!pProfiles || !pnCfg)
		return;

	CProfile* pProtectionPrf = pProfiles->GetProfile(AVP_PROFILE_PROTECTION);
	CProfile* pOasPrf = pProfiles->GetProfile(AVP_PROFILE_FILEMONITOR);
	CProfile* pMcPrf = pProfiles->GetProfile(AVP_PROFILE_MAILMONITOR);
	CProfile* pWebPrf = pProfiles->GetProfile(AVP_PROFILE_WEBMONITOR);
	CProfile* pOgPrf = pProfiles->GetProfile(AVP_PROFILE_OFFICEGUARD);
	
	pxnode pRtp = xtree_get_node(pnCfg, L"REALTIME_PROT_SETTINGS\\dat");
	if (pRtp) // у FS этого значения нет, а настройки есть
	{
		tDWORD t = 0;
		
		/* Нефига не работает, где-то после upgrade эти настройки перебиваются.
		if (pProtectionPrf && xtree_query_val(pRtp, L"KLRTP_SE_RTP_DISABLE", t))
			pProtectionPrf->Enable(t == 0);
		if (pOasPrf && xtree_query_val(pRtp, L"KLRTP_SE_ONACESS_DISABLE", t))
			pOasPrf->Enable(t == 0);	
		if (pMcPrf && xtree_query_val(pRtp, L"KLRTP_SE_MAILCHK_DISABLE", t))
			pMcPrf->Enable(t == 0);	
		if (pWebPrf && xtree_query_val(pRtp, L"KLRTP_SE_SCRIPTCHK_DISABLE", t))	
			pWebPrf->Enable(t == 0);	
		if (pOgPrf && xtree_query_val(pRtp, L"KLRTP_SE_OFFICEGRD_DISABLE", t))
			pOgPrf->Enable(t == 0);
		*/
			
		if (xtree_query_val(pRtp, L"KLRTP_SE_TASK_LEVEL", t))
		{
			switch (t)
			{
			case 0x0: // PROT_HIGH_SECUR
				if (pOasPrf) pOasPrf->ResetSettingsLevel(3);
				if (pMcPrf) pMcPrf->ResetSettingsLevel(3);
				if (pWebPrf) pWebPrf->ResetSettingsLevel(3);
				return;
				
			case 0x1: // PROT_RECOMMENDED
				if (pOasPrf) pOasPrf->ResetSettingsLevel(SETTINGS_LEVEL_DEFAULT);
				if (pMcPrf) pMcPrf->ResetSettingsLevel(SETTINGS_LEVEL_DEFAULT);
				if (pWebPrf) pWebPrf->ResetSettingsLevel(SETTINGS_LEVEL_DEFAULT);
				return;
				
			case 0x2: // PROT_HIGH_SPEED
				if (pOasPrf) pOasPrf->ResetSettingsLevel(2);
				if (pMcPrf) pMcPrf->ResetSettingsLevel(2);
				if (pWebPrf) pWebPrf->ResetSettingsLevel(2);
				return;
			}
		}
	}
	bCustom = true;
	if (pOasPrf) pOasPrf->ResetSettingsLevel(SETTINGS_LEVEL_CUSTOM);
	if (pMcPrf) pMcPrf->ResetSettingsLevel(SETTINGS_LEVEL_CUSTOM);
	if (pWebPrf) pWebPrf->ResetSettingsLevel(SETTINGS_LEVEL_CUSTOM);
}