ÿþ// dui-demo.cpp : main source file // #include "stdafx.h" #include "MainDlg.h" #include "MBRealWndHandler.h" //ÎNPE‡eöN R} ÿèlaÎN‡eöN R}ï„_MOn #define RES_TYPE 0 //#define SYSRES_TYPE 0 // #define RES_TYPE 0 //PE // #define RES_TYPE 1 //ZIP // #define RES_TYPE 2 //7z // #define RES_TYPE 2 //‡eöN //»S‰cYy˜/ec ÿåNMQãNx>f—_÷mqN #if (RES_TYPE==1) #include "resprovider-zip\zipresprovider-param.h" #else #if (RES_TYPE==2) #include "resprovider-7zip\zip7resprovider-param.h" #endif #endif #ifdef _DEBUG #define SYS_NAMED_RESOURCE _T("soui-sys-resourced.dll") #else #define SYS_NAMED_RESOURCE _T("soui-sys-resource.dll") #endif #if defined DEBUG || defined _DEBUG const TCHAR kSubProcess[] = _T("mbsubprocess.exe"); //const TCHAR kCdnProcess[] = _T("mbcdn.exe"); #else const TCHAR kSubProcess[] = _T("mbsubprocess.exe"); //const TCHAR kCdnProcess[] = _T("mbcdn.exe"); #endif // .dump CMiniDumper g_miniDumper(true); // KmՋO(u„v§c6RðS_sQ bool g_bUseConsole = false; /*freopen( "CONOUT$","w",stdout); printf("test\n"); */ // end KmՋO(u„v§c6RðS_sQ // ‰[ňW[SO void InstallResourceFont(HINSTANCE hResInstance, LPCTSTR lpsFont, LPCTSTR lpsType) { HRSRC hRes = FindResource(hResInstance, lpsFont, lpsType); if(hRes) { HGLOBAL hMem = LoadResource(hResInstance, hRes); void *pData = LockResource(hMem); DWORD dwLen = SizeofResource(hResInstance, hRes); DWORD dwFonts = 0; HANDLE m_hFont = AddFontMemResourceEx( pData, // font resource dwLen, // number of bytes in font resource NULL, // Reserved. Must be 0. &dwFonts); // number of fonts installed if(m_hFont == NULL) { } } } // RËYSꁚ[IN„v9_úQ—z bool InitMsgBox() { pugi::xml_document xmlDoc; if(!LOADXML(xmlDoc,_T("DLG_XML_MSGBOX"),_T("LAYOUT")) || !SetMBMsgTemplate(xmlDoc.child(L"SOUI"))) { return false; } return true; } //š[IN/UN„vN*NR,UIRESù[aŒ,ROBJ_IN_CPP/fresource.h-Nš[IN„v[0 ROBJ_IN_CPP bool ProcessParam( CString strCmd,CString &strServer,int &nPort,CString &strLoginName,CString &strPassword,int &nStartLoginTime ) { CString strCmdLine; CString strParam; BOOL bRetValue = false; strCmdLine = strCmd; strParam = strCmdLine; CStringArray asVarName, asValue; CString strPort; CString strVarName; CString strLoginTime; int nIndex, nCount; strServer = _T(""); strLoginName = _T(""); strPassword = _T(""); nPort = DEFAULTPORT_ORG; nStartLoginTime = 0; CBaseStringMgr::GetParam( strParam, asVarName, asValue, _T(";") ); nCount = asVarName.GetSize( ); if ( nCount <= 0 ) { return true; } for ( nIndex = 0; nIndex < nCount; nIndex++ ) { strVarName = asVarName.GetAt( nIndex ); if ( strVarName.CompareNoCase( _T("Server") ) == 0 ) { strServer = asValue.GetAt( nIndex ); } else if ( strVarName.CompareNoCase( _T("LoginName") ) == 0 ) { strLoginName = asValue.GetAt( nIndex ); } else if ( strVarName.CompareNoCase( _T("Password") ) == 0 ) { strPassword = asValue.GetAt( nIndex ); } else if ( strVarName.CompareNoCase( _T("Port") ) == 0 ) { strPort = asValue.GetAt( nIndex ); nPort = _ttoi( strPort ); } else if ( strVarName.CompareNoCase( _T("LoginTime") ) == 0 ) { strLoginTime = asValue.GetAt( nIndex ); nStartLoginTime = _tstoi( strLoginTime ); if(nStartLoginTime > 10 ) nStartLoginTime = 0; } } return true; } unsigned int _stdcall ThreadFunctionLogoutUser(void *pV) { CMBServerMgr *pSvrMgr = (CMBServerMgr *)pV; if ( pSvrMgr ) { try { CMBSecCoreWebCMgr *pMBSecCoreWebCMgr = new CMBSecCoreWebCMgr(); pMBSecCoreWebCMgr->SetServerInfo(_T("127.0.0.1"),PORT_SECCOREWEBS,_T("MBC")); pMBSecCoreWebCMgr->SetAuthKey(KEY_OIPS_WRITE); CString strOrgServerInfo; CString strLoginName = pSvrMgr->GetUserLogin()->m_strLoginName; strOrgServerInfo.Format(_T("%s:%s"), pSvrMgr->GetUserLogin()->m_strServerName,pSvrMgr->GetUserLogin()->m_strPort ); pMBSecCoreWebCMgr->LogoutUser(strOrgServerInfo, strLoginName); delete pMBSecCoreWebCMgr; } catch(...) { } } _endthreadex( 0 ); return 0; } //void UpdateSTKAppPack( ) //{ // CString strUpsUpdateFilePath;; // strUpsUpdateFilePath.Format( _T("%s\\mbupdate.exe"),CBaseCommFun::GetModulePath( ) ); // if ( GetFileAttributes( strUpsUpdateFilePath ) != -1 ) // { // CString strParam = _T("AppProcName=mbcU.exe;Server=39.100.64.174;Port=5018;AppFlag=MBC;CurVer=1.2.1;FileSFlag=Default;FileS=39.100.64.174;FileSPort=5012"); // //#ifndef _DEBUG // CString strUpsUpdateFileDir; // strUpsUpdateFileDir = CBaseCommFun::GetPathName( strUpsUpdateFilePath ); // ::ShellExecute( NULL, _T("open"),strUpsUpdateFilePath, strParam,strUpsUpdateFileDir, SW_SHOWNORMAL ); // } //} BOOL DeleteDir( CString strDir ) { CString strTmpPath; WIN32_FIND_DATA wfd; BOOL bRet = TRUE; int nCnt =0; strTmpPath.Format(_T("%s\\*.*"), strDir); HANDLE hFind = FindFirstFile(strTmpPath,&wfd); if(hFind == INVALID_HANDLE_VALUE) { return TRUE; } do { if(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { if ( _tcscmp( wfd.cFileName, _T( ".." ) ) == 0 || _tcscmp( wfd.cFileName, _T( "." ) ) == 0 ) continue ; strTmpPath.Format(_T("%s\\%s"), strDir, wfd.cFileName); DeleteDir(strTmpPath); } else { nCnt++; strTmpPath.Format(_T("%s\\%s"), strDir, wfd.cFileName); DeleteFile(strTmpPath); } } while(FindNextFile(hFind,&wfd)); FindClose(hFind); RemoveDirectory(strDir); return bRet; } BOOL DeleteCefDir( CString strDir ) { CString strTmpPath; WIN32_FIND_DATA wfd; BOOL bRet = TRUE; int nCnt =0; CString strFileName; strTmpPath.Format(_T("%s\\*.*"), strDir); HANDLE hFind = FindFirstFile(strTmpPath,&wfd); if(hFind == INVALID_HANDLE_VALUE) { return TRUE; } do { if(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { if ( _tcscmp( wfd.cFileName, _T( ".." ) ) == 0 || _tcscmp( wfd.cFileName, _T( "." ) ) == 0 ) continue ; strFileName.Format(_T("%s"), wfd.cFileName); if(strFileName.CompareNoCase(_T("Resources")) == 0) continue ; strTmpPath.Format(_T("%s\\%s"), strDir, wfd.cFileName); DeleteDir(strTmpPath); } else { nCnt++; strTmpPath.Format(_T("%s\\%s"), strDir, wfd.cFileName); DeleteFile(strTmpPath); } } while(FindNextFile(hFind,&wfd)); FindClose(hFind); return bRet; } int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int /*nCmdShow*/) { HRESULT hRes = OleInitialize(NULL); SASSERT(SUCCEEDED(hRes)); // RËYSž[‹OåSÄg afxCurrentInstanceHandle = _AtlBaseModule.GetModuleInstance(); afxCurrentResourceHandle = _AtlBaseModule.GetResourceInstance(); CString strCfgName,strModulePath; int nRet = 0; //UpdateSTKAppPack( ); SComMgr *pComMgr = new SComMgr; TCHAR szCurrentDir[MAX_PATH] = { 0 }; GetModuleFileName(NULL, szCurrentDir, sizeof(szCurrentDir)); LPTSTR lpInsertPos = _tcsrchr(szCurrentDir, _T('\\')); // M‘n‡eöN _tcscpy(lpInsertPos + 1, _T("\0")); strModulePath = szCurrentDir; #ifdef _DEBUG _tcscpy(lpInsertPos + 1, _T("..\\mbc")); #else _tcscpy(lpInsertPos + 1, _T("\0")); #endif SetCurrentDirectory(szCurrentDir); //  R}ê&^„vriched20.DLL,vQž[/fmsftedit.dll. // ‚YœgO(uû|ß~„vriched20.dll ÿ(W¡‹—{)ۏI{¹eb— g˜,ŸSàV*gåg SStringW re = szCurrentDir; re += L"\\riched20.dll"; LoadLibrary(re); { BOOL bLoaded = FALSE; // soui R}Dn CAutoRefPtr<SOUI::IImgDecoderFactory> pImgDecoderFactory; CAutoRefPtr<SOUI::IRenderFactory> pRenderFactory; bLoaded = pComMgr->CreateRender_Skia((IObjRef**)&pRenderFactory); //bLoaded = pComMgr->CreateRender_GDI((IObjRef**)&pRenderFactory); SASSERT_FMT(bLoaded, _T("load interface [render] failed!")); bLoaded = pComMgr->CreateImgDecoder((IObjRef**)&pImgDecoderFactory); SASSERT_FMT(bLoaded, _T("load interface [%s] failed!"), _T("imgdecoder")); pRenderFactory->SetImgDecoderFactory(pImgDecoderFactory); SApplication *theApp = new SApplication(pRenderFactory, hInstance); // skin theApp->RegisterSkinClass<CMBSkin>(); theApp->RegisterSkinClass<SSkinGif>();//èlŒQSkinGif //extened skins theApp->RegisterSkinClass<SColorMask>(); theApp->RegisterSkinClass<SAntialiasSkin>(); theApp->RegisterSkinClass<SSkinVScrollbar>(); theApp->RegisterWindowClass<SSnapshotCtrl>(); theApp->RegisterWindowClass<CEdit9527>(); theApp->RegisterWindowClass<CSnapshotMagnifierCtrl>(); #ifdef _DEBUG // éb†NÅN(WReleaseHr,gSbSDnRû|ß~Dn(WDEBUG NËYÈ~O(uDLL R} { HMODULE hModSysResource = LoadLibrary(SYS_NAMED_RESOURCE); if (hModSysResource) { CAutoRefPtr<IResProvider> sysResProvider; CreateResProvider(RES_PE, (IObjRef**)&sysResProvider); sysResProvider->Init((WPARAM)hModSysResource, 0); theApp->LoadSystemNamedResource(sysResProvider); FreeLibrary(hModSysResource); } else { SASSERT(0); } } #else //ÎNDLL R}û|ß~Dn { HMODULE hModSysResource = LoadLibrary(SYS_NAMED_RESOURCE); if (hModSysResource) { CAutoRefPtr<IResProvider> sysResProvider; CreateResProvider(RES_PE, (IObjRef**)&sysResProvider); sysResProvider->Init((WPARAM)hModSysResource, 0); theApp->LoadSystemNamedResource(sysResProvider); FreeLibrary(hModSysResource); } else { SASSERT(0); } } #endif CAutoRefPtr<IResProvider> pResProvider; #ifdef _DEBUG // éb†NÅN(WReleaseHr,gSbSDnR(WDEBUG NËYÈ~O(u‡eöN R} { CreateResProvider(RES_FILE, (IObjRef**)&pResProvider); bLoaded = pResProvider->Init((LPARAM)_T("uires"), 0); SASSERT(bLoaded); } #else { CreateResProvider(RES_PE, (IObjRef**)&pResProvider); bLoaded = pResProvider->Init((WPARAM)hInstance, 0); SASSERT(bLoaded); } #endif // w¹[—zãS„vO(u CMBRealWndHandler *pRealWndHandler = new CMBRealWndHandler; theApp->SetRealWndHandler(pRealWndHandler); pRealWndHandler->Release(); //èlŒQµ~TÚn¨Rag®v¤€ theApp->RegisterSkinClass<SSkinNewScrollbar>(); // RËYSDn theApp->InitXmlNamedID(namedXmlID, ARRAYSIZE(namedXmlID), TRUE); theApp->AddResProvider(pResProvider); // RËYSꁚ[IN„v9_úQ—z InitMsgBox(); // èlŒQmb //SWkeLoader wkeLoader; //if(wkeLoader.Init(_T("node.dll"))) // theApp->RegisterWindowClass<SWkeWebkit>();//èlŒQWKEOmȉhV //theApp->RegisterWindowClass<SShellNotifyIcon>(); theApp->RegisterWindowClass<STurn3dView>(); theApp->RegisterWindowClass<SShellNotifyIcon>(); theApp->RegisterWindowClass<SRadioBox2>();//èlŒQRadioBox2 theApp->RegisterWindowClass<SRadioEx>();//èlŒQRadioBox2 theApp->RegisterWindowClass<SIconButton>();//èlŒQIconButton theApp->RegisterWindowClass<CMBDocTreeView>(); theApp->RegisterWindowClass<CMBPathCtrl>();//èlŒQ AddressBarCtrl theApp->RegisterWindowClass<STileViewEx>(); // èlŒQ STileViewEx theApp->RegisterWindowClass<SImageWndEx>(); // èlŒQ SImageWndEx theApp->RegisterWindowClass<SMCListViewEx>(); theApp->RegisterWindowClass<SHeaderCtrlEx>(); theApp->RegisterWindowClass<SImageCenter>(); theApp->RegisterWindowClass<SRoundImageCenter>(); // Rhˆ'T theApp->RegisterWindowClass<CMBSearchMCListView>(); theApp->RegisterWindowClass<CMBTreeViewEx>(); theApp->RegisterWindowClass<SUserTreeView>(); theApp->RegisterWindowClass<SCheckBox2>(); theApp->RegisterWindowClass<SAniWindow>(); // data theApp->RegisterWindowClass<CMBDataGroupList>(); theApp->RegisterWindowClass<CMBDataTileNav>(); // doc theApp->RegisterWindowClass<CMBAppGroupList>(); theApp->RegisterWindowClass<CMBAppTileNav>(); // SRoundImage theApp->RegisterWindowClass<SRoundImage>(); // PageCtrl theApp->RegisterWindowClass<SPageCtrl2>(); theApp->RegisterWindowClass<SPageCtrl>(); theApp->RegisterWindowClass<SPageNo>(); // Tag theApp->RegisterWindowClass<STag>(); theApp->RegisterWindowClass<STagView>(); // SRatingBarEx theApp->RegisterWindowClass<SRatingBarEx>(); //VerListView theApp->RegisterWindowClass<CMBVerListView>(); //MCListView theApp->RegisterWindowClass<CMBMCListView>(); //MBScrollView theApp->RegisterWindowClass<CMBScrollView>(); //MBDateTimePicker theApp->RegisterWindowClass<CMBDateTimePicker>(); //MBComboBox theApp->RegisterWindowClass<CMBComboBox>(); //MBWindowEx theApp->RegisterWindowClass<CMBWindowEx>(); //MBDocSTreeView theApp->RegisterWindowClass<CMBDocSTreeView>(); // MBMcListViewEx theApp->RegisterWindowClass<CMBMcListViewEx>(); // MBVaultTreeView theApp->RegisterWindowClass<CMBVaultTreeView>(); theApp->RegisterWindowClass<SQrCtrl>(); theApp->RegisterWindowClass<CMBFireListCtrl>(); theApp->RegisterWindowClass<SButtonEx>(); theApp->RegisterWindowClass<SWindowEx>(); theApp->RegisterWindowClass<SSplitBar>(); theApp->RegisterWindowClass<SImageView>(); theApp->RegisterWindowClass<SImRichEdit>(); theApp->RegisterWindowClass<SChatEditLog>(); theApp->RegisterWindowClass<SChatEditMsg>(); theApp->RegisterWindowClass<SEditOrgUser>(); theApp->RegisterWindowClass<SGifPlayer>(); theApp->RegisterWindowClass<CMBAutoRadio>(); //theApp->RegisterWindowClass<SWebView>(); // èlŒQ cef„v§cöN // ‰[ňW[SOþVh InstallResourceFont(SApplication::getSingleton().GetInstance(), MAKEINTRESOURCE(IDR_TTF_MOBOXICON), _T("TTF")); InstallResourceFont(SApplication::getSingleton().GetInstance(), MAKEINTRESOURCE(IDR_TTF_USERFONT), _T("TTF")); // ʑ>e(Wmain-N CMBServerMgr *pSvrMgr = new CMBServerMgr(); //pSvrMgr->m_strModulePath = strModulePath; CMBCfgInfo *pCfgInfo = pSvrMgr->GetCfgInfo(); strCfgName.Format( _T("%s\\data\\mbcConfig.ini"),CBaseCommFun::GetWorkDir() ); pCfgInfo->ReInit(strCfgName); // KmՋO(u„v§c6RðS wah 20181110 if( g_bUseConsole ) AllocConsole(); // BLOCK: Run application { //$R­e z^/f&T gÂSpe CString strServer = _T(""); CString strLoginName = _T(""); CString strPassword = _T(""); int nPort = DEFAULTPORT_ORG; int nStartLoginTime = 0; ProcessParam(lpstrCmdLine,strServer,nPort,strLoginName, strPassword, nStartLoginTime); /*if(strServer.IsEmpty() && strLoginName.IsEmpty() && strPassword.IsEmpty()) { return; } else if( !strServer.IsEmpty() && !strLoginName.IsEmpty() && !strPassword.IsEmpty()) { return; }*/ /*strServer = _T("116.62.155.124"); strLoginName = _T("test7"); strPassword = _T("000000"); nStartLoginTime =10;*/ // RËYS{vU_—z CMBLoginWnd dlLgoin; dlLgoin.SetSvrMgr(pSvrMgr); dlLgoin.SetCurLoginInfo(strServer,nPort,strLoginName, strPassword,nStartLoginTime); dlLgoin.Create(GetActiveWindow(), 0, 0, 0, 0); dlLgoin.SendMessage(WM_INITDIALOG); dlLgoin.CenterWindow(dlLgoin.m_hWnd); dlLgoin.AnimateHostWindow(200, AW_CENTER); if(nStartLoginTime > 0) { if( !strServer.IsEmpty() && !strLoginName.IsEmpty()) dlLgoin.ShowWindow(SW_HIDE); else { if( pSvrMgr->GetCfgInfo()->m_strAutoLogin == _T("1") ) dlLgoin.ShowWindow(SW_HIDE); } } nRet = theApp->Run(dlLgoin.m_hWnd); // O(uåw-NÃ_„vˆmo`:g6R SNotifyCenter* pNotifyCenter = new SNotifyCenter; if (dlLgoin.GetReturnCode() == 0) { CString szPropName; HANDLE hValue = (HANDLE)1; if( !CBaseCommFun::CheckProcessExist(_T("OIPSecCore.exe"))) { CBaseCommFun::StartServer( _T("OIPSecCore") ); } if( CBaseCommFun::CheckProcessExist(_T("OIPSecCore.exe"))) { CString strOrgServerInfo; strOrgServerInfo.Format(_T("%s:%s"), pSvrMgr->GetUserLogin()->m_strServerName,pSvrMgr->GetUserLogin()->m_strPort ); pSvrMgr->GetSecCoreWebCMgr()->RegisterUser(strOrgServerInfo,pSvrMgr->GetUserLogin()->m_strOrgServerID, pSvrMgr->GetUserLogin()->m_strLoginName, pSvrMgr->GetUserLogin()->m_strUserName, pSvrMgr->GetUserLogin()->m_strAliasName, pSvrMgr->GetUserLogin()->m_strSessionID); } szPropName.Format( _T("MBC_%s-%s-%s"), pSvrMgr->GetUserLogin()->m_strServerName, pSvrMgr->GetUserLogin()->m_strPort, pSvrMgr->GetUserLogin()->m_strLoginName ); szPropName.MakeLower(); // RËYScef pSvrMgr->GetUserLogin()->m_nMBCShowMode = pSvrMgr->GetCfgInfo()->m_iniFile.GetProfileInt(_T("MBC_BASE"),_T("ShowMode")); CCef3RunEngine *pCef3RunEngine = new CCef3RunEngine(); pCef3RunEngine->Initialize(theApp,hInstance); // RËYS;NLub— CMainDlg dlgMain; dlgMain.SetSvrMgr( pSvrMgr ); //dlgMain.Create(GetActiveWindow(),WS_POPUP | WS_DLGFRAME | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,NULL,0,0,0,0); dlgMain.Create(GetActiveWindow(),WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,NULL,0,0,0,0); //dlgMain.Create(GetActiveWindow()); dlgMain.SendMessage(WM_INITDIALOG); dlgMain.CenterWindow( dlgMain.m_hWnd); dlgMain.ShowWindow(SW_SHOWNORMAL); nRet = theApp->Run(dlgMain.m_hWnd); BOOL bCleanWebCach = dlgMain.IsCleanWebCache(); // sQí•cef pCef3RunEngine->Release(); if( pCef3RunEngine ) { delete pCef3RunEngine; pCef3RunEngine = NULL; } if( CBaseCommFun::CheckProcessExist(_T("OIPSecCore.exe"))) { unsigned int nThreadID; ::_beginthreadex(0, 0, ThreadFunctionLogoutUser, (void*)pSvrMgr, 0, &nThreadID); } if(bCleanWebCach) { CString strTempDir; strTempDir.Format(_T("%s\\cef"),CBaseCommFun::GetModulePath( )); if( GetFileAttributes( strTempDir) != -1) DeleteCefDir(strTempDir); } } delete pNotifyCenter; } // KmՋO(u„v§c6RðS wah 20181110 if( g_bUseConsole ) FreeConsole(); delete theApp; //// nd– if( pSvrMgr != NULL ) { delete pSvrMgr; pSvrMgr = NULL; } } delete pComMgr; OleUninitialize(); // cef göeOúQ°sP[ۏ z*gúQ„v˜ ÿàVdk(Wُ̑Kb¨Rʑ>e //CMBProcessOpt::KillProcessFromName(kSubProcess); // //CMBProcessOpt::KillProcessFromName(kCdnProcess); // window ˆmo`ª_¯sò]Ï~Ó~_g ÿ@b gDnýò]Ï~ʑ>e ÿFO göe ÿ¿~ zbۏ z`S(uû|ß~Dn ÿû|ß~ʑ>e„vöeô•Ǐ• ÿŒ(uُ*N¹eÕlïSåNËz;R¿~_g CMBProcessOpt::TerminateApp(); // ïSý€¡l g(u ÿHQ™Q(Wُ̑ ÿÏQ\ù[ z^úQ„vÅbç_ return nRet; }