コード例 #1
0
ファイル: DKZipUnarchiver.cpp プロジェクト: hhg128/DKGL
			static DKObject<UnZipFile> Create(const DKString& zipFile, const DKString& file, const char* password)
			{
				if (zipFile.Length() == 0 || file.Length() == 0)
					return NULL;

				DKString filename = zipFile.FilePathString();

				unzFile uf = NULL;
#ifdef _WIN32
				{
					zlib_filefunc64_def ffunc;
					fill_win32_filefunc64W(&ffunc);
					uf = unzOpen2_64((const wchar_t*)filename, &ffunc); // UTF16LE
				}
#else
				{
					DKStringU8 filenameUTF8(filename);
					if (filenameUTF8.Bytes() > 0)
						uf = unzOpen64((const char*)filenameUTF8); // UTF8
				}
#endif
				if (uf)
				{
					unz_file_info64 file_info;
					DKStringU8 fileUTF8(file);
					if (fileUTF8.Bytes() > 0 &&
						unzLocateFile(uf, (const char*)fileUTF8, 0) == UNZ_OK &&
						unzGetCurrentFileInfo64(uf, &file_info, NULL, 0, NULL, 0, NULL, 0) == UNZ_OK &&
						file_info.uncompressed_size > 0)
					{
						if (unzOpenCurrentFilePassword(uf, password) == UNZ_OK)
						{
							DKObject<UnZipFile> p = DKOBJECT_NEW UnZipFile(uf, file_info, password);
							return p;
						}
						else
						{
							DKLog("[%s] failed to open file: %ls.\n", DKLIB_FUNCTION_NAME, (const wchar_t*)file);
						}
					}
				}
				return NULL;
			}
