void CGroupPackFileDownloadWnd::Notify(TNotifyUI& msg)
{
	if (_tcsicmp(msg.sType, _T("click")) == 0)
	{
		CDuiString strControlName = msg.pSender->GetName();

		//关闭界面
		if (_tcsicmp(msg.pSender->GetName(), "btn_close_downloadwnd") == 0)
		{
// 			if (NULL != m_hMainWnd)
// 			{
// 				::SendMessage(m_hMainWnd, WM_GROUPDOWNLOAD_PACKFILE_CLOSED, 0, 0);
// 			}
// 
// 			Close();
			ShowWindow(false);
		}
		//下载 所有文件
		else if (_tcsicmp(msg.pSender->GetName(), "btn_download_packfiles") == 0)
		{
			if (  IsDownLoading() || m_bDownloaded)
			{
				return;
			}
			
			sPackReadReceipt* pPackReadReceipt = new sPackReadReceipt();
			pPackReadReceipt->strPackID = m_pCurrPackItem->strPackID;
			pPackReadReceipt->strRoomName = m_strRoomID ;
			pPackReadReceipt->strFrom =  CController::Instance()->GetXmppClient()->jid().username();
			pPackReadReceipt->strPackName = m_pCurrPackItem->strPackName;
			pPackReadReceipt->strAttribute = m_pCurrPackItem->strPackProp;

			SYSTEMTIME sysTime;
			::GetLocalTime(&sysTime);
			char* pTime = new char[128];
			sprintf(pTime,"%4d/%02d/%02d %02d:%02d:%02d.%03d 星期%1d",sysTime.wYear,sysTime.wMonth,sysTime.wDay,sysTime.wHour,sysTime.wMinute, sysTime.wSecond,sysTime.wMilliseconds,sysTime.wDayOfWeek);

			pPackReadReceipt->strTime = pTime;

			::SendMessage(mainDlg::getInstance()->GetHWND(), WM_GROUPDOWNLOAD_PACKFILE_DOWNLOADED, (WPARAM)pPackReadReceipt, 0);
 			
			OnDownLoadPackFiles();
		}
		//打开文件所在位置
		else if (_tcsicmp(msg.pSender->GetName(), "btn_open_downloaded_packfiles") == 0)
		{
			if (NULL != m_pCurrPackItem)
			{
				tstring strPackDir = CFileHelper::GetPackDir(m_pCurrPackItem->strPackName, m_pCurrPackItem->strPackID);
				if (!strPackDir.empty())
				{
					ShellExecute(NULL, NULL, strPackDir.c_str(), NULL,NULL,SW_SHOWNORMAL);
				}
			}
		}
		//打开,已下载文件
		else if (_tcsicmp(msg.pSender->GetName(), "btn_open_downloaded_file") == 0)
		{
			CContainerUI* pListItem  = static_cast<CContainerUI*>(msg.pSender->GetParent());
			if (NULL != pListItem)
			{
				char* pBuff = (char*)pListItem->GetTag();
				tstring strLocalFullFileName = pBuff;
				if (!strLocalFullFileName.empty())
				{
					ShellExecute(NULL, NULL, strLocalFullFileName.c_str(), NULL,NULL,SW_SHOWNORMAL);
				}
			}
		}
	}
	else if(_tcsicmp(msg.sType, _T("itemclick")) == 0)
	{
		//HandleItemClickEvent(msg);		
	}
	else if (_tcsicmp(msg.sType, _T("itemselect")) == 0)
	{
		
	}
	else if(_tcsicmp(msg.sType, _T("selectchanged")) == 0)
	{
		int bac=100;
	}
}
	void CHorizontalLayoutUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue)
	{
		if( _tcsicmp(pstrName, _T("sepwidth")) == 0 ) SetSepWidth(_ttoi(pstrValue));
		else if( _tcsicmp(pstrName, _T("sepimm")) == 0 ) SetSepImmMode(_tcsicmp(pstrValue, _T("true")) == 0);
		else CContainerUI::SetAttribute(pstrName, pstrValue);
	}
	void CAnimationTabLayoutUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue)
	{
		if( _tcsicmp(pstrName, _T("animation_direction")) == 0 && _tcsicmp( pstrValue, _T("vertical")) == 0 ) m_bIsVerticalDirection = true; // pstrValue = "vertical" or "horizontal"
		return CTabLayoutUI::SetAttribute(pstrName, pstrValue);
	}
void CHttpDownloadDlg::DownloadThread()
{
	ENCODING_INIT;
	//Create the Internet session handle
	ASSERT(m_hInternetSession == NULL);
	m_hInternetSession = ::InternetOpen(AfxGetAppName(), INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
	if (m_hInternetSession == NULL)
	{
		TRACE(_T("Failed in call to InternetOpen, Error:%d\n"), ::GetLastError());
		HandleThreadErrorWithLastError(GetResString(IDS_HTTPDOWNLOAD_GENERIC_ERROR));
		return;
	}

	//Should we exit the thread
	if (m_bAbort)
	{
		PostMessage(WM_HTTPDOWNLOAD_THREAD_FINISHED);
		return;
	}  

	//Setup the status callback function
	if (::InternetSetStatusCallback(m_hInternetSession, _OnStatusCallBack) == INTERNET_INVALID_STATUS_CALLBACK)
	{
		TRACE(_T("Failed in call to InternetSetStatusCallback, Error:%d\n"), ::GetLastError());
		HandleThreadErrorWithLastError(GetResString(IDS_HTTPDOWNLOAD_GENERIC_ERROR));
		return;
	}

	//Should we exit the thread
	if (m_bAbort)
	{
		PostMessage(WM_HTTPDOWNLOAD_THREAD_FINISHED);
		return;
	}

	//Make the connection to the HTTP server
	ASSERT(m_hHttpConnection == NULL);
	if (m_sUserName.GetLength())
		// Elandal: Assumes sizeof(void*) == sizeof(unsigned long)
		m_hHttpConnection = ::InternetConnect(m_hInternetSession, m_sServer, m_nPort, m_sUserName, 
                                          m_sPassword, m_dwServiceType, 0, (DWORD) this);
	else
		// Elandal: Assumes sizeof(void*) == sizeof(unsigned long)
		m_hHttpConnection = ::InternetConnect(m_hInternetSession, m_sServer, m_nPort, NULL, 
                                          NULL, m_dwServiceType, 0, (DWORD) this);
	if (m_hHttpConnection == NULL)
	{
		TRACE(_T("Failed in call to InternetConnect, Error:%d\n"), ::GetLastError());
		HandleThreadErrorWithLastError(GetResString(IDS_HTTPDOWNLOAD_FAIL_CONNECT_SERVER));
		return;
	}

	//Should we exit the thread
	if (m_bAbort)
	{
		PostMessage(WM_HTTPDOWNLOAD_THREAD_FINISHED);
		return;
	}

	//Start the animation to signify that the download is taking place
	PlayAnimation();

	//Issue the request to read the file
	LPCTSTR ppszAcceptTypes[2];
	ppszAcceptTypes[0] = _T("*/*");  //We support accepting any mime file type since this is a simple download of a file
	ppszAcceptTypes[1] = NULL;
	ASSERT(m_hHttpFile == NULL);
	// Elandal: Assumes sizeof(void*) == sizeof(unsigned long)
	m_hHttpFile = HttpOpenRequest(m_hHttpConnection, NULL, m_sObject, NULL, NULL, ppszAcceptTypes, INTERNET_FLAG_RELOAD | 
								  INTERNET_FLAG_DONT_CACHE | INTERNET_FLAG_KEEP_CONNECTION, (DWORD)this);
	if (m_hHttpFile == NULL)
	{
		TRACE(_T("Failed in call to HttpOpenRequest, Error:%d\n"), ::GetLastError());
		HandleThreadErrorWithLastError(GetResString(IDS_HTTPDOWNLOAD_FAIL_CONNECT_SERVER));
		return;
	}

	//Should we exit the thread
	if (m_bAbort)
	{
		PostMessage(WM_HTTPDOWNLOAD_THREAD_FINISHED);
		return;
	}

	//fill in what encoding we support
	HttpAddRequestHeaders(m_hHttpFile, ACCEPT_ENCODING_HEADER, (DWORD)-1L, HTTP_ADDREQ_FLAG_ADD);

//label used to jump to if we need to resend the request
resend:

	//Issue the request
	BOOL bSend = ::HttpSendRequest(m_hHttpFile, NULL, 0, NULL, 0);
	if (!bSend)
	{
		TRACE(_T("Failed in call to HttpSendRequest, Error:%d\n"), ::GetLastError());
		HandleThreadErrorWithLastError(GetResString(IDS_HTTPDOWNLOAD_FAIL_CONNECT_SERVER));
		return;
	}

	//Check the HTTP status code
	TCHAR szStatusCode[32];
	DWORD dwInfoSize = 32;
	if (!HttpQueryInfo(m_hHttpFile, HTTP_QUERY_STATUS_CODE, szStatusCode, &dwInfoSize, NULL))
	{
		TRACE(_T("Failed in call to HttpQueryInfo for HTTP query status code, Error:%d\n"), ::GetLastError());
		HandleThreadError(GetResString(IDS_HTTPDOWNLOAD_INVALID_SERVER_RESPONSE));
		return;
	}
	else
	{
		long nStatusCode = _ttol(szStatusCode);

		//Handle any authentication errors
		if (nStatusCode == HTTP_STATUS_PROXY_AUTH_REQ || nStatusCode == HTTP_STATUS_DENIED)
		{
			// We have to read all outstanding data on the Internet handle
			// before we can resubmit request. Just discard the data.
			char szData[51];
			DWORD dwSize;
			do
			{
				::InternetReadFile(m_hHttpFile, (LPVOID)szData, 50, &dwSize);
			}
			while (dwSize != 0);

			//Bring up the standard authentication dialog
			if (::InternetErrorDlg(GetSafeHwnd(), m_hHttpFile, ERROR_INTERNET_INCORRECT_PASSWORD, FLAGS_ERROR_UI_FILTER_FOR_ERRORS |
                             FLAGS_ERROR_UI_FLAGS_GENERATE_DATA | FLAGS_ERROR_UI_FLAGS_CHANGE_OPTIONS, NULL) == ERROR_INTERNET_FORCE_RETRY)
				goto resend;
		}
		else if (nStatusCode != HTTP_STATUS_OK)
		{
			TRACE(_T("Failed to retrieve a HTTP 200 status, Status Code:%d\n"), nStatusCode);
			HandleThreadErrorWithLastError(GetResString(IDS_HTTPDOWNLOAD_INVALID_HTTP_RESPONSE), nStatusCode);
			return;
		}
	}

	//Check to see if any encodings are supported
	//  ENCODING_QUERY;
	TCHAR szContentEncoding[32];
	DWORD dwEncodeStringSize = 32;
	if(::HttpQueryInfo(m_hHttpFile, HTTP_QUERY_CONTENT_ENCODING, szContentEncoding, &dwEncodeStringSize, NULL))
	{
		if(!_tcsicmp(szContentEncoding, _T("gzip")) || !_tcsicmp(szContentEncoding, _T("x-gzip")))
			bEncodedWithGZIP = TRUE;
	}

	//Update the status control to reflect that we are getting the file information
	SetStatus(GetResString(IDS_HTTPDOWNLOAD_GETTING_FILE_INFORMATION));

	// Get the length of the file.
	TCHAR szContentLength[32];
	dwInfoSize = 32;
	DWORD dwFileSize = 0;
	BOOL bGotFileSize = FALSE;
	if (::HttpQueryInfo(m_hHttpFile, HTTP_QUERY_CONTENT_LENGTH, szContentLength, &dwInfoSize, NULL))
	{
		//Set the progress control range
		bGotFileSize = TRUE;
		dwFileSize = (DWORD) _ttol(szContentLength);
		SetProgressRange(dwFileSize);
	}

	//Update the status to say that we are now downloading the file
	SetStatus(GetResString(IDS_HTTPDOWNLOAD_RETREIVEING_FILE));

	//Now do the actual read of the file
	DWORD dwStartTicks = ::GetTickCount();
	DWORD dwCurrentTicks = dwStartTicks;
	DWORD dwBytesRead = 0;
	char szReadBuf[1024];
	DWORD dwBytesToRead = 1024;
	DWORD dwTotalBytesRead = 0;
	DWORD dwLastTotalBytes = 0;
	DWORD dwLastPercentage = 0;

	PREPARE_DECODER;
	do
	{
		if (!::InternetReadFile(m_hHttpFile, szReadBuf, dwBytesToRead, &dwBytesRead))
		{
			TRACE(_T("Failed in call to InternetReadFile, Error:%d\n"), ::GetLastError());
			HandleThreadErrorWithLastError(GetResString(IDS_HTTPDOWNLOAD_ERROR_READFILE));
			return;
		}
		else if (dwBytesRead && !m_bAbort)
		{
			//Write the data to file
			TRY
			{
				DECODE_DATA(m_FileToWrite, szReadBuf, dwBytesRead);
			}
			CATCH(CFileException, e);
			{
				TRACE(_T("An exception occured while writing to the download file\n"));
				HandleThreadErrorWithLastError(GetResString(IDS_HTTPDOWNLOAD_ERROR_READFILE), e->m_lOsError);
				e->Delete();
				//clean up any encoding data before we return
				ENCODING_CLEAN_UP;
				return;
			}
			END_CATCH

			//Increment the total number of bytes read
			dwTotalBytesRead += dwBytesRead;  

			UpdateControlsDuringTransfer(dwStartTicks, dwCurrentTicks, dwTotalBytesRead, dwLastTotalBytes, 
                                     dwLastPercentage, bGotFileSize, dwFileSize);
		}
	}
	while (dwBytesRead && !m_bAbort);

	//Delete the file being downloaded to if it is present and the download was aborted
	m_FileToWrite.Close();
	if (m_bAbort)
		::DeleteFile(m_sFileToDownloadInto);

	//clean up any encoding data before we return
	ENCODING_CLEAN_UP;;

	//We're finished
	PostMessage(WM_HTTPDOWNLOAD_THREAD_FINISHED);
}
Beispiel #5
0
static void fillListBox()
{
	WIN32_FIND_DATA wfd;
	HANDLE hSearch;
	FILE* fp = NULL;

	TCHAR szFilePath[MAX_PATH];
	TCHAR szFilePathSearch[MAX_PATH];
	TCHAR szFileName[MAX_PATH];
	TCHAR PatchName[MAX_PATH];

	int nHandlePos = 0;
	int nNumNodes = 0;

	nPatchIndex = 0;
	nNumPatches = 0;

	TVINSERTSTRUCT TvItem;
	memset(&TvItem, 0, sizeof(TvItem));
	TvItem.item.mask = TVIF_TEXT | TVIF_PARAM;
	TvItem.hInsertAfter = TVI_LAST;

	_stprintf(szFilePath, _T("%s%s\\"), getMiscPath(PATH_IPS), BurnDrvGetText(DRV_NAME));
	_stprintf(szFilePathSearch, _T("%s*.dat"), szFilePath);

	hSearch = FindFirstFile(szFilePathSearch, &wfd);

	if (hSearch != INVALID_HANDLE_VALUE) {
		int Done = 0;

		while (!Done) {
			memset(szFileName, '\0', MAX_PATH);
			_stprintf(szFileName, _T("%s%s"), szFilePath, wfd.cFileName);

			fp = _tfopen(szFileName, _T("r"));
			if (fp) {
				memset(PatchName, '\0', MAX_PATH);

				TCHAR* PatchDesc = getPatchDescByLangcode(fp, nPatchLang);
				// If not available - try English first
				if (PatchDesc == NULL) {
					PatchDesc = getPatchDescByLangcode(fp, 0);
					// Simplified Chinese is the reference language
					if (PatchDesc == NULL) {
						PatchDesc = getPatchDescByLangcode(fp, 1);
					}
				}
				if (PatchDesc == NULL) {
					fclose(fp);
					break;
				}

				for (unsigned int i = 0; i < _tcslen(PatchDesc); i++) {
					if (PatchDesc[i] == '\r' || PatchDesc[i] == '\n') {
						break;
					}
					PatchName[i] = PatchDesc[i];
				}

				// Check for categories
				int nNumTokens = 0;
				TCHAR szCategory[MAX_PATH];
				TCHAR tempText[MAX_PATH];
				TCHAR itemName[MAX_PATH] = _T("");
				TVITEM Tvi;
				size_t nPatchNameLength = _tcslen(PatchName);

				TCHAR* Tokens = _tcstok(PatchName, _T("/"));
				while (Tokens != NULL) {
					if (nNumTokens == 0) {
						bool bAddItem = true;

						// Check if item already exists
						nNumNodes = TreeView_GetCount(hIpsList);
						for (int i = 0; i < nNumNodes; i++) {
							memset(&Tvi, 0, sizeof(Tvi));
							Tvi.hItem = hItemHandles[i];
							Tvi.mask = TVIF_TEXT | TVIF_HANDLE;
							Tvi.pszText = tempText;
							Tvi.cchTextMax = MAX_PATH;
							TreeView_GetItem(hIpsList, &Tvi);

							if (!_tcsicmp(Tvi.pszText, Tokens)) {
								bAddItem = false; // item exists, don't add it
								break;
							}
						}

						// add category
						if (bAddItem) {
							TvItem.hParent = TVI_ROOT;
							TvItem.item.pszText = Tokens;
							hItemHandles[nHandlePos] = TreeView_InsertItem(hIpsList, &TvItem);

							nHandlePos++;
							if (nHandlePos >= MAX_NODES) {
								nHandlePos = MAX_NODES - 1;
							}
						}

						if (_tcslen(Tokens) == nPatchNameLength) {
							saveDatName(nPatchIndex, wfd.cFileName);
							hPatchHandlesIndex[nPatchIndex] = hItemHandles[nHandlePos - 1];
							_tcscpy(szPatchFileNames[nPatchIndex], szFileName);

							nPatchIndex++;
							if (nPatchIndex >= MAX_NODES) {
								nPatchIndex = MAX_NODES - 1;
							}
						}

						_tcscpy(szCategory, Tokens);
					} else {
						HTREEITEM hNode = TVI_ROOT;
						// See which category we should be in
						nNumNodes = TreeView_GetCount(hIpsList);
						for (int i = 0; i < nNumNodes; i++) {
							memset(&Tvi, 0, sizeof(Tvi));
							Tvi.hItem = hItemHandles[i];
							Tvi.mask = TVIF_TEXT | TVIF_HANDLE;
							Tvi.pszText = tempText;
							Tvi.cchTextMax = MAX_PATH;
							TreeView_GetItem(hIpsList, &Tvi);

							if (!_tcsicmp(Tvi.pszText, szCategory)) {
								hNode = Tvi.hItem;
								break;
							}
						}

						// add ips items
						saveDatName(nPatchIndex, wfd.cFileName);
						_stprintf(itemName, _T("%s [%s]"), Tokens, wfd.cFileName);
						TvItem.hParent = hNode;
						TvItem.item.pszText = itemName;
						hItemHandles[nHandlePos] = TreeView_InsertItem(hIpsList, &TvItem);

						hPatchHandlesIndex[nPatchIndex] = hItemHandles[nHandlePos];
						_tcscpy(szPatchFileNames[nPatchIndex], szFileName);

						nHandlePos++;
						if (nHandlePos >= MAX_NODES) {
							nHandlePos = MAX_NODES - 1;
						}
						nPatchIndex++;
						if (nPatchIndex >= MAX_NODES) {
							nPatchIndex = MAX_NODES - 1;
						}
					}

					Tokens = _tcstok(NULL, _T("/"));
					nNumTokens++;
				}

				fclose(fp);
			}

			Done = !FindNextFile(hSearch, &wfd);
		}

		FindClose(hSearch);
	}

	nNumPatches = nPatchIndex;

	// Expand all branches
	nNumNodes = TreeView_GetCount(hIpsList);
	for (int i = 0; i < nNumNodes; i++) {
		TreeView_Expand(hIpsList, hItemHandles[i], TVE_EXPAND);
	}
}
Beispiel #6
0
	LPVOID CComboUI::GetInterface(LPCTSTR pstrName)
	{
		if( _tcsicmp(pstrName, DUI_CTR_COMBO) == 0 ) return static_cast<CComboUI*>(this);
		if( _tcsicmp(pstrName, _T("IListOwner")) == 0 ) return static_cast<IListOwnerUI*>(this);
		return CContainerUI::GetInterface(pstrName);
	}
Beispiel #7
0
	void CTabLayoutUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue)
	{
		if( _tcsicmp(pstrName, _T("selectedid")) == 0 ) SelectItem(_ttoi(pstrValue));
		return CContainerUI::SetAttribute(pstrName, pstrValue);
	}
