Exemple #1
0
CPropertyDlg::CPropertyDlg( MainFrame* parent, int taskid )
        : wxDialog( parent, -1, _("Task properties"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE| wxRESIZE_BORDER )
{
    m_pParent = parent;

    _TaskAttr *tsk = m_pParent->GetTask( taskid );

    if ( tsk == NULL )
        return ;


    //m_sUrl = wxString( tsk->sURL.c_str() );
	m_sUrl=wxString( tsk->sURL.c_str(), wxConvLocal );//unicode patch

    //m_sRefer = wxString( tsk->sRefer.c_str() );
	m_sRefer=wxString( tsk->sRefer.c_str(), wxConvLocal ); //unicode patch

    //对这个url分离用户名和密码
    if ( !m_sUrl.IsEmpty() )
    {
        CUrlParser par;
        std::string m_swap;
#ifndef _UNICODE
        if ( par.SetUrl( m_sUrl.mb_str( wxConvLocal ) ) )
#else
			if( par.SetUrl( m_sUrl.mb_str(wxConvLocal).data() ) ) //unicode patch
#endif
        {
            if ( par.GetUrlType() == FTP_PROTOCOL )
            {
                m_sUser = wxString( par.GetUser().c_str(), wxConvLocal );
                m_sPass = wxString( par.GetPass().c_str(), wxConvLocal );
                m_sUrl = wxString( par.GetRawUrl().c_str(), wxConvLocal );
            }
            else
            {
                m_sUrl = wxString( par.GetRawUrl().c_str(), wxConvLocal );
            }

            if ( par.GetFileName().empty() )
            {
                m_sRename = _( "index.html" );
            }
            else
            {
                //m_sRename = par.GetFileName();
					m_sRename=wxString(par.GetFileName().c_str(),wxConvLocal); //unicode patch
            }
        }
    }

    //m_sSavePath = wxString( tsk->sSavePath.c_str() );
	m_sSavePath=wxString( tsk->sSavePath.c_str(), wxConvLocal ); //unicode patch
    m_nThreadNum = tsk->nThread;
    m_nRetry = tsk->nRetry;
    m_nRetryWait = tsk->nRetryWait;

    m_nSocksProxy = 0;
    m_nFtpProxy = 0;
    m_nHttpProxy = 0;
    m_nRunNow = 0;
    m_nFileSpin = 0;

    m_pMirrorBox = NULL;
    m_ThSpin = NULL;
    m_ThRetry = NULL;
    m_ThRetryWait = NULL;
    m_FileSpin = NULL;
    m_pTextCtrl = NULL;
    m_bOpenUrlKeyEvent = false;
    InitProxyList( tsk->sSockProxy, tsk->sFtpProxy, tsk->sHttpProxy );

    Init( tsk->nStatus );

    //add mirror string

    for ( int i = 0;i < int( tsk->sMirrorURL.size() );i++ )
    {
        AddMirrorUrl( wxString( tsk->sMirrorURL[ i ].c_str(), wxConvLocal ) );
    }
}
CNewTaskDlg::CNewTaskDlg( MainFrame* parent, wxString defUrl, wxString refer, wxString defSavePath )
        : wxDialog( parent, -1, _MGSTR( _S_NEW_TASK ), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER )
{
    m_pParent = parent;
    m_sUrl = defUrl;
	
    m_sRefer = refer;
    //对这个url分离用户名和密码

    if ( !m_sUrl.IsEmpty() )
    {
        CUrlParser par;
        std::string m_swap;

#ifndef _UNICODE
        if ( par.SetUrl( m_sUrl.mb_str( wxConvLocal ) ) )
#else
		if ( par.SetUrl( m_sUrl.mb_str( wxConvLocal ).data() ) )
#endif
        {
            if ( par.GetUrlType() == FTP_PROTOCOL )
            {
                m_sUser = wxString( par.GetUser().c_str(), wxConvLocal );
                m_sPass = wxString( par.GetPass().c_str(), wxConvLocal );
                m_sUrl = wxString( par.GetRawUrl().c_str(), wxConvLocal );
            }
            else
            {
                m_sUrl = wxString( par.GetRawUrl().c_str(), wxConvLocal );
            }

            if ( par.GetFileName().empty() )
            {
                m_sRename = wxT( "index.html" );
            }
            else
            {
                //m_sRename = par.GetFileName();
				m_sRename=wxString(par.GetFileName().c_str(),wxConvLocal);
            }
        }
    }

    m_sSavePath = defSavePath;

    if ( m_sSavePath.IsEmpty() )
    {
        m_sSavePath = wxString( gDefSavePath.c_str(), wxConvLocal );

        if ( m_sSavePath.IsEmpty() )
        {
            std::string home;
            GetUserHome( home );
            m_sSavePath = wxString( home.c_str(), wxConvLocal );
        }
    }

    m_nThreadNum = gTaskDefThread;
    m_nSocksProxy = 0;
    m_nFtpProxy = 0;
    m_nHttpProxy = 0;
    m_nRunNow = 0; //run
    m_nFileSpin = 1;
    m_nRetry = gRetryTime;
    m_nRetryWait = gRetryWait;
    m_sSavePath = wxString( gDefSavePath.c_str(), wxConvLocal );
    m_pMirrorBox = NULL;
    m_ThSpin = NULL;
    m_ThRetry = NULL;
    m_ThRetryWait = NULL;
    m_FileSpin = NULL;
    m_pTextCtrl = NULL;
	m_RenameCtrl=NULL;
    m_bOpenUrlKeyEvent = false;
    //这里准备一下代理列表
    InitProxyList();
    Init();

}