コード例 #2
0
ファイル: smbop.cpp プロジェクト: feraligatr/vbagx
int
LoadBufferFromSMB (char * sbuffer, char *filepath, bool silent)
{
	if(!ConnectShare (NOTSILENT))
		return 0;

	SMBFILE smbfile;
	int ret;
	int boffset = 0;

	smbfile =
	SMB_OpenFile (SMBPath(filepath), SMB_OPEN_READING, SMB_OF_OPEN, smbconn);

	if (!smbfile)
	{
		if(!silent)
		{
			char msg[100];
			sprintf(msg, "Couldn't open SMB: %s", SMBPath(filepath));
			WaitPrompt (msg);
		}
		return 0;
	}

	ret = SMB_ReadFile (sbuffer, 1024, boffset, smbfile);

	if (IsZipFile (sbuffer))
	{
		boffset = UnZipFile ((unsigned char *)sbuffer, smbfile); // unzip from SMB
	}
	else
	{
		// Just load the file up
		while ((ret = SMB_ReadFile (sbuffer + boffset, 1024, boffset, smbfile)) > 0)
			boffset += ret;
	}
	SMB_CloseFile (smbfile);

	return boffset;
}
コード例 #3
0
ファイル: SMLoginScene.cpp プロジェクト: chaosren/HHHH
//===========================================================================
void CSMLoginScene::OnTimer( OBJID idTag )
{
	static bool bFirst = true;

	if (bFirst)
	{
		LOGD("Entry First OnTimer");
		//idTag = TAG_TIMER_UPDATE;
		bFirst = false;
	}

	if ( idTag == TAG_TIMER_UPDATE ) 
	{
		if ( !rename( m_strSavePath.c_str(), m_strSavePath.c_str() ) )
		{
			if ( remove( m_strSavePath.c_str() ) )
			{ 
				m_pTimer->KillTimer(this, TAG_TIMER_UPDATE);
				return;
			}
		}

		FromUrl(m_strUpdateURL.c_str());
		ToPath(m_strSavePath.c_str()); 
		Download();
		m_pTimer->KillTimer(this, TAG_TIMER_UPDATE);
	}
	else if ( idTag == TAG_TIMER_DOWNLOAD_SUCCESS )
	{
		m_pTimer->KillTimer(this, TAG_TIMER_DOWNLOAD_SUCCESS);
        
		LOGD("Entry TAG_TIMER_DOWNLOAD_SUCCESS process.");
		UnZipFile( m_strSavePath.c_str(), m_strCachePath.c_str());
	}
    else if ( idTag == TAG_TIMER_UNZIP_SUCCESS )
	{
		m_pTimer->KillTimer(this, TAG_TIMER_UNZIP_SUCCESS);
		if ( remove(m_strSavePath.c_str()) )
		{
		    NDLog("delete:%s failed",m_strSavePath.c_str());
		    //return;
		}
        std::string szListFile = NDPath::GetCashesPath() + SZ_DEL_FILE;
		DeleteFileFromFile( szListFile );
    
		if(kDeqUpdateUrl.size() > 0)
		{
		    kDeqUpdateUrl.pop_front();
		}

		PackageCount++;
		//查找下载队列
		if (kDeqUpdateUrl.size() > 0)
		{
		    //定义保存路径
		    m_strUpdateURL = *kDeqUpdateUrl.begin();
		    //m_savePath = [[NSString stringWithFormat:@"%s/update%d.zip", m_cachPath.c_str(), PackageCount] UTF8String];
		    m_pTimer->SetTimer( this, TAG_TIMER_UPDATE, 0.5f );
		    StartDownload();
		}
		else
		{
		    //跳转到启动界面
		    StartEntry();
		}
	}
	else if ( TAG_TIMER_CHECK_WIFI == idTag )
	{
		//如果检测没开启WIFI则不断检测//
    	if ( NDBeforeGameMgrObj.isWifiNetWork() )
    	{
			m_pTimer->KillTimer( this, TAG_TIMER_CHECK_WIFI );
			CloseConfirmDlg();
			StartUpdate();
    	}
	}
	else if ( TAG_TIMER_CHECK_UPDATE == idTag )
	{
        m_pTimer->KillTimer(this, TAG_TIMER_CHECK_UPDATE);
        ShowUpdateOff();
	}
	else if ( TAG_TIMER_CHECK_COPY == idTag )
	{
        int copyStatus = NDBeforeGameMgr::GetCopyStatus();
        switch (copyStatus) 
        {
            case -1:
                m_pTimer->KillTimer( this, TAG_TIMER_CHECK_COPY );
                //NSLog( @"Copy files error!" );
                exit(0);
                break;
            case 0:
                break;
            case 1:
                m_pTimer->KillTimer( this, TAG_TIMER_CHECK_COPY );
                NDBeforeGameMgrObj.doNDSdkLogin();
                ShowWaitingAni();
                break;
            default:
                break;
        }
	}
    else if ( TAG_TIMER_FIRST_RUN == idTag )
	{
		LOGD("Entry TAG_TIMER_FIRST_RUN == idTag");
		m_pTimer->KillTimer( this, TAG_TIMER_FIRST_RUN );
		CreateUpdateUILayer();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
		CCLog( "@@login02: to call OnEvent_LoginOKNormal()\r\n" );

        m_iAccountID = NDBeforeGameMgrObj.GetCurrentUser();
		OnEvent_LoginOKNormal(m_iAccountID);
#else
#ifdef USE_MGSDK
		NDUIImage * pImage = (NDUIImage *)m_pLayerUpdate->GetChild( TAG_CTRL_PIC_BG);
		if ( pImage )
		{
			NDPicture * pPicture = new NDPicture;
			pPicture->Initialization( NDPath::GetUIImgPath( SZ_MOBAGE_BG_PNG_PATH ).c_str() );
			pImage->SetPicture( pPicture, true );
		}
#endif
#if CACHE_MODE == 1
    	if ( NDBeforeGameMgrObj.CheckFirstTimeRuning() )
        {
        	if ( m_pLabelPromtp )
            {
        		m_pLabelPromtp->SetText( NDCommonCString2(SZ_FIRST_INSTALL).c_str() );
        		m_pLabelPromtp->SetVisible( true );
                ShowWaitingAni();
#ifdef USE_MGSDK
        		m_pLabelPromtp->SetVisible( false );//Mobage的版本暂将文字绘在背景图上
#endif
            }
            m_pTimer->SetTimer( this, TAG_TIMER_CHECK_COPY, 0.5f );
        }
        else
#endif
        {
            NDBeforeGameMgrObj.doNDSdkLogin();
            ShowWaitingAni();
		}
#endif
    	//CreateUpdateUILayer();
		//NDBeforeGameMgrObj.CheckClientVersion(SZ_UPDATE_URL);
	}
	else if ( TAG_TIMER_LOAD_RES_OK == idTag )
	{
		m_pTimer->KillTimer( this, TAG_TIMER_LOAD_RES_OK );
		CloseWaitingAni();
		CloseUpdateUILayer();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
		//if ( m_iAccountID == 0 )
		m_iAccountID = ScriptMgrObj.excuteLuaFuncRetN( "GetAccountID", "Login_ServerUI" );
#endif
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
		m_iAccountID = NDBeforeGameMgrObj.GetCurrentUser();
#endif
		ScriptMgrObj.excuteLuaFunc( "ShowUI", "Entry", m_iAccountID );
		//    ScriptMgrObj.excuteLuaFunc("ProecssLocalNotification", "MsgLoginSuc");
	}
}
コード例 #4
0
ファイル: DlgView.cpp プロジェクト: SoyPay/DacrsUI
LRESULT CDlgView::onBnCLick( WPARAM wParam, LPARAM lParam )
{
    CButtonCtrl *button = (CButtonCtrl*)lParam;
    ADD_APP_DATA itemdata =(ADD_APP_DATA)button->m_pData;
    if (itemdata.isLagerPic)
    {
        ShellExecute(NULL,"open",TEXT("http://8btc.com/thread-25079-1-1.html"),NULL,NULL, SW_SHOWNORMAL);
        return 0;
    }
    if (itemdata.isInstall)
    {
        ADD_APP_DATA BtData;
        GetAppUrlValue(itemdata.type,itemdata.appname,BtData);
        if (BtData.appname != "" && BtData.version != itemdata.version)
        {
            if ( IDYES == UiFun::MessageBoxEx(_T("此程序有更新的版本,是否要下载") , UiFun::UI_LoadString("COMM_MODULE" , "COMM_TIP" ,theApp.gsLanguage) , MFB_YESNO|MFB_TIP ) )
            {
                string dowloufilepath = m_apppath + "\\"+strprintf("%s",itemdata.appname);
                string dowloufileName = dowloufilepath + "\\"+strprintf("%s.zip",itemdata.appname);

                string dowlouUrlPaht = m_urlpath +"/"+strprintf("%s",itemdata.appname);
                string dowlouUrName = dowlouUrlPaht +"/"+strprintf("%s.zip",itemdata.appname);
                if (Download(dowlouUrName.c_str(),dowloufileName.c_str()))
                {
                    UnZipFile(dowloufileName,dowloufilepath);
                    ///删除下载的临时文件
                    DeleteFile(dowloufileName.c_str());
                    button->m_pData.version = BtData.version;
                    MoidfyListAndSaveToFile(itemdata.type ,itemdata.appname,button->m_pData);
                }
            }
        }
        ///打开应用程序
        {
            string appname = strprintf("%s",itemdata.appname)+".exe";
            map<string,PROCESS_INFORMATION>::iterator it = m_process.find(itemdata.appname);
            if (it != m_process.end()) /// 此应用程序已经打开,置顶
            {
                PROCESS_INFORMATION item = it->second;
                HANDLE processHandle = OpenProcess(PROCESS_ALL_ACCESS,FALSE,item.dwProcessId);
                if(NULL != processHandle)
                {
                    ProcessWindow procwin;
                    procwin.dwProcessId = item.dwProcessId;
                    procwin.hwndWindow = NULL;

                    // 查找主窗口
                    EnumWindows(EnumWindowCallBack, (LPARAM)&procwin);

                    //SetWindowPos(&this->wndTopMost, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
                    //显示窗口
                    ::ShowWindow(procwin.hwndWindow , SW_NORMAL);
                    //前端显示
                    ::SetForegroundWindow(procwin.hwndWindow );
                    ::SetWindowPos( procwin.hwndWindow ,0,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
                    CloseHandle(processHandle);
                    return 0;
                }

            }
            string appfileexe = m_apppath + "\\"+strprintf("%s",itemdata.appname)+"\\"+strprintf("%s",itemdata.appname)+strprintf("\\%s",itemdata.appname)+".exe";
            /// 配置文件安装了,但是找不到exe,重新设置配置文件没有安装
            if (_access(appfileexe.c_str(),0) == -1)
            {
                button->m_pData.isInstall = false;
                MoidfyListAndSaveToFile(itemdata.type ,itemdata.appname,button->m_pData);
                return 0;
            }
            PROCESS_INFORMATION		app_pi;
            STARTUPINFOA si;
            memset(&si, 0, sizeof(STARTUPINFO));
            si.cb = sizeof(STARTUPINFO);
            si.dwFlags = STARTF_USESHOWWINDOW;
            si.wShowWindow =SW_HIDE;//SW_HIDE; //SW_SHOW;
            if(!CreateProcessA(NULL,(LPSTR)appfileexe.c_str(),NULL,NULL,FALSE,0,NULL,NULL,&si,&app_pi))
            {
                int n = GetLastError();
                AfxMessageBox(_T("CreateProcessA sever error!"));
                LogPrint("INFO", "开启服务端程序失败\n");
                exit(1);
            }
            CloseHandle(app_pi.hProcess);
            CloseHandle(app_pi.hThread);
            m_process[itemdata.appname]=app_pi;
        }
    } else { /// 下载可执行程序
        string dowloufilepath = m_apppath + "\\"+strprintf("%s",itemdata.appname);
        string dowloufileName = dowloufilepath + "\\"+strprintf("%s.zip",itemdata.appname);

        string dowlouUrlPaht = m_urlpath +"/"+strprintf("%s",itemdata.appname);
        string dowlouUrName = dowlouUrlPaht +"/"+strprintf("%s.zip",itemdata.appname);
        if (Download(dowlouUrName.c_str(),dowloufileName.c_str()))
        {
            UnZipFile(dowloufileName,dowloufilepath);
            ///删除下载的临时文件
            DeleteFile(dowloufileName.c_str());
            button->m_pData.isInstall = true;
            //// 替换图片
            {
                string filepathe;
                filepathe = m_apppath +"\\"+itemdata.appname+"\\ini.bmp";

                CString FileName;
                FileName.AppendFormat(_T("%s"),filepathe.c_str());
                HBITMAP hbmp = (HBITMAP)::LoadImage(AfxGetInstanceHandle(), FileName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION | LR_DEFAULTSIZE);
                HBITMAP hbmp2;
                FileName.Format(_T("%s\\%s\\Install.bmp"),m_apppath.c_str(),itemdata.appname.c_str());
                hbmp2 = (HBITMAP)::LoadImage(AfxGetInstanceHandle(), FileName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION | LR_DEFAULTSIZE);

                if (hbmp2 != NULL && hbmp != NULL)
                {
                    button->SetBitmaps( hbmp2 ,  RGB(255, 255, 255), hbmp ,  RGB(255, 255, 255) );

                }
            }
            MoidfyListAndSaveToFile(itemdata.type ,itemdata.appname,button->m_pData);
            AfxMessageBox(_T("已经下载完成!"));
        }
    }
    return 0;

}