BOOL CAlbumFolder::OrganiseFile(CLibraryFile* pFile)
{
	BOOL bResult = FALSE;

	if ( m_sSchemaURI == CSchema::uriAllFiles )
	{
		AddFile( pFile );
		return TRUE;
	}

	if ( m_bCollSHA1 && ( m_pCollection != NULL || GetCollection() ) )
	{
		if ( m_pCollSHA1 == pFile->m_pSHA1 ||
			 m_pCollection->FindFile( pFile, TRUE ) )
		{
			AddFile( pFile );
			return TRUE;
		}
		else
		{
			return FALSE;
		}
	}

	if ( pFile->m_pMetadata == NULL && m_pParent != NULL ) return FALSE;

	if ( m_sSchemaURI == CSchema::uriMusicRoot )
	{
		if ( ! pFile->IsSchemaURI( CSchema::uriAudio ) ) return FALSE;
	}
	else if ( m_sSchemaURI == CSchema::uriMusicAlbumCollection )
	{
		if ( ! pFile->IsSchemaURI( CSchema::uriAudio ) ) return FALSE;

		CString strAlbum = pFile->m_pMetadata->GetAttributeValue( _T("album") );
		CXMLNode::UniformString( strAlbum );

		if ( strAlbum.IsEmpty() ) return FALSE;
		if ( _tcsicmp( strAlbum, _T("tba") ) == 0 ) return FALSE;
		if ( _tcsicmp( strAlbum, _T("na") ) == 0 ) return FALSE;
		if ( _tcsicmp( strAlbum, _T("n/a") ) == 0 ) return FALSE;
		if ( _tcsicmp( strAlbum, _T("none") ) == 0 ) return FALSE;
		if ( _tcsicmp( strAlbum, _T("empty") ) == 0 ) return FALSE;
		if ( _tcsicmp( strAlbum, _T("unknown") ) == 0 ) return FALSE;
		if ( _tcsistr( strAlbum, _T("uploaded by") ) ) return FALSE;
		if ( _tcsistr( strAlbum, _T("ripped by") ) ) return FALSE;
		if ( _tcsistr( strAlbum, _T("downloaded") ) ) return FALSE;
		if ( _tcsistr( strAlbum, _T("http") ) ) return FALSE;
		if ( _tcsistr( strAlbum, _T("mp3") ) ) return FALSE;
		if ( _tcsistr( strAlbum, _T("www.mp3sfinder.com") ) ) return FALSE;
		if ( _tcsistr( strAlbum, _T("single") ) ) strAlbum = _T("Singles");

		for ( POSITION pos = GetFolderIterator() ; pos ; )
		{
			CAlbumFolder* pAlbum = GetNextFolder( pos );

			if ( pAlbum->m_sName.CompareNoCase( strAlbum ) == 0 )
			{
				bResult = pAlbum->OrganiseFile( pFile );
			}
			else if ( pAlbum->m_bAutoDelete )
			{
				pAlbum->RemoveFile( pFile );
			}
		}

		if ( bResult ) return TRUE;

		CAlbumFolder* pAlbum = AddFolder( CSchema::uriMusicAlbum, strAlbum, TRUE );

		return pAlbum->OrganiseFile( pFile );
	}
	else if ( m_sSchemaURI == CSchema::uriMusicAlbum )
	{
		if ( ! pFile->IsSchemaURI( CSchema::uriAudio ) ) return FALSE;

		CString strAlbum = pFile->m_pMetadata->GetAttributeValue( _T("album") );
		CXMLNode::UniformString( strAlbum );
		if ( _tcsistr( strAlbum, _T("single") ) ) strAlbum = _T("Singles");
		if ( strAlbum.CompareNoCase( m_sName ) ) return FALSE;

		AddFile( pFile );

		if ( _tcsistr( m_sName, _T("soundtrack") ) != NULL ||
			 _tcsistr( m_sName, _T("ost") ) != NULL )
		{
			// TODO: Scrap artist specific info !
			MetaFromFile( pFile );
		}
		else
		{
			MetaFromFile( pFile );
		}

		return TRUE;
	}
	else if ( m_sSchemaURI == CSchema::uriMusicArtistCollection )
	{
		if ( ! pFile->IsSchemaURI( CSchema::uriAudio ) ) return FALSE;

		CString strArtist = pFile->m_pMetadata->GetAttributeValue( _T("artist") );
		CXMLNode::UniformString( strArtist );

		Replace( strArtist, _T(" (www.mp3sfinder.com)"), _T("") );
		if ( strArtist.IsEmpty() ) return FALSE;

		for ( POSITION pos = GetFolderIterator() ; pos ; )
		{
			CAlbumFolder* pAlbum = GetNextFolder( pos );

			if ( pAlbum->m_sName.CompareNoCase( strArtist ) == 0 )
			{
				bResult = pAlbum->OrganiseFile( pFile );
			}
			else if ( pAlbum->m_bAutoDelete )
			{
				pAlbum->RemoveFile( pFile );
			}
		}

		if ( bResult ) return TRUE;

		CAlbumFolder* pAlbum = AddFolder( CSchema::uriMusicArtist, strArtist, TRUE );

		return pAlbum->OrganiseFile( pFile );
	}
	else if ( m_sSchemaURI == CSchema::uriMusicArtist )
	{
		if ( ! pFile->IsSchemaURI( CSchema::uriAudio ) ) return FALSE;

		CString strArtist = pFile->m_pMetadata->GetAttributeValue( _T("artist") );
		CXMLNode::UniformString( strArtist );
		if ( strArtist.CompareNoCase( m_sName ) ) return FALSE;

		AddFile( pFile );
		MetaFromFile( pFile );

		return TRUE;
	}
	else if ( m_sSchemaURI == CSchema::uriMusicGenreCollection )
	{
		if ( ! pFile->IsSchemaURI( CSchema::uriAudio ) ) return FALSE;

		CString strGenre = pFile->m_pMetadata->GetAttributeValue( _T("genre") );
		if ( strGenre.IsEmpty() ) return FALSE;

		for ( POSITION pos = GetFolderIterator() ; pos ; )
		{
			CAlbumFolder* pAlbum = GetNextFolder( pos );

			if ( pAlbum->m_sName.CompareNoCase( strGenre ) == 0 )
			{
				bResult = pAlbum->OrganiseFile( pFile );
			}
			else if ( pAlbum->m_bAutoDelete )
			{
				pAlbum->RemoveFile( pFile );
			}
		}

		if ( bResult ) return TRUE;

		CAlbumFolder* pAlbum = AddFolder( CSchema::uriMusicGenre, strGenre, TRUE );

		return pAlbum->OrganiseFile( pFile );
	}
	else if ( m_sSchemaURI == CSchema::uriMusicGenre )
	{
		if ( ! pFile->IsSchemaURI( CSchema::uriAudio ) ) return FALSE;

		CString strGenre = pFile->m_pMetadata->GetAttributeValue( _T("genre") );
		if ( strGenre.CompareNoCase( m_sName ) ) return FALSE;

		AddFile( pFile );
		MetaFromFile( pFile );

		return TRUE;
	}
	else if ( m_sSchemaURI == CSchema::uriMusicAll )
	{
		if ( ! pFile->IsSchemaURI( CSchema::uriAudio ) ) return FALSE;
		AddFile( pFile );
		return TRUE;
	}
	else if ( m_sSchemaURI == CSchema::uriVideoRoot )
	{
		if ( ! pFile->IsSchemaURI( CSchema::uriVideo ) ) return FALSE;
	}
	else if ( m_sSchemaURI == CSchema::uriVideoSeriesCollection )
	{
		if ( ! pFile->IsSchemaURI( CSchema::uriVideo ) ) return FALSE;

		CString strSeries = pFile->m_pMetadata->GetAttributeValue( _T("series") );
		CXMLNode::UniformString( strSeries );
		if ( strSeries.IsEmpty() ) return FALSE;

		for ( POSITION pos = GetFolderIterator() ; pos ; )
		{
			CAlbumFolder* pAlbum = GetNextFolder( pos );

			if ( pAlbum->m_sName.CompareNoCase( strSeries ) == 0 )
			{
				bResult = pAlbum->OrganiseFile( pFile );
			}
			else if ( pAlbum->m_bAutoDelete )
			{
				pAlbum->RemoveFile( pFile );
			}
		}

		if ( bResult ) return TRUE;

		CAlbumFolder* pAlbum = AddFolder( CSchema::uriVideoSeries, strSeries, TRUE );

		return pAlbum->OrganiseFile( pFile );
	}
	else if ( m_sSchemaURI == CSchema::uriVideoSeries )
	{
		if ( ! pFile->IsSchemaURI( CSchema::uriVideo ) ) return FALSE;

		CString strSeries = pFile->m_pMetadata->GetAttributeValue( _T("series") );
		CXMLNode::UniformString( strSeries );
		if ( strSeries.CompareNoCase( m_sName ) ) return FALSE;

		AddFile( pFile );
		MetaFromFile( pFile );

		return TRUE;
	}
	else if ( m_sSchemaURI == CSchema::uriVideoFilmCollection )
	{
		if ( ! pFile->IsSchemaURI( CSchema::uriVideo ) ) return FALSE;

		CString strType = pFile->m_pMetadata->GetAttributeValue( _T("type") );
		if ( strType.CompareNoCase( _T("film") ) ) return FALSE;

		CString strTitle = pFile->m_pMetadata->GetAttributeValue( _T("title") );
		CXMLNode::UniformString( strTitle );
		if ( strTitle.IsEmpty() ) return FALSE;

		for ( POSITION pos = GetFolderIterator() ; pos ; )
		{
			CAlbumFolder* pAlbum = GetNextFolder( pos );

			if ( pAlbum->m_sName.CompareNoCase( strTitle ) == 0 )
			{
				bResult = pAlbum->OrganiseFile( pFile );
			}
			else if ( pAlbum->m_bAutoDelete )
			{
				pAlbum->RemoveFile( pFile );
			}
		}

		if ( bResult ) return TRUE;

		CAlbumFolder* pAlbum = AddFolder( CSchema::uriVideoFilm, strTitle, TRUE );

		return pAlbum->OrganiseFile( pFile );
	}
	else if ( m_sSchemaURI == CSchema::uriVideoFilm )
	{
		if ( ! pFile->IsSchemaURI( CSchema::uriVideo ) ) return FALSE;

		CString strType = pFile->m_pMetadata->GetAttributeValue( _T("type") );
		if ( strType.CompareNoCase( _T("film") ) ) return FALSE;

		CString strTitle = pFile->m_pMetadata->GetAttributeValue( _T("title") );
		CXMLNode::UniformString( strTitle );
		if ( strTitle.CompareNoCase( m_sName ) ) return FALSE;

		AddFile( pFile );
		MetaFromFile( pFile );

		return TRUE;
	}
	else if ( m_sSchemaURI == CSchema::uriVideoMusicCollection )
	{
		if ( ! pFile->IsSchemaURI( CSchema::uriVideo ) ) return FALSE;

		CString strType = pFile->m_pMetadata->GetAttributeValue( _T("type") );
		if ( strType.CompareNoCase( _T("music video") ) ) return FALSE;

		AddFile( pFile );

		return TRUE;
	}
	else if ( m_sSchemaURI == CSchema::uriVideoAll )
	{
		if ( ! pFile->IsSchemaURI( CSchema::uriVideo ) ) return FALSE;
		AddFile( pFile );
		return TRUE;
	}
	else if ( m_sSchemaURI == CSchema::uriImageRoot )
	{
		if ( ! pFile->IsSchemaURI( CSchema::uriImage ) ) return FALSE;
	}
	else if ( m_sSchemaURI == CSchema::uriImageAll )
	{
		if ( ! pFile->IsSchemaURI( CSchema::uriImage ) ) return FALSE;
		AddFile( pFile );
		return TRUE;
	}
	else if ( m_sSchemaURI == CSchema::uriApplicationRoot )
	{
		if ( ! pFile->IsSchemaURI( CSchema::uriApplication ) ) return FALSE;
	}
	else if ( m_sSchemaURI == CSchema::uriApplicationAll )
	{
		if ( ! pFile->IsSchemaURI( CSchema::uriApplication ) ) return FALSE;
		AddFile( pFile );
		return TRUE;
	}
	else if ( m_sSchemaURI == CSchema::uriBookRoot )
	{
		if ( ! pFile->IsSchemaURI( CSchema::uriBook ) ) return FALSE;
	}
	else if ( m_sSchemaURI == CSchema::uriBookAll )
	{
		if ( ! pFile->IsSchemaURI( CSchema::uriBook ) ) return FALSE;
		AddFile( pFile );
		return TRUE;
	}
	else if ( m_sSchemaURI == CSchema::uriDocumentRoot )
	{
		if ( ! pFile->IsSchemaURI( CSchema::uriDocument ) &&
			 ! pFile->IsSchemaURI( CSchema::uriSpreadsheet ) &&
			 ! pFile->IsSchemaURI( CSchema::uriPresentation ) ) return FALSE;
	}
	else if ( m_sSchemaURI == CSchema::uriDocumentAll )
	{
		if ( ! pFile->IsSchemaURI( CSchema::uriDocument ) &&
			 ! pFile->IsSchemaURI( CSchema::uriSpreadsheet ) &&
			 ! pFile->IsSchemaURI( CSchema::uriPresentation ) ) return FALSE;
		AddFile( pFile );
		return TRUE;
	}

	for ( POSITION pos = GetFolderIterator() ; pos ; )
	{
		bResult |= GetNextFolder( pos )->OrganiseFile( pFile );
	}

	return bResult;
}
Beispiel #9
0
void ChatDialog::Notify(TNotifyUI& msg)
{
	if (_tcsicmp(msg.sType.GetData(), _T("windowinit")) == 0)
	{
		OnPrepare(msg);
	}
	else if (_tcsicmp(msg.sType.GetData(), _T("killfocus")) == 0)
	{
	}
	else if (_tcsicmp(msg.sType.GetData(), _T("click")) == 0)
	{
		if (_tcsicmp(msg.pSender->GetName().GetData(), kCloseButtonControlName) == 0)
		{
			OnExit(msg);
		}
		else if (_tcsicmp(msg.pSender->GetName().GetData(), kMinButtonControlName) == 0)
		{
#if defined(UNDER_CE)
			::ShowWindow(m_hWnd, SW_MINIMIZE);
#else
			SendMessage(WM_SYSCOMMAND, SC_MINIMIZE, 0);
#endif
		}
		else if (_tcsicmp(msg.pSender->GetName().GetData(), kMaxButtonControlName) == 0)
		{
#if defined(UNDER_CE)
			::ShowWindow(m_hWnd, SW_MAXIMIZE);
			CControlUI* pControl = static_cast<CControlUI*>(m_PaintManager.FindControl(kMaxButtonControlName));
			if( pControl ) pControl->SetVisible(false);
			pControl = static_cast<CControlUI*>(m_PaintManager.FindControl(kRestoreButtonControlName));
			if( pControl ) pControl->SetVisible(true);
#else
			SendMessage(WM_SYSCOMMAND, SC_MAXIMIZE, 0);
#endif
		}
		else if (_tcsicmp(msg.pSender->GetName().GetData(), kRestoreButtonControlName) == 0)
		{
#if defined(UNDER_CE)
			::ShowWindow(m_hWnd, SW_RESTORE);
			CControlUI* pControl = static_cast<CControlUI*>(m_PaintManager.FindControl(kMaxButtonControlName));
			if( pControl ) pControl->SetVisible(true);
			pControl = static_cast<CControlUI*>(m_PaintManager.FindControl(kRestoreButtonControlName));
			if( pControl ) pControl->SetVisible(false);
#else
			SendMessage(WM_SYSCOMMAND, SC_RESTORE, 0);
#endif
		}
		else if (_tcsicmp(msg.pSender->GetName().GetData(), kFontButtonControlName) == 0)
		{
			CContainerUI* pFontbar = static_cast<CContainerUI*>(m_PaintManager.FindControl(kFontbarControlName));
			if (pFontbar != NULL)
				pFontbar->SetVisible(!pFontbar->IsVisible());
		}
		else if (_tcsicmp(msg.pSender->GetName().GetData(), kEmotionButtonControlName) == 0)
		{
			POINT pt = {0};
			CDuiRect rcEmotionBtn = msg.pSender->GetPos();
			CDuiRect rcWindow;
			GetWindowRect(m_hWnd, &rcWindow);

			pt.y = rcWindow.top + rcEmotionBtn.top;
			pt.x = rcWindow.left + rcEmotionBtn.left;
			//emotion_list_window_.SelectEmotion(pt);
		}
		else if (_tcsicmp(msg.pSender->GetName().GetData(), kSendButtonControlName) == 0)
        {
            SendMsg();
		}
	}
    else if( _tcsicmp(msg.sType.GetData(), _T("return")) == 0 ) 
    {
        if (_tcsicmp(msg.pSender->GetName().GetData(), kInputRichEditControlName) == 0)
        {
            SendMsg();
        }
    }
	else if (_tcsicmp(msg.sType.GetData(), _T("timer")) == 0)
	{
		return OnTimer(msg);
	}
	else if (_tcsicmp(msg.sType.GetData(), _T("selectchanged")) == 0)
	{
		if (_tcsicmp(msg.pSender->GetName().GetData(), kColorButtonControlName) == 0)
		{
			CContainerUI* pFontbar = static_cast<CContainerUI*>(m_PaintManager.FindControl(kFontbarControlName));
			if (pFontbar != NULL)
			{
				POINT pt = {0};
				CDuiRect rcFontbar = pFontbar->GetPos();
				CDuiRect rcColorBtn = msg.pSender->GetPos();
				CDuiRect rcWindow;
				GetWindowRect(m_hWnd, &rcWindow);

				pt.y = rcWindow.top + rcFontbar.top;
				pt.x = rcWindow.left + rcColorBtn.left + static_cast<LONG>(rcColorBtn.right - rcColorBtn.left / 2);
				new CColorPicker(this, pt);
			}
		}
		else if (_tcsicmp(msg.pSender->GetName().GetData(), kBoldButtonControlName) == 0)
		{
			COptionUI* bold_button = static_cast<COptionUI*>(msg.pSender);
			if (bold_button != NULL)
			{
				bold_ = bold_button->IsSelected();
				FontStyleChanged();
			}
		}
		else if (_tcsicmp(msg.pSender->GetName().GetData(), kItalicButtonControlName) == 0)
		{
			COptionUI* italic_button = static_cast<COptionUI*>(msg.pSender);
			if (italic_button != NULL)
			{
				italic_ = italic_button->IsSelected();
				FontStyleChanged();
			}
		}
		else if (_tcsicmp(msg.pSender->GetName().GetData(), KUnderlineButtonControlName) == 0)
		{
			COptionUI* underline_button = static_cast<COptionUI*>(msg.pSender);
			if (underline_button != NULL)
			{
				underline_ = underline_button->IsSelected();
				FontStyleChanged();
			}
		}
	}
	else if (_tcsicmp(msg.sType.GetData(), _T("itemselect")) == 0)
	{
		if (_tcsicmp(msg.pSender->GetName().GetData(), kFontTypeControlName) == 0)
		{
			CComboUI* font_type = static_cast<CComboUI*>(msg.pSender);
			if (font_type != NULL)
			{
				font_face_name_ = font_type->GetText();
				FontStyleChanged();
			}
		}
		else if (_tcsicmp(msg.pSender->GetName().GetData(), kFontSizeControlName) == 0)
		{
			CComboUI* font_size = static_cast<CComboUI*>(msg.pSender);
			if (font_size != NULL)
			{
				font_size_ = _ttoi(font_size->GetText().GetData());
				FontStyleChanged();
			}
		}
	}
}
Beispiel #10
0
bool CTestResource::Matches  (const CeCosTest::ExecutionParameters &e,bool bIgnoreLocking) const
{
  return (bIgnoreLocking||(!m_bLocked)) && (0==_tcsicmp(e.PlatformName(),m_Target)); 
};
// ----------------
// Global routines
// ----------------
bool IsSupportedHTTPProtocol(LPCTSTR pProtocol)
{
	return	!_tcsicmp(pProtocol, TEXT("http")) ||
			!_tcsicmp(pProtocol, TEXT("https"));
}
bool IsInstalled(HINSTANCE hin,bool & bInstall) throw()
{
	bInstall = false;
	bool bOK = false;
	SC_HANDLE hSCM = 0;
	SC_HANDLE hService = 0;
	LPQUERY_SERVICE_CONFIG lpsc = 0;
	do
	{
		hSCM = ::OpenSCManager(NULL, NULL, GENERIC_READ);
		if(hSCM == 0) break;
		hService = ::OpenService(hSCM,_T("WinRobotHost"),GENERIC_READ );
		if( hService == 0){
			if( GetLastError() == ERROR_SERVICE_DOES_NOT_EXIST )
			{
				bOK = true;
			}
			break;
		}
		DWORD dwBytesNeeded = 0;
		if(!QueryServiceConfig( 
			hService, 
			NULL, 
			0, 
			&dwBytesNeeded))
		{
			if( ERROR_INSUFFICIENT_BUFFER ==  GetLastError() )
			{
				
				lpsc = (LPQUERY_SERVICE_CONFIG) LocalAlloc(LMEM_FIXED, dwBytesNeeded);
			}
			else
			{
				DebugOutF(filelog::log_error,"QueryServiceConfig failed (%d)", GetLastError());
				break;
			}
		}

		if( !QueryServiceConfig( 
			hService, 
			lpsc, 
			dwBytesNeeded, 
			&dwBytesNeeded) ) 
		{
			DebugOutF(filelog::log_error,"QueryServiceConfig failed (%d)", GetLastError());
			break;
		}
		// if is not same service exe file
		TCHAR path[MAX_PATH] = {0};
		GetModuleFileName(hin,path,MAX_PATH);
		PathRemoveFileSpec(path);
#if _WIN64
		PathAppend(path,_T("WinRobotHostx64.exe"));
#else
		PathAppend(path,_T("WinRobotHostx86.exe"));
#endif
		
		ATL::CString service_path;
		service_path.Format(_T("\"%s\" -runas service"),path);
		
		bOK = true;
		if( _tcsicmp(lpsc->lpBinaryPathName,service_path) != 0 )
		{
			break;
		}


		bInstall = true;
	}while(0);

	if(hService)::CloseServiceHandle(hService);
	if(hSCM)::CloseServiceHandle(hSCM);
	if(lpsc) LocalFree(lpsc);
	return bOK;
}
Beispiel #13
0
static bool
ParseLineTNP(Airspaces &airspace_database, const TCHAR *line,
             TempAirspaceType &temp_area, bool &ignore)
{
  const TCHAR* parameter;
  if ((parameter = string_after_prefix_ci(line, _T("INCLUDE="))) != NULL) {
    if (_tcsicmp(parameter, _T("YES")) == 0)
      ignore = false;
    else if (_tcsicmp(parameter, _T("NO")) == 0)
      ignore = true;

    return true;
  }

  if (ignore)
    return true;

  if ((parameter = string_after_prefix_ci(line, _T("TITLE="))) != NULL) {
    temp_area.Name = parameter;
  } else if ((parameter = string_after_prefix_ci(line, _T("TYPE="))) != NULL) {
    if (!temp_area.Waiting)
      temp_area.AddPolygon(airspace_database);

    temp_area.reset();

    temp_area.Type = ParseTypeTNP(parameter);
    temp_area.Waiting = false;
  } else if ((parameter = string_after_prefix_ci(line, _T("CLASS="))) != NULL) {
    if (temp_area.Type == OTHER)
      temp_area.Type = ParseClassTNP(parameter);
  } else if ((parameter = string_after_prefix_ci(line, _T("TOPS="))) != NULL) {
    ReadAltitude(parameter, &temp_area.Top);
  } else if ((parameter = string_after_prefix_ci(line, _T("BASE="))) != NULL) {
    ReadAltitude(parameter, &temp_area.Base);
  } else if ((parameter = string_after_prefix_ci(line, _T("POINT="))) != NULL) {
    GeoPoint TempPoint;

    if (!ParseCoordsTNP(parameter, TempPoint))
      return false;

    temp_area.points.push_back(TempPoint);
  } else if ((parameter =
      string_after_prefix_ci(line, _T("CIRCLE "))) != NULL) {
    if (!ParseCircleTNP(parameter, temp_area))
      return false;

    temp_area.AddCircle(airspace_database);
  } else if ((parameter =
      string_after_prefix_ci(line, _T("CLOCKWISE "))) != NULL) {
    temp_area.Rotation = 1;
    if (!ParseArcTNP(parameter, temp_area))
      return false;
  } else if ((parameter =
      string_after_prefix_ci(line, _T("ANTI-CLOCKWISE "))) != NULL) {
    temp_area.Rotation = -1;
    if (!ParseArcTNP(parameter, temp_area))
      return false;
  }

  return true;
}
Beispiel #14
0
static AirspaceClass_t
ParseTypeTNP(const TCHAR* text)
{
  if (_tcsicmp(text, _T("C")) == 0 ||
      _tcsicmp(text, _T("CTA")) == 0 ||
      _tcsicmp(text, _T("CTA")) == 0 ||
      _tcsicmp(text, _T("CTA/CTR")) == 0)
    return CTR;

  if (_tcsicmp(text, _T("R")) == 0 ||
      _tcsicmp(text, _T("RESTRICTED")) == 0)
    return RESTRICT;

  if (_tcsicmp(text, _T("P")) == 0 ||
      _tcsicmp(text, _T("PROHIBITED")) == 0)
    return RESTRICT;

  if (_tcsicmp(text, _T("D")) == 0 ||
      _tcsicmp(text, _T("DANGER")) == 0)
    return RESTRICT;

  if (_tcsicmp(text, _T("G")) == 0 ||
      _tcsicmp(text, _T("GSEC")) == 0)
    return WAVE;

  return OTHER;
}
Beispiel #15
0
PassFail TestSQLSpecialColumns(TestInfo *pTestInfo, int MX_MP_SPECIFIC)
{                  
	TEST_DECLARE;
 	TCHAR			Heading[MAX_HEADING_SIZE];
 	RETCODE			returncode;
 	SQLHANDLE 		henv;
 	SQLHANDLE 		hdbc;
 	SQLHANDLE		hstmt;
	TCHAR			TQualifier[NAME_LEN],TOwner[NAME_LEN],TName[NAME_LEN];
	UWORD			fColType[NUM_COLTYPE] = {SQL_BEST_ROWID,SQL_ROWVER};
	UWORD			Scope[NUM_SCOPE] = {SQL_SCOPE_CURROW,SQL_SCOPE_TRANSACTION,SQL_SCOPE_SESSION};
	UWORD			Nullable[NUM_NULL] = {SQL_NO_NULLS,SQL_NULLABLE};
	TCHAR			ocname[MAX_COLUMN_NAME],octype[MAX_COLUMN_NAME];
	SWORD			oscope,ocdatatype,ocsca,ocpc;
	SDWORD			ocprec,oclen;		
	SQLLEN			oscopelen,ocnamelen,ocdatatypelen,octypelen,ocpreclen,oclenlen,ocscalen,ocpclen;

	struct
	{
		TCHAR		*ColName;
		SWORD		ColDataType;
		TCHAR		*ColTypeName;
		TCHAR		*ColTypeOutput;
		TCHAR		*ColTypeLen;
		SDWORD		ColPrec;
		SWORD		ColSca;
		SDWORD		ColLen;
	} Columns[] = {
							{_T("--"),SQL_CHAR,_T("char"),_T("CHAR"),_T("(10) CHARACTER SET ISO88591"),10,0,10},
							{_T("--"),SQL_VARCHAR,_T("varchar"),_T("VARCHAR"),_T("(10) CHARACTER SET ISO88591"),10,0,10},
							{_T("--"),SQL_VARCHAR,_T("varchar"),_T("VARCHAR"),_T("(255) CHARACTER SET ISO88591"),255,0,255},
							{_T("--"),SQL_WCHAR,_T("char"),_T("NCHAR"),_T("(10) CHARACTER SET UCS2"),10,0,20},
							{_T("--"),SQL_WVARCHAR,_T("varchar"),_T("NCHAR VARYING"),_T("(10) CHARACTER SET UCS2"),10,0,20},
							{_T("--"),SQL_WVARCHAR,_T("varchar"),_T("NCHAR VARYING"),_T("(255) CHARACTER SET UCS2"),255,0,510},
							{_T("--"),SQL_DECIMAL,_T("decimal"),_T("DECIMAL SIGNED"),_T("(10,5)"),10,5,12},
							{_T("--"),SQL_NUMERIC,_T("numeric"),_T("NUMERIC SIGNED"),_T("(10,5)"),10,5,12},
							{_T("--"),SQL_NUMERIC,_T("numeric"),_T("NUMERIC SIGNED"),_T("(19,0)"),19,0,21},				//Bignum
							{_T("--"),SQL_NUMERIC,_T("numeric"),_T("NUMERIC SIGNED"),_T("(19,6)"),19,6,21},				//Bignum
							{_T("--"),SQL_NUMERIC,_T("numeric"),_T("NUMERIC SIGNED"),_T("(128,0)"),128,0,130},			//Bignum
							{_T("--"),SQL_NUMERIC,_T("numeric"),_T("NUMERIC SIGNED"),_T("(128,128)"),128,128,130},		//Bignum
							{_T("--"),SQL_NUMERIC,_T("numeric"),_T("NUMERIC SIGNED"),_T("(128,64)"),128,64,130},			//Bignum
							{_T("--"),SQL_NUMERIC,_T("numeric"),_T("NUMERIC UNSIGNED"),_T("(10,5) unsigned"),10,5,12},		//Bignum
							{_T("--"),SQL_NUMERIC,_T("numeric"),_T("NUMERIC UNSIGNED"),_T("(18,5) unsigned"),18,5,20},		//Bignum
							{_T("--"),SQL_NUMERIC,_T("numeric"),_T("NUMERIC UNSIGNED"),_T("(30,10) unsigned"),30,10,32},	//Bignum
							{_T("--"),SQL_SMALLINT,_T("smallint"),_T("SMALLINT SIGNED"),_T(""),5,0,2},
							{_T("--"),SQL_INTEGER,_T("integer"),_T("INTEGER SIGNED"),_T(""),10,0,4},
							{_T("--"),SQL_BIGINT,_T("bigint"),_T("BIGINT SIGNED"),_T(""),19,0,20},
							{_T("--"),SQL_DATE,_T("date"),_T("DATE"),_T(""),10,0,6},
							{_T("--"),SQL_TIME,_T("time"),_T("TIME"),_T(""),8,0,6},
							{_T("--"),SQL_TIMESTAMP,_T("TIMESTAMP"),_T("timestamp"),_T(""),26,6,16},
							{_T("--"),SQL_BIT,_T("bit"),_T("BIT"),_T(""),1,1,0},
							{_T("--"),SQL_TINYINT,_T("tinyint"),_T("TINYINT"),_T(""),3,0,2},
							{_T("--"),SQL_BINARY,_T("binary"),_T("BINARY"),_T("(10)"),10,0,10},
							{_T("--"),SQL_VARBINARY,_T("varbinary"),_T("VARBINARY"),_T("(10)"),10,0,10},
							{_T("--"),SQL_WCHAR,_T("char"),_T("NCHAR"),_T("(10) CHARACTER SET UTF8"),10,0,20},
							{_T("--"),SQL_WVARCHAR,_T("varchar"),_T("NCHAR VARYING"),_T("(10) CHARACTER SET UTF8"),10,0,20},
							{_T("--"),SQL_WVARCHAR,_T("varchar"),_T("NCHAR VARYING"),_T("(255) CHARACTER SET UTF8"),255,0,510},
							{_T("--"),0,_T("endloop"),_T(""),0,0,0,0}
						};

	TCHAR	*TableStr[4];
	TCHAR	ColStr[MAX_NOS_SIZE], KeyStr[MAX_NOS_SIZE], CreateTbl[MAX_NOS_SIZE],END_LOOP[10];
	int		i = 0, k = 0,ct = 0, s = 0, t = 0, n = 0, psc = 1;
    BOOL    found = FALSE;
	//TCHAR *charNameUCS2 = _T("NCHAR");
	//TCHAR *varcharNameUCS2 = _T("NCHAR VARYING");

//===========================================================================================================
	var_list_t *var_list;
	var_list = load_api_vars(_T("SQLSpecialColumns"), charset_file);
	if (var_list == NULL) return FAILED;

	//print_list(var_list);
	Columns[0].ColName = var_mapping(_T("SQLSpecialColumns_Columns_1"), var_list);
	Columns[1].ColName = var_mapping(_T("SQLSpecialColumns_Columns_2"), var_list);
	Columns[2].ColName = var_mapping(_T("SQLSpecialColumns_Columns_3"), var_list);
	Columns[3].ColName = var_mapping(_T("SQLSpecialColumns_Columns_4"), var_list);
	Columns[4].ColName = var_mapping(_T("SQLSpecialColumns_Columns_5"), var_list);
	Columns[5].ColName = var_mapping(_T("SQLSpecialColumns_Columns_6"), var_list);
	Columns[6].ColName = var_mapping(_T("SQLSpecialColumns_Columns_7"), var_list);
	Columns[7].ColName = var_mapping(_T("SQLSpecialColumns_Columns_8"), var_list);
	Columns[8].ColName = var_mapping(_T("SQLSpecialColumns_Columns_9"), var_list);
	Columns[9].ColName = var_mapping(_T("SQLSpecialColumns_Columns_10"), var_list);
	Columns[10].ColName = var_mapping(_T("SQLSpecialColumns_Columns_11"), var_list);
	Columns[11].ColName = var_mapping(_T("SQLSpecialColumns_Columns_12"), var_list);
	Columns[12].ColName = var_mapping(_T("SQLSpecialColumns_Columns_13"), var_list);
	Columns[13].ColName = var_mapping(_T("SQLSpecialColumns_Columns_14"), var_list);
	Columns[14].ColName = var_mapping(_T("SQLSpecialColumns_Columns_15"), var_list);
	Columns[15].ColName = var_mapping(_T("SQLSpecialColumns_Columns_16"), var_list);
	Columns[16].ColName = var_mapping(_T("SQLSpecialColumns_Columns_17"), var_list);
	Columns[17].ColName = var_mapping(_T("SQLSpecialColumns_Columns_18"), var_list);
	Columns[18].ColName = var_mapping(_T("SQLSpecialColumns_Columns_19"), var_list);
	Columns[19].ColName = var_mapping(_T("SQLSpecialColumns_Columns_20"), var_list);
	Columns[20].ColName = var_mapping(_T("SQLSpecialColumns_Columns_21"), var_list);
	Columns[21].ColName = var_mapping(_T("SQLSpecialColumns_Columns_22"), var_list);
	Columns[22].ColName = var_mapping(_T("SQLSpecialColumns_Columns_23"), var_list);
	Columns[23].ColName = var_mapping(_T("SQLSpecialColumns_Columns_24"), var_list);
	Columns[24].ColName = var_mapping(_T("SQLSpecialColumns_Columns_25"), var_list);
	Columns[25].ColName = var_mapping(_T("SQLSpecialColumns_Columns_26"), var_list);
	Columns[26].ColName = var_mapping(_T("SQLSpecialColumns_Columns_27"), var_list);
	Columns[27].ColName = var_mapping(_T("SQLSpecialColumns_Columns_28"), var_list);
	Columns[28].ColName = var_mapping(_T("SQLSpecialColumns_Columns_29"), var_list);

	TableStr[0] = var_mapping(_T("SQLSpecialColumns_TableStr_1"), var_list);
	TableStr[1] = var_mapping(_T("SQLSpecialColumns_TableStr_2"), var_list);
	TableStr[2] = var_mapping(_T("SQLSpecialColumns_TableStr_3"), var_list);
	TableStr[3] = var_mapping(_T("SQLSpecialColumns_TableStr_4"), var_list);

//=========================================================================================

	//if(isUCS2) {
	//	LogMsg(NONE,_T("Setup for UCS2 mode testing: ColPrec has to be doubled\n"));

	//	i = 0;
	//	while(_tcsicmp(Columns[i].ColTypeName,_T("endloop")) != 0) {
	//		if (Columns[i].ColDataType == SQL_WCHAR){
	//			Columns[i].ColDataType = SQL_WCHAR;
	//			Columns[i].ColTypeOutput = charNameUCS2;
	//			//Columns[i].ColPrec *= 2;  --> This is in character, no need to double
	//			Columns[i].ColLen *= 2;
	//		}
	//		else if (Columns[i].ColDataType == SQL_WVARCHAR) {
	//			Columns[i].ColDataType = SQL_WVARCHAR;
	//			Columns[i].ColTypeOutput = varcharNameUCS2;
	//			//Columns[i].ColPrec *= 2;  --> This is in character, no need to double
	//			Columns[i].ColLen *= 2;
	//		}
	//		else if (Columns[i].ColDataType == SQL_WLONGVARCHAR)	{
	//			Columns[i].ColDataType = SQL_WLONGVARCHAR;
	//			Columns[i].ColTypeOutput = varcharNameUCS2;
	//			//Columns[i].ColPrec *= 2;  --> This is in character, no need to double
	//			Columns[i].ColLen *= 2;
	//		}
	//		i++;
	//	}
	//	i = 0;
	//}

//=========================================================================================

	if (MX_MP_SPECIFIC == MX_SPECIFIC)
		LogMsg(LINEBEFORE+SHORTTIMESTAMP,_T("Begin testing API => MX Specific SQLSpecialColumns.\n"));
	else
		LogMsg(LINEBEFORE+SHORTTIMESTAMP,_T("Begin testing API => MP Specific SQLSpecialColumns.\n"));
	
	TEST_INIT;
	TESTCASE_BEGIN("Setup for SQLSpecialColumns tests\n");

	if(!FullConnect(pTestInfo)){
		LogMsg(NONE,_T("Unable to connect\n"));
		TEST_FAILED;
		TEST_RETURN;
		}

	henv = pTestInfo->henv;
 	hdbc = pTestInfo->hdbc;
 	hstmt = (SQLHANDLE)pTestInfo->hstmt;
   	
	returncode = SQLAllocStmt((SQLHANDLE)hdbc, &hstmt);	
  	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocStmt")){
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
		}
	TESTCASE_END;

	_tcscpy(ColStr,_T(""));
	_tcscpy(KeyStr,_T(""));
	_tcscpy(END_LOOP,_T(""));
	_tcscpy(TName,TableStr[2]);

	if (MX_MP_SPECIFIC == MX_SPECIFIC)
	{
		_tcscpy(TQualifier,pTestInfo->Catalog);
		_tcscpy(TOwner,pTestInfo->Schema);
		_tcscpy(END_LOOP,_T("bit"));
	}
	else
	{
		_tcscpy(TQualifier,_T(""));
		_tcscpy(TOwner,pTestInfo->UserID);
		_tcscpy(END_LOOP,_T("endloop"));
	}

	while (_tcsicmp(Columns[i].ColTypeName,END_LOOP) != 0)
	{
		SQLExecDirect(hstmt,(SQLTCHAR*) (SQLTCHAR *)TableStr[1],SQL_NTS); // cleanup
		if (i > 0)
		{
			_tcscat(ColStr,_T(","));
			_tcscat(KeyStr,_T(","));
		}
		_tcscat(ColStr,Columns[i].ColName);
		_tcscat(ColStr,_T(" "));
		_tcscat(ColStr,Columns[i].ColTypeName);
		_tcscat(ColStr,Columns[i].ColTypeLen);
		_tcscat(ColStr,_T(" not null"));
		_tcscat(KeyStr,Columns[i].ColName);
		_tcscpy(CreateTbl,_T(""));
		_tcscat(CreateTbl,TableStr[0]);
		_tcscat(CreateTbl,_T("("));
		_tcscat(CreateTbl,ColStr);
		_tcscat(CreateTbl,_T(", primary key("));
		_tcscat(CreateTbl,KeyStr);
		_tcscat(CreateTbl,_T("))"));

		_stprintf(Heading,_T("Test Positive Functionality of SQLSpecialColumns for this table:\n"));
		_tcscat(Heading,CreateTbl);
		_tcscat(Heading,_T("\n"));
		TESTCASE_BEGINW(Heading);
		returncode = SQLExecDirect(hstmt,(SQLTCHAR*)CreateTbl,SQL_NTS);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect")){
			TEST_FAILED;
			LogAllErrors(henv,hdbc,hstmt);
		}
		else{
			if (_tcslen(TQualifier) > 0)
				returncode = SQLSpecialColumns(hstmt,fColType[ct],(SQLTCHAR*)TQualifier,(SWORD)_tcslen(TQualifier),(SQLTCHAR*)TOwner,(SWORD)_tcslen(TOwner),(SQLTCHAR*)TName,(SWORD)_tcslen(TName),Scope[s],Nullable[n]);
			else
				returncode = SQLSpecialColumns(hstmt,fColType[ct],NULL,0,(SQLTCHAR*)TOwner,(SWORD)_tcslen(TOwner),(SQLTCHAR*)TName,(SWORD)_tcslen(TName),Scope[s],Nullable[n]);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLSpecialColumns")){
				TEST_FAILED;
				LogAllErrors(henv,hdbc,hstmt);
				}
			else{
				oscope = 0;
				_tcscpy(ocname,_T(""));
				ocdatatype = 0;
				_tcscpy(octype,_T(""));
				ocprec = 0;
				oclen = 0;
				ocsca = 0;
				ocpc = 0;
				SQLBindCol(hstmt,1,SQL_C_SHORT,&oscope,0,&oscopelen);
			    SQLBindCol(hstmt,2,SQL_C_TCHAR,ocname,MAX_COLUMN_NAME,&ocnamelen);
				SQLBindCol(hstmt,3,SQL_C_SHORT,&ocdatatype,0,&ocdatatypelen);
				SQLBindCol(hstmt,4,SQL_C_TCHAR,octype,MAX_COLUMN_NAME,&octypelen);
				SQLBindCol(hstmt,5,SQL_C_LONG,&ocprec,0,&ocpreclen);
				SQLBindCol(hstmt,6,SQL_C_LONG,&oclen,0,&oclenlen);
				SQLBindCol(hstmt,7,SQL_C_SHORT,&ocsca,0,&ocscalen);
				SQLBindCol(hstmt,8,SQL_C_SHORT,&ocpc,0,&ocpclen);

				k = 0;
				while (returncode == SQL_SUCCESS){
					returncode = SQLFetch(hstmt);
					if((returncode!=SQL_NO_DATA_FOUND)
							&&(!CHECKRC(SQL_SUCCESS,returncode,"SQLFetch"))){
						TEST_FAILED;
						LogAllErrors(henv,hdbc,hstmt);
						}
					else{
						if (returncode == SQL_SUCCESS){
							if (MX_MP_SPECIFIC == MX_SPECIFIC)
							{
								psc = SQL_PC_NOT_PSEUDO;
							}
							else
							{
								psc = 1;
							}
							LogMsg(NONE,_T("Comparing results for SQLSpecialColumns\n"));
                            t = 0;
                            found = FALSE;
                            while(_tcscmp(Columns[t].ColTypeName,_T("endloop"))!=0) {
                                if(cwcscmp(ocname, Columns[t].ColName,TRUE) == 0) {
							        if ((oscope == Scope[s]) 
								        && (ocdatatype == Columns[t].ColDataType) 
								        && (_tcsicmp(octype,Columns[t].ColTypeOutput) == 0) 
								        && (ocprec == Columns[t].ColPrec) 
								        && (oclen == Columns[t].ColLen) 
								        && (ocsca == Columns[t].ColSca) 
								        && (ocpc == (SWORD)psc)){
								        /*
								        LogMsg(NONE,_T("Scope expect: %d and actual: %d are matched\n"),Scope[s],oscope);
								        LogMsg(NONE,_T("colname expect: %s and actual: %s are matched\n"),Columns[t].ColName,ocname);
								        LogMsg(NONE,_T("ColDataType expect: %d and actual: %d are matched\n"),Columns[t].ColDataType,ocdatatype);
								        LogMsg(NONE,_T("ColTypeOutput expect: %s and actual: %s are matched\n"),Columns[t].ColTypeOutput,octype);
								        LogMsg(NONE,_T("ColPrec expect: %d and actual: %d are matched\n"),Columns[t].ColPrec,ocprec);
								        LogMsg(NONE,_T("ColLen expect: %d and actual: %d are matched\n"),Columns[t].ColLen,oclen);
								        LogMsg(NONE,_T("ColScale expect: %d and actual: %d are matched\n"),Columns[t].ColSca,ocsca);
								        LogMsg(NONE,_T("ColPseudoCol expect: %d and actual: %d are matched\n\n"),(SWORD)psc,ocpc);
								        */
							        } else {
							            TEST_FAILED;	
							            if (oscope != Scope[s]) 
								            LogMsg(ERRMSG,_T("Scope expect: %d and actual: %d are not matched\n"),Scope[t],oscope);
							            if (ocdatatype != Columns[t].ColDataType) 
								            LogMsg(ERRMSG,_T("ColDataType expect: %d and actual: %d are not matched\n"),Columns[t].ColDataType,ocdatatype);
							            if (_tcsicmp(octype,Columns[t].ColTypeOutput) != 0) 
								            LogMsg(ERRMSG,_T("ColTypeName expect: %s and actual: %s are not matched\n"),Columns[t].ColTypeOutput,octype);
							            if (ocprec != Columns[t].ColPrec) 
								            LogMsg(ERRMSG,_T("ColPrec expect: %d and actual: %d are not matched\n"),Columns[t].ColPrec,ocprec);
							            if (oclen != Columns[t].ColLen) 
								            LogMsg(ERRMSG,_T("ColLen expect: %d and actual: %d are not matched\n"),Columns[t].ColLen,oclen);
							            if (ocsca != Columns[t].ColSca) 
								            LogMsg(ERRMSG,_T("ColScale expect: %d and actual: %d are not matched\n"),Columns[t].ColSca,ocsca);
							            if (ocpc != (SWORD)psc)
								            LogMsg(ERRMSG,_T("ColPseudoCol expect: %d and actual: %d are not matched\n\n"),(SWORD)psc,ocpc);
						            }
                                    found = TRUE;
                                    break;
                                } else {
                                    t++;
                                }
                            }
                            if(!found) {
                                TEST_FAILED;
                                LogMsg(ERRMSG,_T("Unexpected returned data: %s\n"), ocname);
                            }
						}
                    }
					if (returncode == SQL_SUCCESS)
						k++;
					} // end while
					if(k == 0)
					{
						TEST_FAILED;
						LogMsg(ERRMSG,_T("No Data Found => Atleast one row should be fetched\n"));
					}
				}
			SQLFreeStmt(hstmt,SQL_UNBIND);
			SQLFreeStmt(hstmt,SQL_CLOSE);
			}
			SQLExecDirect(hstmt,(SQLTCHAR*) (SQLTCHAR *)TableStr[1],SQL_NTS);
		i++;
		TESTCASE_END;
		}  // end while

	//========================================================================================================

	_stprintf(Heading,_T("SQLSpecialColumns: Negative test with NULL handle\n"));
	TESTCASE_BEGINW(Heading);

	hstmt = (SQLHANDLE)NULL;
	_tcscpy(TQualifier,_T(""));
	_tcscpy(TOwner,pTestInfo->UserID);
	_tcscpy(TName,TableStr[3]);
	i = 0;

	returncode = SQLSpecialColumns(hstmt,fColType[i],(SQLTCHAR*)TQualifier,(SWORD)_tcslen(TQualifier),(SQLTCHAR*)TOwner,(SWORD)_tcslen(TOwner),(SQLTCHAR*)TName,(SWORD)_tcslen(TName),Scope[i],Nullable[i]);
	if(!CHECKRC(SQL_INVALID_HANDLE,returncode,"SQLSpecialColumns"))
	{
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
	}
	TESTCASE_END;

	//========================================================================================================

	FullDisconnect(pTestInfo);
	LogMsg(SHORTTIMESTAMP+LINEAFTER,_T("End testing API => SQLSpecialColumns.\n"));
	free_list(var_list);
	TEST_RETURN;
}
void CALLBACK XAcDocOp::AutoCloseTimerProc(
									  HWND hwnd,         // handle to window
									  UINT uMsg,         // WM_TIMER message
									  UINT_PTR idEvent,  // timer identifier
									  DWORD dwTime       // current system time
									  )
{
	assert(sm_dwTimerId == idEvent);

	BOOL	bKillTimer	= FALSE;

	//枚举当前线程中窗口
	EnumCurrentThreadWindows();

	HWND	hFindedWnd;
	DWORD	dwStyle;
	TCHAR	lpszCaption[100];
	//查找符合要求的
	for(int i  = 0 ; i < sm_arrThreadWindows.GetCount() ; i++)
	{
		hFindedWnd	= sm_arrThreadWindows.GetAt(i);
		if(!::IsWindow(hFindedWnd))
			continue;

		dwStyle	= ::GetWindowLong(hFindedWnd , GWL_STYLE);
		if(dwStyle & WS_CHILD)	//是子窗口
			continue;

		::GetWindowText(hFindedWnd , lpszCaption , 100);
		if(_tcsicmp(lpszCaption , _T("AutoCAD 警告")) == 0)	//找到了只读提示对话框
		{
			HWND	hOkWnd;
			hOkWnd	= ::GetDlgItem(hFindedWnd , IDYES);
			if(hOkWnd == NULL)
				continue;

			//发送消息
			::SendMessage(hFindedWnd , WM_COMMAND ,(WPARAM) MAKELONG(IDYES , BN_CLICKED) , (LPARAM)hOkWnd);

			bKillTimer	= TRUE;
			break;
		}
	}
	
	//是否销毁定时器销毁定时器
	if(!bKillTimer)
	{
		DWORD	dwCurrent;
		dwCurrent	= ::GetTickCount();
		if(dwCurrent > sm_dwStartAutoClose)	//时间大于10秒
		{
			if(dwCurrent - sm_dwStartAutoClose > 10000)
				bKillTimer	= TRUE;
		}
		else
		{
			if(sm_dwStartAutoClose - dwCurrent > 10000)
				bKillTimer	= TRUE;
		}		
	}

	if(bKillTimer)
	{
		::KillTimer(NULL , idEvent);

		sm_dwStartAutoClose	= 0;
		sm_dwTimerId		= 0;
	}
}
Beispiel #17
0
	LRESULT CComboWnd::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
	{
		if( uMsg == WM_CREATE ) {
			m_pm.SetForceUseSharedRes(true);
			m_pm.Init(m_hWnd);
			// The trick is to add the items to the new container. Their owner gets
			// reassigned by this operation - which is why it is important to reassign
			// the items back to the righfull owner/manager when the window closes.
			m_pLayout = new CVerticalLayoutUI;
			m_pLayout->SetManager(&m_pm, NULL, true);
			LPCTSTR pDefaultAttributes = m_pOwner->GetManager()->GetDefaultAttributeList(_T("VerticalLayout"));
			if( pDefaultAttributes ) {
				m_pLayout->ApplyAttributeList(pDefaultAttributes);
			}
			m_pLayout->SetInset(CDuiRect(1, 1, 1, 1));
			m_pLayout->SetBkColor(0xFFFFFFFF);
			m_pLayout->SetBorderColor(0xFFC6C7D2);
			m_pLayout->SetBorderSize(1);
			m_pLayout->SetAutoDestroy(false);
			m_pLayout->EnableScrollBar();
			m_pLayout->ApplyAttributeList(m_pOwner->GetDropBoxAttributeList());
			for( int i = 0; i < m_pOwner->GetCount(); i++ ) {
				m_pLayout->Add(static_cast<CControlUI*>(m_pOwner->GetItemAt(i)));
			}
			m_pm.AttachDialog(m_pLayout);
			m_pm.AddNotifier(this);
			return 0;
		}
		else if( uMsg == WM_CLOSE ) {
			m_pOwner->SetManager(m_pOwner->GetManager(), m_pOwner->GetParent(), false);
			RECT rcNull = { 0 };
			for( int i = 0; i < m_pOwner->GetCount(); i++ ) static_cast<CControlUI*>(m_pOwner->GetItemAt(i))->SetPos(rcNull);
			m_pOwner->SetFocus();
		}
		else if( uMsg == WM_LBUTTONUP ) {
			POINT pt = { 0 };
			::GetCursorPos(&pt);
			::ScreenToClient(m_pm.GetPaintWindow(), &pt);
			CControlUI* pControl = m_pm.FindControl(pt);
			if( pControl && _tcsicmp(pControl->GetClass(), _T("ScrollBarUI")) != 0 ) PostMessage(WM_KILLFOCUS);
		}
		else if( uMsg == WM_KEYDOWN ) {
			switch( wParam ) {
			case VK_ESCAPE:
				m_pOwner->SelectItem(m_iOldSel, true);
				EnsureVisible(m_iOldSel);
			case VK_RETURN:
				PostMessage(WM_KILLFOCUS);
				break;
			default:
				TEventUI event;
				event.Type = UIEVENT_KEYDOWN;
				event.chKey = (TCHAR)wParam;
				m_pOwner->DoEvent(event);
				EnsureVisible(m_pOwner->GetCurSel());
				return 0;
			}
		}
		else if( uMsg == WM_MOUSEWHEEL ) {
			int zDelta = (int) (short) HIWORD(wParam);
			TEventUI event = { 0 };
			event.Type = UIEVENT_SCROLLWHEEL;
			event.wParam = MAKELPARAM(zDelta < 0 ? SB_LINEDOWN : SB_LINEUP, 0);
			event.lParam = lParam;
			event.dwTimestamp = ::GetTickCount();
			m_pOwner->DoEvent(event);
			EnsureVisible(m_pOwner->GetCurSel());
			return 0;
		}
		else if( uMsg == WM_KILLFOCUS ) {
			if( m_hWnd != (HWND) wParam ) PostMessage(WM_CLOSE);
		}

		LRESULT lRes = 0;
		if( m_pm.MessageHandler(uMsg, wParam, lParam, lRes) ) return lRes;
		return CWindowWnd::HandleMessage(uMsg, wParam, lParam);
	}
