Exemplo n.º 1
0
UIDownloaderExtensionPack::UIDownloaderExtensionPack()
{
    /* Prepare instance: */
    if (!m_spInstance)
        m_spInstance = this;

    /* Prepare source/target: */
    QString strExtPackUnderscoredName(QString(GUI_ExtPackName).replace(' ', '_'));
    QString strTemplateSourcePath("http://download.virtualbox.org/virtualbox/%1/");
    QString strTemplateSourceName(QString("%1-%2.vbox-extpack").arg(strExtPackUnderscoredName));
    QString strSourcePath(strTemplateSourcePath.arg(vboxGlobal().vboxVersionStringNormalized()));
    QString strSourceName(strTemplateSourceName.arg(vboxGlobal().vboxVersionStringNormalized()));
    QString strSource(strSourcePath + strSourceName);
    QString strTargetPath(vboxGlobal().homeFolder());
    QString strTargetName(strSourceName);
    QString strTarget(QDir(strTargetPath).absoluteFilePath(strTargetName));

    /* Set source/target: */
    setSource(strSource);
    setTarget(strTarget);
}
Exemplo n.º 2
0
void CServerPointDlg::OnBnClickedGenerateMd5()
{
	UpdateData(TRUE);
	if (m_strSource.IsEmpty())
	{
		// 源字符串为空
		m_strMD5.Empty();
		UpdateData(FALSE);
		return ;
	} 
	else
	{
		CStringA strSource(m_strSource);
		string strMD5 = Md5HexString(strSource.GetBuffer());
		strSource.ReleaseBuffer();
		wstring wstrMD5 = S2T(strMD5);
		m_strMD5.Empty();
		m_strMD5.Format(L"%s", wstrMD5.c_str());
		UpdateData(FALSE);
	}
}
Exemplo n.º 3
0
BOOL CLibraryWnd::OnCollection(LPCTSTR pszPath)
{
	CAlbumFolder* pFolder = NULL;
	CLibraryFolder* pLibFolder;
	CCollectionFile pCollection;
	CString strMessage;

	if ( ! pCollection.Open( pszPath ) )	// Verify specified collection is valid
	{
		// User clicked an invalid collection
		strMessage.Format( LoadString( IDS_LIBRARY_COLLECTION_INVALID ), pszPath );
		MsgBox( strMessage, MB_ICONEXCLAMATION );
		return FALSE;
	}

	// Create the collection folder (in case it doesn't exist)
	CreateDirectory( Settings.Downloads.CollectionPath );
	// Add the collection folder to the library (in case it isn't there)
	pLibFolder = LibraryFolders.AddFolder( Settings.Downloads.CollectionPath );
	// Force a scan of it (in case watch library folders is disabled)
	pLibFolder = LibraryFolders.GetFolder( Settings.Downloads.CollectionPath );
	if ( pLibFolder != NULL ) pLibFolder->Scan();

	CSingleLock oLock( &Library.m_pSection, TRUE );
	if ( CLibraryFile* pFile = LibraryMaps.LookupFileByPath( pszPath, FALSE, TRUE ) )
	{
		// Collection IS already in the library

		// Re-mount the collection
		LibraryFolders.MountCollection( pFile->m_oSHA1, &pCollection );
		pFolder = LibraryFolders.GetCollection( pFile->m_oSHA1 );
		oLock.Unlock();
	}
	else	// Collection is not already in the main library
	{
		oLock.Unlock();
		// Check the collection folder
		CString strSource( pszPath ), strTarget;

		const int nName = strSource.ReverseFind( L'\\' );
		if ( nName >= 0 )
		{
			strTarget = Settings.Downloads.CollectionPath + strSource.Mid( nName );
			LibraryBuilder.RequestPriority( strTarget );
		}

		oLock.Lock();
		if ( CLibraryFile* pTargetFile = LibraryMaps.LookupFileByPath( strTarget, FALSE, TRUE ) )
		{
			// Collection is already in the collection folder

			// Re-mount the collection
			LibraryFolders.MountCollection( pTargetFile->m_oSHA1, &pCollection );
			pFolder = LibraryFolders.GetCollection( pTargetFile->m_oSHA1 );
			oLock.Unlock();
		}
		else	// Collection is not already in collection folder
		{
			oLock.Unlock();

			if ( ! strTarget.IsEmpty() && CopyFile( strSource, strTarget, TRUE ) )
			{
				// Collection was copied into the collection folder

				// Force a scan of collection folder (in case watch library folders is disabled)
				if ( pLibFolder != NULL ) pLibFolder->Scan();

				strMessage.Format( LoadString( IDS_LIBRARY_COLLECTION_INSTALLED ), (LPCTSTR)pCollection.GetTitle() );
				MsgBox( strMessage, MB_ICONINFORMATION );

				oLock.Lock();
				if ( CLibraryFolder* pCollectionFolder = LibraryFolders.GetFolder(Settings.Downloads.CollectionPath ) )
				{
					pCollectionFolder->Scan();
				}
				if ( CLibraryFile* pTargetFile1 = LibraryMaps.LookupFileByPath( strTarget, FALSE, TRUE ) )
				{
					// Re-mount the collection
					LibraryFolders.MountCollection( pTargetFile1->m_oSHA1, &pCollection );
					pFolder = LibraryFolders.GetCollection( pTargetFile1->m_oSHA1 );
				}
				oLock.Unlock();
			}
			else if ( GetLastError() == ERROR_FILE_EXISTS )
			{
				// File with this name already exists:
				// We cannot copy the collection because it's already there, but it doesn't appear in the library.
				// The greatest probablility is that the file is there, but hasn't been added yet.
				// Best bet is to pretend everything is okay, since the delay it takes the user to respond may fix everything.

				strMessage.Format( LoadString( IDS_LIBRARY_COLLECTION_INSTALLED ), (LPCTSTR)pCollection.GetTitle() );
				MsgBox( strMessage, MB_ICONINFORMATION );

				oLock.Lock();
				if ( CLibraryFile* pTargetFile1 = LibraryMaps.LookupFileByPath( strTarget, FALSE, TRUE ) )
				{
					// Collection was already there: Re-mount the collection
					LibraryFolders.MountCollection( pTargetFile1->m_oSHA1, &pCollection );
					pFolder = LibraryFolders.GetCollection( pTargetFile1->m_oSHA1 );
					oLock.Unlock();
				}
				else	// File of this name exists in the folder, but does not appear in the library.
				{
					// Most likely cause- Corrupt file in collection folder.
					oLock.Unlock();
					strMessage.Format( LoadString( IDS_LIBRARY_COLLECTION_CANT_INSTALL ), (LPCTSTR)pCollection.GetTitle(), (LPCTSTR)Settings.Downloads.CollectionPath );
					MsgBox( strMessage, MB_ICONEXCLAMATION );
				}
			}
			else	// Was not able to copy collection to the collection folder for Unknown reason -Display an error message
			{
				strMessage.Format( LoadString( IDS_LIBRARY_COLLECTION_CANT_INSTALL ), (LPCTSTR)pCollection.GetTitle(), (LPCTSTR)Settings.Downloads.CollectionPath );
				MsgBox( strMessage, MB_ICONEXCLAMATION );
			}
		}
	}

	if ( pFolder )
		Display( pFolder ); 	// Show the collection

	return ( pFolder != NULL );
}
Exemplo n.º 4
0
std::string ToProtocolString(const wchar_t* str)
{
	std::wstring strSource(str);
	return ToProtocolString(strSource);
}
/*---------------------------------------------------------------------*//**
	フレーム処理
**//*---------------------------------------------------------------------*/
void MagicTypingMode::exec(ExecRes* res, const ExecCtx* ec)
{
    GameModeBase::exec(res, ec);

    switch(_smode)
    {
    case SMODE_TYPING:
    {
        SourceEditWindow* wndSrcedt = Game::getGame()->getGui()->getSourceEditWindow();
        ASSERT(wndSrcedt != 0L);
        if(wndSrcedt->isDone())	// 完了検知
        {
            // 入力完了ならばマ法を放つ
            if(wndSrcedt->isInputDone())
            {
                if(Game::getGame()->getMyParty()->pcUnit(MyParty::PC_MY) != 0L)
                {
                    // 自キャラを得る
                    Spirit* sprt = Game::getGame()->getMyParty()->pcUnit(MyParty::PC_MY)->spirit();
                    ASSERT(sprt != 0L);

                    // ソースコードを得る
                    VcString code;
                    wndSrcedt->takeSourceText(&code);

                    // ソウマ実行
                    if(	(code.getLength() > 0) &&
                            (_srckind != SourceDef::SRCKIND_NULL)	)
                    {
                        Spirit::SoumaBehaviorParam sbp(
                            &code,						// ソースコードを設定する
                            _srckind,					// 最終種別を適用
                            false	);					// 現時点では不明
                        sprt->startBehavior(Spirit::BEHV_SOUMA, &sbp);
                    }

                    // ソースエディトウインドウのソース文字列から不要なスペースや改行を削除する
                    wndSrcedt->trimSourceText();

                    // フォーカスカーサーの操作をしばらく禁止する
                    FocusCursor* fccsr = Game::getGame()->getGui()->getFocusCursor();
                    ASSERT(fccsr != 0L);
                    fccsr->setPreventTapCounter(30.0f);	// 30 フレーム待て
                }

                // 以前のモードへ戻る
                changePrevMode();
            }
            // リスト入力による完了ならばマ法リストウインドウを開く
            else if(wndSrcedt->isListClickDone())
            {
                // マ法リストウインドウを開く
                SourceListWindow* wndSourcelist = Game::getGame()->getGui()->getMagicListWindow();
                ASSERT(wndSourcelist != 0L);
                wndSourcelist->setCase(SourceListWindow::SLWCASE_SELECT);
                wndSourcelist->showWindow(true);
                _smode = SMODE_SELLIST;
            }
            // キャンセル
            else
            {
                // 以前のモードへ戻る
                changePrevMode();
            }

            // マ法入力ウインドウを閉じる
            SourceEditWindow* wndSrcedt = Game::getGame()->getGui()->getSourceEditWindow();
            ASSERT(wndSrcedt != 0L);
            wndSrcedt->showWindow(false);
        }
    }
    break;
    case SMODE_SELLIST:
    {
        SourceListWindow* wndMlist = Game::getGame()->getGui()->getMagicListWindow();
        ASSERT(wndMlist != 0L);
        if(wndMlist->isDone())	// 完了検知
        {
            // 選択したマ法をソースエディタにセット
            const Source* source = wndMlist->getSelectedSource();
            SourceEditWindow* wndSrcedt = Game::getGame()->getGui()->getSourceEditWindow();
            ASSERT(wndSrcedt != 0L);
            if(source != 0L)	// リストを選択した
            {
                // 種別を更新
                _srckind = source->getSourceKind();

                // 関数呼び出し補完文字列
                VcString strFuncCall;
                switch(_srckind)
                {
                case SourceDef::SRCKIND_JS:
                    strFuncCall.set("();");
                    break;
                case SourceDef::SRCKIND_SS:
                    strFuncCall.set(" a o.");
                    break;
                }

                // ソース入力ウインドウに設定する
                VcString strSource(*source->getName() + strFuncCall);
                wndSrcedt->setup(SourceEditWindow::ACTMODE_LIVE, &strSource);

                if(_isDirectListMode && (Game::getGame()->getMyParty()->pcUnit(MyParty::PC_MY) != 0L))
                {
                    // 自キャラを得る
                    Spirit* sprt = Game::getGame()->getMyParty()->pcUnit(MyParty::PC_MY)->spirit();
                    ASSERT(sprt != 0L);

                    // ソースコードを得る
                    VcString code;
                    wndSrcedt->takeSourceText(&code);

                    // ソウマ実行
                    Spirit::SoumaBehaviorParam sbp(
                        &code,
                        _srckind,
                        source->isUserCustomized()	);
                    sprt->startBehavior(Spirit::BEHV_SOUMA, &sbp);

                    // フォーカスカーサーの操作をしばらく禁止する
                    FocusCursor* fccsr = Game::getGame()->getGui()->getFocusCursor();
                    ASSERT(fccsr != 0L);
                    fccsr->setPreventTapCounter(30.0f);	// 30 フレーム待て
                }
            }

            if(_isDirectListMode)
            {
                // 以前のモードへ戻る
                changePrevMode();
            }
            else
            {
                // ソース入力ウインドウを開く
                wndSrcedt->showWindow(true);
                _smode = SMODE_TYPING;
            }

            // ソースリストウインドウを閉じる
            wndMlist->showWindow(false);
        }
    }
    break;
    }
}