Example #1
0
void CSubChannelCfg::OnOK() 
{

	UpdateData(TRUE);

	g_sSettings.SetSubFirstIsSupoer(m_bFirstIsSuper);
	g_sSettings.SetAutoCloseSub(m_bAutoClose);
	g_sSettings.SetLimitSub(m_uMax);


	UINT uMode = 0;


	uMode = g_sSettings.GetChannelMode();
	if(m_bEnable){

		uMode |= CM_SUBCHANNELS;
	}
	else{

		uMode &= ~CM_SUBCHANNELS;
	}
	g_sSettings.SetChannelMode(uMode);

	switch(m_nSubLevel){

	case 0:  // everyone
		uMode = UM_NORMAL;
		break;
	case 1:	// voice admin agent
		uMode = UM_ADMIN|UM_AGENT|UM_VOICED;
		break;
	case 2: // admin agent
		uMode = UM_ADMIN|UM_AGENT;
		break;
	case 3:// admin
		uMode = UM_ADMIN;
		break;
	default: // host
		uMode = UM_HOST;
		break;
	}
	g_sSettings.SetSubPermission(uMode);
	g_sSettings.SetDisplaySubText(m_bDisplaySubs);
	g_sSettings.SetSubListed(m_bSubList);

	g_sSettings.Save();
	CWnd* pWnd = AfxGetApp()->m_pMainWnd;
	if(pWnd){

		pWnd->SendMessage(UWM_SETTINGS, 0, 0);
	}
}
Example #2
0
void CLoginCfg::OnOK() 
{

	if(!UpdateData(TRUE)) return;

	UINT uMode = UM_NORMAL;
	if(m_bDefVoice) uMode |= UM_VOICED;
	if(m_bDefAdmin) uMode |= UM_ADMIN;
	if(m_bDefAgent) uMode |= UM_AGENT;
	g_sSettings.SetDefaultUserMode(uMode);

	g_sSettings.Save();

	CWnd* pWnd = AfxGetApp()->m_pMainWnd;
	if(pWnd){

		pWnd->SendMessage(UWM_SETTINGS, 0, 0);
	}
}
Example #3
0
void CSettingsBar::OnBnClickedOk()
{

	UpdateData(TRUE);

	m_strKeyMsg.Replace("\r\n", "\\n");
	m_strMotd.Replace("\r\n", "\\n");
	g_sSettings.SetGodName(m_strGodName);
	g_sSettings.SetGodVisible(m_bGodVisible);
	g_sSettings.SetGodFiles(m_dwGodFiles);
	g_sSettings.SetGodLine(m_nLine);
	g_sSettings.SetListed(m_bRoomListed);
	g_sSettings.SetTopic(m_strTopic);
	g_sSettings.SetMotd(m_strMotd);
	g_sSettings.SetKeyMsg(m_strKeyMsg);
	g_sSettings.SetWelcome(m_strWelcome);
	g_sSettings.SetColor(m_nColor);
	g_sSettings.SetKeyword(m_strKeyWord);
	
	UINT uMode = g_sSettings.GetChannelMode();
	if(m_strKeyWord.GetLength() && (uMode&CM_KEYWORD != CM_KEYWORD)){

		uMode |= CM_KEYWORD;
	}
	else if(m_strKeyWord.IsEmpty() && (uMode&CM_KEYWORD == CM_KEYWORD)){

		uMode &= ~CM_KEYWORD;
	}
	g_sSettings.SetChannelMode(uMode);
	g_sSettings.Save();

	CWnd* pWnd = AfxGetApp()->m_pMainWnd;
	if(pWnd){

		pWnd->SendMessage(UWM_SETTINGS, 0, 0);
	}
}
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;
}