Beispiel #18
0
// returns 1 if *.dat spec is matched
int isValidProfileName(const TCHAR *name)
{
	size_t len = _tcslen(name) - 4;
	return len > 0 && _tcsicmp(&name[len], _T(".dat")) == 0;
}
Beispiel #19
0
	void CComboUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue)
	{
		if( _tcsicmp(pstrName, _T("align")) == 0 ) {
			if( _tcsstr(pstrValue, _T("left")) != NULL ) {
				m_uTextStyle &= ~(DT_CENTER | DT_RIGHT | DT_SINGLELINE);
				m_uTextStyle |= DT_LEFT;
			}
			if( _tcsstr(pstrValue, _T("center")) != NULL ) {
				m_uTextStyle &= ~(DT_LEFT | DT_RIGHT );
				m_uTextStyle |= DT_CENTER;
			}
			if( _tcsstr(pstrValue, _T("right")) != NULL ) {
				m_uTextStyle &= ~(DT_LEFT | DT_CENTER | DT_SINGLELINE);
				m_uTextStyle |= DT_RIGHT;
			}
		}
		else if( _tcsicmp(pstrName, _T("valign")) == 0 ) {
			if( _tcsstr(pstrValue, _T("top")) != NULL ) {
				m_uTextStyle &= ~(DT_BOTTOM | DT_VCENTER);
				m_uTextStyle |= (DT_TOP | DT_SINGLELINE);
			}
			if( _tcsstr(pstrValue, _T("vcenter")) != NULL ) {
				m_uTextStyle &= ~(DT_TOP | DT_BOTTOM );            
				m_uTextStyle |= (DT_VCENTER | DT_SINGLELINE);
			}
			if( _tcsstr(pstrValue, _T("bottom")) != NULL ) {
				m_uTextStyle &= ~(DT_TOP | DT_VCENTER);
				m_uTextStyle |= (DT_BOTTOM | DT_SINGLELINE);
			}
		}
		else if( _tcsicmp(pstrName, _T("endellipsis")) == 0 ) {
			if( _tcsicmp(pstrValue, _T("true")) == 0 ) m_uTextStyle |= DT_END_ELLIPSIS;
			else m_uTextStyle &= ~DT_END_ELLIPSIS;
		}   
		else if( _tcsicmp(pstrName, _T("wordbreak")) == 0 ) {
			if( _tcsicmp(pstrValue, _T("true")) == 0 ) {
				m_uTextStyle &= ~DT_SINGLELINE;
				m_uTextStyle |= DT_WORDBREAK | DT_EDITCONTROL;
			}
			else {
				m_uTextStyle &= ~DT_WORDBREAK & ~DT_EDITCONTROL;
				m_uTextStyle |= DT_SINGLELINE;
			}
		}    
		else if( _tcsicmp(pstrName, _T("font")) == 0 ) SetFont(_ttoi(pstrValue));
		else if( _tcsicmp(pstrName, _T("textcolor")) == 0 ) {
			if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue);
			LPTSTR pstr = NULL;
			DWORD clrColor = _tcstoul(pstrValue, &pstr, 16);
			SetTextColor(clrColor);
		}
		else if( _tcsicmp(pstrName, _T("disabledtextcolor")) == 0 ) {
			if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue);
			LPTSTR pstr = NULL;
			DWORD clrColor = _tcstoul(pstrValue, &pstr, 16);
			SetDisabledTextColor(clrColor);
		}
		else if( _tcsicmp(pstrName, _T("textpadding")) == 0 ) {
			RECT rcTextPadding = { 0 };
			LPTSTR pstr = NULL;
			rcTextPadding.left = _tcstol(pstrValue, &pstr, 10);  ASSERT(pstr);    
			rcTextPadding.top = _tcstol(pstr + 1, &pstr, 10);    ASSERT(pstr);    
			rcTextPadding.right = _tcstol(pstr + 1, &pstr, 10);  ASSERT(pstr);    
			rcTextPadding.bottom = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr);    
			SetTextPadding(rcTextPadding);
		}
		else if( _tcsicmp(pstrName, _T("showhtml")) == 0 ) SetShowHtml(_tcsicmp(pstrValue, _T("true")) == 0);
		else if( _tcsicmp(pstrName, _T("normalimage")) == 0 ) SetNormalImage(pstrValue);
		else if( _tcsicmp(pstrName, _T("hotimage")) == 0 ) SetHotImage(pstrValue);
		else if( _tcsicmp(pstrName, _T("pushedimage")) == 0 ) SetPushedImage(pstrValue);
		else if( _tcsicmp(pstrName, _T("focusedimage")) == 0 ) SetFocusedImage(pstrValue);
		else if( _tcsicmp(pstrName, _T("disabledimage")) == 0 ) SetDisabledImage(pstrValue);
		else if( _tcsicmp(pstrName, _T("dropbox")) == 0 ) SetDropBoxAttributeList(pstrValue);
		else if( _tcsicmp(pstrName, _T("dropboxsize")) == 0)
		{
			SIZE szDropBoxSize = { 0 };
			LPTSTR pstr = NULL;
			szDropBoxSize.cx = _tcstol(pstrValue, &pstr, 10);  ASSERT(pstr);    
			szDropBoxSize.cy = _tcstol(pstr + 1, &pstr, 10);    ASSERT(pstr);    
			SetDropBoxSize(szDropBoxSize);
		}
		else if( _tcsicmp(pstrName, _T("itemfont")) == 0 ) m_ListInfo.nFont = _ttoi(pstrValue);
		else if( _tcsicmp(pstrName, _T("itemalign")) == 0 ) {
			if( _tcsstr(pstrValue, _T("left")) != NULL ) {
				m_ListInfo.uTextStyle &= ~(DT_CENTER | DT_RIGHT);
				m_ListInfo.uTextStyle |= DT_LEFT;
			}
			if( _tcsstr(pstrValue, _T("center")) != NULL ) {
				m_ListInfo.uTextStyle &= ~(DT_LEFT | DT_RIGHT);
				m_ListInfo.uTextStyle |= DT_CENTER;
			}
			if( _tcsstr(pstrValue, _T("right")) != NULL ) {
				m_ListInfo.uTextStyle &= ~(DT_LEFT | DT_CENTER);
				m_ListInfo.uTextStyle |= DT_RIGHT;
			}
		}
		else if( _tcsicmp(pstrName, _T("itemtextpadding")) == 0 ) {
			RECT rcTextPadding = { 0 };
			LPTSTR pstr = NULL;
			rcTextPadding.left = _tcstol(pstrValue, &pstr, 10);  ASSERT(pstr);    
			rcTextPadding.top = _tcstol(pstr + 1, &pstr, 10);    ASSERT(pstr);    
			rcTextPadding.right = _tcstol(pstr + 1, &pstr, 10);  ASSERT(pstr);    
			rcTextPadding.bottom = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr);    
			SetItemTextPadding(rcTextPadding);
		}
		else if( _tcsicmp(pstrName, _T("itemtextcolor")) == 0 ) {
			if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue);
			LPTSTR pstr = NULL;
			DWORD clrColor = _tcstoul(pstrValue, &pstr, 16);
			SetItemTextColor(clrColor);
		}
		else if( _tcsicmp(pstrName, _T("itembkcolor")) == 0 ) {
			if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue);
			LPTSTR pstr = NULL;
			DWORD clrColor = _tcstoul(pstrValue, &pstr, 16);
			SetItemBkColor(clrColor);
		}
		else if( _tcsicmp(pstrName, _T("itembkimage")) == 0 ) SetItemBkImage(pstrValue);
		else if( _tcsicmp(pstrName, _T("itemaltbk")) == 0 ) SetAlternateBk(_tcsicmp(pstrValue, _T("true")) == 0);
		else if( _tcsicmp(pstrName, _T("itemselectedtextcolor")) == 0 ) {
			if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue);
			LPTSTR pstr = NULL;
			DWORD clrColor = _tcstoul(pstrValue, &pstr, 16);
			SetSelectedItemTextColor(clrColor);
		}
		else if( _tcsicmp(pstrName, _T("itemselectedbkcolor")) == 0 ) {
			if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue);
			LPTSTR pstr = NULL;
			DWORD clrColor = _tcstoul(pstrValue, &pstr, 16);
			SetSelectedItemBkColor(clrColor);
		}
		else if( _tcsicmp(pstrName, _T("itemselectedimage")) == 0 ) SetSelectedItemImage(pstrValue);
		else if( _tcsicmp(pstrName, _T("itemhottextcolor")) == 0 ) {
			if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue);
			LPTSTR pstr = NULL;
			DWORD clrColor = _tcstoul(pstrValue, &pstr, 16);
			SetHotItemTextColor(clrColor);
		}
		else if( _tcsicmp(pstrName, _T("itemhotbkcolor")) == 0 ) {
			if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue);
			LPTSTR pstr = NULL;
			DWORD clrColor = _tcstoul(pstrValue, &pstr, 16);
			SetHotItemBkColor(clrColor);
		}
		else if( _tcsicmp(pstrName, _T("itemhotimage")) == 0 ) SetHotItemImage(pstrValue);
		else if( _tcsicmp(pstrName, _T("itemdisabledtextcolor")) == 0 ) {
			if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue);
			LPTSTR pstr = NULL;
			DWORD clrColor = _tcstoul(pstrValue, &pstr, 16);
			SetDisabledItemTextColor(clrColor);
		}
		else if( _tcsicmp(pstrName, _T("itemdisabledbkcolor")) == 0 ) {
			if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue);
			LPTSTR pstr = NULL;
			DWORD clrColor = _tcstoul(pstrValue, &pstr, 16);
			SetDisabledItemBkColor(clrColor);
		}
		else if( _tcsicmp(pstrName, _T("itemdisabledimage")) == 0 ) SetDisabledItemImage(pstrValue);
		else if( _tcsicmp(pstrName, _T("itemlinecolor")) == 0 ) {
			if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue);
			LPTSTR pstr = NULL;
			DWORD clrColor = _tcstoul(pstrValue, &pstr, 16);
			SetItemLineColor(clrColor);
		}
		else if( _tcsicmp(pstrName, _T("itemshowhtml")) == 0 ) SetItemShowHtml(_tcsicmp(pstrValue, _T("true")) == 0);
		else CContainerUI::SetAttribute(pstrName, pstrValue);
	}
