BOOL MessageLoop(BOOL blocking) { MSG messages; if (!(blocking ? GetMessage(&messages, NULL, 0, 0) : PeekMessage(&messages, NULL, 0, 0, PM_REMOVE) )) return FALSE; if (hJailbreakThread != NULL && !IsThreadAlive(hJailbreakThread)) { DWORD dwExitCode = 0; if (GetExitCodeThread(hJailbreakThread, &dwExitCode) && dwExitCode == 0) { SendMessage(nButton, WM_SETTEXT, 0, TEXT("Jailbreak Complete!")); SendMessage(progress, PBM_SETPOS, 100, 0); EnableWindow(progress, FALSE); jbcomplete = TRUE; SendMessage(enter, WM_SETTEXT, 0, TEXT("Quit")); EnableWindow(enter, TRUE); } else { SendMessage(nButton, WM_SETTEXT, 0, TEXT("Jailbreak Failed :(")); SendMessage(progress, PBM_SETPOS, 100, 0); EnableWindow(progress, FALSE); jbcomplete = TRUE; SendMessage(enter, WM_SETTEXT, 0, TEXT("Quit (Restart to Retry)")); EnableWindow(enter, TRUE); } } TranslateMessage(&messages); DispatchMessage(&messages); return TRUE; }
void CDownloadTask::Construct(dtask nTask) { ASSERT_VALID( m_pDownload ); ASSERT( m_nTask == dtaskNone ); ASSERT( ! IsThreadAlive() ); m_nTask = nTask; m_pRequest.Free(); m_bSuccess = false; m_sDestination.Empty(); m_nFileError = NO_ERROR; m_oMergeFiles.RemoveAll(); m_bMergeValidation = FALSE; m_fProgress = 0; }
void CLibraryMetaPanel::Update() { CSingleLock pLock1( &Library.m_pSection, TRUE ); CSingleLock pLock2( &m_pSection, TRUE ); CLibraryListPtr pSel( GetViewSelection() ); m_nSelected = pSel ? static_cast< int >( pSel->GetCount() ) : 0; // Show info for library files only CLibraryFile* pFirst = NULL; if ( m_nSelected ) { const CLibraryListItem& pItem = pSel->GetHead(); if ( pItem.Type == CLibraryListItem::LibraryFile ) pFirst = Library.LookupFile( pItem ); if ( pFirst == NULL ) m_nSelected = 0; } m_nIcon32 = m_nIcon48 = -1; if ( m_nSelected == 1 ) { m_nIndex = pFirst->m_nIndex; m_sName = pFirst->m_sName; m_sPath = pFirst->GetPath(); m_sFolder = pFirst->GetFolder(); m_sSize = Settings.SmartVolume( pFirst->GetSize() ); m_sType = ShellIcons.GetTypeString( m_sName ); m_nIcon32 = ShellIcons.Get( pFirst->GetPath(), 32 ); m_nIcon48 = ShellIcons.Get( pFirst->GetPath(), 48 ); m_nRating = pFirst->m_nRating; } else if ( m_nSelected > 1 ) { CString strFormat; LoadString( strFormat, IDS_LIBPANEL_MULTIPLE_FILES ); m_sName.Format( strFormat, m_nSelected ); QWORD nSize = 0; m_sFolder = pFirst->GetFolder(); m_nIcon32 = ShellIcons.Get( pFirst->GetPath(), 32 ); m_nIcon48 = ShellIcons.Get( pFirst->GetPath(), 48 ); m_nRating = 0; for ( POSITION pos = pSel->GetHeadPosition() ; pos ; ) { CLibraryFile* pFile = Library.LookupFile( pSel->GetNext( pos ) ); if ( pFile == NULL ) continue; nSize += pFile->GetSize() / 1024; if ( pFile->IsAvailable() && pFile->GetFolder().CompareNoCase( m_sFolder ) ) { LoadString( m_sFolder, IDS_LIBPANEL_MULTIPLE_FOLDERS ); } int nIcon = ShellIcons.Get( pFile->GetPath(), 48 ); if ( nIcon != m_nIcon48 ) m_nIcon48 = -1; nIcon = ShellIcons.Get( pFile->GetPath(), 32 ); if ( nIcon != m_nIcon32 ) m_nIcon32 = -1; } m_sSize = Settings.SmartVolume( nSize ); m_sPath.Empty(); m_sType.Empty(); } m_pSchema = NULL; if ( pSel ) { for ( POSITION pos = pSel->GetHeadPosition() ; pos ; ) { const CLibraryListItem& pItem = pSel->GetNext( pos ); if ( pItem.Type != CLibraryListItem::LibraryFile ) continue; CLibraryFile* pFile = Library.LookupFile( pItem ); if ( pFile == NULL ) continue; m_pSchema = pFile->m_pSchema; if ( m_pSchema ) break; } } if ( m_pServiceData ) { m_pMetadata->Setup( m_pServiceData ); } else { m_pMetadata->Setup( m_pSchema ); if ( m_pSchema && pSel ) { for ( POSITION pos = pSel->GetHeadPosition() ; pos ; ) { const CLibraryListItem& pItem = pSel->GetNext( pos ); if ( pItem.Type != CLibraryListItem::LibraryFile ) continue; if ( CLibraryFile* pFile = Library.LookupFile( pItem ) ) { if ( pFile->m_pMetadata != NULL && m_pSchema->Equals( pFile->m_pSchema ) ) { m_pMetadata->Combine( pFile->m_pMetadata ); } } } } } m_pMetadata->CreateLinks(); m_pMetadata->Clean( 4096 ); CClientDC dc( this ); if ( Settings.General.LanguageRTL ) SetLayout( dc.m_hDC, LAYOUT_BITMAPORIENTATIONPRESERVED ); SCROLLINFO pInfo; CRect rc; GetClientRect( &rc ); int nThumbSize = min( max( rc.Height() - 16, 64 ), (int)Settings.Library.ThumbSize ); int nHeight = 54 + m_pMetadata->Layout( &dc, rc.Width() - 24 - nThumbSize ); pInfo.cbSize = sizeof(pInfo); pInfo.fMask = SIF_ALL & ~SIF_TRACKPOS; pInfo.nMin = 0; pInfo.nMax = nHeight; pInfo.nPage = rc.Height(); pInfo.nPos = GetScrollPos( SB_VERT ); pInfo.nPos = max( 0, min( pInfo.nPos, pInfo.nMax - (int)pInfo.nPage + 1 ) ); SetScrollInfo( SB_VERT, &pInfo, TRUE ); if ( m_bForceUpdate || ( m_sThumb != m_sPath ) ) { m_bForceUpdate = FALSE; if ( m_bmThumb.m_hObject ) m_bmThumb.DeleteObject(); if ( ! IsThreadAlive() ) { BeginThread( "CtrlLibraryMetaPanel" ); } } pLock2.Unlock(); pLock1.Unlock(); Invalidate(); }
void CLibraryMetaPanel::OnPaint() { CSingleLock pLock( &m_pSection, TRUE ); CPaintDC dc( this ); CRect rcClient; CString str; DWORD dwFlags = ( Settings.General.LanguageRTL ? ETO_RTLREADING : 0 ); GetClientRect( &rcClient ); CFont* pOldFont = dc.GetCurrentFont(); dc.SetTextColor( CoolInterface.m_crText ); dc.SetBkColor( CoolInterface.m_crWindow ); dc.SetBkMode( OPAQUE ); if ( m_nSelected == 0 ) { dc.SelectObject( &CoolInterface.m_fntNormal ); LoadString( str, IDS_LIBPANEL_NO_SELECTION ); CSize sz = dc.GetTextExtent( str ); CPoint pt = rcClient.CenterPoint(); pt.x -= sz.cx / 2; pt.y -= sz.cy / 2; dc.ExtTextOut( pt.x, pt.y, ETO_OPAQUE|dwFlags, &rcClient, str, NULL ); dc.SelectObject( pOldFont ); return; } // Draw thumbnail or icon int nThumbSize = min( max( rcClient.Height() - 16, 64 ), (int)Settings.Library.ThumbSize ); CRect rcWork( rcClient.left + 8, rcClient.top + 8, rcClient.left + 8 + nThumbSize, rcClient.top + 8 + nThumbSize ); CoolInterface.DrawThumbnail( &dc, rcWork, TRUE, FALSE, m_bmThumb, m_nIcon48, m_nIcon32, IsThreadAlive() ? LoadString( IDS_SEARCH_DETAILS_PREVIEWING ) : CString() ); rcWork.SetRect( rcWork.right + 8, rcWork.top, rcClient.right - 8, rcClient.bottom ); dc.SetViewportOrg( 0, -GetScrollPos( SB_VERT ) ); dc.SetBkColor( CoolInterface.m_crWindow ); if ( m_nRating > 1 ) { CPoint ptStar( rcWork.right - 3, rcWork.top - 2 ); m_rcRating.SetRectEmpty(); for ( int nRating = m_nRating - 1 ; nRating ; nRating-- ) { ptStar.x -= 16; CoolInterface.Draw( &dc, IDI_STAR, 16, ptStar.x, ptStar.y, CoolInterface.m_crWindow ); dc.ExcludeClipRect( ptStar.x, ptStar.y, ptStar.x + 16, ptStar.y + 16 ); m_rcRating.UnionRect( &m_rcRating, CRect( ptStar.x, ptStar.y, ptStar.x + 16, ptStar.y + 16 ) ); } } else if ( m_nRating == 1 ) { CPoint ptStar( rcWork.right - 3, rcWork.top - 2 ); m_rcRating.SetRectEmpty(); ptStar.x -= 16; CoolInterface.Draw( &dc, IDI_FAKE, 16, ptStar.x, ptStar.y, CoolInterface.m_crWindow ); dc.ExcludeClipRect( ptStar.x, ptStar.y, ptStar.x + 16, ptStar.y + 16 ); m_rcRating.UnionRect( &m_rcRating, CRect( ptStar.x, ptStar.y, ptStar.x + 16, ptStar.y + 16 ) ); } else { m_rcRating.SetRectEmpty(); dc.SelectObject( &CoolInterface.m_fntUnder ); dc.SetTextColor( CoolInterface.m_crTextLink ); LoadString( str, IDS_LIBPANEL_RATE_FILE ); CSize szText = dc.GetTextExtent( str ); DrawText( &dc, rcWork.right - szText.cx, rcWork.top, str, &m_rcRating ); } dc.SelectObject( &CoolInterface.m_fntCaption ); dc.SetTextColor( CoolInterface.m_crText ); DrawText( &dc, rcWork.left, rcWork.top, m_sName, NULL, rcWork.Width() - m_rcRating.Width() - 4 ); rcWork.top += 20; dc.FillSolidRect( rcWork.left, rcWork.top, rcWork.Width(), 1, CoolInterface.m_crMargin ); dc.ExcludeClipRect( rcWork.left, rcWork.top, rcWork.right, rcWork.top + 1 ); dc.SetBkColor( CoolInterface.m_crWindow ); dc.SetTextColor( CoolInterface.m_crText ); rcWork.top += 4; dc.SelectObject( &CoolInterface.m_fntBold ); LoadString( str, IDS_TIP_LOCATION ); if ( Settings.General.LanguageRTL ) DrawText( &dc, rcWork.left, rcWork.top, ':' + str ); else DrawText( &dc, rcWork.left, rcWork.top, str + ':' ); LoadString( str, IDS_TIP_SIZE ); DrawText( &dc, rcWork.right - 125, rcWork.top, str + ':' ); dc.SelectObject( &CoolInterface.m_fntNormal ); DrawText( &dc, rcWork.right - 60, rcWork.top, m_sSize ); if ( m_sFolder.Find( '\\' ) >= 0 ) { dc.SelectObject( &CoolInterface.m_fntUnder ); dc.SetTextColor( CoolInterface.m_crTextLink ); str = m_sFolder; long nTextLength = dc.GetTextExtent( str + _T('\x2026') ).cx; const long nLimit = rcWork.Width() - 125 - 68 - 10; if ( nTextLength > nLimit && nLimit > 0 ) { while ( nTextLength > nLimit ) { if ( str.IsEmpty() ) break; str = str.Left( str.GetLength() - 1 ); nTextLength = dc.GetTextExtent( str + _T('\x2026') ).cx; } str += _T('\x2026'); } else if ( nLimit <= 0 ) str.Empty(); } else str.Empty(); DrawText( &dc, rcWork.left + 68, rcWork.top, str, &m_rcFolder ); if ( m_sFolder.Find( '\\' ) < 0 ) m_rcFolder.SetRectEmpty(); rcWork.top += 18; m_pMetadata->Paint( &dc, &rcWork ); dc.SetViewportOrg( 0, 0 ); dc.SelectObject( pOldFont ); dc.FillSolidRect( &rcClient, CoolInterface.m_crWindow ); }
BOOL CBitprintsDownloader::IsWorking() { return IsThreadAlive() && ! m_bFinished; }
void CLibraryTipCtrl::OnPaint(CDC* pDC) { CSingleLock pLock( &m_pSection, TRUE ); CPoint pt( 0, 0 ); CSize sz( m_sz.cx, TIP_TEXTHEIGHT ); DrawText( pDC, &pt, m_sName, &sz ); pt.y += TIP_TEXTHEIGHT; pDC->SelectObject( &CoolInterface.m_fntNormal ); if ( ! m_sSHA1.IsEmpty() ) { DrawText( pDC, &pt, m_sSHA1, &sz ); pt.y += TIP_TEXTHEIGHT; } if ( ! m_sTTH.IsEmpty() ) { DrawText( pDC, &pt, m_sTTH, &sz ); pt.y += TIP_TEXTHEIGHT; } if ( ! m_sED2K.IsEmpty() ) { DrawText( pDC, &pt, m_sED2K, &sz ); pt.y += TIP_TEXTHEIGHT; } if ( ! m_sBTH.IsEmpty() ) { DrawText( pDC, &pt, m_sBTH, &sz ); pt.y += TIP_TEXTHEIGHT; } if ( ! m_sMD5.IsEmpty() ) { DrawText( pDC, &pt, m_sMD5, &sz ); pt.y += TIP_TEXTHEIGHT; } DrawRule( pDC, &pt ); CRect rcThumb( pt.x, pt.y, pt.x + Settings.Library.ThumbSize + 2, pt.y + Settings.Library.ThumbSize + 2 ); CoolInterface.DrawThumbnail( pDC, rcThumb, IsThreadAlive(), FALSE, m_bmThumb, m_nIcon, -1 ); pDC->ExcludeClipRect( &rcThumb ); int nCount = 0; pt.x += Settings.Library.ThumbSize; sz.cx -= pt.x + 8 + m_nKeyWidth; for ( POSITION pos = m_pMetadata.GetIterator() ; pos ; ) { CMetaItem* pItem = m_pMetadata.GetNext( pos ); if ( pItem->m_pMember && pItem->m_pMember->m_bHidden ) continue; pt.x += 8; DrawText( pDC, &pt, Settings.General.LanguageRTL ? ':' + pItem->m_sKey : pItem->m_sKey + ':', &sz ); pt.x += m_nKeyWidth; DrawText( pDC, &pt, pItem->m_sValue, &sz ); pt.x -= 8 + m_nKeyWidth; pt.y += TIP_TEXTHEIGHT; if ( ++nCount == 5 ) { pt.x += 4; pt.y -= 2; DrawRule( pDC, &pt, TRUE ); pt.x -= 4; pt.y -= 2; } } }