MagStringView::MagStringView(BRect rect, const char* name,
		const char* label)
	: BStringView(rect, name, label)
{
	AddFilter(new BMessageFilter(B_MOUSE_UP, MouseUpFilter));
	AddFilter(new BMessageFilter(B_MOUSE_DOWN, MouseDownFilter));
}
Exemple #2
0
  SortWayDataGenerator::SortWayDataGenerator()
  : SortDataGenerator<Way>(WayDataFile::WAYS_DAT,WayDataFile::WAYS_IDMAP)
  {
    AddSource(OptimizeAreaWayIdsGenerator::WAYS_TMP);

    AddFilter(std::make_shared<WayLocationProcessorFilter>());
    AddFilter(std::make_shared<WayNodeReductionProcessorFilter>());
    AddFilter(std::make_shared<WayTypeIgnoreProcessorFilter>());
  }
HRESULT MainDialog::EnumDMOs(IEnumDMO *pEnumCat)
{
    HRESULT hr=S_OK;
    int nFilters=0;
    WCHAR *wszName=0;
    CLSID clsid;

    // Clear the current filter list
    ClearFilterList();

    // If there are no filters of a requested type, show default string
    if (!pEnumCat)
    {
        m_FilterList.AddString(TEXT("<< No entries >>"));
        SetNumFilters(0);
        return S_OK;
    }

    // Enumerate all items associated with the moniker
    while (pEnumCat->Next(1, &clsid, &wszName, NULL) == S_OK)
    {
        nFilters++;

        // As a precaution, verify that the DMO has a name.  If not,
        // give it a temporary name so that it can be added to the list box
        // and still have an associated CLSID.

		size_t len;
		hr = StringCchLength(wszName, STRSAFE_MAX_CCH, &len);
		if (SUCCEEDED(hr))
		{
	        // Add this DMO's name and CLSID to the listbox
		    AddFilter(wszName, &clsid);
		}
		else
		{
		    AddFilter(TEXT("<< Invalid DMO name >>\0"), &clsid);
		}

        CoTaskMemFree(wszName);
        wszName = 0;
    }

    // If no DMOs matched the query, show a default item
    if (nFilters == 0)
	{
        m_FilterList.AddString(TEXT("<< No entries >>"));
	}

    // Update count of enumerated filters
    SetNumFilters(nFilters);
    return hr;
}
/* Handles startup.
*/
static AIErr StartupPlugin ( SPInterfaceMessage* message )
{
	AIErr error = kNoErr;
	error = AcquireSuites( message->d.basic );
	if (!error) {
		// Allocate our globals - Illustrator will keep track of these.
		error = message->d.basic->AllocateBlock( sizeof(Globals), (void **) &g );
		if ( !error ) { 
			message->d.globals = g;
		}
	}
	if (!error) {
		error = AddMenu(message);
	}
	if (!error) {	
		error = AddFilter(message);
	}
	if (!error) {
		error = AddTool(message);
	}
	if (!error) {
		error = AddAction(message);
	}
	ReleaseSuites( message->d.basic );
	return error;
}
Exemple #5
0
void CFilterPageImpl::UpdateGrid(int focus)
{
	m_grid.DeleteAllItems();
	for (auto it = m_filters.begin(); it != m_filters.end(); ++it)
		AddFilter(*it);
	m_grid.SelectItem(focus);
}
Exemple #6
0
HRESULT CFGManagerBDA::CreateKSFilter(IBaseFilter** ppBF, CLSID KSCategory, CStringW& DisplayName)
{
	HRESULT		hr = VFW_E_NOT_FOUND;
	BeginEnumSysDev (KSCategory, pMoniker) {
		CComPtr<IPropertyBag>	pPB;
		CComVariant				var;
		LPOLESTR				strName = NULL;
		if (SUCCEEDED (pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB)) &&
				SUCCEEDED (pMoniker->GetDisplayName(NULL, NULL, &strName)) &&
				SUCCEEDED (pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL)) ) {
			CStringW	Name = CStringW(strName);
			if (Name != DisplayName) {
				continue;
			}

			hr = pMoniker->BindToObject(NULL, NULL, IID_IBaseFilter, (void**)ppBF);
			if (SUCCEEDED (hr)) {
				hr = AddFilter (*ppBF, CStringW(var.bstrVal));
			}
			break;
		}

		if (strName) {
			CoTaskMemFree(strName);
		}
	}
