예제 #1
0
CString FindIncludeFile( const TCHAR *pszIncludeFilename, const TCHAR *pszIncludePath )
{
	CString strEnvInclude;
	CStringList strrgPathList;
	
	if( FileExists( pszIncludeFilename ) )
		return CString(pszIncludeFilename);
	
	// add current directory to path list;
	strrgPathList.AddTail( ".\\" );
	
	// add path specified in the command line (/I option)
	if( pszIncludePath )
		AddPath( strrgPathList, pszIncludePath );
	
	// add path specified in the INCLUDE variable
	if( strEnvInclude.GetEnvironmentVariable( _T("INCLUDE") ) )
		AddPath( strrgPathList, strEnvInclude );
	
	POSITION pos = strrgPathList.GetHeadPosition();
	for (int i=0;i < strrgPathList.GetCount();i++)
	{
		CString strPath = strrgPathList.GetNext(pos);
		CString tmp = strPath.Right(1);
		if( tmp != ":" && tmp != "\\" )
			strPath += '\\';
		
		strPath += pszIncludeFilename;
		
		if( FileExists( strPath ) )
			return CString(strPath);
	}

	return CString("");
}
예제 #2
0
BOOL CCmdColor::execute(CString &params)
{
	// Decode parameters
	CStringList paramStrList;
	CScriptParser::StringSplit(paramStrList, params, CString( ' ' ));

	// Need at least 3 params for r, g, b
	const int numParams = 3;
	if(paramStrList.GetCount() < numParams)
	{
		return FALSE;
	}

	float channels[numParams];
	POSITION pos = paramStrList.GetHeadPosition();
	for(int i = 0; i < numParams; ++i)
	{
		CString paramStr = paramStrList.GetNext(pos);
		channels[i] = (float)wcstod(paramStr, NULL);
	}

	CRasterizer::Instance()->SetColor(channels[0], channels[1], channels[2]);

	return TRUE;
}
예제 #3
0
BOOL CCmdDrawPixel::execute(CString &params)
{
	// Decode parameters
	CStringList paramStrList;
	CScriptParser::StringSplit(paramStrList, params, CString( ' ' ));

	// Need at least 2 params for x, y
	const int numParams = 2;
	if(paramStrList.GetCount() < numParams)
	{
		return FALSE;
	}

	int coords[numParams];
	POSITION pos = paramStrList.GetHeadPosition();
	for(int i = 0; i < numParams; i++)
	{
		CString paramStr = paramStrList.GetNext(pos);
		coords[i] = (int)(wcstod(paramStr, NULL) + 0.5f);
	}

	CRasterizer::Instance()->DrawPoint(coords[0], coords[1]);

	return TRUE;
}
void CLibraryFileView::OnContextMenu(CWnd* /*pWnd*/, CPoint point)
{
	GetToolTip()->Hide();

	CStringList oFiles;
	{
		CQuickLock pLock( Library.m_pSection );
		POSITION posSel = StartSelectedFileLoop();
		while ( CLibraryFile* pFile = GetNextSelectedFile( posSel ) )
		{
			oFiles.AddTail( pFile->GetPath() );
		}
	}

	if ( oFiles.GetCount() == 0 )
	{
		// No files were selected, try folder itself
		if ( CLibraryTreeItem* pRoot = GetFolderSelection() )
		{
			if ( pRoot->m_pPhysical )
				oFiles.AddTail( pRoot->m_pPhysical->m_sPath );
		}
	}

	if ( point.x == -1 && point.y == -1 )	// Keyboard fix
		ClientToScreen( &point );

	CString strName( m_pszToolBar );
//	strName += Settings.Library.ShowVirtual ? _T(".Virtual") : _T(".Physical");		// For now, CLibraryFileView.Virtual = CLibraryFileView.Physical

	Skin.TrackPopupMenu( strName, point, ID_LIBRARY_LAUNCH, oFiles );
}
예제 #5
0
// v7.2 - update 03 - added for mods to StartDropList - adjust 
//        droplist to width of text - Allen Shiels
int CUGDropListType::GetMaxStringWidth(const CStringList& list) const
{	
	int maxWidth = 0;	

	CDC* pDC = m_listBox->GetDC();	
	CFont* pFont = m_listBox->GetFont();
	CFont* pOldFont = pDC->SelectObject(pFont);	// Loop through each item in the list calculating	// the text extent for each string in the list box font	

	int	len = (int)list.GetCount();	

	POSITION position = list.GetHeadPosition();	

	int pos = 0;	

	while(pos < len) 
	{		
		CSize sz = pDC->GetTextExtent(list.GetAt(position));		
		if (sz.cx > maxWidth)			
			maxWidth = sz.cx;					
		pos++;		
		if(pos < len)			
			list.GetNext(position);	
	}	

	pDC->SelectObject(pOldFont);	
	m_listBox->ReleaseDC(pDC);	

	return maxWidth + 10; // + a bit to stop clipping
}
예제 #6
0
void __cdecl ScriptSetPopulator(TestSet *pTestSet)
{
	// TODO read from registry
	CString szTestDir(_T("Scripts"));

	CStringList cStringList;
	CFileFind cFinder;
	CString szPattern;


	szPattern.Format(_T("%s\\*.vbs"), szTestDir);
	BOOL bWorking = cFinder.FindFile(szPattern);
	while (bWorking)
	{
		bWorking = cFinder.FindNextFile();
		cStringList.AddTail(cFinder.GetFileName());
	}
	
	szPattern.Format(_T("%s\\*.js"), szTestDir);
	bWorking = cFinder.FindFile(szPattern);
	while (bWorking)
	{
		bWorking = cFinder.FindNextFile();
		cStringList.AddTail(cFinder.GetFileName());
	}

	// Create a set of tests from the scripts found
	Test *pTests = (Test *) malloc(sizeof(Test) * cStringList.GetCount());
	for (int i = 0; i < cStringList.GetCount(); i++)
	{
		CString szScript = cStringList.GetAt(cStringList.FindIndex(i));
		_tcscpy(pTests[i].szName, szScript);
		_tcscpy(pTests[i].szDesc, _T("Run the specified script"));
		pTests[i].pfn = tstScriptTest;
	}

	pTestSet->nTests = cStringList.GetCount();
	pTestSet->aTests = pTests;
}
예제 #7
0
// takes a list of strings and converts it to a string like "apples,peaches,pears" 
void ListToString (const CStringList & thelist, const char delim, CString & str)
  {
  int iCount = 0;

  str.Empty ();

  if (thelist.IsEmpty ())
    return;

  for (POSITION pos = thelist.GetHeadPosition (); pos; )
    {
    str += thelist.GetNext (pos);
    if (++iCount < thelist.GetCount ())
      str += delim;
    } // end of getting each one

  } // end of ListToString