Beispiel #20
0
CControlUI* CPicBarDlg::CreateControl(LPCTSTR pstrClass)
{
	if (_tcsicmp(pstrClass, _T("ButtonEx")) == 0)
		return new CButtonExUI;
	return NULL;
}
Beispiel #21
0
	LPVOID CTabLayoutUI::GetInterface(LPCTSTR pstrName)
	{
		if( _tcsicmp(pstrName, DUI_CTR_TABLAYOUT) == 0 ) return static_cast<CTabLayoutUI*>(this);
		return CContainerUI::GetInterface(pstrName);
	}
Beispiel #22
0
int TextureManager::LoadTexture( const TCHAR* _filename, DWORD _colorkey )
{
	// Make sure it's valid
	if(!_filename) return -1;

	// Make sure the texture isn't already loaded.
	for (unsigned int i = 0; i < m_Textures.size(); i++)
	{
		// compare strings without caring about upper or lowercase.
		if (_tcsicmp(_filename, m_Textures[i].filename) == 0)	// 0 means they are equal.
		{
			m_Textures[i].ref++; // add a reference to this texture.
			return i;	// return the index.
		}
	}

	// Look for an open spot.
	int nID = -1;
	for (unsigned int i = 0; i < m_Textures.size(); i++)
	{
		if (m_Textures[i].ref == 0)
		{
			nID = i;
			break;
		}
	}

	// if we didn't find an open spot, load it in a new one
	if (nID == -1)
	{
		// A temp texture object.
		Texture loaded;

		// Copy the filename of the loaded texture.
		_tcscpy_s(loaded.filename, _countof(loaded.filename), _filename);

		// Load the texture from the given file.
		HRESULT hr = 0;
		if (FAILED(hr = D3DXCreateTextureFromFileEx(m_Device, _filename, 0, 0, D3DX_DEFAULT, 0,
			D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT,
			D3DX_DEFAULT, _colorkey, 0, 0, &loaded.texture)))
		{
			// Failed.
			TCHAR szBuffer[256] = {0};
			_stprintf_s(szBuffer, _countof(szBuffer), _T("Failed to Create Texture - %s"), _filename); 
			MessageBox(0, szBuffer, _T("TextureManager Error"), MB_OK);
			return -1;
		}

		// AddRef.
		loaded.ref = 1;

		// Get surface description (to find Width/Height of the texture)
		D3DSURFACE_DESC d3dSurfDesc;
		ZeroMemory(&d3dSurfDesc, sizeof(d3dSurfDesc));

		loaded.texture->GetLevelDesc(0, &d3dSurfDesc);

		// Remember the Width and Height
		loaded.width	= d3dSurfDesc.Width;
		loaded.height	= d3dSurfDesc.Height;

		// Put the texture into the list.
		m_Textures.push_back(loaded);

		// Return the nID of the texture.
		return (int)m_Textures.size() - 1;
	}
	// we found an open spot
	else
	{
		// Make sure the texture has been released.
		SAFE_RELEASE(m_Textures[nID].texture);

		// Copy the filename of the loaded texture.
		_tcscpy_s(m_Textures[nID].filename, _countof(m_Textures[nID].filename), _filename);

		// Load the texture from the given file.
		HRESULT hr = 0;
		if (FAILED(hr = D3DXCreateTextureFromFileEx(m_Device, _filename, 0, 0, D3DX_DEFAULT, 0,
			D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT,
			D3DX_DEFAULT, _colorkey, 0, 0, &m_Textures[nID].texture)))
		{
			// Failed.
			TCHAR szBuffer[256] = {0};
			_stprintf_s(szBuffer, _countof( szBuffer ), _T("Failed to Create Texture - %s"), _filename); 
			MessageBox(0, szBuffer, _T("TextureManager Error"), MB_OK);
			return -1;
		}

		// Get surface description (to find Width/Height of the texture)
		D3DSURFACE_DESC d3dSurfDesc;
		ZeroMemory(&d3dSurfDesc, sizeof(d3dSurfDesc));

		m_Textures[nID].texture->GetLevelDesc(0, &d3dSurfDesc);

		// Remember the Width and Height
		m_Textures[nID].width	= d3dSurfDesc.Width;
		m_Textures[nID].height	= d3dSurfDesc.Height;

		// AddRef
		m_Textures[nID].ref = 1;

		// Return the nID of the texture.
		return nID;
	}
}
Beispiel #23
0
static FT_Error GetFontByFaceName(const char *font_name, FT_Face *face)
{
	FT_Error err = FT_Err_Cannot_Open_Resource;
	HKEY hKey;
	LONG ret;
	TCHAR vbuffer[MAX_PATH], dbuffer[256];
	TCHAR *font_namep;
	char *font_path;
	uint index;

	/* On windows NT (2000, NT3.5, XP, etc.) the fonts are stored in the
	 * "Windows NT" key, on Windows 9x in the Windows key. To save us having
	 * to retrieve the windows version, we'll just query both */
	ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T(FONT_DIR_NT), 0, KEY_READ, &hKey);
	if (ret != ERROR_SUCCESS) ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T(FONT_DIR_9X), 0, KEY_READ, &hKey);

	if (ret != ERROR_SUCCESS) {
		DEBUG(freetype, 0, "Cannot open registry key HKLM\\SOFTWARE\\Microsoft\\Windows (NT)\\CurrentVersion\\Fonts");
		return err;
	}

	/* For Unicode we need some conversion between widechar and
	 * normal char to match the data returned by RegEnumValue,
	 * otherwise just use parameter */
