Beispiel #1
0
char* LoadJpegFile (char *jpegbuf, char *bmpbuf)
{
	DWORD 		       ImgSize;
	DWORD              JpegBufSize;
	int				   funcret;
	LPBITMAPINFOHEADER lpImgData;
	//JpegBufSize=size;
	lpJpegBuf=jpegbuf;
	InitTable();
	if((funcret=InitTag())!=FUNC_OK)
	{
		showerror(funcret);
		return NULL;
	}
	//create new bitmapfileheader and bitmapinfoheader
	memset((char *)&bf,0,sizeof(BITMAPFILEHEADER));	
	memset((char *)&bi,0,sizeof(BITMAPINFOHEADER));

	bi.biSize=(DWORD)sizeof(BITMAPINFOHEADER);
	bi.biWidth=(LONG)(ImgWidth);
	bi.biHeight=(LONG)(ImgHeight);
	bi.biPlanes=1;
	bi.biBitCount=24;
	bi.biClrUsed=0;
	bi.biClrImportant=0;
	bi.biCompression=BI_RGB;
	NumColors=0;
	LineBytes=(DWORD)WIDTHBYTES(bi.biWidth*bi.biBitCount);
	ImgSize=(DWORD)LineBytes*bi.biHeight;
	
	bf.bfType=0x4d42;
	bf.bfSize=/*sizeof(BITMAPFILEHEADER)*/ 14+sizeof(BITMAPINFOHEADER)+NumColors*sizeof(RGBQUAD)+ImgSize;
	bf.bfOffBits=(DWORD)(NumColors*sizeof(RGBQUAD)+14/*sizeof(BITMAPFILEHEADER)*/+sizeof(BITMAPINFOHEADER));

	lpPtr = (char*)bmpbuf + 54;

	if((SampRate_Y_H==0)||(SampRate_Y_V==0))
	{
		showerror(FUNC_FORMAT_ERROR);
		return NULL ;
	}

	funcret=Decode();

	memcpy(bmpbuf, &bf.bfType,sizeof(WORD));
	memcpy(bmpbuf+2, ((char*)&bf)+4, 12);
	memcpy(bmpbuf+14, (LPSTR)&bi,sizeof(BITMAPINFOHEADER));

	if(funcret!=FUNC_OK)
	{
		showerror(funcret);
		return NULL;
	}
	return lpPtr;
}
//读取JPEG代码,并解码
BOOL LoadJpegFile (const unsigned char *JpegFileName)
{								  
    DWORD			    JpegBufSize; 
	const unsigned char *hJpegBuf;
	int				    funcret;
 
 	hJpegBuf=JpegFileName;//JPEG文件头
	lpJpegBuf=(unsigned char*)hJpegBuf;//转换为变量指针  
	InitTable();  
	if((funcret=InitTag())!=FUNC_OK)//初始化表头不成功 
	{					 
		showerror(funcret);//错误信息显示
		return FALSE;
	}    
	if((SampRate_Y_H==0)||(SampRate_Y_V==0))
	{	    
		return FALSE ;
	}	   
	funcret=Decode();
	if(funcret==FUNC_OK)//解码成功
	{   
		return TRUE;
	}
	else
	{ 
		return FALSE;
	}
}
Beispiel #3
0
void ui::OnFreshenDNSInfo()
{
    m_p_last_selected_dns_item = nullptr;
    m_orgin_dns_item_color = 0xFFFFFFFF;
    m_p_dns_info_list->RemoveAll();
    m_map_dns_item_ip.clear();

    EnableUserOperation(false);
    std::thread(
        [this]()
    {
        std::shared_ptr<freshen_dns_info_result_data> sp_res_data = std::make_shared<freshen_dns_info_result_data>();
        result res = m_p_notifyer->on_freshen_dns_info(*sp_res_data.get());
        if (res != result_success)
        {
            showerror("Ë¢ÐÂDNSʧ°Ü-->[%s]", result_string(res));
            EnableUserOperation(true);
            return;
        }
        post_call(
            [this, sp_res_data]()
        {
            showlog("Ë¢ÐÂDNSÁбíºÄʱ[%ws]", sp_res_data->_str_freshen_take_time.c_str());
            for (auto it : sp_res_data->_vec_ip_dns_info)
            {
                ui_dns_info& info = it;

                DuiLib::CDialogBuilder builder;
                DuiLib::CListContainerElementUI* p_item = static_cast<DuiLib::CListContainerElementUI*>(builder.Create(_T("dns_info_item.xml"), (UINT)0, NULL, &m_PaintManager));
                Assert(p_item != nullptr);

                if (m_orgin_dns_item_color == 0xFFFFFFFF)
                {
                    m_orgin_dns_item_color = p_item->GetBkColor();
                }

                DuiLib::CLabelUI* p_dns_vip_label = static_cast<DuiLib::CLabelUI*>(p_item->FindSubControl(_T("dns_vip_label")));
                Assert(p_dns_vip_label != nullptr);
                DuiLib::CLabelUI* p_dns_uptime_label = static_cast<DuiLib::CLabelUI*>(p_item->FindSubControl(_T("dns_uptime_label")));
                Assert(p_dns_uptime_label != nullptr);
                DuiLib::CLabelUI* p_dns_ping_t_ms_label = static_cast<DuiLib::CLabelUI*>(p_item->FindSubControl(_T("dns_ping_t_ms_label")));
                Assert(p_dns_ping_t_ms_label != nullptr);

                p_dns_vip_label->SetText(info._str_vip.c_str());
                p_dns_uptime_label->SetText(info._str_uptime.c_str());
                p_dns_ping_t_ms_label->SetText(info._str_ping_t_ms.c_str());

                m_p_dns_info_list->Add(p_item);
                m_map_dns_item_ip.insert(std::make_pair(p_item, info._str_vip));
            }

            EnableUserOperation(true);
        }
        );
    }
    ).detach();
}
Beispiel #4
0
void ui::InitWindow()
{
    m_p_exit_btn = static_cast<DuiLib::CButtonUI*>(m_PaintManager.FindControl(_T("exit_btn")));
    Assert(m_p_exit_btn != nullptr);
    m_p_min_btn = static_cast<DuiLib::CButtonUI*>(m_PaintManager.FindControl(_T("min_btn")));
    Assert(m_p_min_btn != nullptr);
    m_p_version_label = static_cast<DuiLib::CButtonUI*>(m_PaintManager.FindControl(_T("version_label")));
    Assert(m_p_version_label != nullptr);
    m_p_auto_done_btn = static_cast<DuiLib::CButtonUI*>(m_PaintManager.FindControl(_T("auto_done_btn")));
    Assert(m_p_auto_done_btn != nullptr);
    m_p_professional_view = static_cast<DuiLib::CVerticalLayoutUI*>(m_PaintManager.FindControl(_T("professional_view")));
    Assert(m_p_professional_view != nullptr);
    m_p_adapter_info_list = static_cast<DuiLib::CListUI*>(m_PaintManager.FindControl(_T("adapter_info_list")));
    Assert(m_p_adapter_info_list != nullptr);
    m_p_dns_info_list = static_cast<DuiLib::CListUI*>(m_PaintManager.FindControl(_T("dns_info_list")));
    Assert(m_p_dns_info_list != nullptr);
    m_p_freshen_adapter_btn = static_cast<DuiLib::CButtonUI*>(m_PaintManager.FindControl(_T("freshen_adapter_btn")));
    Assert(m_p_freshen_adapter_btn != nullptr);
    m_p_freshen_dns_btn = static_cast<DuiLib::CButtonUI*>(m_PaintManager.FindControl(_T("freshen_dns_btn")));
    Assert(m_p_freshen_dns_btn != nullptr);
    m_p_switch_adapter_dns_btn = static_cast<DuiLib::CButtonUI*>(m_PaintManager.FindControl(_T("switch_adapter_dns_btn")));
    Assert(m_p_switch_adapter_dns_btn != nullptr);
    m_p_log_list = static_cast<DuiLib::CListUI*>(m_PaintManager.FindControl(_T("log_list")));
    Assert(m_p_log_list != nullptr);
    
    m_p_version_label->SetText(get_version().c_str());
    m_p_log_list->GetHeader()->SetFixedHeight(1);
    m_p_dns_info_list->GetHeader()->SetFixedHeight(1);
    m_p_adapter_info_list->GetHeader()->SetFixedHeight(1);

    EnableUserOperation(false);
    std::thread(
        [this]()
    {
        result res = m_p_notifyer->on_initialize(); 
        if (res == result_success)
        {
            post_call(
                [this]()
            {
                EnableUserOperation(true);
            }
                );
        }
        else
        {
            showerror("³õʼ»¯Ê§°Ü-->[%s]", result_string(res));
        }
    }
    ).detach();

}
Beispiel #5
0
//works with xp
static int registerprogid()
{
	HKEY hKey;
	DWORD dis = 0;
	int ret = 1;
	char keyname[512];
	char cmd[1024];
	char filename[1024];
	LONG err;

	//get executable filename
	GetModuleFileName(GetModuleHandle(0),filename,1024);

	//register progid
	sprintf(cmd,"\"%s\" \"%%1\"",filename);
	sprintf(keyname,"Software\\Classes\\%s\\shell\\open\\command",progid);
	if((err = RegCreateKeyEx(HKEY_CURRENT_USER,keyname,0,NULL,0,KEY_READ | KEY_WRITE,NULL,&hKey,&dis)) == ERROR_SUCCESS) {
		log_printf("registerprogid:  setting default value to '%s'\n",cmd);
		RegSetValueEx(hKey,NULL,0,REG_EXPAND_SZ,(LPBYTE)cmd,(DWORD)strlen(cmd) + 1);
		RegCloseKey(hKey);
	}
	else {
		showerror(err);
	}

	//register default icon
	sprintf(cmd,"%s,0",filename);
	sprintf(keyname,"Software\\Classes\\%s\\defaulticon",progid);
	log_printf("registerprogid:  creating key '%s'\n",keyname);
	if((err = RegCreateKeyEx(HKEY_CURRENT_USER,keyname,0,NULL,0,KEY_READ | KEY_WRITE,NULL,&hKey,&dis)) == ERROR_SUCCESS) {
		RegSetValueEx(hKey,NULL,0,REG_EXPAND_SZ,(LPBYTE)cmd,(DWORD)strlen(cmd) + 1);
		RegCloseKey(hKey);
	}
	else {
		showerror(err);
	}
	return(ret);
}
Beispiel #6
0
int send_all( int sock, char *action )
{
   /*
    * Send everything in stdin to the socket. Each LF encountered
    * results in a send.
    * This code borrowed from rxstack.c in REXX/imc
    */
   int c,rc;
   unsigned int len;
   streng *result;

   for ( ; ; )
   {
      len = 0;
      while ( ( c = getchar() ) != EOF )
      {
         if ( c == REGINA_EOL )
         {
#if defined(DOS) || defined(OS2) || defined(WIN32)
            if (len && ( buff[len-1] == REGINA_CR ) )
               len--;
#endif
            break;
         }
         if ( len >= bufflen
         && (( buff = (char *)realloc( buff, bufflen <<= 1 ) ) == NULL ) )
         {
           showerror( ERR_STORAGE_EXHAUSTED, 0, ERR_STORAGE_EXHAUSTED_TMPL );
           exit( ERR_STORAGE_EXHAUSTED );
         }
         buff[len++] = (char)c;
      }
      if ( (c == EOF || feof(stdin) )
      &&  !len)
         break;
      DEBUGDUMP(printf("--- Queue %s ---\n", action[0] == RXSTACK_QUEUE_FIFO ? "FIFO" : "LIFO"););
      rc = send_command_to_rxstack( NULL, sock, action, buff, len );
      if ( rc != -1 )
      {
         result = read_result_from_rxstack( NULL, sock, RXSTACK_HEADER_SIZE );
         DROPSTRENG( result );
      }
   }
Beispiel #7
0
int init_external_queue( const tsd_t *TSD )
{
   int rc=0;
#ifdef WIN32
   WORD wsver = (WORD)MAKEWORD(1,1);
   WSADATA wsaData;
   if ( WSAStartup( wsver, &wsaData ) != 0 )
   {
      /* TSD will be NULL when called from rxqueue or rxstack */
      if ( TSD == NULL )
         showerror( ERR_EXTERNAL_QUEUE, ERR_RXSTACK_NO_WINSOCK, ERR_RXSTACK_NO_WINSOCK_TMPL, WSAGetLastError() );
      else if ( !TSD->called_from_saa )
         exiterror( ERR_EXTERNAL_QUEUE, ERR_RXSTACK_NO_WINSOCK, WSAGetLastError() );
      rc = 1;
   }
#else
   TSD = TSD; /* keep compiler happy */
#endif
   return rc;
}
Beispiel #8
0
void ui::OnAutoDone()
{
    EnableUserOperation(false);
    std::thread(
        [this]()
    {
        std::wstring take_time;
        result res = m_p_notifyer->on_auto_done(take_time);
        if (res == result_success)
        {
            showlog("×Ô¶¯ÓÅ»¯DNS³É¹¦£¬ºÄʱ[%ws]", take_time.c_str());
        }
        else
        {
            showerror("×Ô¶¯ÓÅ»¯DNSʧ°Ü-->[%s]", result_string(res));
        }
        EnableUserOperation(true);
    }
    ).detach();
}
Beispiel #9
0
static int registerassociation(char *extension)
{
	HKEY hKey;
	DWORD dis = 0;
	int ret = 1;
	char keyname[128];
	char filename[1024];
	LONG err;

	GetModuleFileName(GetModuleHandle(0),filename,1024);

	//register progid
	sprintf(keyname,"Software\\Classes\\%s",extension);
	log_printf("registerassociation:  creating key '%s'\n",keyname);
	if((err = RegCreateKeyEx(HKEY_CURRENT_USER,keyname,0,NULL,0,KEY_READ | KEY_WRITE,NULL,&hKey,&dis)) == ERROR_SUCCESS) {
		RegSetValueEx(hKey,NULL,0,REG_SZ,(LPBYTE)progid,(DWORD)strlen(progid) + 1);
		RegCloseKey(hKey);
	}
	else {
		showerror(err);
	}
	return(ret);
}