예제 #8
0
LONG CuDlgReplicationServerPageAssignment::OnLoad (WPARAM wParam, LPARAM lParam)
{
	LPCTSTR pClass = (LPCTSTR)wParam;
	ASSERT (lstrcmp (pClass, _T("CaReplicationServerDataPageAssignment")) == 0);
	CTypedPtrList<CObList, CStringList*>* pListTuple;
	CaReplicationServerDataPageAssignment* pData = (CaReplicationServerDataPageAssignment*)lParam;
	ASSERT (pData);
	if (!pData)
		return 0L;
	pListTuple = &(pData->m_listTuple);
	CStringList* pObj = NULL;
	POSITION p, pos = pListTuple->GetHeadPosition();
	try
	{
		// For each column:
		const int LAYOUT_NUMBER = 5;
		for (int i=0; i<LAYOUT_NUMBER; i++)
			m_cListCtrl.SetColumnWidth(i, pData->m_cxHeader.GetAt(i));

		int nCount;
		while (pos != NULL)
		{
			pObj = pListTuple->GetNext (pos);
			ASSERT (pObj);
			ASSERT (pObj->GetCount() == 5);
			nCount = m_cListCtrl.GetItemCount();
			p = pObj->GetHeadPosition();
			m_cListCtrl.InsertItem  (nCount,    (LPCTSTR)pObj->GetNext(p));
			m_cListCtrl.SetItemText (nCount, 1, (LPCTSTR)pObj->GetNext(p));
			m_cListCtrl.SetItemText (nCount, 2, (LPCTSTR)pObj->GetNext(p));
			m_cListCtrl.SetItemText (nCount, 3, (LPCTSTR)pObj->GetNext(p));
			m_cListCtrl.SetItemText (nCount, 4, (LPCTSTR)pObj->GetNext(p));
		}
		m_cListCtrl.SetScrollPos (SB_HORZ, pData->m_scrollPos.cx);
		m_cListCtrl.SetScrollPos (SB_VERT, pData->m_scrollPos.cy);
	}
	catch (CMemoryException* e)
	{
		theApp.OutOfMemoryMessage();
		e->Delete();
	}
	return 0L;
}
예제 #9
0
void vmsFilesToDelete::Process()
{
	CStringList sl;
	_App.FilesToDelete (sl);

	for (int i = sl.GetCount () - 1; i >= 0; i--)
	{
		LPCTSTR psz = sl.GetAt (sl.FindIndex (i));
		BOOL bOK = TRUE;
		if (GetFileAttributes (psz) != DWORD (-1))
			bOK = DeleteFile (psz);
		if (bOK)
			sl.RemoveAt (sl.FindIndex (i));
	}

	
	
	_App.FilesToDelete_save (sl);
}
예제 #10
0
bool CRegistryKey::getValues(CStringList& values)
{
    values.RemoveAll();

    if (RegOpenKeyEx(m_base, m_path, 0, KEY_EXECUTE|m_sam, &m_hKey)==ERROR_SUCCESS)
    {
        for (int i = 0, rc = ERROR_SUCCESS; rc == ERROR_SUCCESS; ++i)
        {
            TCHAR value[255];
            DWORD size = _countof(value);
            rc = RegEnumValue(m_hKey, i, value, &size, NULL, NULL, NULL, NULL);
            if (rc == ERROR_SUCCESS)
            {
                values.AddTail(value);
            }
        }
    }

    return values.GetCount() > 0;
}
예제 #11
0
bool CRegistryKey::getSubKeys(CStringList& subkeys)
{
    subkeys.RemoveAll();

    if (RegOpenKeyEx(m_base, m_path, 0, KEY_EXECUTE|m_sam, &m_hKey)==ERROR_SUCCESS)
    {
        for (int i = 0, rc = ERROR_SUCCESS; rc == ERROR_SUCCESS; ++i)
        {
            TCHAR value[1024];
            DWORD size = _countof(value);
            FILETIME last_write_time;
            rc = RegEnumKeyEx(m_hKey, i, value, &size, NULL, NULL, NULL, &last_write_time);
            if (rc == ERROR_SUCCESS)
            {
                subkeys.AddTail(value);
            }
        }
    }

    return subkeys.GetCount() > 0;
}
예제 #12
0
//ÅÅÐò½Ó¿Úº¯Êý(bAsc=TRUEÉýÐò)
void SortList(CStringList &KeyList, CStringList &ValList, BOOL bAsc)
{
	int Count = KeyList.GetCount();

	_rec *r = new _rec[Count*sizeof(_rec)];

	POSITION posKey = KeyList.FindIndex(0);
	POSITION posVal = ValList.FindIndex(0);

	int i=0;
	while(posKey && posVal)
	{
		CString Key = KeyList.GetNext(posKey);
		CString Val = ValList.GetNext(posVal);
		r[i].key = Key;
		r[i].val = Val;		
		i++;
	}

	//ÅÅÐòº¯Êý
	_Sort(r,Count,bAsc);

	KeyList.RemoveAll();
	ValList.RemoveAll();

	for(int j=0; j<Count; j++)
	{
		CString s1 = r[j].key;
		CString s2 = r[j].val;

		KeyList.AddTail(r[j].key);
		ValList.AddTail(r[j].val);
	}

	delete[] r;
}
예제 #13
0
BOOL CVersionInfo::FromFile(const CString &strModulePath, LPCTSTR lpszResourceId, WORD wLangId)
{
	CVersionInfoBuffer viLoadBuf;

	m_wLangId = wLangId;
	m_lpszResourceId = (LPTSTR)lpszResourceId;

	//LoadVersionInfoResource will update member variables m_wLangId, m_lpszResourceId, which is awkward, need to change this flow
	if (!LoadVersionInfoResource(strModulePath, viLoadBuf, lpszResourceId, wLangId))
		return FALSE;

	m_strModulePath = strModulePath;

	DWORD dwSize = viLoadBuf.GetPosition();
	VERSION_INFO_HEADER* pVI = (VERSION_INFO_HEADER*) viLoadBuf.GetData();
	
	ASSERT(!wcscmp(pVI->szKey, L"VS_VERSION_INFO"));

	VS_FIXEDFILEINFO* pFixedInfo = (VS_FIXEDFILEINFO*)DWORDALIGN(&pVI->szKey[wcslen(pVI->szKey)+1]);
	
	memcpy(&m_vsFixedFileInfo, pFixedInfo, sizeof(VS_FIXEDFILEINFO));
	
	// Iterate children StringFileInfo or VarFileInfo
	BaseFileInfo *pChild = (BaseFileInfo*) DWORDALIGN((DWORD)pFixedInfo + pVI->wValueLength);
	
	BOOL bHasVar = FALSE;
	BOOL bHasStrings = FALSE;
	BOOL bBlockOrderKnown = FALSE;
	CStringList lstTranslations;

	while ((DWORD)pChild < ((DWORD)(pVI) + pVI->wLength))
	{
		if (!wcscmp(pChild->szKey, L"StringFileInfo"))
		{
			//It is a StringFileInfo
			//ASSERT(1 == pChild->wType);
			//如果类型是0表示二进制内容,类型为1时才包含字符串内容
			if (1 != pChild->wType)
			{
				//pChild = (BaseFileInfo*)DWORDALIGN((DWORD)pChild + pChild->wLength);
				//continue;
			}

			StringFileInfo* pStringFI = (StringFileInfo*)pChild;
			ASSERT(!pStringFI->wValueLength);
			
			//MSDN says: Specifies an array of zero or one StringFileInfo structures.  So there should be only one StringFileInfo at most
			ASSERT(m_stringFileInfo.IsEmpty());
			
			m_stringFileInfo.FromStringFileInfo(pStringFI);
			bHasStrings = TRUE;
		}
		else
		{
			VarFileInfo* pVarInfo = (VarFileInfo*)pChild;
			//ASSERT(1 == pVarInfo->wType);
			//如果类型是0表示二进制内容,类型为1时才包含字符串内容
			if (1 != pChild->wType)
			{
				//pChild = (BaseFileInfo*)DWORDALIGN((DWORD)pChild + pChild->wLength);
				//continue;
			}

			ASSERT(!wcscmp(pVarInfo->szKey, L"VarFileInfo"));
			ASSERT(!pVarInfo->wValueLength);
			//Iterate Var elements
			//There really must be only one
			Var* pVar = (Var*) DWORDALIGN(&pVarInfo->szKey[wcslen(pVarInfo->szKey)+1]);
			while ((DWORD)pVar < ((DWORD) pVarInfo + pVarInfo->wLength))
			{
				ASSERT(!bHasVar && "Multiple Vars in VarFileInfo");
				ASSERT(!wcscmp(pVar->szKey, L"Translation"));
				ASSERT(pVar->wValueLength);
				
				DWORD *pValue = (DWORD*) DWORDALIGN(&pVar->szKey[wcslen(pVar->szKey)+1]);
				DWORD *pdwTranslation = pValue;
				while ((LPBYTE)pdwTranslation < (LPBYTE)pValue + pVar->wValueLength)
				{
					CString strStringTableKey;
					strStringTableKey.Format(_T("%04x%04x"), LOWORD(*pdwTranslation), HIWORD(*pdwTranslation));
								
					lstTranslations.AddTail(strStringTableKey);
					pdwTranslation++;
				}

				bHasVar = TRUE;
				pVar = (Var*) DWORDALIGN((DWORD)pVar + pVar->wLength);
			}

			ASSERT(bHasVar && "No Var in VarFileInfo");

		}
		
		if (!bBlockOrderKnown)
		{
			bBlockOrderKnown = TRUE;
			m_bRegularInfoOrder = bHasStrings;
		}
		pChild = (BaseFileInfo*) DWORDALIGN((DWORD)pChild + pChild->wLength);
	}


#ifdef _DEBUG
	ASSERT((DWORD)lstTranslations.GetCount() == m_stringFileInfo.GetStringTableCount());

	CString strKey = m_stringFileInfo.GetFirstStringTable().GetKey();
	POSITION posTranslation = lstTranslations.GetHeadPosition();
	while (posTranslation)
	{
		CString strTranslation = lstTranslations.GetNext(posTranslation);
		CString strTranslationUpper (strTranslation);
		strTranslation.MakeUpper();

		ASSERT(m_stringFileInfo.HasStringTable(strTranslation) || m_stringFileInfo.HasStringTable(strTranslationUpper));
	}

	//Verify Write
	CVersionInfoBuffer viSaveBuf;
	Write(viSaveBuf);
	ASSERT(viSaveBuf.GetPosition() == viLoadBuf.GetPosition());
	ASSERT(!memcmp(viSaveBuf.GetData(), viLoadBuf.GetData(), viSaveBuf.GetPosition()));

	CFile fOriginal(_T("f1.res"), CFile::modeCreate | CFile::modeWrite);
	fOriginal.Write(viLoadBuf.GetData(), viLoadBuf.GetPosition());
	fOriginal.Close();

	CFile fSaved(_T("f2.res"), CFile::modeCreate | CFile::modeWrite);
	fSaved.Write(viSaveBuf.GetData(), viSaveBuf.GetPosition());
	fSaved.Close();
#endif
	return TRUE;
}
예제 #14
0
BOOL IJA_llQueryTableTransaction (
    CaQueryTransactionInfo* pQueryInfo,
    CTypedPtrList<CObList, CaColumn*>* pListColumn,
    CTypedPtrList < CObList, CaTableTransactionItemData* >& listTransaction)
{
	CString strDatabase;
	CString strDatabaseOwner;
	CString strTable;
	CString strTableOwner;
	CString strStatement;

	pQueryInfo->GetDatabase (strDatabase, strDatabaseOwner);
	pQueryInfo->GetTable (strTable, strTableOwner);

	//
	// Open the session:
	CaTemporarySession session (pQueryInfo->GetNode(), strDatabase);
	if (!session.IsConnected())
	{
		//
		// Failedto get Session.
		CString strMsg;
		strMsg.LoadString (IDS_FAIL_TO_GETSESSION);
		AfxMessageBox (strMsg);
		return FALSE;
	}

	CString strTempTable = _T("");
	CString csGranteeList = _T(""); /* no grantee list required here */
	BOOL bOK = IJA_TableAuditdbOutput (pQueryInfo, &session, strTempTable, pListColumn, csGranteeList);
	if (!bOK) {
		session.Release(SESSION_ROLLBACK);
		return FALSE;
	}
	BOOL bOnLocal = session.IsLocalNode();
	//
	// STEP 1: Select row that are INSERT, DELETE, REPOLD, REPNEW
	// Select the rows (table transactions) from the newly created Table:
	CString strSessionPrefix = _T("");
	if (bOnLocal)
		strSessionPrefix = _T("session.");

	strStatement.Format (
		_T("select * from %s%s where operation  in ('repold', 'repnew', 'append', 'insert', 'delete')"),
		(LPCTSTR)strSessionPrefix,
		(LPCTSTR)strTempTable);
	CaIjaCursor cursor(1, strStatement);
	if (cursor.Open())
	{
		int nCount = 0;
		CStringList listData;
		CString strItem1;
		CString strItem2;

		while (cursor.Fetch(listData, nCount))
		{
			CaTableTransactionItemData* pTran = new CaTableTransactionItemData();

			POSITION pos = listData.GetHeadPosition();
			ASSERT (listData.GetCount() >= 10); // At least 10 columns;
			if (listData.GetCount() < 10)
			{
				delete pTran;
				return FALSE;
			}
			pTran->SetTable (strTable);
			pTran->SetTableOwner (strTableOwner);

			if (pos != NULL)
			{
				// LSN:
				strItem1 = listData.GetNext (pos);
				strItem2 = listData.GetNext (pos);
				pTran->SetLsn (_ttoul(strItem1), _ttoul(strItem2));
				// TID:
				strItem1 = listData.GetNext (pos); 
				pTran->SetTid(_ttol(strItem1));
				// Date:
				strItem1 = listData.GetNext (pos);
				pTran->SetDate(strItem1);
				// User Name:
				strItem1 = listData.GetNext (pos);
				pTran->SetUser (strItem1);
				// Operation:
				strItem1 = listData.GetNext (pos);
				if (strItem1.CompareNoCase (_T("insert")) == 0 || strItem1.CompareNoCase (_T("append")) == 0)
					pTran->SetOperation (T_INSERT);
				else
				if (strItem1.CompareNoCase (_T("delete")) == 0)
					pTran->SetOperation (T_DELETE);
				else
				if (strItem1.CompareNoCase (_T("repold")) == 0)
					pTran->SetOperation (T_BEFOREUPDATE);
				else
				if (strItem1.CompareNoCase (_T("repnew")) == 0)
					pTran->SetOperation (T_AFTERUPDATE);
				else
				{
					ASSERT (FALSE);
					pTran->SetOperation (T_UNKNOWN);
				}
				// Transaction:
				strItem1 = listData.GetNext (pos);
				strItem2 = listData.GetNext (pos);
				pTran->SetTransactionID (_ttoul(strItem1), _ttoul(strItem2));
				// Ignore:
				strItem1 = listData.GetNext (pos);
				strItem2 = listData.GetNext (pos);
			}
			pTran->SetCommit  (TRUE);
			pTran->SetJournal (TRUE);

			CStringList& listAuditedData = pTran->GetListData();
			while (pos != NULL)
			{
				strItem1 = listData.GetNext (pos);
				listAuditedData.AddTail(strItem1);
			}

			listTransaction.AddTail (pTran);
			listData.RemoveAll();
		}

		cursor.Close();
	}

	//
	// STEP 2: Select rows that are COMMIT, ABORT, COMMITNJ, ABORTNJ
	//         to update the previous select result if the rows are commit, abort, ...
	// Select the rows (table transactions) from the newly created Table:
	strStatement.Format (
		_T("select * from %s%s where operation  in ('commit', 'abort', 'commitnj', 'abortnj')"),
		(LPCTSTR)strSessionPrefix,
		(LPCTSTR)strTempTable);

	CaIjaCursor cursor2(2, strStatement);
	if (cursor2.Open())
	{
		CaTableTransactionItemData* pFound = NULL;
		int nCount = 0;
		CStringList listData;
		CString strItem1;
		CString strItem2;
		CString strOperation;

		while (cursor2.Fetch(listData, nCount))
		{
			POSITION pos = listData.GetHeadPosition();
			ASSERT (listData.GetCount() >= 10); // At least 10 columns;
			if (listData.GetCount() < 10)
				return FALSE;

			if (pos != NULL)
			{
				// LSN:
				strItem1 = listData.GetNext (pos);
				strItem2 = listData.GetNext (pos);
				// Ignore:
				strItem1 = listData.GetNext (pos); 
				// Date:
				strItem1 = listData.GetNext (pos);
				// User Name:
				strItem1 = listData.GetNext (pos);
				// Operation:
				strOperation = listData.GetNext (pos);

				// Transaction:
				strItem1 = listData.GetNext (pos);
				strItem2 = listData.GetNext (pos);
				TRANSACTION_ChangeState (_ttoul(strItem1), _ttoul(strItem2), strOperation, listTransaction);
				// Ignore:
				strItem1 = listData.GetNext (pos);
				strItem2 = listData.GetNext (pos);
			}
			listData.RemoveAll();
		}

		cursor2.Close();
	}

	//
	// Make sure that the temporary table has been destroyed:
	if (!bOnLocal && bOK && !strTempTable.IsEmpty()) 
	{
		strStatement.Format ( _T("drop table %s"), (LPCTSTR)strTempTable);
		CaLowlevelAddAlterDrop param (pQueryInfo->GetNode(), strDatabase, strStatement);
		param.NeedSession(FALSE); // Use the current open session.
		param.SetStatement(strStatement);
		if (!param.ExecuteStatement(NULL))
		{
			CString strMsg;
			strMsg.LoadString(IDS_FAIL_DROP_TEMP_TABLE);
			AfxMessageBox(strMsg);
		}
	}

	session.Release(); // Release session and commit.
	return TRUE;
}
예제 #15
0
BOOL CWizSoundSysPage::OnInitDialog()
{
    CNGWizardPage::OnInitDialog();

    TRANSLATE(*this, IDD);

    //fill output
    switch(m_nSoundSystem)
    {
    case SOUNDSYSTEM_WINMM :
        m_WinButton.SetCheck(BST_CHECKED);
        OnBnClickedRadioWinaudio();
        break;
    case SOUNDSYSTEM_DSOUND :
    default :
        m_DxButton.SetCheck(BST_CHECKED);
        OnBnClickedRadioDirectsound();
        break;
    }

    if(m_nOutputDevice == -1)
    {
        m_OutputDriversCombo.SetCurSel(0);
        m_nOutputDevice = int(m_OutputDriversCombo.GetItemData(m_OutputDriversCombo.GetCurSel()));
    }

    if(m_nInputDevice == -1)
    {
        m_InputDriversCombo.SetCurSel(0);
        m_nInputDevice = int(m_InputDriversCombo.GetItemData(m_InputDriversCombo.GetCurSel()));
    }

    OnCbnSelchangeComboOutputdriver();
    OnCbnSelchangeComboInputdriver();

    //find select mixer device
    CStringList list;
    int count = TT_Mixer_GetWaveInControlCount(0);
    int nSelectedIndex = -1;
    for(int i=0;i<count;i++)
    {
        TCHAR buff[TT_STRLEN] = {};
        TT_Mixer_GetWaveInControlName(0, i, buff);
        list.AddTail(buff);
        if(TT_Mixer_GetWaveInControlSelected(0, i))
            nSelectedIndex = i;
    }
    if(list.GetCount())
    {
        for(POSITION pos=list.GetHeadPosition(); pos!= NULL;)
            m_wndMixerCombo.AddString(list.GetNext(pos));
        m_wndMixerCombo.SetCurSel(nSelectedIndex);
    }
    else
    {
        m_wndMixerCombo.EnableWindow(FALSE);
    }

    return TRUE;  // return TRUE unless you set the focus to a control
    // EXCEPTION: OCX Property Pages should return FALSE
}
예제 #16
0
BOOL DNS_MONITOR(char *server, int port, char *domain, CStringList &lstAddress, 
				 char *custpath, char *szReturn)
{
	u_char reply[1000];
	SOCKET udpSocket;
    struct sockaddr_in serv;
	unsigned int n;
	int dw, ret, Count = 0, iCount = 0;
	LONG	dwBeginTime, dwElapseTime;

	u_char request[1000] =
				{ 
				0x01, 0x01, 0x01, 0x00,
				0x00, 0x01, 0x00, 0x00,
				0x00, 0x00, 0x00, 0x00
				};
	Count = 12;

	for(n = 0;n < strlen(domain);n ++)
	{
		if(domain[n] != '.')
		{
			iCount ++;
			request[Count + iCount] = domain[n];
		}
		else
		{
			request[Count] = iCount;
			Count = Count + iCount + 1;
			iCount = 0;
		}
	}
	request[Count] = iCount;
	Count = Count + iCount + 1;
	request[Count] = 0x00;
	request[Count + 1] = 0x00;
	request[Count + 2] = 0x01;
	request[Count + 3] = 0x00;
	request[Count + 4] = 0x01;
	Count += 5;

	udpSocket = socket(AF_INET, SOCK_DGRAM, 0);
	if(udpSocket == INVALID_SOCKET)
	{
		sprintf(szReturn, "error=%s", FuncGetStringFromIDS("<%IDS_DNS_1%>"));//<%IDS_DNS_1%>
		return FALSE;
	}

	struct hostent *hp;
	hp = gethostbyname(server);
	if(!hp)
	{
		sprintf(szReturn, "error=%s", FuncGetStringFromIDS("<%IDS_DNS_2%>"));//<%IDS_DNS_2%>
		return FALSE;
	}

	memcpy(&serv.sin_addr,hp->h_addr_list[0],hp->h_length);
    serv.sin_family = AF_INET;
    serv.sin_port = htons(port);
	
	dwBeginTime = GetTickCount();
    n = sendto(udpSocket, (char *)request, Count, 0, (struct sockaddr *)&serv, sizeof(serv));
	if(n == SOCKET_ERROR)
	{
		sprintf(szReturn, "error=%s", FuncGetStringFromIDS("<%IDS_DNS_3%>"));//<%IDS_DNS_3%>
		return FALSE;
	}
	
	ret = RESPONSE_WAIT(udpSocket, DNS_TIMEOUT);
	if(ret > 0)
	{
		dw = sizeof(serv);
		if((n = recvfrom(udpSocket, (char *)reply, 1000, 0, (struct sockaddr *)&serv, &dw)) < 0)
		{
			sprintf(szReturn, "error=%s", FuncGetStringFromIDS("<%IDS_DNS_4%>"));//<%IDS_DNS_4%>
			return FALSE;
		}

		switch(reply[3] & 0x0F)
		{
		case 0:
			break;
		case 1:
			// Malformed DNS Request Packet
			sprintf(szReturn, "error=%s", FuncGetStringFromIDS("<%IDS_DNS_5%>"));//<%IDS_DNS_5%>
			return FALSE;
		case 2:
			sprintf(szReturn, "error=%s", FuncGetStringFromIDS("<%IDS_DNS_6%>"));//<%IDS_DNS_6%>
			return FALSE;
		case 3:
			sprintf(szReturn, "error=%s", FuncGetStringFromIDS("<%IDS_DNS_7%>"));//<%IDS_DNS_7%>
			return FALSE;
		}

		if(reply[0] == request[0] && reply[1] == request[1])
		{
			if(reply[6] * 256 + reply[7] == 0)
			{
				sprintf(szReturn, "error=%s", FuncGetStringFromIDS("<%IDS_DNS_8%>"));//<%IDS_DNS_8%>
				return FALSE;
			}

			//DNSMessageParser(reply, n);

			if(lstAddress.GetCount() != 0)
			{
				ret = VerifyDNS(reply, n, lstAddress);
				if(ret == 0)
				{
					dwElapseTime = GetTickCount() - dwBeginTime;
					sprintf(szReturn, "roundTripTime=%ld$", dwElapseTime);
					return TRUE;
				}
				else if(ret == -1)
				{
					sprintf(szReturn, "error=%s", FuncGetStringFromIDS("<%IDS_DNS_9%>"));//<%IDS_DNS_9%>
					return FALSE;
				}
				else if(ret == -2)
				{
					sprintf(szReturn, "error=%s", FuncGetStringFromIDS("<%IDS_DNS_11%>"));	//Verify Failed,<%IDS_DNS_11%> 
					return FALSE;
				}
				else
				{
					sprintf(szReturn, "error=%s", FuncGetStringFromIDS("<%IDS_DNS_12%>"));//<%IDS_DNS_12%>
					return FALSE;
				}
			}
			else
			{
				dwElapseTime = GetTickCount() - dwBeginTime;
				sprintf(szReturn, "roundTripTime=%ld$", dwElapseTime);
			}
		}
		else
		{
			sprintf(szReturn, "error=%s", FuncGetStringFromIDS("<%IDS_DNS_13%>"));//<%IDS_DNS_13%>
			return FALSE;
		}
	}
	else
	{
		if(ret == 0)
		{
			sprintf(szReturn, "error=%s", FuncGetStringFromIDS("<%IDS_DNS_14%>"));	//<%IDS_DNS_14%>
			return FALSE;
		}
		else
		{
			sprintf(szReturn, "error=%s", FuncGetStringFromIDS("<%IDS_DNS_15%>"));//<%IDS_DNS_15%>
			return FALSE;
		}
	}

	return TRUE;
}
////////////////////////////////////////////
// OnExecute
// Demonstrate:
// IDirectorySearch::ExecuteSearch
// IDirectorySearch::GetNextRow
// IDirectorySearch::GetColumn
// IDirectorySearch::SetSearchPreference
//
/////////////////////////////////////////////
void CDlgIDirectorySearch::OnExecute() 
{
	ASSERT( m_pSearch );
	CWaitCursor wait;
	
	UpdateData(TRUE); // Get data from the Dialog Box
	HRESULT hr;
	ADS_SEARCH_HANDLE hSearch;
	ADS_SEARCH_COLUMN col;
	CString s;
	int idx=0;
	int nCount;
	LPWSTR *pszAttr=NULL;
	POSITION pos;
	USES_CONVERSION;


	


	/////////////////////////////////
	// Reset the Total Number
	//////////////////////////////////
	SetDlgItemText( IDC_TOTAL, _T(""));


	/////////////////////////////////////////////
	// Get the attribute list, and preparing..
	///////////////////////////////////////////
	CStringList sAttrList;
	m_cListView.DeleteAllItems(); // Reset the UI

    while( m_cListView.DeleteColumn(0))
	{
		;
	}

	//////////////////////////////////////////////////
	// Preparing for attribute list
	// and columns to display
	CString sTemp;
	m_cAttrList.GetWindowText(s);

	// we need to add adspath, so that we can refer to this object later when user dblclk the item
	if ( !s.IsEmpty() )
	{
		sTemp = s;
		sTemp.MakeLower();
		if ( s.Find(_T("adspath"),0) == -1 )
		{
			s += _T(",ADsPath");
		}
	}

	// convert to string list for easy manipulation
	StringToStringList( s, sAttrList );



	nCount = sAttrList.GetCount();
	idx=0;
	if ( nCount )
	{
		
		pszAttr = (LPWSTR*) AllocADsMem( nCount * sizeof(LPWSTR));
	
		pos = sAttrList.GetHeadPosition();
		while ( pos != NULL )
		{
			s = sAttrList.GetAt(pos);
			pszAttr[idx] = T2OLE(s);
			sAttrList.GetNext(pos );
			idx++;
		}
	}
	else
	{
		nCount = -1;
	}






	/////////////////////////////////////////
	// BEGIN  Set the preferences
	///////////////////////////////////////
	DWORD dwCountPref = 0;
	ADS_SEARCHPREF_INFO prefInfo[ MAX_SEARCH_PREF ];
	ADS_SORTKEY *pSortKey = NULL;

	if ( m_bEnableFilter == FALSE )
	{
		// Reset the preference
		m_pSearch->SetSearchPreference( prefInfo, dwCountPref );
	}
	else // Preferences are specified
	{
		////////////////////////
		// Timeout Pref
		////////////////////////////
		if ( m_nTimeOut != 0 )
		{
			prefInfo[dwCountPref].dwSearchPref = ADS_SEARCHPREF_TIMEOUT;
			prefInfo[dwCountPref].vValue.dwType = ADSTYPE_INTEGER;
			prefInfo[dwCountPref].vValue.Integer = m_nTimeOut;
			dwCountPref++;
		}

		//////////////////////////////
		// Search Scope
		/////////////////////////////
		idx = m_CADsSearchScope.GetCurSel();
		if ( idx != CB_ERR )
		{
			prefInfo[dwCountPref].dwSearchPref = ADS_SEARCHPREF_SEARCH_SCOPE;
			prefInfo[dwCountPref].vValue.dwType = ADSTYPE_INTEGER;
			prefInfo[dwCountPref].vValue.Integer = idx;
			dwCountPref++;
		}



		///////////////////////////////////////////////////
		// Cache Result. The default is to cache the result
		/////////////////////////////////////////////////
		if ( !m_bCacheResult )
		{
			prefInfo[dwCountPref].dwSearchPref = ADS_SEARCHPREF_SEARCH_SCOPE;
			prefInfo[dwCountPref].vValue.dwType = ADSTYPE_BOOLEAN;
			prefInfo[dwCountPref].vValue.Boolean = FALSE;
			dwCountPref++;
		}

		//////////////////////////////////////////////////
		// Page Size
		///////////////////////////////////////////////////
		if ( m_nPageSize > 0 )
		{
			prefInfo[dwCountPref].dwSearchPref = ADS_SEARCHPREF_PAGESIZE;
			prefInfo[dwCountPref].vValue.dwType = ADSTYPE_INTEGER;;
			prefInfo[dwCountPref].vValue.Integer = m_nPageSize;
			dwCountPref++;
		}


		////////////////////////////////////////////////
		// Chase Referrals
		///////////////////////////////////////////////
		idx = m_cChaseReferrals.GetCurSel();
		if ( idx != CB_ERR )
		{
			prefInfo[dwCountPref].dwSearchPref = ADS_SEARCHPREF_CHASE_REFERRALS;
			prefInfo[dwCountPref].vValue.dwType = ADSTYPE_INTEGER;
			switch( idx )
			{
			case 0:
				 prefInfo[dwCountPref].vValue.Integer = ADS_CHASE_REFERRALS_NEVER; 
				 break;
			case 1:
				 prefInfo[dwCountPref].vValue.Integer = ADS_CHASE_REFERRALS_SUBORDINATE;
				 break;
			case 2:
				 prefInfo[dwCountPref].vValue.Integer = ADS_CHASE_REFERRALS_EXTERNAL;
				 break;
			default:
				 prefInfo[dwCountPref].vValue.Integer = ADS_CHASE_REFERRALS_EXTERNAL;
				 
			}
			
			dwCountPref++;
		}


		///////////////////////////////////////////////
		// Sort On
		////////////////////////////////////////////////
		if ( !m_sSortOn.IsEmpty() )
		{
			CStringList sList;
			UINT nCount;
			prefInfo[dwCountPref].dwSearchPref = ADS_SEARCHPREF_SORT_ON;
			prefInfo[dwCountPref].vValue.dwType = ADSTYPE_PROV_SPECIFIC;
  			StringToStringList( m_sSortOn, sList );

			nCount = sList.GetCount();
			if ( nCount >  0 )
			{
				POSITION pos;
				pos= sList.GetHeadPosition();
				pSortKey = (ADS_SORTKEY *) LocalAlloc( LMEM_FIXED | LMEM_ZEROINIT, sizeof(ADS_SORTKEY) * nCount );
				idx = 0;
				while( pos != NULL )
				{
					pSortKey[idx].pszAttrType = T2OLE(sList.GetAt(pos));
					pSortKey[idx].pszReserved = NULL;
					pSortKey[idx].fReverseorder =0;

					// Next
					idx++;
					sList.GetNext( pos );
				}
				
				prefInfo[dwCountPref].vValue.ProviderSpecific.dwLength = sizeof(ADS_SORTKEY) * nCount;
				prefInfo[dwCountPref].vValue.ProviderSpecific.lpValue = (LPBYTE) pSortKey;
				dwCountPref++;
			}

		}

		//////////////////////////////////////////////
		// Size Limit
		//////////////////////////////////////////////
		if ( m_nSizeLimit > 0 )
		{
            prefInfo[dwCountPref].dwSearchPref = ADS_SEARCHPREF_SIZE_LIMIT;
            prefInfo[dwCountPref].vValue.dwType = ADSTYPE_INTEGER;
            prefInfo[dwCountPref].vValue.Integer = m_nSizeLimit;
			dwCountPref++;
		}


		//////////////////////////////////////////////////
		// A Synchronous
		///////////////////////////////////////////////////
		if ( m_bAsynch )
		{
			prefInfo[dwCountPref].dwSearchPref = ADS_SEARCHPREF_ASYNCHRONOUS;
            prefInfo[dwCountPref].vValue.dwType = ADSTYPE_BOOLEAN;
            prefInfo[dwCountPref].vValue.Integer = TRUE;
			dwCountPref++;

		}

		/////////////////////////////////////////////////////
		//  Attribute Type Only
		//////////////////////////////////////////////////////
		if ( m_bAttrib )
		{
			prefInfo[dwCountPref].dwSearchPref = ADS_SEARCHPREF_ATTRIBTYPES_ONLY;
            prefInfo[dwCountPref].vValue.dwType = ADSTYPE_BOOLEAN;
            prefInfo[dwCountPref].vValue.Integer = TRUE;
			dwCountPref++;

		}


		/////////////////////////////////////////////////////
		//  Derefence Alias
		//////////////////////////////////////////////////////
		if ( m_nDeref != CB_ERR )
		{
			prefInfo[dwCountPref].dwSearchPref = ADS_SEARCHPREF_DEREF_ALIASES;
            prefInfo[dwCountPref].vValue.dwType = ADSTYPE_INTEGER;
            prefInfo[dwCountPref].vValue.Integer = m_nDeref;
			dwCountPref++;


		}



		///////////////////////////////////////////////
		// Now Set the selected preferences
		//////////////////////////////////////////////
		hr = m_pSearch->SetSearchPreference( prefInfo, dwCountPref );


		
	}

	/////////////////////////////////////////
	// END  Set the preferences
	///////////////////////////////////////





	////////////////////////////////////////
	// Execute the Search
	//////////////////////////////////////
	DWORD dwCount=0;

	hr = m_pSearch->ExecuteSearch(T2OLE(m_sFilter), pszAttr, nCount, &hSearch );


	////////////////////////////////
	//// cleanup
	////////////////////////////////
	if ( pszAttr ) 
	{
  		FreeADsMem( pszAttr );
	}
	
	if ( pSortKey )
	{
		LocalFree( pSortKey );
	}




	if ( !SUCCEEDED(hr) )
	{
		AfxMessageBox(GetErrorMessage(hr));
		return;
	}

	////////////////////////////////////////////////////////
	// Enumerate the rows
	////////////////////////////////////////////////////////

	sAttrList.RemoveAll();

	

	
	/////////////////////////////////////////////////////////
	// Retrieve the column names returned from the server
	///////////////////////////////////////////////////////////
	LPWSTR pszColumn;
	hr = m_pSearch->GetFirstRow( hSearch );

	if ( !SUCCEEDED(hr) )
	{
		return;
	}
	
	

	idx=0;
	while( (hr=m_pSearch->GetNextColumnName( hSearch, &pszColumn )) != S_ADS_NOMORE_COLUMNS )
	{
		s = OLE2T( pszColumn );
		m_cListView.InsertColumn(idx, s, LVCFMT_LEFT, 150 ); // adding columns to the UI	
		sAttrList.AddTail(s);
		FreeADsMem( pszColumn );
		idx++;
	}



	/////////////////////////////////////////////
	// Start iterating the result set
	////////////////////////////////////////////
	int nCol;
	CStringList sValueList;

    do 
	{
		nCol=0;
		pos = sAttrList.GetHeadPosition();

		while( pos != NULL )
		{
		
		    s = sAttrList.GetAt(pos); //column name

			// Get the Name and display it in the list 
			hr = m_pSearch->GetColumn( hSearch, T2OLE(s), &col );
			if ( SUCCEEDED(hr) )
			{
				s =_T("");
				
				if ( col.dwADsType != ADSTYPE_INVALID ) // if we request for attrib only, no value will be returned
				{
					ADsToStringList(col.pADsValues, col.dwNumValues, sValueList );
					StringListToString( sValueList, s );
				}
	
				if ( nCol )
				{
					m_cListView.SetItemText(0,nCol, s);
				}
				else
				{
				   m_cListView.InsertItem(0, s);
				}
				
				m_pSearch->FreeColumn( &col );
			}


			

			nCol++;
			sAttrList.GetNext(pos);

		}
		dwCount++;
		/////////////////////////////
		//Display the total so far
		////////////////////////////////
		s.Format("%ld object(s)", dwCount );
		SetDlgItemText( IDC_TOTAL, s );
	
	} 
	while( (hr=m_pSearch->GetNextRow( hSearch)) != S_ADS_NOMORE_ROWS );	 

	

	m_pSearch->CloseSearchHandle( hSearch ); 



	


}
예제 #18
0
// do the action required to open a single atomic tag (iAction)
void CMUSHclientDoc::MXP_OpenAtomicTag (const CString strTag,
                                        int iAction, 
                                        CStyle * pStyle,
                                        CString & strAction,    // new action
                                        CString & strHint,      // new hint
                                        CString & strVariable,   // new variable
                                        CArgumentList & ArgumentList)
  {
CString strArgument;
CString strArgumentName;
bool bIgnoreUnusedArgs = false; // cut down on some spam by setting this
COLORREF colour1,
         colour2;

unsigned short iFlags      = pStyle->iFlags;      
COLORREF       iForeColour = pStyle->iForeColour; 
COLORREF       iBackColour = pStyle->iBackColour; 

  // call script if required
  if (m_dispidOnMXP_OpenTag != DISPID_UNKNOWN || m_bPluginProcessesOpenTag)
    {
    // dummy-up an argument list
    CString strArgument;
    CArgument * pArgument;
    POSITION pos;

    // put the arguments into the array

    for (pos = ArgumentList.GetHeadPosition (); pos; )
      {
      pArgument = ArgumentList.GetNext (pos);
      
      // empty ones we will put there by position
      if (pArgument->strName.IsEmpty ())
        strArgument += CFormat ("'%s'",
                      (LPCTSTR) pArgument->strValue);
      else
        strArgument += CFormat ("%s='%s'",
                      (LPCTSTR) pArgument->strName,
                      (LPCTSTR) pArgument->strValue);

      if (pos)
        strArgument += " ";

      }      // end of looping through each argument

    bool bNotWanted = MXP_StartTagScript (strTag, strArgument, ArgumentList);

    // re-get current style in case the script did a world.note
    pStyle = m_pCurrentLine->styleList.GetTail ();

    // put things backt to how they were
    pStyle->iFlags      = iFlags;      
    pStyle->iForeColour = iForeColour; 
    pStyle->iBackColour = iBackColour; 

    if (bNotWanted)
      return;   // they didn't want to go ahead with this tag

    }


// find current foreground and background RGB values
  GetStyleRGB (pStyle, colour1, colour2);

// special processing for Pueblo
// a tag like this: <A XCH_CMD="examine #1"> 
// will convert to a SEND tag

  if (iAction == MXP_ACTION_HYPERLINK &&
      PUEBLO_ACTIVE)
    {
    strArgument = GetArgument (ArgumentList, "xch_cmd", 0, true);
    if (!strArgument.IsEmpty ())
      {
      m_bPuebloActive = true;  // for correct newline processing
      iAction = MXP_ACTION_SEND;
      }
    }    

  // now take the action 
  switch (iAction)
    {

    // temporarily make headlines the same as bold
    case MXP_ACTION_H1: 
    case MXP_ACTION_H2: 
    case MXP_ACTION_H3: 
    case MXP_ACTION_H4: 
    case MXP_ACTION_H5: 
    case MXP_ACTION_H6: 

    case MXP_ACTION_BOLD: pStyle->iFlags |= HILITE; break;
    case MXP_ACTION_UNDERLINE: pStyle->iFlags |= UNDERLINE; break;
    case MXP_ACTION_ITALIC: pStyle->iFlags |= BLINK; break;

    case MXP_ACTION_COLOR:
         {

         pStyle->iForeColour = colour1;
         pStyle->iBackColour = colour2;
         // convert to RGB colour to start with in case only FORE or BACK supplied
         pStyle->iFlags &= ~COLOURTYPE;  // clear bits, eg. custom
         pStyle->iFlags |= COLOUR_RGB;

         // foreground colour
         strArgument = GetArgument (ArgumentList, "fore", 1, true);  // get foreground colour
         if (!m_bIgnoreMXPcolourChanges)
           if (SetColour (strArgument, pStyle->iForeColour)) 
             MXP_error (DBG_ERROR, errMXP_UnknownColour,
                        TFormat ("Unknown colour: \"%s\"" ,
                                 (LPCTSTR) strArgument));

         // background colour
         strArgument = GetArgument (ArgumentList, "back", 2, true);  // get background colour
         if (!m_bIgnoreMXPcolourChanges)
           if (SetColour (strArgument, pStyle->iBackColour)) 
             MXP_error (DBG_ERROR, errMXP_UnknownColour,
                        TFormat ("Unknown colour: \"%s\"" ,
                                 (LPCTSTR) strArgument));
         }
         break;   // end of COLOR

    case MXP_ACTION_HIGH:
         {
         CColor clr;

         pStyle->iForeColour = colour1;
         pStyle->iBackColour = colour2;
         // convert to RGB colour to start with 
         pStyle->iFlags &= ~COLOURTYPE;  // clear bits, eg. custom
         pStyle->iFlags |= COLOUR_RGB;

         clr.SetColor (colour1);
         float lum = clr.GetLuminance ();
         lum += 0.15f;
         if (lum > 1.0f)
           lum = 1.0f;
         clr.SetLuminance (lum);
         pStyle->iForeColour = clr; 
         
         }
         break;   // end of COLOR

    case MXP_ACTION_SEND: 
          // send to mud hyperlink

          pStyle->iFlags &= ~ACTIONTYPE;   // cancel old actions
          if (GetKeyword (ArgumentList, "prompt"))
            pStyle->iFlags |= ACTION_PROMPT;   // prompt action
          else
            pStyle->iFlags |= ACTION_SEND;   // send-to action

          if (m_bUnderlineHyperlinks)
            pStyle->iFlags |= UNDERLINE;   // underline it

          if (m_bUseCustomLinkColour)
            {
            // find current background RGB value
            pStyle->iForeColour = m_iHyperlinkColour;    // use hyperlink colour
            pStyle->iBackColour = colour2;
            pStyle->iFlags &= ~COLOURTYPE;  // clear bits, eg. custom
            pStyle->iFlags |= COLOUR_RGB;
            }

          strArgument = GetArgument (ArgumentList,"href", 1, false);  // get link
          if (strArgument.IsEmpty ())
            strArgument = GetArgument (ArgumentList,"xch_cmd", 1, false);  // get link
            
          strAction = strArgument;   // hyperlink
         
          strArgument = GetArgument (ArgumentList, "hint", 2, false);  // get hints
          if (strArgument.IsEmpty ())
            strArgument = GetArgument (ArgumentList,"xch_hint", 2, false);  // get hint
          
          strHint = strArgument;     // hints

          break;  // end of MXP_ACTION_SEND

    case MXP_ACTION_HYPERLINK: 
          // hyperlink

          strArgument = GetArgument (ArgumentList,"href", 1, false);  // get link
          strAction = strArgument;   // hyperlink

          pStyle->iFlags &= ~ACTIONTYPE;   // cancel old actions
          pStyle->iFlags |= ACTION_HYPERLINK | UNDERLINE;   // send-to action

          if (m_bUseCustomLinkColour)
            {
            pStyle->iForeColour = m_iHyperlinkColour;    // use hyperlink colour
            pStyle->iBackColour = colour2;
            pStyle->iFlags &= ~COLOURTYPE;  // clear bits, eg. custom
            pStyle->iFlags |= COLOUR_RGB;
            }

          break;  // end of MXP_ACTION_HYPERLINK

    case MXP_ACTION_FONT:
          {
          pStyle->iForeColour = colour1;
          pStyle->iBackColour = colour2;
          // convert to RGB colour to start with in case only FORE or BACK supplied
          pStyle->iFlags &= ~COLOURTYPE;  // clear bits, eg. custom
          pStyle->iFlags |= COLOUR_RGB;

          // eg. <FONT COLOR=Red,Blink>
          CStringList list;

          strArgument = GetArgument (ArgumentList,"color", 1, true);  // get color etc.
          if (strArgument.IsEmpty () && PUEBLO_ACTIVE)
            strArgument = GetArgument (ArgumentList,"fgcolor", 1, true);  // get color
          StringToList (strArgument, ",", list);   // break into components

          for (POSITION pos = list.GetHeadPosition (); pos; )
            {
            CString strItem = list.GetNext (pos); // get action item

            if (strItem == "blink")
               pStyle->iFlags |= BLINK;
            else
            if (strItem == "italic")
               pStyle->iFlags |= BLINK;
            else
            if (strItem == "underline")
               pStyle->iFlags |= UNDERLINE;
            else
            if (strItem == "bold")
               pStyle->iFlags |= HILITE;
            else
            if (strItem == "inverse")
               pStyle->iFlags |= INVERSE;
            else
              {  // must be colour name, yes?

              // foreground colour
              if (!m_bIgnoreMXPcolourChanges)
                if (SetColour (strItem, pStyle->iForeColour)) 
                  MXP_error (DBG_ERROR, errMXP_UnknownColour,
                              TFormat ("Unknown colour: \"%s\"" ,
                                      (LPCTSTR) strItem));
              } // end of colour

            } // end of handling each item in the list
          strArgument = GetArgument (ArgumentList,"back", 2, true);  // get back color
          if (strArgument.IsEmpty () && PUEBLO_ACTIVE)
            strArgument = GetArgument (ArgumentList,"bgcolor", 2, true);  // get back color
          // background colour

          if (!m_bIgnoreMXPcolourChanges)
            if (SetColour (strArgument, pStyle->iBackColour)) 
              MXP_error (DBG_ERROR, errMXP_UnknownColour,
                        TFormat ("Unknown colour: \"%s\"" ,
                                  (LPCTSTR) strArgument));

          // get font size argument to avoid warnings about unused arguments
          strArgument = GetArgument (ArgumentList,"size", 0, true);  // get font size
          }
          break; // end of FONT

    case MXP_ACTION_VERSION:
            {

            CString strVersion = CFormat ("\x1B[1z<VERSION MXP=\"%s\" CLIENT=MUSHclient "
                      "VERSION=\"%s\" REGISTERED=YES>%s",
                     MXP_VERSION,
                     MUSHCLIENT_VERSION,
                     ENDLINE
                     );

            SendPacket (strVersion, strVersion.GetLength ());  // send version info back
            MXP_error (DBG_INFO, infoMXP_VersionSent,
                      TFormat ("Sent version response: %s" ,
                                (LPCTSTR) strVersion.Mid (4)));

            }
          break;  // end of VERSION

    case MXP_ACTION_AFK:
          if (m_bSendMXP_AFK_Response)    // if player wants us to
            {
            strArgument = GetArgument (ArgumentList,"challenge", 1, false);  // get challenge

            // find time since last player input
            CTimeSpan ts = CTime::GetCurrentTime() - m_tLastPlayerInput;
            CString strAFK = CFormat ("\x1B[1z<AFK %ld %s>%s",
                      ts.GetTotalSeconds  (),
                      (LPCTSTR) strArgument,
                      ENDLINE
                     );

            SendPacket (strAFK, strAFK.GetLength ());  // send AFK info back
            MXP_error (DBG_INFO, infoMXP_AFKSent,
                      TFormat ("Sent AFK response: %s" ,
                                (LPCTSTR) strAFK.Mid (4)));
            } // end of AFK
          break;

    case MXP_ACTION_SUPPORT:
            {
            CString strSupports;
            CAtomicElement * pElement;
            CStringList list;
            CString strName;       

            if (ArgumentList.IsEmpty ())
              {
              for (POSITION pos = App.m_ElementMap.GetStartPosition(); pos; ) 
                {                                                
                App.m_ElementMap.GetNextAssoc (pos, strName, pElement);

                if ((pElement->iFlags & TAG_NOT_IMP) == 0)
                  {
                  strSupports += "+";
                  strSupports += pElement->strName;
                  strSupports += " ";

                  // now list the sub-items it supports
                  StringToList (pElement->strArgs, ",", list);   // break into components
                  for (POSITION argpos = list.GetHeadPosition (); argpos; )
                    {
                    CString strItem = list.GetNext (argpos); // get argument item
                    strSupports += "+";
                    strSupports += pElement->strName;
                    strSupports += ".";
                    strSupports += strItem;
                    strSupports += " ";
                    } // end of doing each sub-item
                  } // end of being implemented
                }  // end of looping through all atomic elements
              } // end of wanting complete list
            else
              {
              for (POSITION pos = ArgumentList.GetHeadPosition (); pos; )
                {
                CArgument * pArgument = ArgumentList.GetNext (pos); 
                CStringList questionlist;
                StringToList (pArgument->strValue, ".", questionlist);   // break into components

                // should be one or two words, eg. send.prompt or color
                if (questionlist.GetCount () > 2)
                  {
                  MXP_error (DBG_ERROR, errMXP_InvalidSupportArgument,
                            TFormat ("Invalid <support> argument: %s" ,
                                      (LPCTSTR) pArgument->strValue));
                  return;
                  }
                
                CString strTag =  questionlist.RemoveHead ();
                strTag.MakeLower ();

                // check valid name requested
                if (!IsValidName (strTag))
                  {
                  MXP_error (DBG_ERROR, errMXP_InvalidSupportArgument,
                            TFormat ("Invalid <support> argument: %s" ,
                                      (LPCTSTR) strTag));
                  return;
                  }

                // look up main element name

                if (!App.m_ElementMap.Lookup (strTag, pElement) ||
                   (pElement->iFlags & TAG_NOT_IMP) != 0)
                  {     // not supported
                  strSupports += "-";
                  strSupports += strTag;
                  strSupports += " ";
                  continue;   // all done for this argument
                  }

                // only one word - they aren't looking for a suboption
                if (questionlist.IsEmpty ())
                  {     // supported
                  strSupports += "+";
                  strSupports += strTag;
                  strSupports += " ";
                  continue;   // all done for this argument
                  }
                  
                CString strSubtag =  questionlist.RemoveHead ();
                strSubtag.MakeLower ();

                if (strSubtag == "*")
                  {   // they want list of options for this tag
                  // now list the sub-items it supports
                  StringToList (pElement->strArgs, ",", list);   // break into components
                  for (POSITION argpos = list.GetHeadPosition (); argpos; )
                    {
                    CString strItem = list.GetNext (argpos); // get argument item
                    strSupports += "+";
                    strSupports += pElement->strName;
                    strSupports += ".";
                    strSupports += strItem;
                    strSupports += " ";
                    } // end of doing each sub-item
                  } // end of wildcard
                else
                  {  // not wildcard - must be name
                  // check valid name requested
                  if (!IsValidName (strSubtag))
                    {
                    MXP_error (DBG_ERROR, errMXP_InvalidSupportArgument,
                              TFormat ("Invalid <support> argument: %s" ,
                                        (LPCTSTR) strSubtag));
                    return;
                    }

                  // so, see if that word is in our arguments list
                  StringToList (pElement->strArgs, ",", list);   // break into components
                  if (list.Find (strSubtag))
                    {
                    strSupports += "+";
                    strSupports += pArgument->strValue;
                    strSupports += " ";
                    }
                  else
                    {
                    strSupports += "-";
                    strSupports += pArgument->strValue;
                    strSupports += " ";
                    }
                  }    // end of not looking for wildcard
                } // end of doing each argument

              } // find individual items

            CString strMessage = CFormat ("\x1B[1z<SUPPORTS %s>%s",
                                          (LPCTSTR) strSupports,
                                          ENDLINE);

            SendPacket (strMessage, strMessage.GetLength ());  // send version info back
            MXP_error (DBG_INFO, infoMXP_SupportsSent,
                      TFormat ("Sent supports response: %s" ,
                                (LPCTSTR) strMessage.Mid (4)));

            }
          bIgnoreUnusedArgs = true;

          break;  // end of MXP_ACTION_SUPPORT

    case MXP_ACTION_OPTION:
            {
            CString strOptions;
            CStringList list;
            CString strName;       

            if (ArgumentList.IsEmpty ())
              {

              for (long i = 0; OptionsTable [i].pName; i++)
                {
                char * pName = OptionsTable [i].pName;
                strOptions += CFormat ("%s=%ld ",
                               pName, 
                               (LPCTSTR) GetOptionItem (i));
                }

              } // end of wanting complete list
            else
              {
              for (POSITION pos = ArgumentList.GetHeadPosition (); pos; )
                {
                CArgument * pArgument = ArgumentList.GetNext (pos); 

                strOptions += CFormat ("%s=%ld",
                               (LPCTSTR) pArgument->strValue, 
                               (LPCTSTR) GetOption (pArgument->strValue));

                } // end of doing each argument

              } // find individual items

            CString strMessage = CFormat ("\x1B[1z<OPTIONS %s>%s",
                                          (LPCTSTR) strOptions,
                                          ENDLINE);

            SendPacket (strMessage, strMessage.GetLength ());  // send version info back
            MXP_error (DBG_INFO, infoMXP_OptionsSent,
                      TFormat ("Sent options response: %s" ,
                                (LPCTSTR) strMessage.Mid (4)));

            }
          bIgnoreUnusedArgs = true;

          break;  // end of MXP_ACTION_OPTION

    case MXP_ACTION_RECOMMEND_OPTION:
          if (m_bMudCanChangeOptions)
            {
            CString strOptions;
            CStringList list;
            CString strName;       

            for (POSITION pos = ArgumentList.GetHeadPosition (); pos; )
              {
              CArgument * pArgument = ArgumentList.GetNext (pos); 

              int iItem;
              int iResult = FindBaseOption (pArgument->strName, OptionsTable, iItem);

              if (iResult != eOK)
                MXP_error (DBG_ERROR, errMXP_InvalidOptionArgument,
                          TFormat ("Option named '%s' not known.",
                          (LPCTSTR) pArgument->strName));      
              else if (!(OptionsTable [iItem].iFlags & OPT_SERVER_CAN_WRITE))
                MXP_error (DBG_ERROR, errMXP_CannotChangeOption,
                          TFormat ("Option named '%s' cannot be changed.",
                          (LPCTSTR) pArgument->strName));      
              else
                {
                iResult = SetOptionItem (iItem, atol (pArgument->strValue), true, false);
                if (iResult == eOK)
                  MXP_error (DBG_INFO, infoMXP_OptionChanged,
                            TFormat ("Option named '%s' changed to '%s'.",
                            (LPCTSTR) pArgument->strName,
                            (LPCTSTR) pArgument->strValue)); 
                else
                  MXP_error (DBG_ERROR, errMXP_OptionOutOfRange,
                            TFormat ("Option named '%s' could not be changed to '%s' (out of range).",
                            (LPCTSTR) pArgument->strName,
                            (LPCTSTR) pArgument->strValue));      
                }

              } // end of doing each argument

            }
          bIgnoreUnusedArgs = true;

          break;  // end of MXP_ACTION_RECOMMEND_OPTION


    case MXP_ACTION_USER:
            if (!m_name.IsEmpty () && 
                m_connect_now == eConnectMXP)
              {
              CString strPacket = m_name + ENDLINE;
              SendPacket (strPacket, strPacket.GetLength ());  // send name to MUD
              MXP_error (DBG_INFO, infoMXP_CharacterNameSent,
                          TFormat ("Sent character name: %s" ,
                                  (LPCTSTR) m_name));      
              }
            else if (m_connect_now != eConnectMXP)
              MXP_error (DBG_WARNING, wrnMXP_CharacterNameRequestedButNotDefined,
                        Translate ("Character name requested but auto-connect not set to MXP."));      
            else
              MXP_error (DBG_WARNING, wrnMXP_CharacterNameRequestedButNotDefined,
                        Translate ("Character name requested but none defined."));      
            break;  // end of USER

    case MXP_ACTION_PASSWORD:
            if (m_nTotalLinesSent > 10)     // security check
              MXP_error (DBG_WARNING, wrnMXP_PasswordNotSent,
                        "Too many lines sent to MUD - password not sent.");      
            else
            if (!m_password.IsEmpty () && 
                m_connect_now == eConnectMXP)
              {
              CString strPacket = m_password + ENDLINE;
              SendPacket (strPacket, strPacket.GetLength ());  // send password to MUD
              MXP_error (DBG_INFO, infoMXP_PasswordSent,
                        "Sent password to world.");      
              }
            else if (m_connect_now != eConnectMXP)
              MXP_error (DBG_WARNING, wrnMXP_PasswordRequestedButNotDefined,
                        "Password requested but auto-connect not set to MXP.");      
            else
              MXP_error (DBG_WARNING, wrnMXP_PasswordRequestedButNotDefined,
                        "Password requested but none defined.");      
            break;  // end of PASSWORD

         // new para
    case MXP_ACTION_P:
          // experimental
          m_cLastChar = 0;
          m_bInParagraph = true;      
          break;  // end of MXP_ACTION_P
    
          // new line
    case MXP_ACTION_BR:
          bIgnoreUnusedArgs = true; // don't worry about args for now :)

          StartNewLine (true, 0);
          SetNewLineColour (0);
          break;  // end of MXP_ACTION_BR

          // reset
    case MXP_ACTION_RESET:
          MXP_Off ();
          break;  // end of MXP_ACTION_RESET

          // MXP options  (MXP OFF, MXP DEFAULT_OPEN, MXP DEFAULT_SECURE etc.
    case MXP_ACTION_MXP:
          
          if (GetKeyword (ArgumentList, "off"))
            MXP_Off (true);

          /*
          if (GetKeyword (ArgumentList, "default_open"))
            {
            MXP_error (DBG_INFO, "MXP default mode now OPEN.");
            m_iMXP_defaultMode = eMXP_open;
            }  // end of DEFAULT_OPEN

          if (GetKeyword (ArgumentList, "default_secure"))
            {
            MXP_error (DBG_INFO, "MXP default mode now SECURE.");
            m_iMXP_defaultMode = eMXP_secure;
            }  // end of DEFAULT_SECURE

          if (GetKeyword (ArgumentList, "default_locked"))
            {
            MXP_error (DBG_INFO, "MXP default mode now LOCKED.");
            m_iMXP_defaultMode = eMXP_locked;
            }  // end of DEFAULT_LOCKED


          if (GetKeyword (ArgumentList, "use_newlines"))
            {
            MXP_error (DBG_INFO, "Now interpreting newlines as normal.");
            m_bInParagraph = false;      
            }   // end of USE_NEWLINES

          if (GetKeyword (ArgumentList, "ignore_newlines"))
            {
            MXP_error (DBG_INFO, "Now ignoring newlines.");
            m_bInParagraph = true;      
            }   // end of IGNORE_NEWLINES

          */

          break;  // end of MXP_ACTION_MXP

    case MXP_ACTION_SCRIPT:
          MXP_error (DBG_INFO, infoMXP_ScriptCollectionStarted,
                      "Script collection mode entered (discarding script).");
          m_bMXP_script = true;
          break;  // end of MXP_ACTION_SCRIPT

    case MXP_ACTION_HR: 

          {
          // wrap up previous line if necessary
          if (m_pCurrentLine->len > 0)
             StartNewLine (true, 0);

          /*
          CString strLine;
          char * p = strLine.GetBuffer (m_nWrapColumn);
          memset (p, 175, m_nWrapColumn);
          strLine.ReleaseBuffer (m_nWrapColumn);
          AddToLine (strLine, 0);
          */
          // mark line as HR line
          m_pCurrentLine->flags = HORIZ_RULE;
          
          StartNewLine (true, 0); // now finish this line
          }
          break;  // end of MXP_ACTION_HR

    case MXP_ACTION_PRE: 
          m_bPreMode = true;
          break;  // end of MXP_ACTION_PRE

     case MXP_ACTION_UL:   
          m_iListMode = eUnorderedList;
          m_iListCount = 0;
          break;  // end of MXP_ACTION_UL
     case MXP_ACTION_OL:   
          m_iListMode = eOrderedList;
          m_iListCount = 0;
          break;  // end of MXP_ACTION_OL
     case MXP_ACTION_LI:   
         {
          // wrap up previous line if necessary
          if (m_pCurrentLine->len > 0)
             StartNewLine (true, 0);
          CString strListItem = " * ";
          if (m_iListMode == eOrderedList)
            strListItem.Format (" %i. ", ++m_iListCount);
          AddToLine (strListItem, 0);
          }
          break;  // end of MXP_ACTION_LI

    // pueblo tags we put here so we don't get warnings

      case MXP_ACTION_BODY : bIgnoreUnusedArgs = true; break; // just ignore it
      case MXP_ACTION_HEAD : bIgnoreUnusedArgs = true; break; // just ignore it
      case MXP_ACTION_HTML : bIgnoreUnusedArgs = true; break; // just ignore it
      case MXP_ACTION_TITLE: bIgnoreUnusedArgs = true; break; // just ignore it
      case MXP_ACTION_SAMP : bIgnoreUnusedArgs = true; break; // just ignore it
      case MXP_ACTION_CENTER : bIgnoreUnusedArgs = true; break; // just ignore it
      case MXP_ACTION_XCH_PANE : bIgnoreUnusedArgs = true; break; // just ignore it

      case MXP_ACTION_IMG  : 
      case MXP_ACTION_IMAGE:

        {
          GetKeyword (ArgumentList, "ismap"); // make sure we realise it is a keyword

          // detect newline treatment
          strArgument = GetArgument (ArgumentList,"xch_mode", 0, false);  // get mode
          if (!strArgument.IsEmpty ())
            {
            m_bPuebloActive = true;  // for correct newline processing
            if (strArgument.CompareNoCase ("purehtml") == 0)
               m_bSuppressNewline = true;
            else
            if (strArgument.CompareNoCase ("html") == 0)
               m_bSuppressNewline = false;
            } // end of some sort of Pueblo

          strArgument = GetArgument (ArgumentList,"url", 0, false);  // get link
          if (strArgument.IsEmpty () && PUEBLO_ACTIVE)   
            strArgument = GetArgument (ArgumentList,"src", 0, false);  // get link

          CString strFilename = GetArgument (ArgumentList,"fname", 0, false); // and file name

          if (!strArgument.IsEmpty ())
            {

            CString strOldAction = strAction;
            int iFlags = pStyle->iFlags;
            COLORREF iForeColour = pStyle->iForeColour;
            COLORREF iBackColour = pStyle->iBackColour;

            // ensure on new line
            if (m_pCurrentLine->len > 0)
               StartNewLine (true, 0);

            // starting a new line may have deleted pStyle

            pStyle = m_pCurrentLine->styleList.GetTail ();

            if (m_bUseCustomLinkColour)
              {
              pStyle->iForeColour = m_iHyperlinkColour;    // use hyperlink colour
              pStyle->iBackColour = colour2;
              pStyle->iFlags &= ~COLOURTYPE;  // clear bits, eg. custom
              pStyle->iFlags |= COLOUR_RGB;
              }

            strArgument += strFilename;   // append filename to URL
            strAction = strArgument;   // hyperlink
            pStyle->iFlags &= ~ACTIONTYPE;   // cancel old actions
            pStyle->iFlags |= ACTION_HYPERLINK;   // send-to action

            if (m_bUnderlineHyperlinks)
              pStyle->iFlags |= UNDERLINE;   // send-to action

            AddToLine ("[", 0);          
            AddToLine (strArgument, 0);
            AddToLine ("]", 0);

            // have to add the action now, before we start a new line
            pStyle->pAction = GetAction (strAction, strHint, strVariable);
            strAction.Empty ();

            StartNewLine (true, 0);   // new line after image tag
            // go back to old style (ie. lose the underlining)
            AddStyle (iFlags, 
                     iForeColour, 
                     iBackColour, 
                     0, 
                     strOldAction);

            }
        }
        break; // end of MXP_ACTION_IMG

    case MXP_ACTION_XCH_PAGE:
         bIgnoreUnusedArgs = true;
         m_bPuebloActive = true;  // for correct newline processing
         MXP_Off ();    // same as <reset>?
      break;  // end of MXP_ACTION_XCH_PAGE

    case MXP_ACTION_VAR: 
          // set variable

          strVariable = GetArgument (ArgumentList,"", 1, false);  // get name

          // case insensitive
          strVariable.MakeLower ();

          if (!IsValidName (strVariable))
            {
            MXP_error (DBG_ERROR, errMXP_InvalidDefinition,
                      TFormat ("Invalid MXP entity name: <!%s>", 
                      (LPCTSTR) strVariable)); 
            strVariable.Empty ();
            return;
            }

            { // protect local variable
            CString strEntityContents;

            if (App.m_EntityMap.Lookup (strVariable, strEntityContents))
              {
              MXP_error (DBG_ERROR, errMXP_CannotRedefineEntity,
                        TFormat ("Cannot redefine entity: &%s;", 
                        (LPCTSTR) strVariable)); 
              strVariable.Empty ();
              return;
              }
              }

          break;  // end of MXP_ACTION_VAR


    default:
          {
          // warn them it is not implemented
          MXP_error (DBG_WARNING, wrnMXP_TagNotImplemented,
                     TFormat ("MXP tag <%s> is not implemented" ,
                             (LPCTSTR) strTag));
          }   // end of default

    } // end of switch on iAction

  if (!bIgnoreUnusedArgs)
    CheckArgumentsUsed (strTag, ArgumentList);

  } // end of CMUSHclientDoc::MXP_OpenAtomicTag
