Пример #1
0
void CFairyPackerView::OnEditAddfolder()
{
    // TODO: 在此添加命令处理程序代码
    // 选择一个目标文件夹
    TCHAR szPath[MAX_PATH];
    ZeroMemory( szPath,sizeof(szPath) );

    BROWSEINFO bi;
    bi.hwndOwner = m_hWnd;
    bi.pidlRoot = NULL;
    bi.pszDisplayName = szPath;
    bi.lpszTitle = _T("请选择需要要添加的目录:");
    bi.ulFlags = 0;
    bi.lpfn = NULL;
    bi.lParam = 0;
    bi.iImage = 0;

    //弹出选择目录对话框
    LPITEMIDLIST lp = SHBrowseForFolder(&bi);
    if( !(lp && SHGetPathFromIDList(lp, szPath)) )
        return;

    AString addToDir = "";
    CFairyExplorer* exp = &GetDocument()->m_Explorer;
    CFairyExplorer::PKNode* pNode = GetSelectedNode();
    if( pNode && pNode->bIsDirectory )
        addToDir = pNode->strName;

    UINT fileCount = exp->GetDiskFileCount( F_UnicodeToUTF8(szPath) );
    FFilePairList params;
    params.push_back( std::make_pair(F_UnicodeToUTF8(szPath), addToDir) );
    ProcessOperation( FAIRY_OP_ADDFILE,exp,fileCount,params );
    m_pDocument->UpdateAllViews( NULL );
}
Пример #2
0
void CFairyPackerView::OnEditAddfile()
{
    // TODO: 在此添加命令处理程序代码
    static std::vector<TCHAR> tmpBuf;
    tmpBuf.resize( 1000 * (MAX_PATH + 1) + 1 );
    CFileDialog dlg( TRUE,NULL,NULL,OFN_ALLOWMULTISELECT );
    dlg.GetOFN().lpstrFile = &tmpBuf[0];
    dlg.GetOFN().nMaxFile = 1000 * (MAX_PATH + 1) + 1;
    if( dlg.DoModal() != IDOK ) return;

    AString addToDir = "";
    CFairyExplorer* exp = &GetDocument()->m_Explorer;
    CFairyExplorer::PKNode* node = GetSelectedNode();
    if( node != NULL && node->bIsDirectory )
        addToDir = node->strName;

    int fileCount = 0;
    FFilePairList params;
    POSITION pos = dlg.GetStartPosition();
    while( pos )
    {
        CString filename = dlg.GetNextPathName(pos);
        fileCount += exp->GetDiskFileCount( F_UnicodeToUTF8((const TCHAR*)filename) );
        params.push_back( std::make_pair(F_UnicodeToUTF8((const TCHAR*)filename), addToDir) );
    }

    ProcessOperation( FAIRY_OP_ADDFILE,exp,fileCount,params );
    m_pDocument->UpdateAllViews(NULL);
}
Пример #3
0
void CFairyPackerView::OnEditExtract()
{
    // TODO: 在此添加命令处理程序代码
    CListCtrl& lc = GetListCtrl();
    CFairyExplorer& exp = GetDocument()->m_Explorer;

    UINT fileCount = 0;
    FFilePairList fileList;
    POSITION pos = lc.GetFirstSelectedItemPosition();
    if( !pos )
    {
        fileCount = exp.GetNodeFileCount( exp.GetCurrentNode() );
        fileList.push_back( std::make_pair(".", "") );
    }
    else
    {
        while( pos )
        {
            int selected = lc.GetNextSelectedItem( pos );
            CFairyExplorer::PKNode* node = (CFairyExplorer::PKNode*)lc.GetItemData( selected );
            if( !node ) continue;
            fileCount += exp.GetNodeFileCount( node );
            fileList.push_back( std::make_pair(node->strName,"") );
        }
    }

    ProcessOperation( FAIRY_OP_EXTRACT,&exp,fileCount,fileList );
}
Пример #4
0
void CFairyPackerView::OnOpenNode( CFairyExplorer::PKNode* pNode )
{
    CFairyExplorer* exp = &GetDocument()->m_Explorer;
    if( pNode == NULL )
    {
        exp->EnterFolder( ".." );
        m_pDocument->UpdateAllViews( NULL );
    }
    else if( pNode->bIsDirectory )
    {
        exp->SetCurrentNode( pNode );
        m_pDocument->UpdateAllViews( NULL );
    }
    else
    {
        // 解压并运行指定的文件
        TCHAR tempPath[MAX_PATH];
        ::GetTempPath( MAX_PATH, tempPath );
        _tcscat_s( tempPath, MAX_PATH, _T("__FPK_TEMP__") );
        FFilePairList files;
        files.push_back( std::make_pair(pNode->strName, F_UnicodeToUTF8(tempPath)) );
        ProcessOperation( FAIRY_OP_EXTRACT, exp, 1, files );
        ::ShellExecute( NULL, _T("open"), F_UTF8ToUnicode(pNode->strName).c_str(), NULL, tempPath, SW_SHOW );
    }
}
Пример #5
0
void CUpdater::ProcessNotification(std::unique_ptr<CNotification> && notification)
{
	if (state_ != UpdaterState::checking && state_ != UpdaterState::newversion_downloading) {
		return;
	}

	switch (notification->GetID())
	{
	case nId_asyncrequest:
		{
			auto pData = unique_static_cast<CAsyncRequestNotification>(std::move(notification));
			if (pData->GetRequestID() == reqId_fileexists) {
				static_cast<CFileExistsNotification *>(pData.get())->overwriteAction = CFileExistsNotification::resume;
			}
			else if (pData->GetRequestID() == reqId_certificate) {
				auto & certNotification = static_cast<CCertificateNotification &>(*pData.get());
				if (m_use_internal_rootcert) {
					auto certs = certNotification.GetCertificates();
					if( certs.size() > 1 ) {
						auto ca = certs.back();

						unsigned int ca_data_length{};
						unsigned char const* ca_data = ca.GetRawData(ca_data_length);

						wxMemoryBuffer updater_root = wxBase64Decode(s_update_cert, wxNO_LEN, wxBase64DecodeMode_SkipWS);
						if( ca_data_length == updater_root.GetDataLen() && !memcmp(ca_data, updater_root.GetData(), ca_data_length) ) {
							certNotification.m_trusted = true;
						}
					}
				}
				else {
					certNotification.m_trusted = true;
				}
			}
			engine_->SetAsyncRequestReply(std::move(pData));
		}
		break;
	case nId_data:
		ProcessData(static_cast<CDataNotification&>(*notification.get()));
		break;
	case nId_operation:
		ProcessOperation(static_cast<COperationNotification const&>(*notification.get()));
		break;
	case nId_logmsg:
		{
			auto const& msg = static_cast<CLogmsgNotification const&>(*notification.get());
			log_ += msg.msg + _T("\n");
		}
		break;
	default:
		break;
	}
}
Пример #6
0
void CFairyPackerView::OnEditExtractto()
{
    // TODO: 在此添加命令处理程序代码
    CListCtrl& lc = GetListCtrl();
    CFairyExplorer& exp = GetDocument()->m_Explorer;

    // 选择一个目标文件夹
    TCHAR szPath[MAX_PATH];
    ZeroMemory( szPath,sizeof(szPath) );

    BROWSEINFO bi;
    bi.hwndOwner = m_hWnd;
    bi.pidlRoot = NULL;
    bi.pszDisplayName = szPath;
    bi.lpszTitle = _T("请选择需要要解压的目录:");
    bi.ulFlags = 0;
    bi.lpfn = NULL;
    bi.lParam = 0;
    bi.iImage = 0;

    //弹出选择目录对话框
    LPITEMIDLIST lp = SHBrowseForFolder(&bi);
    if( !(lp && SHGetPathFromIDList(lp,szPath)) )
        return;

    UINT fileCount = 0;
    FFilePairList fileList;
    POSITION pos = lc.GetFirstSelectedItemPosition();
    if( !pos )
    {
        fileCount = exp.GetNodeFileCount( exp.GetCurrentNode() );
        fileList.push_back( std::make_pair(".", F_UnicodeToUTF8(szPath)) );
    }
    else
    {
        while( pos )
        {
            int selected = lc.GetNextSelectedItem( pos );
            CFairyExplorer::PKNode* node = (CFairyExplorer::PKNode*)lc.GetItemData( selected );
            if( !node ) continue;
            fileCount += exp.GetNodeFileCount( node );
            fileList.push_back( std::make_pair(node->strName, F_UnicodeToUTF8(szPath)) );
        }
    }

    ProcessOperation( FAIRY_OP_EXTRACT,&exp,fileCount,fileList );
}
Пример #7
0
void CFairyPackerView::OnEditDedrag()
{
    // TODO: 在此添加命令处理程序代码
    CFairyExplorer* exp = &GetDocument()->m_Explorer;
    uint32 fragSize = exp->GetPackage()->GetFragmentSize();
    if( fragSize == 0 )
    {
        MessageBox( _T("没有碎片需要整理!"), _T("提示"), MB_OK|MB_ICONINFORMATION );
        return;
    }

    UINT fileCount = exp->GetNodeFileCount( exp->GetRootNode() );
    FFilePairList params;
    params.push_back( std::make_pair("","") );
    int ret = ProcessOperation( FAIRY_OP_DEFRAG,exp,fileCount,params );
    if( !ret )
    {
        TCHAR info[120];
        _stprintf_s( info, 120, _T("碎片整理完毕,为您节省了%d字节!"), fragSize );
        MessageBox( info, _T("提示"), MB_OK|MB_ICONINFORMATION );
    }
}
Пример #8
0
void CUpdater::ProcessNotification(CNotification* notification)
{
	if (state_ != checking && state_ != newversion_downloading) {
		return;
	}

	switch (notification->GetID())
	{
	case nId_asyncrequest:
		{
			CAsyncRequestNotification* pData = reinterpret_cast<CAsyncRequestNotification *>(notification);
			if (pData->GetRequestID() == reqId_fileexists) {
				reinterpret_cast<CFileExistsNotification *>(pData)->overwriteAction = CFileExistsNotification::resume;
			}
			else if (pData->GetRequestID() == reqId_certificate) {
				CCertificateNotification* pCertNotification = (CCertificateNotification*)pData;
				pCertNotification->m_trusted = true;
			}
			engine_->SetAsyncRequestReply(pData);
		}
		break;
	case nId_data:
		ProcessData(notification);
		break;
	case nId_operation:
		ProcessOperation(notification);
		break;
	case nId_logmsg:
		{
			CLogmsgNotification* msg = reinterpret_cast<CLogmsgNotification *>(notification);
			log_ += msg->msg + _T("\n");
		}
		break;
	default:
		break;
	}
}