コード例 #1
0
//从链接中抓取Rss的XML数据,并向RssFeed列表中插入数据。
//并且得到RssFeed的名字加入RssFeedList中。
//将该RssFeed对应的RssItem 的map加入RssItemList中。
bool GetRssMsgFromLink(HWND hwnd, TCHAR* szRssFeedLink)
{
	//先得到暂存文件的全路径,看全路径是否有问题。
	TCHAR szTempRssXmlPath[MAX_PATH] = { NULL };
	InitRssXMLTempSavePath(hwnd, szTempRssXmlPath);
	//开始下载xml文本信息。
	HRESULT hResult = URLDownloadToFile(NULL, szRssFeedLink, szTempRssXmlPath, 0, NULL);
	if (hResult != S_OK)
	{
		MessageBox(hwnd, TEXT("抓取RssFeed失败!请检查网络设置!!"), TEXT("ERROR"), MB_OK | MB_ICONERROR);
		return false;
	}
	//下载之后保存该RssFeed的链接。
	char* cszRssFeedLink = FileEncode::UnicodeToAnsi((char*)szRssFeedLink);
	RssFeedLinks.push_back(string(cszRssFeedLink));
	free(cszRssFeedLink);
	//下载到本地暂存路径之后开始读入。
	string rssFeedTitle;
	map<string, RssContent> rssItemMap;//保存RssFeed中RssItem对应的信息。
	ReadXmlFile(szTempRssXmlPath, rssFeedTitle, rssItemMap);
	//向RssFeedList中加入RssFeed的名字。
	RssFeedList.push_back(rssFeedTitle);
	//在向RssFeed的列表中加入对应的项。
	//在此之前先检查空行的存在。
	ClearRssListBlank(hwnd, IDC_RssFeedList);
	TCHAR* szRssFeedTitle = FileEncode::UTF8ToUnicode((char*)rssFeedTitle.c_str());
	SendMessage(GetDlgItem(hwnd, IDC_RssFeedList), LB_INSERTSTRING, (WPARAM)-1, (LPARAM)szRssFeedTitle);
	free(szRssFeedTitle);
	//向RssItemList中加入该RssItem对应的信息。
	RssItemList.push_back(rssItemMap);
	return true;
}
コード例 #2
0
//刷新RssFeed列表里面确定的某一项。
//HWND 父窗口的句柄,刷新RssFeed列表里面的某一项。
bool RefreshReeFeedInList(HWND hwnd)
{
	HWND hRssFeedListWnd = GetDlgItem(hwnd, IDC_RssFeedList);
	int iCurRssFeedIndex = SendMessage(hRssFeedListWnd, LB_GETCURSEL, (WPARAM)0, (LPARAM)0);
	if (LB_ERR == iCurRssFeedIndex)
	{
		MessageBox(hwnd, TEXT("您未选中要更新的RssFeed项!"), TEXT("Message"), MB_OK);
		return false;
	}
	//然后从RssFeedLink的列表里面取出对应的链接,开始刷新。
	TCHAR* szRssFeedLink = FileEncode::AnsiToUnicode((char*)(RssFeedLinks[iCurRssFeedIndex].c_str()));
	//先得到暂存文件的全路径,看全路径是否有问题。
	TCHAR szTempRssXmlPath[MAX_PATH] = { NULL };
	InitRssXMLTempSavePath(hwnd, szTempRssXmlPath);
	//开始下载xml文本信息。
	HRESULT hResult = URLDownloadToFile(NULL, szRssFeedLink, szTempRssXmlPath, 0, NULL);
	if (hResult != S_OK)
	{
		MessageBox(hwnd, TEXT("抓取RssFeed失败!请检查网络设置!!"), TEXT("ERROR"), MB_OK | MB_ICONERROR);
		return false;
	}
	//下载到本地暂存路径之后开始读入。
	string rssFeedTitle;
	map<string, RssContent> rssItemMap;//保存RssFeed中RssItem对应的信息。
	ReadXmlFile(szTempRssXmlPath, rssFeedTitle, rssItemMap);
	//在RssListItem对应的位置替换掉原来的map。
	RssItemList[iCurRssFeedIndex] = rssItemMap;
	return true;
}
コード例 #3
0
bool VerifyXmlEntries()
{
    if (!DoesFileExist(XmlFileName))
    {
        return false;
    }

    std::vector<std::wstring> XmlContents;
    ReadXmlFile(XmlFileName, XmlContents);

    int lineNumber;
    if (!FindXmlFirstLine(XmlContents, XmlEntries[0], lineNumber))
    {
        // Couldn't find the first line of the xml entries in the xml file, so we need to add them.
        if (!InsertXmlEntries(XmlContents))
        {
            return false;
        }
        else
        {
            return WriteLinesToFile(XmlFileName, XmlContents);
        }
    }
    else
    {
        // we found the first line, good enough.  Don't want to FORCE people to
        // setup this file exactly like me, but just want to add the entries if
        // they haven't got them already.
        
        // we'll check and see if what's there matches the internals of what we
        // have here.  If they match, we'll exit normally, otherwise we'll prompt
        // the user, asking them if they want us to repair the builder_setup.xml.

        if (CheckXmlMatch(XmlContents))
        {
            return true;  //matches, nothing to do here.
        }
        else
        {
            std::wstring message = L"It appears that the portion of builder_setup.xml that deals with "
                                   L"blender files is out of date, or has been altered.  Would you like "
                                   L"to repair this now?";
            int result = MessageBox(NULL, message.c_str(), L"Repair builder_setup.xml?", MB_YESNO | MB_ICONEXCLAMATION);
            if (result != IDYES)
            {
                return true;  // we tried, but they don't want it.
            }

            // attempt to repair XML file.
            if (!RepairXmlFile(XmlContents))
            {
                std::wstring message = L"Unable to repair xml file.  Delete builder_setup.xml, and run verify files through steam to replace it.  Then run this utility again.";
                MessageBox(NULL, message.c_str(), L"Error", MB_OK | MB_ICONERROR);
            }
            return true;
        }
    }
}
コード例 #4
0
BOOL OSAL_ConfigController_SetNumValue(const char *ignore, const char *config_name, UINT32 *value)
{
    BOOL result = FALSE;
    BOOL bXmlRead, bSetInnerText, bXmlWrite;
    pXmlElement xmlRoot, xmlTopElement, xmlTargetElement;
    char buf[16] = {0};

    if (config_name == NULL) {
        return result;
    }

    pthread_mutex_lock(&g_configmutex);

    // Open Config XML file
    xmlRoot = CreateEmptyXmlData();


    bXmlRead = ReadXmlFile(xmlRoot, CONFIG_XMLFILE);
    if (!bXmlRead) {
		OSALTRACE(OSAL_ERROR, ("cannot read config xml file"));
		pthread_mutex_unlock(&g_configmutex);

        return result;
    }

    // Find "config_name"
    xmlTopElement = FindChild(xmlRoot, CONFIG_INTEL_WIMAX);
    xmlTargetElement = FindChild(xmlTopElement, config_name);
    if (xmlTargetElement != NULL) {
	//convert integer to string
	snprintf(buf, sizeof(buf), "%d", *value);
        bSetInnerText = SetElementInnerText(xmlTargetElement, buf);
        if(bSetInnerText == TRUE) {
            // write to XML file
            bXmlWrite = WriteXmlFile(xmlTopElement, CONFIG_XMLFILE_TMP);
            if(bXmlWrite == TRUE) {
                result = TRUE;
			}
			else {
				OSALTRACE(OSAL_ERROR, ("cannot write config xml file"));
				result = FALSE;
			}
		}
	}


    // Close XML
    FreeXmlData(xmlRoot);
	//swap the file
	pthread_mutex_lock(&g_swapfilemutex);
	rename(CONFIG_XMLFILE_TMP,CONFIG_XMLFILE);
	pthread_mutex_unlock(&g_swapfilemutex);
	pthread_mutex_unlock(&g_configmutex);


    return result;
}
コード例 #5
0
BOOL OSAL_ConfigController_GetNumValue(const char *ignore, const char *config_name, UINT32 * value)
{
	BOOL result = FALSE;
	BOOL bXmlRead;
	pXmlElement xmlRoot, xmlTopElement, xmlTargetElement;
	const char *target_data;

	BOOL bDnDOutputQuery = FALSE;

	if (config_name == NULL) {
		return result;
	}

	if ( strcasecmp(config_name, OSAL_KEY_ENTRY_DND_OUTPUT_MODE) == 0)
	{
		bDnDOutputQuery = TRUE;
	}

	pthread_mutex_lock(&g_configmutex);

	// Open Config XML file
	xmlRoot = CreateEmptyXmlData();

  
	bXmlRead = ReadXmlFile(xmlRoot, CONFIG_XMLFILE);
	if (!bXmlRead) {
		OSALTRACE(OSAL_ERROR, ("cannot read config xml file"));
		pthread_mutex_unlock(&g_configmutex);
		return result;
	}

	// Find "config_name"
	xmlTopElement = FindChild(xmlRoot, CONFIG_INTEL_WIMAX);
	xmlTargetElement = FindChild(xmlTopElement, config_name);
	if (xmlTargetElement != NULL) {
		target_data = GetElementInnerText(xmlTargetElement);
		if (target_data != NULL) {
			// Copy to the value
			*value = (UINT32) atoi(target_data);
			result = TRUE;
		}
	}

	if ( bDnDOutputQuery )
	{
		OSALTRACE(OSAL_DEBUG, ("Result of query is %d, and value is %d.", result, result ? *value : -1));
	}

	// Close XML
	FreeXmlData(xmlRoot);

	pthread_mutex_unlock(&g_configmutex);

	return result;
}
コード例 #6
0
BOOL OSAL_ConfigController_GetStrValue(const char *ignore, const char *config_name, char* value,UINT32 maxsize)
{
	BOOL result = FALSE;
	BOOL bXmlRead;
	pXmlElement xmlRoot, xmlTopElement, xmlTargetElement;
	const char *target_data;
	UINT32 data_size=0;

	if (config_name == NULL) {
		return result;
	}

	pthread_mutex_lock(&g_configmutex);
	
	// Open Config XML file
	xmlRoot = CreateEmptyXmlData();

	bXmlRead = ReadXmlFile(xmlRoot, CONFIG_XMLFILE);

	if (!bXmlRead) {
		OSALTRACE(OSAL_ERROR, ("cannot read config xml file"));
		pthread_mutex_unlock(&g_configmutex);
		return result;
	}
	// Find "config_name"
	xmlTopElement = FindChild(xmlRoot, CONFIG_INTEL_WIMAX);
	xmlTargetElement = FindChild(xmlTopElement, config_name);
	if (xmlTargetElement != NULL) 
	{
		target_data = GetElementInnerText(xmlTargetElement);
		data_size = strlen(target_data)+1;
		if (target_data != NULL)
		{
			if(data_size > maxsize -1){
				// Copy to the value
				memcpy(value, target_data, maxsize-1);
				// Added by Kalyan to make the value as a complete string 
				// and to avoid problems with strlen, strcpy on value without \0
				value[maxsize-1] = '\0';
			}
			else {
				memcpy(value, target_data, data_size);
			}
			result = TRUE;
			}
	}

	// Close XML
	FreeXmlData(xmlRoot);

	pthread_mutex_unlock(&g_configmutex);

	return result;
}
コード例 #7
0
 void MdiEditor::NewProject(bool flag)
 {
 	clear();
	if (!flag)
	  	pro_path = QFileDialog::getExistingDirectory (this);
  	if(!pro_path.isNull())
  	{

  		if(!ReadXmlFile(pro_path+"\\settings.xml"))//exist

  		{

  			QFile::remove(pro_path+"\\result.html");
  			QFile::copy("template.html",pro_path+"\\result.html");


  			//load two images
  			QString ImagePathName = QFileDialog::getOpenFileName(
  				this,
  				"Load Image1",
  				QDir::currentPath(),
  				"Image files (*.bmp *.png *.jpg *.gif);All files(*.*)");
  			image1=cv::imread(ImagePathName.toLatin1().data());
			if(image1.rows==0)
 				return;
 			parameters->fname0=(const char *)ImagePathName.toLocal8Bit();
			parameters[0].mask1=Mat::zeros(image1.rows,image1.cols,CV_8UC3);

  			ImagePathName = QFileDialog::getOpenFileName(
  					this,
  					"Load Image2",
  					QDir::currentPath(),
  					"Image files (*.bmp *.png *.jpg *.gif);All files(*.*)");
  			image2=cv::imread(ImagePathName.toLatin1().data());
 			if(image2.rows==0)
 				return;
			parameters->fname1=(const char *)ImagePathName.toLocal8Bit();
  			parameters[0].mask2=Mat::zeros(image2.rows,image2.cols,CV_8UC3);

			QString item;
			item.sprintf("&layer %d",0);
			show_layer[0]=new QAction(item.toLatin1().data(), this);
			layer_view->addAction(show_layer[0]);
			show_layer[0]->setCheckable(true);
			connect(show_layer[0],SIGNAL(triggered()),this,SLOT(Layer0()));

			layer_num++;
		}

		imageEditorL->setImage(image1);
		imageEditorR->setImage(image2);
		imageEditorM->setImage(imageEditorL->_image,imageEditorR->_image);
		ctrbar->_status=1;
		mod=1;

		for(int i=0;i<layer_num;i++)
		{
			int n=log((float)MIN(image1.cols,image1.rows))/log(2.0f)-log((float)parameters[i].start_res)/log(2.0f)+1;
  			pyramids[i].build_pyramid(image1,image2,parameters[i],n,i,gpu_cap);
		}
		thread_start(layer_index);

		Changelayer();
 	}
 }