#if defined(UNICODE)
	font_namep = MallocT<TCHAR>(MAX_PATH);
	MB_TO_WIDE_BUFFER(font_name, font_namep, MAX_PATH * sizeof(TCHAR));
#else
	font_namep = const_cast<char *>(font_name); // only cast because in unicode pointer is not const
#endif

	for (index = 0;; index++) {
		TCHAR *s;
		DWORD vbuflen = lengthof(vbuffer);
		DWORD dbuflen = lengthof(dbuffer);

		ret = RegEnumValue(hKey, index, vbuffer, &vbuflen, NULL, NULL, (byte*)dbuffer, &dbuflen);
		if (ret != ERROR_SUCCESS) goto registry_no_font_found;

		/* The font names in the registry are of the following 3 forms:
		 * - ADMUI3.fon
		 * - Book Antiqua Bold (TrueType)
		 * - Batang & BatangChe & Gungsuh & GungsuhChe (TrueType)
		 * We will strip the font-type '()' if any and work with the font name
		 * itself, which must match exactly; if...
		 * TTC files, font files which contain more than one font are seperated
		 * byt '&'. Our best bet will be to do substr match for the fontname
		 * and then let FreeType figure out which index to load */
		s = _tcschr(vbuffer, _T('('));
		if (s != NULL) s[-1] = '\0';

		if (_tcschr(vbuffer, _T('&')) == NULL) {
			if (_tcsicmp(vbuffer, font_namep) == 0) break;
		} else {
			if (_tcsstr(vbuffer, font_namep) != NULL) break;
		}
	}

	if (!SUCCEEDED(SHGetFolderPath(NULL, CSIDL_FONTS, NULL, SHGFP_TYPE_CURRENT, vbuffer))) {
		DEBUG(freetype, 0, "SHGetFolderPath cannot return fonts directory");
		goto folder_error;
	}

	/* Some fonts are contained in .ttc files, TrueType Collection fonts. These
	 * contain multiple fonts inside this single file. GetFontData however
	 * returns the whole file, so we need to check each font inside to get the
	 * proper font.
	 * Also note that FreeType does not support UNICODE filesnames! */
