//----------------------------------------------------------------------------------------------
//	wmCommand
//----------------------------------------------------------------------------------------------
VOID CControllerPage::wmCommand(
	 HWND	Control
	,WORD	ControlID
	,WORD	NotifyMessage )
{
	//	コントロールによって処理を振り分ける
	switch( ControlID )
	{
		case IDC_SETTING:

			//	通知メッセージによって処理を振り分ける
			switch( NotifyMessage )
			{
				case CBN_SELCHANGE:
					//	設定を変更する
					ChangeSetting();
					break;
			}
			break;

		case IDC_SETTING_SAVE:

			//	通知メッセージによって処理を振り分ける
			switch( NotifyMessage )
			{
				case BN_CLICKED:
					//	設定を保存する
					SaveSetting();
					break;
			}
			break;

		case IDC_SETTING_DELETE:

			//	通知メッセージによって処理を振り分ける
			switch( NotifyMessage )
			{
				case BN_CLICKED:
					//	設定を削除する
					DeleteSetting();
					break;
			}
			break;
	}
}
unsigned int CSettings::DeleteSetting(TDBTSettingDescriptor & Descriptor)
{
	TDBTSettingHandle hset = FindSetting(Descriptor);
	if ((hset == 0) || (hset == DBT_INVALIDPARAM))
	{
		return DBT_INVALIDPARAM;
	}

	unsigned int res = 0;
	if ((Descriptor.Flags & DBT_SDF_FoundValid) && (Descriptor.Flags & DBT_SDF_HashValid))
	{
		CBlockManager * file = &m_BlockManagerPri;

		if (Descriptor.FoundInEntity == 0)
		{
			file = &m_BlockManagerSet;
			hset = hset & ~cSettingsFileFlag;
		}

		CBlockManager::WriteTransaction trans(*file);

		uint32_t sig = cSettingSignature;
		uint32_t size = 0;
		TSetting * setting = file->ReadBlock<TSetting>(hset, size, sig);
		if (setting && (setting->Entity == Descriptor.FoundInEntity))
		{
			CSettingsTree * tree = getSettingsTree(setting->Entity);
			if (tree)
			{
				tree->_DeleteSetting(Descriptor.Hash, hset);
				file->DeleteBlock(hset);
			}
		}

	} else {
		res = DeleteSetting(hset);
	}

	return res;
}
示例#3
0
文件: rps.cpp 项目: kxepal/miranda-ng
void RemoveSettings()
{
	char buffer[10000];

	// Delete protocol settings
	if ( GetSettingBool("GlobalSettings", "RemoveProtocolSettings", TRUE) ) {
		PROTOACCOUNT **accounts;
		int i,count;
		Proto_EnumAccounts(&count, &accounts);

		for (i = 0; i < count; i++) {
			/*if (protos[i]->type != PROTOTYPE_PROTOCOL)
				continue;*/
			if (!accounts[i]->bIsEnabled)
				continue;

			if (accounts[i]->szModuleName == NULL || accounts[i]->szModuleName[0] == '\0')
				continue;

			RemoveProtocolSettings(accounts[i]->szModuleName);
		}

		// Get disabled protocols
		if ( GetSettings("DisabledProtocols", buffer, sizeof(buffer)) ) {
			char *name;
			char *value;

			name = buffer;
			while(name[0] != '\0') {
				value = strchr(name, '=');
				if (value == NULL)
					value = &name[mir_strlen(name)];

				// Has " ?
				if (*name == '"' && *(value-1) == '"') {
					name++;
					*(value-1) = '\0';
				}

				// Disable it
				if (name[0] != '\0')
					RemoveProtocolSettings(name);

				// Get next one
				name = value + mir_strlen(value) + 1;
			}
		}
	}


	// Delete other settings
	if (GetSettings("RemoveSettings", buffer, sizeof(buffer))) {
		char *name;
		char *value;

		name = buffer;
		while(name[0] != '\0') {
			value = strchr(name, '=');
			if (value == NULL)
				value = &name[mir_strlen(name)];

			// Has " ?
			if (*name == '"' && *(value-1) == '"') {
				name++;
				*(value-1) = '\0';
			}

			// Delete it
			if (name[0] != '\0')
				DeleteSetting(name);

			// Get next one
			name = value + mir_strlen(value) + 1;
		}
	}
}