ProtocolHandler::ProtocolHandler(NSLooper *nsHandler)
					:	BHandler()
{
	AddFilter(new ProtocolFilter(nsHandler));
	//load passwords from disk
	LoadPasswords();
}
void
StatusView::AttachedToWindow()
{
	BView::AttachedToWindow();
	if (Parent())
		SetViewColor(Parent()->ViewColor());
	else
		SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	SetLowColor(ViewColor());

	// watching if the driver change the frequency
	fDriverInterface.StartWatching(this);

	// monitor preferences file
	fPrefFileWatcher = new PrefFileWatcher<freq_preferences>(fStorage, this);
	AddFilter(fPrefFileWatcher);

	// FrequencySwitcher
	fFrequencySwitcher = new FrequencySwitcher(&fDriverInterface, this);
	fFrequencySwitcher->SetMode(*(fStorage->GetPreferences()));
	AddFilter(fFrequencySwitcher);

	// perferences menu
	fPreferencesMenu = new BPopUpMenu(B_EMPTY_STRING, false, false);
	fPreferencesMenuFilter = new FrequencyMenu(fPreferencesMenu, this,
		fStorage, &fDriverInterface);

	fPreferencesMenu->SetFont(be_plain_font);

	fPreferencesMenu->AddSeparatorItem();
	fOpenPrefItem = new BMenuItem(B_TRANSLATE(
			"Open Speedstep preferences" B_UTF8_ELLIPSIS),
		new BMessage(kMsgOpenSSPreferences));
	fPreferencesMenu->AddItem(fOpenPrefItem);
	fOpenPrefItem->SetTarget(this);

	if (fInDeskbar) {
		fQuitItem= new BMenuItem(B_TRANSLATE("Quit"),
			new BMessage(B_QUIT_REQUESTED));
		fPreferencesMenu->AddItem(fQuitItem);
		fQuitItem->SetTarget(this);
	}
	AddFilter(fPreferencesMenuFilter);

	fPreferencesMenuFilter->UpdateMenu();
}
Exemple #9
0
void CConvertDlg::AddFile(CString fn)
{
	CString protocol;

	int i = fn.Find(_T("://"));
	if(i > 0)
	{
		CString url = fn.Mid(i);
		CPath path(fn.Left(i));
		path.StripPath();
		protocol = (LPCTSTR)path;
		fn = (LPCTSTR)path + url;
	}

	CComPtr<IBaseFilter> pBF;
	if(FAILED(m_pGB->AddSourceFilter(CStringW(fn), CStringW(fn), &pBF)))
		return;

	int nConnected = 0;
	BeginEnumPins(pBF, pEP, pPin)
	if(S_OK == m_pGB->ConnectFilter(pPin, m_pMux)) nConnected++;
	EndEnumPins;
	if(!nConnected)
	{
		MessageBeep((UINT)-1);
		DeleteFilter(pBF);
		return;
	}

	if(m_tree.GetCount() == 0)
	{
		if(CComQIPtr<IDSMPropertyBag> pPB = m_pMux)
			pPB->DelAllProperties();

		CString ext(_T(".dsm"));

		if(!protocol.IsEmpty())
		{
			m_fn = protocol + ext;
		}
		else
		{
			CPath p(fn);
			if(ext.CompareNoCase(p.GetExtension()) == 0)
				ext = _T(" (remuxed)") + ext;
			p.RemoveExtension();
			m_fn = (LPCTSTR)p + ext;
		}

		UpdateData(FALSE);
	}

	CTreeItemFile* t = DNew CTreeItemFile(fn, pBF, m_tree, NULL);

	AddFilter(*t, pBF);

	m_tree.Expand(*t, TVE_EXPAND);
	m_tree.EnsureVisible(*t);
}
Exemple #10
0
void GmJobFilter::CopyItem (const GmJobFilter & item)
{
	for_each (vpFilters.begin (), vpFilters.end (), ReleaseMemory ());
	vpFilters.clear ();
	bExclude = item.bExclude;
	for (size_t index = 0; index < item.vpFilters.size (); ++index)
		AddFilter (item.vpFilters[index]->FileName, item.vpFilters[index]->DirName, item.vpFilters[index]->IsDir);
}
Exemple #11
0
LRESULT CFilterPageImpl::OnAddItem(NMHDR* /*pnmh*/)
{
	Filter filter;
	AddFilter(filter);
	m_filters.push_back(filter);

	return 0;
}
void NavigatorEditor::SetShortCutFilter(ShortCutFilter *_shortCutFilter)
{
	if (LockLooper())
	{
		AddFilter(_shortCutFilter);
		UnlockLooper();
	}
}
Exemple #13
0
MainWindow::MainWindow()
	:
	BWindow(BRect(0, 0, 300, 400), "Caya", B_TITLED_WINDOW, 0),
	fWorkspaceChanged(false)
{
	fStatusView = new StatusView("statusView");

	SearchBarTextControl* searchBox = 
		new SearchBarTextControl(new BMessage(kSearchContact));

	fListView = new RosterListView("buddyView");
	fListView->SetInvocationMessage(new BMessage(CAYA_OPEN_CHAT_WINDOW));
	BScrollView* scrollView = new BScrollView("scrollview", fListView,
		B_WILL_DRAW, false, true);

	// Wrench menu
	BPopUpMenu* wrenchMenu = new BPopUpMenu("Wrench");
	(void)wrenchMenu->AddItem(new BMenuItem("About" B_UTF8_ELLIPSIS,
		new BMessage(B_ABOUT_REQUESTED)));
	(void)wrenchMenu->AddItem(new BSeparatorItem());
	(void)wrenchMenu->AddItem(new BMenuItem("Preferences" B_UTF8_ELLIPSIS,
		new BMessage(CAYA_SHOW_SETTINGS)));
	(void)wrenchMenu->AddItem(new BSeparatorItem());
	(void)wrenchMenu->AddItem(new BMenuItem("Quit",
		new BMessage(B_QUIT_REQUESTED)));
	wrenchMenu->SetTargetForItems(this);

	// Tool icon
	BResources* res = CayaResources();
	BBitmap* toolIcon = IconFromResources(res, kToolIcon);
	delete res;

	// Wrench tool button
	ToolButton* wrench = new ToolButton(NULL, NULL);
	wrench->SetBitmap(toolIcon);
	wrench->SetMenu(wrenchMenu);

	SetLayout(new BGridLayout(1, 2));
	AddChild(BGridLayoutBuilder(1, 2)
		.Add(searchBox, 0, 0)
		.Add(wrench, 1, 0)
		.Add(scrollView, 0, 1, 2)
		.Add(fStatusView, 0, 2, 2)
		.SetInsets(5, 5, 5, 10)
	);

	AddShortcut('a', B_COMMAND_KEY, new BMessage(B_ABOUT_REQUESTED));
	MoveTo(BAlert::AlertPosition(Bounds().Width(), Bounds().Height() / 2));

	// Filter messages using Server
	fServer = new Server();
	AddFilter(fServer);

	CenterOnScreen();

	//TODO check for errors here
	ReplicantStatusView::InstallReplicant();
}
Exemple #14
0
bool FilterWheel::LoadFromRegistry(std::string strSerialNumber, std::string strWheelName, int iNumFiltersExpected )
{
	QSI_Registry reg;

	std::string strValue;
	std::string strKeyPath = KEY_QSI + strSerialNumber;
	strKeyPath = strKeyPath + "/FilterWheels/";
	strKeyPath = strKeyPath + strWheelName;

	Name = strWheelName;
	Filters.clear();
	m_iNumFilters = 0;

	// open registry key

	m_iNumFilters = reg.GetNumber(strKeyPath, SUBKEY_NumFilters, 0);

	if (m_iNumFilters == 0)
		return false;

	for (int i = 0; i < m_iNumFilters; i++)
	{
		Filter filter;

		std::string  strFilterNum;
		//strFilterNum.Format("%d", i+1);
		strFilterNum = StringOf(i+1);

		std::string  strFilterNameValue = SUBKEY_FilterName + strFilterNum;
		std::string  strName = reg.GetString( strKeyPath, strFilterNameValue, "Unnamed" );
		if (strName == "") strName = "Position " + StringOf(i+1); //strName.Format("Position %d", i+1);
			
		filter.Name = std::string( strName );

		std::string  strFilterOffsetValue = SUBKEY_FilterFocus + strFilterNum;
		filter.Offset = reg.GetNumber( strKeyPath, strFilterOffsetValue, 0 );

		std::string  strFilterTrimValue = SUBKEY_FilterTrim + strFilterNum;
		filter.Trim = reg.GetNumber( strKeyPath, strFilterTrimValue, 0 );

		this->Filters.push_back(filter);
	}

	// Now check to see if we need to expand the wheel size to match the camera's current wheel.
	if (iNumFiltersExpected > m_iNumFilters)
	{
		Filter filter;
		for (int i = m_iNumFilters; i < iNumFiltersExpected; i++)
		{
			AddFilter( filter );
		}
	}
	
	return true;
}
Exemple #15
0
void Feeds::SaveFilter(filters_struct * filter)
{
    if (filter->id == -1)
    {
        AddFilter(filter);
    }
    else
    {
        UpdateFilter(filter);
    }
}
Exemple #16
0
void cLogger::Up(void)
{
  Lock();
  if(!up) {
    PRINTF(L_CORE_AUEXTRA,"%d: UP",cardNum);
    catVers=-1;
    catfilt=AddFilter(1,0x01,0xFF,0,0,true);
    up=true;
    }
  Unlock();
}
Exemple #17
0
//ctor
FloatGadget	::	FloatGadget(	float paramInitValue,
								const char * paramName,
								const char * paramLabel,
								float paramTextViewWidth,
								BLooper * paramMessageTarget,
								LayoutMatrix * paramLayoutMatrix,
								bool paramMakeFocus)
			: 	GadgetBase(	paramName,
							paramLabel,
							paramMessageTarget,
							paramMakeFocus)
{
	try
	{
		LayoutMatrixItem * lmi = new LayoutMatrixItem(	(void *)this,
														paramLayoutMatrix,
														KIND_FLOATGADGET);
		paramLayoutMatrix->mpLayoutMatrixItems->AddItem((void *)lmi);
		if (paramLabel)
		{
			rgb_color * rgbV = new rgb_color;
			myPrefs->GetPreferredFloatGadgetViewColor(rgbV);
			rgb_color * rgbH = new rgb_color;
			myPrefs->GetPreferredFloatGadgetHighColor(rgbH);
			rgb_color * rgbL = new rgb_color;
			myPrefs->GetPreferredFloatGadgetLowColor(rgbL);
			mpLabelView->SetViewColor(*rgbV);
			mpLabelView->SetViewColor(*rgbH);
			mpLabelView->SetViewColor(*rgbL);
		}
	}
	catch (...)
	{
		warning(myPrefs->FailMemory);
		return;
	}
	paramLayoutMatrix->AddToChildren(this);
	char buf[DIGITSnFLOAT];
	sprintf(buf, "%f", paramInitValue);
	SetText(buf);
	if (paramTextViewWidth > 0)
	{
		mfTextViewWidth = paramTextViewWidth;
	}
	else
	{
		mfTextViewWidth = WidestDigit() * (DIGITSnFLOAT - 1);
	}
	BMessageFilter * bmf = new BMessageFilter(	B_PROGRAMMED_DELIVERY, 
												B_LOCAL_SOURCE, 
												'_KYD', 
												filterFloatNumeric);
	AddFilter(bmf);
}//end
Exemple #18
0
static int ProcessMessage(char *Buffer, char *Response) {
  char *Cmd = strtok(Buffer, " ");
  if (Cmd == NULL) {
    sprintf(Response, "no command specified");
    return -1;
  }

  if (strcmp(Cmd, "add") == 0) {
    char *Token = strtok(NULL, " ");
    unsigned FilterID;
    char *FileName;
    if (Token == NULL) {
      sprintf(Response, "wrong format. expect: add <filter ID> <file name>");
      return -1;
    }
    FilterID = atoi(Token);
    FileName = strtok(NULL, " ");
    if (FileName == NULL) {
      sprintf(Response, "wrong format. expect: add <filter ID> <file name>");
      return -1;
    }
    if (AddFilter(FilterID, FileName) == -1) {
      sprintf(Response, "failed to add the filter");
      return -1;
    }
    sprintf(Response, "filter %u is successfully added", FilterID);
  } else if (strcmp(Cmd, "del") == 0) {
    char *Token = strtok(NULL, " ");
    unsigned FilterID;
    if (Token == NULL) {
      sprintf(Response, "wrong format. expect: del <filter ID>");
      return -1;
    }
    FilterID = atoi(Token);
    if (DeleteFilter(FilterID) == -1) {
      sprintf(Response, "failed to delete the filter");
      return -1;
    }
    sprintf(Response, "filter %u is successfully deleted", FilterID);
  } else if (strcmp(Cmd, "ls") == 0) {
    unsigned FilterIDs[MaxNumFilters];
    unsigned NumFilters = ListFilters(FilterIDs, MaxNumFilters);
    unsigned i;
    unsigned Printed = sprintf(Response, "filter IDs:");
    for (i = 0; i < NumFilters; ++i) {
      Printed += sprintf(Response + Printed, " %u", FilterIDs[i]);
    }
  } else {
    sprintf(Response, "unknown command");
    return -1;
  }
  return 0;
}
void SkConvolutionFilter1D::AddFilter(int filterOffset,
                                      const float* filterValues,
                                      int filterLength) {
    SkASSERT(filterLength > 0);

    SkTArray<ConvolutionFixed> fixedValues;
    fixedValues.reset(filterLength);

    for (int i = 0; i < filterLength; ++i) {
        fixedValues.push_back(FloatToFixed(filterValues[i]));
    }

    AddFilter(filterOffset, &fixedValues[0], filterLength);
}
DView::DView(BRect bounds)
	:
	BView(bounds, "graphics card view", B_FOLLOW_ALL, 0)
{
	SetViewColor(B_TRANSPARENT_COLOR);
#ifndef INPUTSERVER_TEST_MODE
	fInputPort = create_port(200, SERVER_INPUT_PORT);
#else
	fInputPort = create_port(100, "ViewInputDevice");
#endif

#ifdef ENABLE_INPUT_SERVER_EMULATION
	AddFilter(new DirectMessageFilter(this));
#endif
}
Exemple #21
0
void cHookManager::AddHook(cLogHook *hook)
{
  Lock();
  PRINTF(L_CORE_HOOK,"%d: starting hook '%s' (%04x)",cardNum,hook->name,hook->id);
  hook->delay.Set(CHAIN_HOLD);
  hook->cardNum=cardNum;
  hooks.Add(hook);
  for(cPid *pid=hook->pids.First(); pid; pid=hook->pids.Next(pid)) {
    cPidFilter *filter=AddFilter(pid->pid,pid->sct,pid->mask,pid->mode,CHAIN_HOLD/8,false);
    if(filter) {
      filter->userData=(void *)hook;
      pid->filter=filter;
      }
    }
  Unlock();
}
Exemple #22
0
void
BDragger::AttachedToWindow()
{
	if (fIsZombie) {
		SetLowColor(kZombieColor);
		SetViewColor(kZombieColor);
	} else {
		SetLowColor(B_TRANSPARENT_COLOR);
		SetViewColor(B_TRANSPARENT_COLOR);
	}

	_DetermineRelationship();
	_AddToList();

	AddFilter(new DragTrackingFilter(this, kMsgDragStarted));
}
Exemple #23
0
void cLogger::StartChain(cLogChain *chain)
{
  if(chain->delayed)
    PRINTF(L_CORE_AUEXTRA,"%d: restarting delayed chain %04x",cardNum,chain->caid);
  chain->delayed=false;
  if(!chain->active) {
    PRINTF(L_CORE_AU,"%d: starting chain %04x",cardNum,chain->caid);
    chain->active=true;
    for(cPid *pid=chain->pids.First(); pid; pid=chain->pids.Next(pid)) {
      cPidFilter *filter=AddFilter(pid->pid,pid->sct,pid->mask,pid->mode,CHAIN_HOLD/8,false);
      if(filter) {
        filter->userData=(void *)chain;
        pid->filter=filter;
        }
      }
    }
}
Exemple #24
0
void CMyFirewallDlg::OnBnClickedBRuleAdd()
{
	UpdateData();

	IPFilter pf;

	pf.id = m_idRule++;

	if(m_protocolType == 0)
  		pf.protocol = 0;
	else if(m_protocolType == 1)
  		pf.protocol = 6;
	else
		pf.protocol = 17;

	char ascii[256];
	wcstombs( ascii, m_destIP, 256 );
	pf.destinationIp = inet_addr(ascii);
	wcstombs( ascii, m_sourceIP, 256 );
	pf.sourceIp = inet_addr(ascii);
	wcstombs( ascii, m_destMask, 256 );
	pf.destinationMask = inet_addr(ascii);
	wcstombs( ascii, m_sourceMask, 256 );
	pf.sourceMask = inet_addr(ascii);
	wcstombs( ascii, m_destPort, 256 );
	pf.destinationPort = htons(atoi(ascii));
	wcstombs( ascii, m_sourcePort, 256 );
	pf.sourcePort = htons(atoi(ascii));
	if( AddFilter(pf) )	//send the rule
	{
		int index = m_listRules.GetItemCount();
		int subIndex = 1;
		if(m_protocolType == 0)
			m_listRules.InsertItem(LVIF_TEXT|LVIF_PARAM, index, _T("All"), 0, 0, 0, pf.id);
		else if(m_protocolType == 1)
			m_listRules.InsertItem(LVIF_TEXT|LVIF_PARAM, index, _T("TCP"), 0, 0, 0, pf.id);
		else
			m_listRules.InsertItem(LVIF_TEXT|LVIF_PARAM, index, _T("UDP"), 0, 0, 0, pf.id);
		m_listRules.SetItem(index, subIndex++, LVIF_TEXT, m_sourceIP, 0, 0, 0, 0, 0);
		m_listRules.SetItem(index, subIndex++, LVIF_TEXT, m_sourceMask, 0, 0, 0, 0, 0);
		m_listRules.SetItem(index, subIndex++, LVIF_TEXT, m_sourcePort, 0, 0, 0, 0, 0);
		m_listRules.SetItem(index, subIndex++, LVIF_TEXT, m_destIP, 0, 0, 0, 0, 0);
		m_listRules.SetItem(index, subIndex++, LVIF_TEXT, m_destMask, 0, 0, 0, 0, 0);
		m_listRules.SetItem(index, subIndex++, LVIF_TEXT, m_destPort, 0, 0, 0, 0, 0);
	}
}
Exemple #25
0
	BeginEnumPins(pBFParent, pEP, pPin)
	{
		CComPtr<IPin> pPinTo;
		CComPtr<IBaseFilter> pBF;
		if(S_OK != m_pGB->IsPinDirection(pPin, PINDIR_OUTPUT)
			|| FAILED(pPin->ConnectedTo(&pPinTo)) || !pPinTo
			|| !(pBF = GetFilterFromPin(pPinTo)))
			continue;

		CTreeItem* t = NULL;

		if(pBF == m_pMux)
		{
			t = DNew CTreeItemPin(pPin, m_tree, hTIParent);
		}
		else
		{
			t = DNew CTreeItemFilter(pBF, m_tree, hTIParent);
			AddFilter(*t, pBF);
		}
	}