#if defined(UNICODE)
	/* We need a cast here back from wide because FreeType doesn't support
	 * widechar filenames. Just use the buffer we allocated before for the
	 * font_name search */
	font_path = (char*)font_namep;
	WIDE_TO_MB_BUFFER(vbuffer, font_path, MAX_PATH * sizeof(TCHAR));
#else
	font_path = vbuffer;
#endif

	ttd_strlcat(font_path, "\\", MAX_PATH * sizeof(TCHAR));
	ttd_strlcat(font_path, WIDE_TO_MB(dbuffer), MAX_PATH * sizeof(TCHAR));

	/* Convert the path into something that FreeType understands */
	font_path = GetShortPath(font_path);

	index = 0;
	do {
		err = FT_New_Face(_library, font_path, index, face);
		if (err != FT_Err_Ok) break;

		if (strncasecmp(font_name, (*face)->family_name, strlen((*face)->family_name)) == 0) break;
		/* Try english name if font name failed */
		if (strncasecmp(font_name + strlen(font_name) + 1, (*face)->family_name, strlen((*face)->family_name)) == 0) break;
		err = FT_Err_Cannot_Open_Resource;

	} while ((FT_Long)++index != (*face)->num_faces);


folder_error:
registry_no_font_found:
#if defined(UNICODE)
	free(font_namep);