예제 #19
0
void CHomeSearchCtrl::Search(bool bAutostart)
{
	CString strText, strURI, strEntry, strClear;

	m_wndText.GetWindowText( strText );
	strText.TrimLeft();
	strText.TrimRight();

	LoadString( strClear, IDS_SEARCH_PAD_CLEAR_HISTORY );
	if ( _tcscmp ( strClear , strText ) == 0 ) return;

	// Check if user mistakenly pasted download link to search input box
	if (theApp.OpenURL( strText, TRUE, TRUE ) )
	{
		m_wndText.SetWindowText( _T("") );
		return;
	}

	CSchemaPtr pSchema = m_wndSchema.GetSelected();
	if ( pSchema != NULL ) strURI = pSchema->GetURI();

	Settings.Search.LastSchemaURI = strURI;

	CQuerySearchPtr pSearch = new CQuerySearch();
	pSearch->m_bAutostart	= bAutostart;
	pSearch->m_sSearch		= strText;
	pSearch->m_pSchema		= pSchema;
	BOOL bValid = pSearch->CheckValid( false );
	if ( ! bValid && bAutostart )
	{
		// Invalid search, open help window
		CQuerySearch::SearchHelp();
	}
	else if ( AdultFilter.IsSearchFiltered( pSearch->m_sSearch ) && bAutostart )
	{
		// Adult search blocked, open help window
		CHelpDlg::Show( _T("SearchHelp.AdultSearch") );
	}
	else
	{
		if ( bValid )
		{
			// Load all
			CStringList oList;
			for ( int i = 0; ; i++ )
			{
				strEntry.Format( _T("Search.%.2i"), i + 1 );
				CString strValue( theApp.GetProfileString( _T("Search"), strEntry ) );
				if ( strValue.IsEmpty() )
					break;
				int lf = strValue.Find( _T('\n') );
				if ( strText.CompareNoCase( ( lf != -1 ) ? strValue.Left( lf ) : strValue ) )
					oList.AddTail( strValue );
			}

			// Cut to 200 items
			while ( oList.GetCount() >= 200 )
				oList.RemoveTail();

			// New one (at top)
			oList.AddHead( strURI.IsEmpty() ? strText : ( strText + _T('\n') + strURI ) );

			// Save list
			POSITION pos = oList.GetHeadPosition();
			for ( int i = 0; pos; ++i )
			{
				strEntry.Format( _T("Search.%.2i"), i + 1 );
				theApp.WriteProfileString( _T("Search"), strEntry, oList.GetNext( pos ) );
			}

			FillHistory();
		}

		new CSearchWnd( pSearch );
	}

	m_wndText.SetWindowText( _T("") );
}
예제 #20
0
bool CThumbInstruction::Validate()
{
	CStringList List;
	RamPos = g_fileManager->getVirtualAddress();

	if (RamPos & 1)
	{
		Logger::queueError(Logger::Warning,L"Opcode not halfword aligned");
	}

	if (Opcode.flags & THUMB_DS)
	{
		Vars.rs = Vars.rd;
	}

	if (Opcode.flags & THUMB_IMMEDIATE)
	{
		if (ParsePostfix(Vars.ImmediateExpression,&List,Vars.Immediate) == false)
		{
			if (List.GetCount() == 0)
			{
				Logger::queueError(Logger::Error,L"Invalid expression");
			} else {
				for (int l = 0; l < List.GetCount(); l++)
				{
					Logger::queueError(Logger::Error,convertUtf8ToWString(List.GetEntry(l)));
				}
			}
			return false;
		}
		Vars.OriginalImmediate = Vars.Immediate;

		if (Opcode.flags & THUMB_BRANCH)
		{
			if (Opcode.flags & THUMB_EXCHANGE)
			{
				if (Vars.Immediate & 3)
				{
					Logger::queueError(Logger::Error,L"Branch target must be word aligned");
					return false;
				}
			} else {
				if (Vars.Immediate & 1)
				{
					Logger::queueError(Logger::Error,L"Branch target must be halfword aligned");
					return false;
				}
			}

			int num = (Vars.Immediate-RamPos-4);
			
			if (num >= (1 << Vars.ImmediateBitLen) || num < (0-(1 << Vars.ImmediateBitLen)))
			{
				Logger::queueError(Logger::Error,L"Branch target %08X out of range",Vars.Immediate);
				return false;
			}

			Vars.Immediate = num >> 1;
			if (Opcode.flags & THUMB_EXCHANGE)
			{
				Vars.Immediate += Vars.Immediate&1;
			}
		} else if (Opcode.flags & THUMB_WORD)
		{
			if (Vars.Immediate & 3)	// not allowed
			{
				Logger::queueError(Logger::Error,L"Immediate value must be a multiple of 4");
				return false;
			}
			Vars.Immediate >>= 2;
		} else if (Opcode.flags & THUMB_HALFWORD)
예제 #21
0
void CSharedDirsTreeCtrl::Reload(bool bForce){
	bool bChanged = false;
	if (!bForce){
		// check for changes in shared dirs
		if (thePrefs.shareddir_list.GetCount() == m_strliSharedDirs.GetCount()){
			POSITION pos = m_strliSharedDirs.GetHeadPosition();
			POSITION pos2 = thePrefs.shareddir_list.GetHeadPosition();
			while (pos != NULL && pos2 != NULL){
				CString str1 = m_strliSharedDirs.GetNext(pos);
				CString str2 = thePrefs.shareddir_list.GetNext(pos2);
				if (str1.Right(1) == "\\"){
					str1 = str1.Left(str1.GetLength()-1);
				}
				if (str2.Right(1) == "\\"){
					str2 = str2.Left(str2.GetLength()-1);
				}
				if  (str1.CompareNoCase(str2) != 0){
					bChanged = true;
					break;
				}
			}
		}
		else
			bChanged = true;

		// check for changes in categories incoming dirs
		CString strMainIncDir = thePrefs.GetIncomingDir();
		if (strMainIncDir.Right(1) == _T("\\"))
			strMainIncDir = strMainIncDir.Left(strMainIncDir.GetLength()-1);
		CStringList strliFound;
		for (int i = 0; i < thePrefs.GetCatCount(); i++){
			Category_Struct* pCatStruct = thePrefs.GetCategory(i);
			if (pCatStruct != NULL){
				CString strCatIncomingPath = pCatStruct->incomingpath;
				if (strCatIncomingPath.Right(1) == _T("\\"))
					strCatIncomingPath = strCatIncomingPath.Left(strCatIncomingPath.GetLength()-1);

				if (!strCatIncomingPath.IsEmpty() && strCatIncomingPath.CompareNoCase(strMainIncDir) != 0
					&& strliFound.Find(strCatIncomingPath) == NULL)
				{
					POSITION pos = m_strliCatIncomingDirs.Find(strCatIncomingPath);
					if (pos != NULL){
						strliFound.AddTail(strCatIncomingPath);
					}
					else{
						bChanged = true;
						break;
					}
				}
			}
		}
		if (strliFound.GetCount() != m_strliCatIncomingDirs.GetCount())
			bChanged = true;

	}
	if (bChanged || bForce){
		FetchSharedDirsList();
		FilterTreeReloadTree();
		Expand(m_pRootUnsharedDirectries->m_htItem, TVE_COLLAPSE); // collapsing is enough to sync for the filtetree, as all items are recreated on every expanding
	}
}
예제 #22
0
bool Get_XML_date (CXMLelement & node,
                        const char * sName,
                        CTime & tValue,
                        const bool bUseDefault)

  {
CString strValue;

  if (!Get_XML_string (node, sName, strValue, true, true))
    if (bUseDefault)
      return false;
    else
      {
      tValue = 0;     // default is no time
      return false;
      }

  if (strValue.IsEmpty ())
      ThrowErrorException ("No time supplied for attribute named '%s'" ,
                          sName);

  // break up date into date portion / time portion
  CStringList strDateTime;
  StringToList (strValue, " ", strDateTime);

  if (strDateTime.GetCount () < 1 || strDateTime.GetCount () > 2)
    ThrowErrorException ("Date/time must consist of YYYY-MM-DD [ HH:MM:SS ]");

  CString strDate = strDateTime.RemoveHead ();
  CString strTime;
  if (!strDateTime.IsEmpty ())
     strTime = strDateTime.RemoveHead ();

  CString strYear, strMonth, strDay;

  CStringList strDateList;
  StringToList (strDate, "-", strDateList);

  if (strDateList.GetCount () != 3)
     ThrowErrorException ("Date must consist of YYYY-MM-DD");
   
  strYear = strDateList.RemoveHead ();
  strMonth = strDateList.RemoveHead ();
  strDay = strDateList.RemoveHead ();

  if (!IsNumber (strYear))
     ThrowErrorException ("Year is not numeric");
  if (!IsNumber (strMonth))
     ThrowErrorException ("Month is not numeric");
  if (!IsNumber (strDay))
     ThrowErrorException ("Day is not numeric");

  int iYear, iMonth, iDay;

  iYear = atoi (strYear);
  iMonth = atoi (strMonth);
  iDay = atoi (strDay);

  if (iYear <  1900 || iYear > 2100)
     ThrowErrorException ("Year must be in range 1900 to 2100");
  
  if (iMonth < 1 || iMonth > 12)
     ThrowErrorException ("Month must be in range 1 to 12");
  
  if (iDay < 1 || iDay > 31)
     ThrowErrorException ("Month must be in range 1 to 31");

  int iHour = 0, iMinute = 0, iSecond = 0;

  if (!strTime.IsEmpty ())
    {

    CString strHour, strMinute, strSecond;

    CStringList strTimeList;
    StringToList (strTime, ":", strTimeList);

    if (strTimeList.GetCount () > 3)
       ThrowErrorException ("Time must consist of HH, HH:MM, or HH:MM:SS");
   
    strHour = strTimeList.RemoveHead ();
    strMinute = "0";
    strSecond = "0";

    if (!strTimeList.IsEmpty ())
      {
      strMinute = strTimeList.RemoveHead ();
      if (!strTimeList.IsEmpty ())
        strSecond = strTimeList.RemoveHead ();
      }

    if (!IsNumber (strHour))
       ThrowErrorException ("Hour is not numeric");
    if (!IsNumber (strMinute))
       ThrowErrorException ("Minute is not numeric");
    if (!IsNumber (strSecond))
       ThrowErrorException ("Second is not numeric");

    iHour = atoi (strHour);
    iMinute = atoi (strMinute);
    iSecond = atoi (strSecond);

    if (iHour <  0 || iHour > 23)
       ThrowErrorException ("Hour must be in range 0 to 23");
  
    if (iMinute < 0 || iMinute > 59)
       ThrowErrorException ("Minute must be in range 0 to 59");
  
    if (iSecond < 0 || iSecond > 59)
       ThrowErrorException ("Minute must be in range 0 to 59");

    } // end of having a time

  tValue = CTime (iYear, iMonth, iDay, iHour, iMinute, iSecond, 0);

  return true;

  }  // end of Get_XML_date
void CDlgIDirectoryObject::OnGet() 
{
   CStringList sList;
   UINT nCount;
   HRESULT hr;
   

   UpdateData(TRUE);

   StringToStringList(m_sAttributes, sList );
   nCount = sList.GetCount();
   if ( nCount == 0 )
   {
	   return;
   }

   
   
   ///////////////////////////////////////
   // Now build the Attribute Names List
   ///////////////////////////////////////
   POSITION			pos;
   DWORD			dwNumAttr;
   LPWSTR			*pAttrNames=NULL;
   ADS_ATTR_INFO	*pAttrInfo;
   DWORD			dwReturn;
   

   USES_CONVERSION;


   pAttrNames = (LPWSTR*) AllocADsMem( sizeof(LPWSTR) * nCount );
   pos = sList.GetHeadPosition();
   dwNumAttr = 0;
   while( pos != NULL )
   {
	   pAttrNames[dwNumAttr] = T2OLE(sList.GetAt(pos));
	   dwNumAttr++;
	   sList.GetNext(pos);
   }

   
 
   
   /////////////////////////////////////////
   // Get attributes value requested
   // Note: The order is not necessarily the same as
   //       requested via pAttrNames.
   ///////////////////////////////////////////
   hr = m_pDirObject->GetObjectAttributes( pAttrNames, dwNumAttr, &pAttrInfo, &dwReturn );

   

   if ( SUCCEEDED(hr) )
   {
	  DWORD idx;
	  CString sDisplay;
	  CStringList sValueList;
	  UINT nCount;
	  POSITION pos;

	  m_cValueList.ResetContent();

	  for( idx=0; idx < dwReturn; idx++) 
	  {		  
          ADsToStringList( pAttrInfo[idx].pADsValues, pAttrInfo[idx].dwNumValues, sValueList );
		  sDisplay = OLE2T(pAttrInfo[idx].pszAttrName);
		  sDisplay += _T(":");
		  m_cValueList.AddString( sDisplay );
		  nCount = sValueList.GetCount();
		  if ( nCount == 0 ) // can not find/convert the value
		  {
			  m_cValueList.AddString(_T(" > [No Value]"));
			  continue;
		  }
		  else
		  {
			  pos = sValueList.GetHeadPosition();
			  while( pos != NULL )
			  {
				  sDisplay = _T(" > ");
				  sDisplay += sValueList.GetAt(pos);
				  m_cValueList.AddString( sDisplay );
				  sValueList.GetNext(pos);
			  }

		  }
		  
	  }

	  sValueList.RemoveAll();
   }

   

   ///////////////////////////////////////////////////////////
   // Use FreADsMem for all memory obtained from ADSI call 
   /////////////////////////////////////////////////////////////
   FreeADsMem( pAttrInfo );
   FreeADsMem( pAttrNames );

	
}
예제 #24
0
void	CWordFilter::Init()
{
	HANDLE	hFile;
	DWORD	dwRead;
	int		nLen;
	BOOL	bResult;
	CStringList list;

	//m_count = 0;

	// 如果文件目录不对,程序移动一下,到config目录下 added by kernel1983 2006.07.31
	if (PathFileExists(thePrefs.GetMuleDirectory(EMULE_EXECUTEABLEDIR) + FLITER_FILE)) 
		MoveFile(thePrefs.GetMuleDirectory(EMULE_EXECUTEABLEDIR) + FLITER_FILE, thePrefs.GetMuleDirectory(EMULE_CONFIGDIR) + FLITER_FILE);

	if (!PathFileExists(thePrefs.GetMuleDirectory(EMULE_CONFIGDIR) + FLITER_FILE))
	{
		// 不存在,所有的都过滤 added by kernel1983 2006.08.08
		m_filterall = true;
		return;
	}

	// Open file for read
	hFile = CreateFile(thePrefs.GetMuleDirectory(EMULE_CONFIGDIR) + FLITER_FILE, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
	//AddLogLine(false,_T(":%s\n"),thePrefs.GetMuleDirectory(EMULE_CONFIGDIR) + FLITER_FILE);
	if(hFile == NULL || hFile == INVALID_HANDLE_VALUE)
	{
		// 读取错误,所有的都过滤 added by kernel1983 2006.08.08
		m_filterall = true;
		return;
	}

	DWORD dwSize = GetFileSize(hFile, NULL);

	TCHAR * pszData = new TCHAR[(dwSize / sizeof(TCHAR)) + 1];			// 申请空间
	bResult = ReadFile(hFile, pszData, dwSize, &dwRead, NULL);		// 读入文件1
	CloseHandle(hFile);
	pszData[(dwSize / sizeof(TCHAR))] = 0;

	if(bResult)
	{
		TCHAR * pszTemp = wcstok(pszData + 1, _T("\r\n"));
		while(pszTemp != NULL)
		{
			nLen = wcslen(pszTemp);
			while(pszTemp[nLen - 1] == '\t' || pszTemp[nLen - 1] == ' ')
			{
				nLen --;
				pszTemp[nLen] = 0;
			}
			while(*pszTemp == '\t' || *pszTemp == ' ')
			{
				pszTemp ++;
				nLen --;
			}
			//AddLogLine(false,_T("pszTemp:%s"),pszTemp);
			//AddLogLine(false,_T("nLen:%d"),nLen);
			if(nLen > 0)list.AddTail(pszTemp);
			//if(nLen == 8)AddLogLine(false,_T(":%d %d %d %d "),((char*)pszTemp)[0],((char*)pszTemp)[1],((char*)pszTemp)[2],((char*)pszTemp)[3]);
			pszTemp = wcstok(NULL, _T("\r\n"));
		}
	}

	delete[] pszData;

	m_count = list.GetCount();
	//AddLogLine(false,_T("m_count:%d"),m_count);

	if(bResult && m_count > 0)
	{
		m_filterwords = new TCHAR*[m_count+1];
		m_kmpvalue = new int*[m_count+1];
		ZeroMemory(m_filterwords, sizeof(TCHAR *) * m_count);
		ZeroMemory(m_kmpvalue, sizeof(int *) * m_count);
	}

	for(int i = 0; bResult && (i < m_count); i ++)
	{
		CString s = list.GetAt(list.FindIndex(i));
		s.MakeLower();
		nLen = s.GetLength();
		//AddLogLine(false,_T("nLen:%d"),nLen);
		m_filterwords[i] = new TCHAR[nLen + 1];
		m_filterwords[i][nLen] = 0;	// 最后一个字节设为0
		m_kmpvalue[i] = new int[nLen];
		//AddLogLine(false,_T("nLen:%d"),nLen);
		_tcscpy(m_filterwords[i],s);
		//AddLogLine(false,_T("m_filterwords[i]:%s"),m_filterwords[i]);
		KMP_GetNext(m_filterwords[i], m_kmpvalue[i]);	// 得到一个与内容有关的数值m_kmpvalue[i]
	}

	if(m_count == 0 || !bResult)
	{
		Free();
		//m_filterall = true;
	}
}
예제 #25
0
파일: ECLASS.CPP 프로젝트: chenbk85/3dlearn
qboolean Eclass_hasModel(eclass_t *e, vec3_t &vMin, vec3_t &vMax)
{
	if (e->modelpath != NULL)
	{
		if (e->model == NULL)
		{
			e->model = reinterpret_cast<entitymodel_t*>(qmalloc(sizeof(entitymodel_t)));
		}
		char *pModelBuff = strdup(e->modelpath);
		char *pSkinBuff = NULL;
		if (e->skinpath)
		{
			pSkinBuff = strdup(e->skinpath);
		}

		CStringList Models;
		CStringList Skins;
		char* pToken = strtok(pModelBuff, ";\0");
		while (pToken != NULL)
		{
			Models.AddTail(pToken);
			pToken = strtok(NULL, ";\0");
		}

		if (pSkinBuff != NULL)
		{
			pToken = strtok(pSkinBuff, ";\0");
			while (pToken != NULL)
			{
				Skins.AddTail(pToken);
				pToken = strtok(NULL, ";\0");
			}
		}

		entitymodel *model = e->model;
		int i = 0;
		for (; i < Models.GetCount(); i++)
		{
			char *pSkin = NULL;
			if (i < Skins.GetCount())
			{
				pSkin = Skins.GetAt(Skins.FindIndex(i)).GetBuffer(0);
			}
			LoadModel(Models.GetAt(Models.FindIndex(i)), e, vMin, vMax, model, pSkin);
			model->pNext = reinterpret_cast<entitymodel_t*>(qmalloc(sizeof(entitymodel_t)));
			model = model->pNext;
		}

		// at this poitn vMin and vMax contain the min max of the model
		// which needs to be centered at origin 0, 0, 0

		VectorSnap(vMin);
		VectorSnap(vMax);

		if (vMax[0] - vMin[0] < 2)
		{
			vMin[0] -= 1;
			vMax[0] += 1;
		}

		if (vMin[1] - vMax[1] < 2)
		{
			vMin[1] -= 1;
			vMax[1] += 1;
		}

		if (vMax[2] - vMin[2] < 2)
		{
			vMax[2] -= 1;
			vMax[2] += 1;
		}

		vec3_t vTemp;
		VectorAdd(vMin, vMax, vTemp);
		VectorScale(vTemp, 0.5, vTemp);
		model = e->model;
		while (model != NULL)
		{
			for (i = 0; i < model->nTriCount; i++)
			{
				for (int j = 0; j < 3; j++)
				{
					;//VectorSubtract(model->pTriList[i].v[j], vTemp, model->pTriList[i].v[j]);
				}
			}
			model = model->pNext;
		}

		free(pModelBuff);
		free(e->modelpath);
		e->modelpath = NULL;

		if(e->skinpath)
		{
			free(e->skinpath);
			e->skinpath = NULL;
			free(pSkinBuff);
		}

	}
	return (e->model != NULL && e->model->nTriCount > 0);
}
예제 #26
0
BOOL CBCGPODBCGridCtrl::OpenSQL (LPCTSTR lpszSQL)
{
	ASSERT (lpszSQL != NULL);
	m_strSQL.Empty ();

	RemoveAll ();

	if (!m_bIsSorting)
	{
		DeleteAllColumns ();
	}
	
	if (m_pDataBase == NULL)
	{
		ASSERT (FALSE);
		return FALSE;
	}

	try
	{
		ASSERT_VALID (m_pDataBase);

		if (!m_pDataBase->IsOpen ())
		{
			ASSERT (FALSE);
			return FALSE;
		}

		if (m_pRecordSet != NULL)
		{
			ASSERT_VALID (m_pRecordSet);

			if (m_pRecordSet->IsOpen ())
			{
				m_pRecordSet->Close ();
			}

			delete m_pRecordSet;
			m_pRecordSet = NULL;
		}

		//---------------------------------------------------------
		// Create a new record set and open it using SQL statement:
		//---------------------------------------------------------
		m_pRecordSet = new CRecordset (m_pDataBase);
		if (!m_pRecordSet->Open (CRecordset::dynaset, lpszSQL))
		{
			return FALSE;
		}

		int nColumns = 0;

		if (!m_bIsSorting)
		{
			//-------------
			// Add columns:
			//-------------
			CStringList lstField;
			if (!GetFieldList (lstField))
			{
				return FALSE;
			}

			int nColumn = 0;
			for (POSITION pos = lstField.GetHeadPosition (); pos != NULL; nColumn++)
			{
				InsertColumn (nColumn, lstField.GetNext (pos), 50);
			}

			nColumns = (int) lstField.GetCount ();
		}
		else
		{
			nColumns = GetColumnCount ();
		}

		if (nColumns == 0)
		{
			// No columns
			AdjustLayout ();
			return TRUE;
		}

		//-------------
		// Add records:
		//-------------
		if (m_pRecordSet->IsEOF () && m_pRecordSet->IsBOF ())
		{
			// The table is empty
			AdjustLayout ();
			return TRUE;
		}

		if (m_bVirtualMode)
		{
			while (!m_pRecordSet->IsEOF ())
			{
				m_pRecordSet->MoveNext ();
			}

			SetVirtualRows (max (0, m_pRecordSet->GetRecordCount ()));
		}
		else
		{
			for (int nRow = 0; !m_pRecordSet->IsEOF (); 
				m_pRecordSet->MoveNext (), nRow++)
			{
				CBCGPGridRow* pRow = CreateRow (nColumns);
				ASSERT_VALID (pRow);

				for (int nColumn = 0; nColumn < nColumns; nColumn++)
				{
					OnAddData (pRow, nColumn, nRow);
				}

				if (OnBeforeAddRow (pRow, nRow))
				{
					AddRow (pRow, FALSE);
				}
				else
				{
					delete pRow;
				}
			}
		}

		m_strSQL = lpszSQL;
		AdjustLayout ();

		if (!m_pRecordSet->CanUpdate ())
		{
			SetReadOnly ();
		}
	}
	catch (CDBException* pEx)
	{
		OnODBCException (pEx);
		pEx->Delete ();

		return FALSE;
	}

	return TRUE;
}
예제 #27
0
BOOL CSetSavedDataPage::OnInitDialog()
{
	ISettingsPropPage::OnInitDialog();

	// find out how many log messages and URLs we've stored
	int nLogHistWC = 0;
	INT_PTR nLogHistMsg = 0;
	int nUrlHistWC = 0;
	INT_PTR nUrlHistItems = 0;
	int nLogHistRepo = 0;
	CRegistryKey regloghist(_T("Software\\TortoiseGit\\History"));
	CStringList loghistlist;
	regloghist.getSubKeys(loghistlist);
	for (POSITION pos = loghistlist.GetHeadPosition(); pos != NULL; )
	{
		CString sHistName = loghistlist.GetNext(pos);
		if (sHistName.Left(6).CompareNoCase(_T("commit"))==0)
		{
			nLogHistWC++;
			CRegistryKey regloghistwc(_T("Software\\TortoiseGit\\History\\")+sHistName);
			CStringList loghistlistwc;
			regloghistwc.getValues(loghistlistwc);
			nLogHistMsg += loghistlistwc.GetCount();
		}
		else
		{
			// repoURLs
			CStringList urlhistlistmain;
			CStringList urlhistlistmainvalues;
			CRegistryKey regurlhistlist(_T("Software\\TortoiseGit\\History\\repoURLS"));
			regurlhistlist.getSubKeys(urlhistlistmain);
			regurlhistlist.getValues(urlhistlistmainvalues);
			nUrlHistItems += urlhistlistmainvalues.GetCount();
			for (POSITION urlpos = urlhistlistmain.GetHeadPosition(); urlpos != NULL; )
			{
				CString sWCUID = urlhistlistmain.GetNext(urlpos);
				nUrlHistWC++;
				CStringList urlhistlistwc;
				CRegistryKey regurlhistlistwc(_T("Software\\TortoiseGit\\History\\repoURLS\\")+sWCUID);
				regurlhistlistwc.getValues(urlhistlistwc);
				nUrlHistItems += urlhistlistwc.GetCount();
			}
		}
	}

	// find out how many dialog sizes / positions we've stored
	INT_PTR nResizableDialogs = 0;
	CRegistryKey regResizable(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState"));
	CStringList resizablelist;
	regResizable.getValues(resizablelist);
	nResizableDialogs += resizablelist.GetCount();

	// find out how many auth data we've stored
	int nSimple = 0;
	int nSSL = 0;
	int nUsername = 0;

	CString sFile;
	bool bIsDir = false;

	TCHAR pathbuf[MAX_PATH] = {0};
	if (SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, pathbuf)==S_OK)
	{
		_tcscat_s(pathbuf, MAX_PATH, _T("\\Subversion\\auth\\"));
		CString sSimple = CString(pathbuf) + _T("svn.simple");
		CString sSSL = CString(pathbuf) + _T("svn.ssl.server");
		CString sUsername = CString(pathbuf) + _T("svn.username");
		CDirFileEnum simpleenum(sSimple);
		while (simpleenum.NextFile(sFile, &bIsDir))
			nSimple++;
		CDirFileEnum sslenum(sSSL);
		while (sslenum.NextFile(sFile, &bIsDir))
			nSSL++;
		CDirFileEnum userenum(sUsername);
		while (userenum.NextFile(sFile, &bIsDir))
			nUsername++;
	}

	CDirFileEnum logenum(CPathUtils::GetAppDataDirectory()+_T("logcache"));
	while (logenum.NextFile(sFile, &bIsDir))
		nLogHistRepo++;
	// the "Repositories.dat" is not a cache file
	nLogHistRepo--;

	BOOL bActionLog = PathFileExists(CPathUtils::GetAppDataDirectory() + _T("logfile.txt"));

	m_btnLogHistClear.EnableWindow(nLogHistMsg || nLogHistWC);
	m_btnUrlHistClear.EnableWindow(nUrlHistItems || nUrlHistWC);
	m_btnResizableHistClear.EnableWindow(nResizableDialogs > 0);
	m_btnAuthHistClear.EnableWindow(nSimple || nSSL || nUsername);
	m_btnRepoLogClear.EnableWindow(nLogHistRepo >= 0);
	m_btnActionLogClear.EnableWindow(bActionLog);
	m_btnActionLogShow.EnableWindow(bActionLog);

	EnableToolTips();

	m_tooltips.Create(this);
	CString sTT;
	sTT.Format(IDS_SETTINGS_SAVEDDATA_LOGHIST_TT, nLogHistMsg, nLogHistWC);
	m_tooltips.AddTool(IDC_LOGHISTORY, sTT);
	m_tooltips.AddTool(IDC_LOGHISTCLEAR, sTT);
	sTT.Format(IDS_SETTINGS_SAVEDDATA_URLHIST_TT, nUrlHistItems, nUrlHistWC);
	m_tooltips.AddTool(IDC_URLHISTORY, sTT);
	m_tooltips.AddTool(IDC_URLHISTCLEAR, sTT);
	sTT.Format(IDS_SETTINGS_SAVEDDATA_RESIZABLE_TT, nResizableDialogs);
	m_tooltips.AddTool(IDC_RESIZABLEHISTORY, sTT);
	m_tooltips.AddTool(IDC_RESIZABLEHISTCLEAR, sTT);
	sTT.Format(IDS_SETTINGS_SAVEDDATA_AUTH_TT, nSimple, nSSL, nUsername);
	m_tooltips.AddTool(IDC_AUTHHISTORY, sTT);
	m_tooltips.AddTool(IDC_AUTHHISTCLEAR, sTT);
	sTT.Format(IDS_SETTINGS_SAVEDDATA_REPOLOGHIST_TT, nLogHistRepo);
	m_tooltips.AddTool(IDC_REPOLOG, sTT);
	m_tooltips.AddTool(IDC_REPOLOGCLEAR, sTT);
	sTT.LoadString(IDS_SETTINGS_SHOWACTIONLOG_TT);
	m_tooltips.AddTool(IDC_ACTIONLOGSHOW, sTT);
	sTT.LoadString(IDS_SETTINGS_MAXACTIONLOGLINES_TT);
	m_tooltips.AddTool(IDC_MAXLINES, sTT);
	sTT.LoadString(IDS_SETTINGS_CLEARACTIONLOG_TT);
	m_tooltips.AddTool(IDC_ACTIONLOGCLEAR, sTT);

	return TRUE;
}
예제 #28
0
/***************************************************
StartDropList
	This internal function is used to parse out 
	the label string, which contains the items to 
	show in the list.  Also this function will
	show the list box in the proper location on the
	screen.
Params:
	<none>
Return:
	UG_ERROR	- the list is already visible.
	UG_SUCCESS	- everything went smoothly, the drop
				  list was shown
***************************************************/
int CUGDropListType::StartDropList()
{
	RECT		rect;
	RECT		clientRect;
	int			dif,len,pos,startpos;
	CFont *		font = NULL;
	LOGFONT		lf;
	CFont *		cfont;
	CStringList list;	  //lists of strings for the list are assembed here
	CString *	items;	  //points to the string used to assemble the list

	//return false if it is already up
	if(	m_listBox->m_HasFocus)
		return UG_ERROR;

	CUGCell cell;
	m_ctrl->GetCellIndirect(m_btnCol,m_btnRow,&cell);

	// make sure that the read only cells do not show droplist
	if ( cell.GetReadOnly() == TRUE )
		return UG_SUCCESS;

	//get the current row and col
	m_btnCol  = m_ctrl->GetCurrentCol();
	m_btnRow = m_ctrl->GetCurrentRow();

	//add the strings to the CStringList
	CString string;
	cell.GetLabelText(&string);
	items = &string;
	len = items->GetLength();
	pos =0;
	startpos =0;
	while(pos <len){
		if(items->GetAt(pos)== _T('\n')){
			list.AddTail(items->Mid(startpos,pos-startpos));
			startpos = pos+1;
		}
		pos++;
	}

	//notify the user of the list, so it can be modified if needed
	if ( OnCellTypeNotify(m_ID,m_btnCol,m_btnRow,UGCT_DROPLISTSTART,(LONG_PTR)&list) == FALSE )
		// if FALSE was returned from OnCellTypeNotify call, than the developer does not
		// wish to show the drop list at the moment.
		return UG_ERROR;
	
	// set default font height
	lf.lfHeight = 12;

	//get the font
	if(cell.IsPropertySet(UGCELL_FONT_SET))
		font = cell.GetFont();
	else if(m_ctrl->m_GI->m_defFont != NULL)
		font = m_ctrl->m_GI->m_defFont;
	
	if(font == NULL)
		font = CFont::FromHandle((HFONT)GetStockObject(SYSTEM_FONT));

	if(font != NULL)
	{
		//find the height of the font
		cfont = font;
		cfont->GetLogFont(&lf); 	// lf.lfHeight

		if( lf.lfHeight < 0 ){
			HDC hDC = CreateCompatibleDC(NULL);
			lf.lfHeight = -MulDiv(lf.lfHeight, GetDeviceCaps(hDC, LOGPIXELSY), 72);
			DeleteDC(hDC);
		}
	}

	//get the rectangle for the listbox
	m_ctrl->GetCellRect(m_btnCol,m_btnRow,&rect);
	rect.top = rect.bottom;
	rect.left+=10;
	rect.right+=10;
	len = (int)list.GetCount();
	if(len >15)
		len = 15;
	rect.bottom += lf.lfHeight * len + 6;
	
	m_ctrl->m_CUGGrid->GetClientRect(&clientRect);
	if(rect.bottom > clientRect.bottom){
		dif = rect.bottom - clientRect.bottom;
		rect.bottom -= dif;
		rect.top -= dif;
		if(rect.top <0)
			rect.top = 0;
	}
	if(rect.right > clientRect.right){
		dif = rect.right - clientRect.right;
		rect.right -= dif;
		rect.left -= dif;
		if(rect.left <0)
			rect.left = 0;
	}

	//create the CListBox
	m_listBox->m_ctrl = m_ctrl;
	m_listBox->m_cellType = this;
	m_listBox->m_cellTypeId = m_ID;
	m_listBox->Create(WS_CHILD|WS_BORDER|WS_VSCROLL,rect,m_ctrl->m_CUGGrid,123);
	
	//set up the font
	if(font != NULL)
		m_listBox->SetFont(font);

	// v7.2 - update 03 - this works to eliminate blank lines that 
	// can occur with odd sized fonts/number of items. Fix courtesy Gerbrand 
	// .start
	int itHeight = m_listBox->GetItemHeight(0);   
	if (len > 15)      
		len = 15;   
	rect.bottom = rect.top + len * itHeight + 6;   
	if(rect.bottom > clientRect.bottom){      
		dif = rect.bottom - clientRect.bottom;      
		rect.bottom -= dif;      
		rect.top -= dif;      
		if(rect.top <0)         
			rect.top = 0;   
	}   
	
	// v7.2 - update 03 - Adjust the rect width to accomodate the largest string
	//			Allen Shiels
	dif = GetMaxStringWidth(list) - (rect.right-rect.left);	
	if (dif > 0) {		
		if (len >= 15) // add a scroll bar width if max items in list
			dif += GetSystemMetrics(SM_CXVSCROLL);		
		rect.right += dif;	
	}

	if(rect.right > clientRect.right){      
		dif = rect.right - clientRect.right;      
		rect.right -= dif;      
		rect.left -= dif;      
		if(rect.left <0)         
			rect.left = 0;   
	}
	// .end
	
	//resize the window again since a new font is being used
	m_listBox->MoveWindow(&rect,FALSE);

	//add the items to the list
	len = (int)list.GetCount();
	POSITION position = list.GetHeadPosition();
	pos =0;
	while(pos < len){
		m_listBox->AddString(list.GetAt(position));
		pos++;
		if(pos < len)
			list.GetNext(position);
	}

	//give the list box pointers to the cell
	m_listBox->m_col = &m_btnCol;
	m_listBox->m_row = &m_btnRow;

	m_listBox->ShowWindow(SW_SHOW);
	m_listBox->SetFocus();
	
	m_btnDown = FALSE;
	m_ctrl->RedrawCell(m_btnCol,m_btnRow);

	return UG_SUCCESS;
}
예제 #29
0
LONG CuDlgReplicationStaticPageActivity::OnLoad (WPARAM wParam, LPARAM lParam)
{
	LPCTSTR pClass = (LPCTSTR)wParam;
	ASSERT (lstrcmp (pClass, _T("CaReplicationStaticDataPageActivity")) == 0);
	CaReplicationStaticDataPageActivity* pData = (CaReplicationStaticDataPageActivity*)lParam;
	if (!pData)
		return 0L;
	POSITION p, pos = NULL;
	CStringList* pObj = NULL;
	try
	{
		m_strInputQueue        = pData->m_strInputQueue;
		m_strDistributionQueue = pData->m_strDistributionQueue;
		m_strStartingTime      = pData->m_strStartingTime;
		UpdateData (FALSE);
		//
		// Summary:
		//
		// For each column:
		const int LAYOUT_NUMBER = 6;
		for (int i=0; i<LAYOUT_NUMBER; i++)
			m_cListCtrl.SetColumnWidth(i, pData->m_cxSummary.GetAt(i));
		int nCount = 0;
		pos = pData->m_listSummary.GetHeadPosition();
		while (pos != NULL)
		{
			pObj = pData->m_listSummary.GetNext (pos);
			ASSERT (pObj);
			ASSERT (pObj->GetCount() == 6);
			nCount = m_cListCtrl.GetItemCount();
			p = pObj->GetHeadPosition();
			m_cListCtrl.InsertItem  (nCount,    (LPCTSTR)pObj->GetNext(p));
			m_cListCtrl.SetItemText (nCount, 1, (LPCTSTR)pObj->GetNext(p));
			m_cListCtrl.SetItemText (nCount, 2, (LPCTSTR)pObj->GetNext(p));
			m_cListCtrl.SetItemText (nCount, 3, (LPCTSTR)pObj->GetNext(p));
			m_cListCtrl.SetItemText (nCount, 4, (LPCTSTR)pObj->GetNext(p));
			m_cListCtrl.SetItemText (nCount, 5, (LPCTSTR)pObj->GetNext(p));
		}
		m_cListCtrl.SetScrollPos (SB_HORZ, pData->m_scrollSummary.cx);
		m_cListCtrl.SetScrollPos (SB_VERT, pData->m_scrollSummary.cy);
		CuListCtrl* pList = NULL;

		//
		// Per database (Outgoing):
		m_pDatabaseOutgoing->SetAllColumnWidth (pData->m_cxDatabaseOutgoing);
		pList = &(m_pDatabaseOutgoing->m_cListCtrl);
		pos = pData->m_listDatabaseOutgoing.GetHeadPosition();
		while (pos != NULL)
		{
			pObj = pData->m_listDatabaseOutgoing.GetNext (pos);
			ASSERT (pObj);
			ASSERT (pObj->GetCount() == 6);
			nCount = pList->GetItemCount();
			p = pObj->GetHeadPosition();
			pList->InsertItem  (nCount,    (LPCTSTR)pObj->GetNext(p));
			pList->SetItemText (nCount, 1, (LPCTSTR)pObj->GetNext(p));
			pList->SetItemText (nCount, 2, (LPCTSTR)pObj->GetNext(p));
			pList->SetItemText (nCount, 3, (LPCTSTR)pObj->GetNext(p));
			pList->SetItemText (nCount, 4, (LPCTSTR)pObj->GetNext(p));
			pList->SetItemText (nCount, 5, (LPCTSTR)pObj->GetNext(p));
		}
		m_pDatabaseOutgoing->SetScrollPosListCtrl (pData->m_scrollDatabaseOutgoing);

		//
		// Per database (Incoming):
		m_pDatabaseIncoming->SetAllColumnWidth (pData->m_cxDatabaseIncoming);
		pList = &(m_pDatabaseIncoming->m_cListCtrl);
		pos = pData->m_listDatabaseIncoming.GetHeadPosition();
		while (pos != NULL)
		{
			pObj = pData->m_listDatabaseIncoming.GetNext (pos);
			ASSERT (pObj);
			ASSERT (pObj->GetCount() == 6);
			nCount = pList->GetItemCount();
			p = pObj->GetHeadPosition();
			pList->InsertItem  (nCount,    (LPCTSTR)pObj->GetNext(p));
			pList->SetItemText (nCount, 1, (LPCTSTR)pObj->GetNext(p));
			pList->SetItemText (nCount, 2, (LPCTSTR)pObj->GetNext(p));
			pList->SetItemText (nCount, 3, (LPCTSTR)pObj->GetNext(p));
			pList->SetItemText (nCount, 4, (LPCTSTR)pObj->GetNext(p));
			pList->SetItemText (nCount, 5, (LPCTSTR)pObj->GetNext(p));
		}
		m_pDatabaseIncoming->SetScrollPosListCtrl (pData->m_scrollDatabaseIncoming);
		//
		// Per database (Total):
		m_pDatabaseTotal->SetAllColumnWidth (pData->m_cxDatabaseTotal);
		pList = &(m_pDatabaseTotal->m_cListCtrl);
		pos = pData->m_listDatabaseTotal.GetHeadPosition();
		while (pos != NULL)
		{
			pObj = pData->m_listDatabaseTotal.GetNext (pos);
			ASSERT (pObj);
			ASSERT (pObj->GetCount() == 6);
			nCount = pList->GetItemCount();
			p = pObj->GetHeadPosition();
			pList->InsertItem  (nCount,    (LPCTSTR)pObj->GetNext(p));
			pList->SetItemText (nCount, 1, (LPCTSTR)pObj->GetNext(p));
			pList->SetItemText (nCount, 2, (LPCTSTR)pObj->GetNext(p));
			pList->SetItemText (nCount, 3, (LPCTSTR)pObj->GetNext(p));
			pList->SetItemText (nCount, 4, (LPCTSTR)pObj->GetNext(p));
			pList->SetItemText (nCount, 5, (LPCTSTR)pObj->GetNext(p));
		}
		m_pDatabaseTotal->SetScrollPosListCtrl (pData->m_scrollDatabaseTotal);

		//
		// Per table (Outgoing):
		m_pTableOutgoing->SetAllColumnWidth (pData->m_cxTableOutgoing);
		pList = &(m_pTableOutgoing->m_cListCtrl);
		pos = pData->m_listTableOutgoing.GetHeadPosition();
		while (pos != NULL)
		{
			pObj = pData->m_listTableOutgoing.GetNext (pos);
			ASSERT (pObj);
			ASSERT (pObj->GetCount() == 6);
			nCount = pList->GetItemCount();
			p = pObj->GetHeadPosition();
			pList->InsertItem  (nCount,    (LPCTSTR)pObj->GetNext(p));
			pList->SetItemText (nCount, 1, (LPCTSTR)pObj->GetNext(p));
			pList->SetItemText (nCount, 2, (LPCTSTR)pObj->GetNext(p));
			pList->SetItemText (nCount, 3, (LPCTSTR)pObj->GetNext(p));
			pList->SetItemText (nCount, 4, (LPCTSTR)pObj->GetNext(p));
			pList->SetItemText (nCount, 5, (LPCTSTR)pObj->GetNext(p));
		}
		m_pTableOutgoing->SetScrollPosListCtrl (pData->m_scrollTableOutgoing);
		//
		// Per table (Incoming):
		m_pTableIncoming->SetAllColumnWidth (pData->m_cxTableIncoming);
		pList = &(m_pTableIncoming->m_cListCtrl);
		pos = pData->m_listTableIncoming.GetHeadPosition();
		while (pos != NULL)
		{
			pObj = pData->m_listTableIncoming.GetNext (pos);
			ASSERT (pObj);
			ASSERT (pObj->GetCount() == 6);
			nCount = pList->GetItemCount();
			p = pObj->GetHeadPosition();
			pList->InsertItem  (nCount,    (LPCTSTR)pObj->GetNext(p));
			pList->SetItemText (nCount, 1, (LPCTSTR)pObj->GetNext(p));
			pList->SetItemText (nCount, 2, (LPCTSTR)pObj->GetNext(p));
			pList->SetItemText (nCount, 3, (LPCTSTR)pObj->GetNext(p));
			pList->SetItemText (nCount, 4, (LPCTSTR)pObj->GetNext(p));
			pList->SetItemText (nCount, 5, (LPCTSTR)pObj->GetNext(p));
		}
		m_pTableIncoming->SetScrollPosListCtrl (pData->m_scrollTableIncoming);
		//
		// Per table (Total):
		m_pTableTotal->SetAllColumnWidth (pData->m_cxTableTotal);
		pList = &(m_pTableTotal->m_cListCtrl);
		pos = pData->m_listTableTotal.GetHeadPosition();
		while (pos != NULL)
		{
			pObj = pData->m_listTableTotal.GetNext (pos);
			ASSERT (pObj);
			ASSERT (pObj->GetCount() == 6);
			nCount = pList->GetItemCount();
			p = pObj->GetHeadPosition();
			pList->InsertItem  (nCount,    (LPCTSTR)pObj->GetNext(p));
			pList->SetItemText (nCount, 1, (LPCTSTR)pObj->GetNext(p));
			pList->SetItemText (nCount, 2, (LPCTSTR)pObj->GetNext(p));
			pList->SetItemText (nCount, 3, (LPCTSTR)pObj->GetNext(p));
			pList->SetItemText (nCount, 4, (LPCTSTR)pObj->GetNext(p));
			pList->SetItemText (nCount, 5, (LPCTSTR)pObj->GetNext(p));
		}	
		m_pTableTotal->SetScrollPosListCtrl (pData->m_scrollTableTotal);
		DisplayPage (pData->m_nCurrentPage);
	}
	catch (CMemoryException* e)
	{
		theApp.OutOfMemoryMessage();
		e->Delete();
	}
	return 0L;
}
예제 #30
0
//*************************************************************************************************
BOOL CBCGPMousePage::OnInitDialog() 
{
	ASSERT (g_pMouseManager != NULL);

	CPropertyPage::OnInitDialog();

	CStringList listOfViewNames;
	g_pMouseManager->GetViewNames (listOfViewNames);

	//-------------------
	// Create image list:
	//-------------------
	if (!m_ViewsImages.Create (	globalData.m_sizeSmallIcon.cx,
								globalData.m_sizeSmallIcon.cy,
								ILC_COLOR | ILC_MASK, 
								(int) listOfViewNames.GetCount (), 1))
	{
		ASSERT (FALSE);
	}

	m_wndListOfViews.SetImageList (&m_ViewsImages, LVSIL_SMALL);

	POSITION pos;
	
	//-----------------
	// Fill views list:
	//-----------------
	CRect rect;
	m_wndListOfViews.GetClientRect (&rect);
	m_wndListOfViews.InsertColumn (0, _T(""), LVCFMT_LEFT, rect.Width () - 1);

	ASSERT (!listOfViewNames.IsEmpty ());

	int iMaxWidth = 0;

	for (pos = listOfViewNames.GetHeadPosition (); pos != NULL;)
	{
		CString strViewName = listOfViewNames.GetNext (pos);
		
		int iImageIndex = -1;

		//---------------
		// Add view icon:
		//---------------
		UINT uiViewIconId = g_pMouseManager->GetViewIconId (
			g_pMouseManager->GetViewIdByName (strViewName));

		HICON hViewIcon;
		if (uiViewIconId != 0 &&
			(hViewIcon = AfxGetApp ()->LoadIcon (uiViewIconId)) != NULL)
		{
			iImageIndex = m_ViewsImages.Add (hViewIcon);
			::DestroyIcon (hViewIcon);
		}

		int iIndex = m_wndListOfViews.GetItemCount ();
		for (int i = 0; i < m_wndListOfViews.GetItemCount (); i ++)
		{
			CString strText = m_wndListOfViews.GetItemText (i, 0);
			if (strText > strViewName)
			{
				iIndex = i;
				break;
			}
		}

		m_wndListOfViews.InsertItem (iIndex, strViewName, iImageIndex);
		m_wndListOfViews.SetItemData (iIndex, 
			(DWORD) g_pMouseManager->GetViewIdByName (strViewName));

		int iStrWidth = m_wndListOfViews.GetStringWidth (strViewName);
		iMaxWidth = max (iStrWidth, iMaxWidth);
	}

	//----------------------------------
	// Add icon width pluse some pixels:
	//----------------------------------
	IMAGEINFO info;
	m_ViewsImages.GetImageInfo (0, &info);
	CRect rectImage = info.rcImage;

	iMaxWidth += rectImage.Width () + 10;
	m_wndListOfViews.SetColumnWidth (0, iMaxWidth);

	//--------------------
	// Fill commands list:
	//--------------------
	CBCGPToolbarCustomize* pWndParent = DYNAMIC_DOWNCAST (CBCGPToolbarCustomize, GetParent ());
	ASSERT (pWndParent != NULL);

	pWndParent->FillAllCommandsList (m_wndListOfCommands);

	//-----------------------	
	// Select the first view:
	//-----------------------
	m_wndListOfViews.SetItemState  (0, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
	m_wndListOfViews.EnsureVisible (0, FALSE);

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}