void VirtualFS::LoadPlugin(VFSTransport::transport_t t, VFSPlugin::plugin_t p, VFSFilter::filter_t f)
{
	AddTransport(t);
	AddPlugin(p);
	AddFilter(f);
}
bool FilterList::LoadFromFile(LPCTSTR pFileName)
{
	Clear();

	Settings Setting;

	if (!Setting.Open(pFileName, TEXT("Filters"), Settings::OPEN_READ))
		return false;

	for (int i = 0;; i++) {
		TCHAR szKeyName[64];
		int KeyPrefixLength = FormatString(szKeyName, cvLengthOf(szKeyName), TEXT("Filter%d."), i);
		LPTSTR pszKeyProp = szKeyName + KeyPrefixLength;
		int MaxKeyProp = cvLengthOf(szKeyName) - KeyPrefixLength;
		FilterInfo Filter;
		int Type, Match;
		TCHAR szBuffer[64];

		CopyString(pszKeyProp, MaxKeyProp, TEXT("Type"));
		if (!Setting.Read(szKeyName, &Type))
			break;
		if (Type < 0 || Type >= FilterInfo::TYPE_TRAILER)
			continue;
		Filter.Type = (FilterInfo::FilterType)Type;

		CopyString(pszKeyProp, MaxKeyProp, TEXT("Match"));
		if (!Setting.Read(szKeyName, &Match)
				|| Match < 0 || Match >= FilterInfo::MATCH_TRAILER)
			continue;
		Filter.Match = (FilterInfo::MatchType)Match;

		if (Filter.Match == FilterInfo::MATCH_EQUAL) {
			CopyString(pszKeyProp, MaxKeyProp, TEXT("Address"));
			if (!Setting.Read(szKeyName, szBuffer, cvLengthOf(szBuffer))
					|| !Filter.Address.Parse(szBuffer))
				continue;
		} else if (Filter.Match == FilterInfo::MATCH_RANGE) {
			CopyString(pszKeyProp, MaxKeyProp, TEXT("AddressLow"));
			if (!Setting.Read(szKeyName, szBuffer, cvLengthOf(szBuffer))
					|| !Filter.AddressRange.Low.Parse(szBuffer))
				continue;
			CopyString(pszKeyProp, MaxKeyProp, TEXT("AddressHigh"));
			if (!Setting.Read(szKeyName, szBuffer, cvLengthOf(szBuffer))
					|| !Filter.AddressRange.High.Parse(szBuffer))
				continue;
		} else {
			cvDebugTrace(TEXT("Invalid filter match type %d\n"), Filter.Match);
			continue;
		}

		Filter.HostName[0] = _T('\0');
		CopyString(pszKeyProp, MaxKeyProp, TEXT("HostName"));
		Setting.Read(szKeyName, Filter.HostName, cvLengthOf(Filter.HostName));

		Filter.Enable = true;
		CopyString(pszKeyProp, MaxKeyProp, TEXT("Enable"));
		Setting.Read(szKeyName, &Filter.Enable);

		::GetSystemTimeAsFileTime(&Filter.AddedTime);
		CopyString(pszKeyProp, MaxKeyProp, TEXT("AddedTime"));
		if (Setting.Read(szKeyName, szBuffer, cvLengthOf(szBuffer))) {
			ULONGLONG Time = StrToUInt64(szBuffer);
			SYSTEMTIME st;
			FILETIME ft;

			st.wYear  = (WORD)(Time / 10000000000000);
			st.wMonth = (WORD)((Time / 100000000000) % 100);
			st.wDay   = (WORD)((Time / 1000000000) % 100);
			st.wHour  = (WORD)((Time / 10000000) % 100);
			st.wMinute = (WORD)((Time / 100000) % 100);
			st.wSecond = (WORD)((Time / 1000) % 100);
			st.wMilliseconds = (WORD)(Time % 1000);
			if (::SystemTimeToFileTime(&st, &ft))
				Filter.AddedTime = ft;
		}

		Filter.Comment[0] = _T('\0');
		CopyString(pszKeyProp, MaxKeyProp, TEXT("Comment"));
		Setting.Read(szKeyName, Filter.Comment, cvLengthOf(Filter.Comment));

		Filter.ID = ++m_IDCount;

		AddFilter(Filter);
	}

	Setting.Close();

	return true;
}
Exemple #28
0
void CPluginTestDlg::OnSearch() 
{
	// If it has already been setup, get rid of it
	if ( m_lpPluginList )
		FreeUpPluginList();

	m_listPlugins.ResetContent();

	int iListIndex = 0;
		
	// Loop through the plugin search path, and add any plugins to the list
	CString szFileSpec;
	m_editSearchPath.GetWindowText(szFileSpec);
	if (szFileSpec.GetAt(szFileSpec.GetLength()-1) != '\\')
		szFileSpec += "\\";
	szFileSpec += "*.8b?";

	CFileFind FileFind;
	int bOK = FileFind.FindFile(szFileSpec);
	if (bOK)
		bOK = FileFind.FindNextFile();

	// Walk the directory...
	BeginWaitCursor();
	while (bOK)
	{
		if (FileFind.IsDirectory())
		{ 
            // Skip over directories
			bOK = FileFind.FindNextFile();
			continue;
		}

		CString szName = FileFind.GetFileName();
		char LastChar = szName.GetAt(szName.GetLength()-1);
		if ( isupper( LastChar ))
			LastChar = tolower( LastChar );

		// Process the matching file
		CString szDLL = FileFind.GetFilePath();

		HMODULE hModule;
		if ( hModule = (HMODULE)LoadLibrary( szDLL ))
		{
			// Do module specifics here...
			STRING szResType;
			szResType[0] = '\0';
			PLUGIN_TYPE piType = PIT_FILTER;

			if ( LastChar == 'f' )
			{
				strcpy( szResType, "_8BFM" );
				piType = PIT_FILTER;

			}
            else
			if ( LastChar == 'e' )
			{
				strcpy( szResType, "_8BEM" );
				piType = PIT_EXPORT;
			}
            else
			if ( LastChar == 'a' )
			{
				strcpy( szResType, "_8BAM" );
				piType = PIT_ACQUIRE;
			}
			else
			{
			}

			HRSRC hResource = FindResource( hModule, (LPCSTR)"#1", (LPCSTR)szResType );

			// if hResource != NULL, then the plugin is the OLD style
			bool bOldStyle;
			CString szFilterName;
			if ( hResource )
			{
				bOldStyle = true;
				HGLOBAL hResData  = LoadResource( hModule, hResource );
				LPSTR lpResData = (LPSTR)LockResource( hResData );
				szFilterName = (LPSTR)&lpResData[2];
				UnlockResource( hResData );
				FreeResource( hResData );
			}
			else
			{
				if (hResource = FindResource( hModule, MAKEINTRESOURCE(16000), (LPCSTR)"PIPL" ))
				{
					bOldStyle = false;
					HGLOBAL hResData  = LoadResource( hModule, hResource );
					LPSTR lpResData = (LPSTR)LockResource( hResData );
					szFilterName = (LPSTR)&lpResData[47];
					UnlockResource( hResData );
					FreeResource( hResData );
				}
			}

			// If we found the resource we were looming for...
			if (hResource)
			{
				AddFilter( szFilterName, szDLL, bOldStyle, piType, iListIndex++ );
				m_listPlugins.AddString(szName);
			}

			FreeLibrary( hModule );
		}

		bOK = FileFind.FindNextFile();
	}

	FileFind.Close();
	EndWaitCursor();
}
Exemple #29
0
bool Terrain::GenFaultFormation(int iterations, int size, int minHeight, 
	int maxHeight, float weight, bool random)
{
	int x1, x2, z1, z2;
	float* heights = nullptr;
	int displacement;

	if(size <= 0)
		return false;
	if(random) // create true random map
		srand(time(nullptr));

	// terrain exists delete existing
	if(m_terrainData)
		delete[] m_terrainData;
	// allocate heightfield array memory
	m_size = size;
	heights = new float[m_size*m_size];
	m_terrainData = new unsigned char[m_size*m_size];
	if(heights == nullptr || m_terrainData == nullptr)
		return false;

	// initialise heightfiled array to zeros
	for(int i = 0; i < m_size*m_size; i++)
		heights[i] = 0;

	// generate heightfield
	for(int j = 0; j < iterations; j++) {
		// calculate reducing displcement value is how much to alter the hight
		displacement = maxHeight - ((maxHeight-minHeight)*j) / iterations;

		// pick the first point P1(x1, z1) at random from the entire heigh map
		x1 = (rand() % m_size);
		z1 = (rand() % m_size);

		// pickup second random point & ensure it's different from first
		do {
			x2 = (rand() % m_size);
			z2 = (rand() % m_size);
		}
		while (x2 == x1 && z2 == z1);

		// for each point P(x, z) in the filed calculate the new height values
		for(int z = 0; z < m_size; z++) {
			for(int x = 0; x < m_size; x++) {
				// determine which side of the line P1P2 point P lies on
				if((x-x1) * (z2-z1) - (x2-x1) * (z-z1) > 0) {
					heights[(z*m_size)+x] += (float)displacement;
				}
			}
		}
		AddFilter(heights, weight);

		// normalis heightfield
		NormaliseTerrain(heights);

		// copy the float heightfield to terrainData (in unsigned char)
		for(int z = 0; z < m_size; z++) {
			for(int x = 0; x < m_size; x++) {
				SetHeightAtPoint((unsigned char)heights[(z*m_size) + x], x, z);
			}
		}
	}
	delete[] heights;

	return true;
}
HRESULT MainDialog::EnumFilters(IEnumMoniker *pEnumCat)
{
    HRESULT hr=S_OK;
    int nFilters=0;

    IMoniker *pMoniker = NULL;

    // Clear the current filter list
    ClearFilterList();

    // If there are no filters of a requested type, show default string
    if (!pEnumCat)
    {
        m_FilterList.AddString(TEXT("<< No entries >>"));
        SetNumFilters(nFilters);
        return S_OK;
    }

    // Enumerate all items associated with the moniker
    while (pEnumCat->Next(1, &pMoniker, NULL) == S_OK)
    {
        IPropertyBag *pPropBag = NULL;
		CLSID clsidFilter;

		VARIANT varName;
        VARIANT varFilterClsid;

		VariantInit(&varName);
		VariantInit(&varFilterClsid);

        // Associate moniker with a file
        hr = pMoniker->BindToStorage(0, 0, IID_IPropertyBag, 
                                    (void **)&pPropBag);

		// Read filter name from property bag
		if (SUCCEEDED(hr))
		{
			hr = pPropBag->Read(L"FriendlyName", &varName, 0);
		}

        // Read filter's CLSID from property bag.  This CLSID string will be
        // converted to a binary CLSID and passed to AddFilter(), which will
        // add the filter's name to the listbox and its CLSID to the listbox
        // item's DataPtr item.  When the user clicks on a filter name in
        // the listbox, we'll read the stored CLSID, convert it to a string,
        // and use it to find the filter's filename in the registry.

		if (SUCCEEDED(hr))
		{
			// Read CLSID string from property bag
			hr = pPropBag->Read(L"CLSID", &varFilterClsid, 0);

            // Add filter name and CLSID to listbox
            if (SUCCEEDED(hr))
            {
                hr = CLSIDFromString(varFilterClsid.bstrVal, &clsidFilter);
            }
            else if (hr == E_PROP_ID_UNSUPPORTED)
            {
                clsidFilter = GUID_NULL; // No CLSID is listed. 
                hr = S_OK;
            }
        }

		// Add filter name and filename to listbox
		if(SUCCEEDED(hr))
		{
	        nFilters++;
			AddFilter(varName.bstrVal, clsidFilter);
		}

		VariantClear(&varName);
		VariantClear(&varFilterClsid);

        // Cleanup interfaces
        SAFE_RELEASE(pPropBag);
        SAFE_RELEASE(pMoniker);
    }

    // Update count of enumerated filters
    SetNumFilters(nFilters);
    return hr;
}