#endif
	RegCloseKey(hKey);
	return err;
}
Beispiel #24
0
BOOL ScanUDisk(IN LPCTSTR lpUDisk,IN BOOL bDelSuspicious)
{
	size_t dwLen = 0;
	size_t dwDirNameLen = 0;

	LPTSTR lpSearchDisk = NULL;		//The U Disk to search
	LPTSTR lpDirName = NULL;		//Full file path
	LPTSTR lpFileName = NULL;		//File with the same name as a directory, but has a ".exe" type extension

	HANDLE hFind = INVALID_HANDLE_VALUE;
	WIN32_FIND_DATA FindFileData;

	//Build the search string
	StringCchLength(lpUDisk,20/*set this to 4 later*/,&dwLen);
	lpSearchDisk = (LPTSTR)LocalAlloc(LPTR,(dwLen+2) * sizeof(TCHAR));
	StringCchPrintf(lpSearchDisk,dwLen+3,TEXT("%s%s"),lpUDisk,TEXT("*"));

	hFind = FindFirstFile(lpSearchDisk, &FindFileData);
	if (hFind != INVALID_HANDLE_VALUE)
	{
		do
		{
			if ( IsDotsDirectory(FindFileData.cFileName) )
				continue;

			//construct the directory or file full path
			StringCchLength(FindFileData.cFileName,MAX_PATH,&dwDirNameLen);	//get the directory name length
			dwDirNameLen += dwLen + 2;
			lpDirName = (LPTSTR)LocalAlloc(LPTR,dwDirNameLen * sizeof(TCHAR));	
			StringCchPrintf(lpDirName,LocalSize((HLOCAL)lpDirName),TEXT("%s%s"),lpUDisk,FindFileData.cFileName);
			
			//construct the full suspicious file path
			lpFileName = (LPTSTR)LocalAlloc(LPTR,(dwDirNameLen + 4) * sizeof(TCHAR));
			StringCchPrintf(lpFileName,LocalSize((HLOCAL)lpFileName),TEXT("%s.exe"),lpDirName);

			if ( (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY )
			{
				//it's a directory
				SetFileAttributes(lpDirName,FindFileData.dwFileAttributes & ~FILE_ATTRIBUTE_HIDDEN & ~FILE_ATTRIBUTE_SYSTEM);
				
				if( bDelSuspicious )
				{
					//delete suspicious file
					DelSuspiciousFile(lpFileName,FindFileData.dwFileAttributes);
				}
			}
			else		//it's a file
			{	
				if( bDelSuspicious )
				{
					//delete "autorun.inf"
					if( !_tcsicmp(FindFileData.cFileName,TEXT("autorun.inf")) )
						DelSuspiciousFile(lpDirName,FILE_ATTRIBUTE_NORMAL);
						
					//delete other malicious files
					if( IsFileMalicious(FindFileData.cFileName) )
					{						
						DelSuspiciousFile(lpDirName,FindFileData.dwFileAttributes);
					}
				}
			}

		} while (FindNextFile(hFind, &FindFileData));
	}
	FindClose(hFind);
	hFind = NULL;

	LocalFree((HLOCAL)lpDirName);
	LocalFree((HLOCAL)lpSearchDisk);
	lpSearchDisk = NULL;
	lpDirName = NULL;	
	
	return TRUE;
}
	LPVOID CHorizontalLayoutUI::GetInterface(LPCTSTR pstrName)
	{
		if( _tcsicmp(pstrName, DUI_CTR_HORIZONTALLAYOUT) == 0 ) return static_cast<CHorizontalLayoutUI*>(this);
		return CContainerUI::GetInterface(pstrName);
	}
Beispiel #26
0
static BOOL
LoadAndParseAppCompatibilityFlags(LPCOMPATIBILITYPAGE info,
                                  LPTSTR szValueName)
{
    LONG e;
    HKEY hk;
    DWORD dwType, dwSize;
    TCHAR szStr[256];

    e = RegOpenKey(HKEY_CURRENT_USER,
                   TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers"),
                   &hk);
    if (e == ERROR_SUCCESS)
    {
        dwSize = sizeof(szStr);

        e = RegQueryValueEx(hk,
                            szValueName,
                            0,
                            &dwType,
                            (LPBYTE)szStr,
                            &dwSize);

        if (e == ERROR_SUCCESS)
        {
            /* FIXME - make sure the string is NULL-terminated! */
            TCHAR *c;
            for (c = szStr;
                 *c != TEXT('\0');
                 c++)
            {
                /* only the first word represents the compatibility mode */
                /* FIXME - parse all words! */
                if (*c == TEXT(' '))
                {
                    *c = TEXT('\0');
                    break;
                }
            }

            info->CSelectedItem = NULL;
            if (szStr[0] != 0)
            {
                PCITEM item;

                for (item = info->CItems;
                     item != NULL;
                     item = item->next)
                {
                    if (!_tcsicmp(szStr, item->szKeyName))
                    {
                        info->CSelectedItem = item;
                        break;
                    }
                }
            }
        }
        RegCloseKey(hk);
    }

    return FALSE;
}
Beispiel #27
0
void ShellDirectory::read_directory(int scan_flags)
{
	CONTEXT("ShellDirectory::read_directory()");

	int level = _level + 1;

	Entry* first_entry = NULL;
	Entry* last = NULL;

	/*if (_folder.empty())
		return;*/

#ifndef _NO_WIN_FS
	TCHAR buffer[_MAX_PATH+_MAX_FNAME];

	if (!(scan_flags&SCAN_NO_FILESYSTEM) && get_path(buffer, COUNTOF(buffer)) && _tcsncmp(buffer,TEXT("::{"),3)) {
		Entry* entry = NULL;	// eliminate useless GCC warning by initializing entry

		LPTSTR p = buffer + _tcslen(buffer);

		lstrcpy(p, TEXT("\\*"));

		WIN32_FIND_DATA w32fd;
		HANDLE hFind = FindFirstFile(buffer, &w32fd);

		if (hFind != INVALID_HANDLE_VALUE) {
			do {
				 // ignore hidden files (usefull in the start menu)
				if (w32fd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN)
					continue;

				 // ignore directory entries "." and ".."
				if ((w32fd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) &&
					w32fd.cFileName[0]==TEXT('.') &&
					(w32fd.cFileName[1]==TEXT('\0') ||
					(w32fd.cFileName[1]==TEXT('.') && w32fd.cFileName[2]==TEXT('\0'))))
					continue;

				lstrcpy(p+1, w32fd.cFileName);

				if (w32fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
					entry = new WinDirectory(this, buffer);
				else
					entry = new WinEntry(this);

				if (!first_entry)
					first_entry = entry;

				if (last)
					last->_next = entry;

				memcpy(&entry->_data, &w32fd, sizeof(WIN32_FIND_DATA));

				entry->_level = level;

				if (!(scan_flags & SCAN_DONT_ACCESS)) {
					HANDLE hFile = CreateFile(buffer, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
												0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0);

					if (hFile != INVALID_HANDLE_VALUE) {
						if (GetFileInformationByHandle(hFile, &entry->_bhfi))
							entry->_bhfi_valid = true;

						if (ScanNTFSStreams(entry, hFile))
							entry->_scanned = true;	// There exist named NTFS sub-streams in this file.

						CloseHandle(hFile);
					}
				}

				 // set file type name
				LPCTSTR ext = g_Globals._ftype_mgr.set_type(entry);

				DWORD attribs = SFGAO_FILESYSTEM;

				if (w32fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
					attribs |= SFGAO_FOLDER|SFGAO_HASSUBFOLDER;

				if (w32fd.dwFileAttributes & FILE_ATTRIBUTE_READONLY)
					attribs |= SFGAO_READONLY;

				//if (w32fd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN)
				//	attribs |= SFGAO_HIDDEN;

				if (w32fd.dwFileAttributes & FILE_ATTRIBUTE_COMPRESSED)
					attribs |= SFGAO_COMPRESSED;

				if (ext && !_tcsicmp(ext, _T(".lnk"))) {
					attribs |= SFGAO_LINK;
					w32fd.dwFileAttributes |= ATTRIBUTE_SYMBOLIC_LINK;
				}

				entry->_shell_attribs = attribs;

				if (w32fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
					entry->_icon_id = ICID_FOLDER;
				else if (!(scan_flags & SCAN_DONT_EXTRACT_ICONS))
					entry->_icon_id = entry->safe_extract_icon();	// Assume small icon, we can extract the large icon later on demand.

				last = entry;
			} while(FindNextFile(hFind, &w32fd));

			FindClose(hFind);
		}
	}
	else // SCAN_NO_FILESYSTEM
#endif
	{
		ShellItemEnumerator enumerator(_folder, SHCONTF_FOLDERS|SHCONTF_NONFOLDERS|SHCONTF_INCLUDEHIDDEN|SHCONTF_SHAREABLE|SHCONTF_STORAGE);

		TCHAR name[MAX_PATH];
		TCHAR path[MAX_PATH];
		HRESULT hr_next = S_OK;

		do {
#define FETCH_ITEM_COUNT	32
			LPITEMIDLIST pidls[FETCH_ITEM_COUNT];
			ULONG cnt = 0;

			memset(pidls, 0, sizeof(pidls));

			hr_next = enumerator->Next(FETCH_ITEM_COUNT, pidls, &cnt);

			/* don't break yet now: Registry Explorer Plugin returns E_FAIL!
			if (!SUCCEEDED(hr_next))
				break; */

			if (hr_next == S_FALSE)
				break;

			for(ULONG n=0; n<cnt; ++n) {
				WIN32_FIND_DATA w32fd;
				BY_HANDLE_FILE_INFORMATION bhfi;
				bool bhfi_valid = false;

				memset(&w32fd, 0, sizeof(WIN32_FIND_DATA));

				SFGAOF attribs_before = ~SFGAO_READONLY & ~SFGAO_VALIDATE;
				SFGAOF attribs = attribs_before;
				HRESULT hr = _folder->GetAttributesOf(1, (LPCITEMIDLIST*)&pidls[n], &attribs);
				bool removeable = false;

				if (SUCCEEDED(hr) && attribs!=attribs_before) {
					 // avoid accessing floppy drives when browsing "My Computer"
					if (attribs & SFGAO_REMOVABLE) {
						attribs |= SFGAO_HASSUBFOLDER;
						removeable = true;
					} else if (!(scan_flags & SCAN_DONT_ACCESS)) {
						SFGAOF attribs2 = SFGAO_READONLY;

						HRESULT hr = _folder->GetAttributesOf(1, (LPCITEMIDLIST*)&pidls[n], &attribs2);

						if (SUCCEEDED(hr))
							attribs |= attribs2;
					}
				} else
					attribs = 0;

				bhfi_valid = fill_w32fdata_shell(pidls[n], attribs, &w32fd, &bhfi,
												 !(scan_flags&SCAN_DONT_ACCESS) && !removeable);

				try {
					Entry* entry = NULL;	// eliminate useless GCC warning by initializing entry

					if (w32fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
						entry = new ShellDirectory(this, pidls[n], _hwnd);
					else
						entry = new ShellEntry(this, pidls[n]);

					if (!first_entry)
						first_entry = entry;

					if (last)
						last->_next = entry;

					memcpy(&entry->_data, &w32fd, sizeof(WIN32_FIND_DATA));

					if (bhfi_valid)
						memcpy(&entry->_bhfi, &bhfi, sizeof(BY_HANDLE_FILE_INFORMATION));

					 // store path in entry->_data.cFileName in case fill_w32fdata_shell() didn't already fill it
					if (!entry->_data.cFileName[0])
						if (SUCCEEDED(path_from_pidl(_folder, pidls[n], path, COUNTOF(path))))
							_tcscpy(entry->_data.cFileName, path);

					if (SUCCEEDED(name_from_pidl(_folder, pidls[n], name, COUNTOF(name), SHGDN_INFOLDER|0x2000/*0x2000=SHGDN_INCLUDE_NONFILESYS*/))) {
						if (!entry->_data.cFileName[0])
							_tcscpy(entry->_data.cFileName, name);
						else if (_tcscmp(entry->_display_name, name))
							entry->_display_name = _tcsdup(name);	// store display name separate from file name; sort display by file name
					}

					if (attribs & SFGAO_LINK)
						w32fd.dwFileAttributes |= ATTRIBUTE_SYMBOLIC_LINK;

					entry->_level = level;
					entry->_shell_attribs = attribs;
					entry->_bhfi_valid = bhfi_valid;

					 // set file type name
					g_Globals._ftype_mgr.set_type(entry);

					 // get icons for files and virtual objects
					if (!(entry->_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ||
						!(attribs & SFGAO_FILESYSTEM)) {
						if (!(scan_flags & SCAN_DONT_EXTRACT_ICONS))
							entry->_icon_id = entry->safe_extract_icon();	// Assume small icon, we can extract the large icon later on demand.
					} else if (entry->_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
						entry->_icon_id = ICID_FOLDER;
					else
						entry->_icon_id = ICID_NONE;	// don't try again later

					last = entry;
				} catch(COMException& e) {
					HandleException(e, _hwnd);
				}
			}
		} while(SUCCEEDED(hr_next));
	}

	if (last)
		last->_next = NULL;

	_down = first_entry;
	_scanned = true;
}
Beispiel #28
0
BOOL GetOnePidFromSession(DWORD& dwPid, DWORD dwSessionId)
{
	HANDLE hProcessSnap		= NULL; 
	HANDLE hProcess         = NULL;
	HANDLE hToken           = NULL;
	BOOL bRetCode			= FALSE; 
	PROCESSENTRY32 pe32     = {0}; 
//	DWORD  dwActiveSessionId  = 0;
	DWORD dwProcessSessionId = 0;
	PVOID pTokenUserBuf = NULL;
	DWORD size = 0;

	// 得到 active session id 先
	//if ( ! GetActiveSessionID(dwActiveSessionId) )
	//{
	//	return FALSE;
	//}

	hProcessSnap = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); 
	if (hProcessSnap == INVALID_HANDLE_VALUE)
	{
		return FALSE; 
	}

	pe32.dwSize = sizeof(PROCESSENTRY32); 

	if (::Process32First(hProcessSnap, &pe32)) 
	{  
		do 
		{
			if (hProcess != NULL)
			{
				::CloseHandle(hProcess);
				hProcess = NULL;
			}

			if (hToken != NULL)
			{
				::CloseHandle(hToken);
				hToken = NULL;
			}
		
			// 不是explorer.exe进程就直接 continue
			if (0 != _tcsicmp(pe32.szExeFile, _T("explorer.exe")))
				continue;

			// 找到一个PID, whoes session id is identical with the active session id
			if (FALSE == ::ProcessIdToSessionId(pe32.th32ProcessID, &dwProcessSessionId) 
				|| dwProcessSessionId != dwSessionId )
				continue;

			// 打开进程并且成功得到了token名柄
			if (NULL == (hProcess = ::OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pe32.th32ProcessID)))
				continue;

			if (FALSE == ::OpenProcessToken(hProcess, TOKEN_ALL_ACCESS, &hToken))
				continue;

			pTokenUserBuf	= NULL;
			size			= 0;
			// 成功检索到token的信息
			if (FALSE == GetTokenInfo(hToken, TokenUser, &pTokenUserBuf, &size))
				continue;
	
			// 从token里拿到sid
			// 这个进程的用户不是system时才中止
			if (!IsSystemUserSid(((PTOKEN_USER)pTokenUserBuf)->User.Sid))
			{
				dwPid = pe32.th32ProcessID;
				bRetCode = TRUE;					

				FreeTokenInfo(pTokenUserBuf);
				pTokenUserBuf = NULL;
				break;
			}

			FreeTokenInfo(pTokenUserBuf);
			pTokenUserBuf = NULL;

		}while (::Process32Next(hProcessSnap, &pe32)); 
	} 

	if (hProcess != NULL)
	{
		::CloseHandle(hProcess);
		hProcess = NULL;
	}

	if (hToken != NULL)
	{
		::CloseHandle(hToken);
		hToken = NULL;
	}

	if (hProcessSnap != INVALID_HANDLE_VALUE)
	{
		::CloseHandle(hProcessSnap);
	}

	return (bRetCode);
}
	LPVOID CAnimationTabLayoutUI::GetInterface(LPCTSTR pstrName)
	{
		if( _tcsicmp(pstrName, _T("AnimationTabLayout")) == 0 ) 
			return static_cast<CAnimationTabLayoutUI*>(this);
		return CTabLayoutUI::GetInterface(pstrName);
	}
	LPVOID CProgressUI::GetInterface(LPCTSTR pstrName)
	{
		if( _tcsicmp(pstrName, DUI_CTR_PROGRESS) == 0 ) return static_cast<CProgressUI*>(this);
		return CLabelUI::GetInterface(pstrName);
	}