BOOL CUserMeetingDlg::CreateMenuGroup(CXMLElement* pXML, HMENU hParent) { UINT nMenuId = MIN_GROUP; for ( POSITION pos = pXML->GetElementIterator() ; pos ; ) { CXMLElement* pSync = pXML->GetNextElement( pos ); if ( ! pSync->IsNamed( "SyncOrder" ) ) continue; static LPCTSTR pszGroup[] = { _T("xgroupname"), _T("xgroupnum") }; CXMLAttribute* pAttri = pSync->GetAttribute( pszGroup[0] ); if ( ! pAttri || pAttri->GetValue().IsEmpty() ) pAttri = pSync->GetAttribute( pszGroup[1] ); if ( pAttri && m_wndGroup.FindStringExact( -1, pAttri->GetValue() ) != m_wndGroup.GetCurSel() ) continue; HMENU hMenu = FindMenuGroup( hParent, pAttri->GetValue() ); if ( ! hMenu ) { hMenu = CreatePopupMenu(); AppendMenu( hParent, MF_STRING|MF_POPUP, (UINT)hMenu, pAttri->GetValue() ); } CString strText = pSync->GetAttributeValue( _T("xname") ); if ( ! strText.IsEmpty() ) strText += '\t'; strText += pSync->GetAttributeValue( _T("xphone") ); AppendMenu( hMenu, MF_STRING, nMenuId++, strText ); if ( nMenuId > MAX_GROUP ) break; } return TRUE; }
BOOL CSchemaMember::LoadType(const CXMLElement* pType) { CString strName = pType->GetName(); if ( strName.CompareNoCase( L"simpleType" ) && strName.CompareNoCase( L"complexType" ) ) return FALSE; m_sType = pType->GetAttributeValue( L"base", L"" ); ToLower( m_sType ); m_bNumeric = ( m_sType == L"decimal" || m_sType == L"int" || m_sType == L"short" ); m_bBoolean = m_sType == L"boolean"; m_bYear = m_sType == L"year"; m_bGUID = m_sType == L"guidtype"; for ( POSITION pos = pType->GetElementIterator(); pos; ) { CXMLElement* pElement = pType->GetNextElement( pos ); CString strElement = pElement->GetName(); if ( strElement.CompareNoCase( L"enumeration" ) == 0 ) { CString strValue = pElement->GetAttributeValue( L"value", L"" ); if ( ! strValue.IsEmpty() ) m_pItems.AddTail( strValue ); } else if ( strElement.CompareNoCase( L"maxInclusive" ) == 0 ) { CString strValue = pElement->GetAttributeValue( L"value", L"0" ); _stscanf( strValue, L"%i", &m_nMaxLength ); } } return TRUE; }
void CAnalogProfilePage::OnItemChangedList(NMHDR* pNMHDR, LRESULT* pResult) { NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR; *pResult = 0; if ( pNMListView->iItem >= 0 ) { if ( ( pNMListView->uOldState & LVIS_SELECTED ) != ( pNMListView->uNewState & LVIS_SELECTED ) ) { if ( pNMListView->uNewState & LVIS_SELECTED ) { CXMLElement* pMap = (CXMLElement*)m_wndList.GetItemData( pNMListView->iItem ); if ( pMap != NULL ) { CString strValue; strValue = pMap->GetAttributeValue( _T("ID") ); m_wndHost.SetWindowText( (LPCTSTR)strValue ); strValue = pMap->GetAttributeValue( _T("LinkId") ); m_wndLinkId.SetWindowText( (LPCTSTR)strValue ); strValue = pMap->GetAttributeValue( _T("LocalId") ); m_wndLocalId.SetWindowText( (LPCTSTR)strValue ); m_wndDelete.EnableWindow( TRUE ); } } } } }
BOOL CSchemaMember::LoadType(CXMLElement* pType) { CString strName = pType->GetName(); if ( strName.CompareNoCase( _T("simpleType") ) && strName.CompareNoCase( _T("complexType") ) ) return FALSE; m_sType = pType->GetAttributeValue( _T("base"), _T("") ); CharLower( m_sType.GetBuffer() ); m_sType.ReleaseBuffer(); m_bNumeric = ( m_sType == _T("short") || m_sType == _T("int") || m_sType == _T("decimal") ); for ( POSITION pos = pType->GetElementIterator() ; pos ; ) { CXMLElement* pElement = pType->GetNextElement( pos ); CString strElement = pElement->GetName(); if ( strElement.CompareNoCase( _T("enumeration") ) == 0 ) { CString strValue = pElement->GetAttributeValue( _T("value"), _T("") ); if ( strValue.GetLength() ) m_pItems.AddTail( strValue ); } else if ( strElement.CompareNoCase( _T("maxInclusive") ) == 0 ) { CString strValue = pElement->GetAttributeValue( _T("value"), _T("0") ); _stscanf( strValue, _T("%i"), &m_nMaxLength ); } } return TRUE; }
void CUserMeetingDlg::OnTimer(UINT nIDEvent) { CXMLElement* pXML = new CXMLElement( NULL, ISyncDataView ); pXML->AddAttribute( "method", "select" ); CXMLElement* pSync = pXML->AddElement( "column_expression" ); pSync->SetValue( "xmeetingphone, xmeetingphonestate=case" " when xmeetingphonestate='0' then '等待'" " when xmeetingphonestate='1' then '呼叫'" " when xmeetingphonestate='2' then '在线'" " else '其他' end" ); pSync = pXML->AddElement( "table_name" ); pSync->SetValue( "from xmeetingroom" ); CString str; str.Format( "xmeetingroomcode=(select xmeetingroomcode" " from xmeetingroomlist where xmeetingroomfee='%s' and xmeetingused='1')", Network.m_xUserId ); pSync = pXML->AddElement( "search_condition" ); pSync->SetValue( (LPCTSTR)str ); Network.SendPacket( new CSyncDataView(pXML) ); delete pXML; pXML = NULL; if ( Network.CallWorker( &pXML, INFINITE ) ) return; int nItem = 0; POSITION posNext = pXML->GetElementIterator(); for ( POSITION pos = posNext ; pos ; pos = posNext ) { CXMLElement* pSync = pXML->GetNextElement( posNext ); CString strDebug = pSync->GetAttributeValue( "xmeetingphone" ); if ( m_wndList.GetItemText(nItem, 0).CompareNoCase( strDebug ) ) { m_wndList.DeleteItem( nItem ); posNext = pos; continue; } CString strValue = pSync->GetAttributeValue( "xmeetingphonestate" ); m_wndList.SetItemText( nItem, 2, strValue ); nItem++; } for ( ; nItem < m_wndList.GetItemCount(); nItem ) { m_wndList.DeleteItem( nItem ); } pXML->Delete(); }
BOOL CNetworkMonitorBox::ProcessXML(POSITION posNext) { CXMLElement* pXML = Profiles.FindProcess( NULL, posNext ); if ( pXML == NULL ) return FALSE; CSingleLock pLock( &Network.m_pSection, TRUE ); CString strValue = pXML->GetAttributeValue( "Host" ); if ( CChannel* pChannel = Network.FindChannel( strValue ) ) { if ( pChannel->m_hSocket == INVALID_SOCKET && pChannel->TimeOut( 60 * 1000 ) ) { CXMLAttribute* pAttri = pXML->GetAttribute( "Retry" ); if ( ! pAttri ) pAttri = pXML->AddAttribute( "Retry" ); if ( _ttoi( pAttri->GetValue() ) >= 2 ) { AlarmToShortMessage( (LPCTSTR)strValue ); strValue = pXML->GetAttributeValue( _T("Path") ); RestartMachine( (LPCTSTR)strValue ); pXML->DeleteAttribute( "Retry" ); } else { strValue.Format( "%i", _ttoi( pAttri->GetValue() ) + 1 ); pAttri->SetValue( (LPCTSTR)strValue ); pChannel->LinkRestart(); pChannel->m_tConnected = GetTickCount(); } } else if ( pChannel->IsConnected() ) { pXML->DeleteAttribute( "Retry" ); } } else { CChannel* pChannel = new CSentryChannel( pXML ); Network.SetChannel( pChannel ); pChannel->LinkRestart(); } if ( posNext ) return ProcessXML( posNext ); return TRUE; }
BOOL CHostBrowser::LoadDCDirectory(CXMLElement* pRoot, CQueryHit*& pHits) { for ( POSITION pos = pRoot->GetElementIterator(); pos; ) { CXMLElement* pElement = pRoot->GetNextElement( pos ); if ( pElement->IsNamed( L"Directory" ) ) { // <Directory Name="Downloads"> if ( ! LoadDCDirectory( pElement, pHits ) ) return FALSE; } else if ( pElement->IsNamed( L"File" ) ) { // <File Name="music.mp3" Size="100000" TTH="3A6D6T2NDRLU6BGSTSJNW3R3QWTV6A44M6AGXMA"/> CString strName = pElement->GetAttributeValue( L"Name" ); QWORD nSize; if ( _stscanf( pElement->GetAttributeValue( L"Size" ), L"%I64i", &nSize ) != 1 ) nSize = SIZE_UNKNOWN; CString strTiger = pElement->GetAttributeValue( L"TTH" ); if ( strName.IsEmpty() || nSize == SIZE_UNKNOWN ) return FALSE; if ( CQueryHit* pHit = new CQueryHit( PROTOCOL_DC ) ) { pHit->m_sName = strName; pHit->m_nSize = nSize; pHit->m_bSize = TRUE; pHit->m_bChat = TRUE; pHit->m_bBrowseHost = TRUE; pHit->m_oTiger.fromString( strTiger ); pHit->m_sNick = m_sNick; pHit->m_bBusy = TRI_FALSE; pHit->m_bPush = TRI_TRUE; pHit->m_pAddress = m_pAddress; pHit->m_nPort = m_nPort; pHit->m_sCountry = theApp.GetCountryCode( m_pAddress ); pHit->m_pVendor = m_pVendor ? m_pVendor : VendorCache.m_pNull; pHit->Resolve(); pHit->m_pNext = pHits; pHits = pHit; } } } return TRUE; }
BOOL CSchemaMember::LoadDescriptor(CXMLElement* pXML) { CString strSearch = pXML->GetAttributeValue( _T("search") ); if ( strSearch.CompareNoCase( _T("generic") ) == 0 ) { m_bIndexed = TRUE; m_bSearched = TRUE; } else if ( strSearch.CompareNoCase( _T("indexed") ) == 0 ) { m_bIndexed = TRUE; } CString strTitle = m_sTitle; m_sTitle.Empty(); for ( POSITION pos = pXML->GetElementIterator() ; pos ; ) { CXMLElement* pElement = pXML->GetNextElement( pos ); if ( pElement->IsNamed( _T("display") ) ) { LoadDisplay( pElement ); } else if ( pElement->IsNamed( _T("title") ) ) { if ( pElement->GetAttributeValue( _T("language") ). CompareNoCase( Settings.General.Language ) == 0 ) { m_sTitle = pElement->GetValue(); } else if ( m_sTitle.IsEmpty() ) { m_sTitle = pElement->GetValue(); } } else if ( pElement->IsNamed( _T("link") ) ) { m_sLinkURI = pElement->GetAttributeValue( _T("location") ); m_sLinkName = pElement->GetAttributeValue( _T("remote") ); } } if ( m_sTitle.IsEmpty() ) m_sTitle = strTitle; return TRUE; }
CXMLElement* CHisReport::FindToday() const { CString strValue; WORD nYear, nMonth, nDay; CTime tt = CTime::GetCurrentTime(); nYear = tt.GetYear(); nMonth = tt.GetMonth(); nDay = tt.GetDay(); for ( POSITION pos = m_pXML->GetElementIterator() ; pos ; ) { CXMLElement* pXML = m_pXML->GetNextElement( pos ); if ( ! pXML->IsNamed( _T("History") ) ) continue; WORD nYear2, nMonth2, nDay2; nYear2 = nMonth2 = nDay2 = 0; strValue = pXML->GetAttributeValue( _T("Date") ); _stscanf( strValue, _T("%d年%d月%d日"), &nYear2, &nMonth2, &nDay2 ); if ( nYear != nYear2 || nMonth != nMonth2 || nDay != nDay2 ) continue; return pXML; } return NULL; }
BOOL CGroupingDlg::ProcessMethod(CXMLElement*& pXML) { for ( POSITION pos = pXML->GetElementIterator() ; pos ; ) { CXMLElement* pSync = pXML->GetNextElement( pos ); CString strValue = pSync->GetAttributeValue( _T("method") ); if ( ! strValue.CompareNoCase( METHOD_INSERT ) ) { ProcessInsert( pSync->GetFirstElement() ); } else if ( ! strValue.CompareNoCase( METHOD_DELETE ) ) { ProcessDelete( pSync->GetFirstElement() ); } else if ( ! strValue.CompareNoCase( METHOD_UPDATE ) ) { ProcessUpdate( pSync->GetFirstElement() ); } } pXML->Delete(); pXML = NULL; return TRUE; }
void CHomeLibraryBox::OnSkinChange() { if ( m_pDocument ) delete m_pDocument; m_pDocument = NULL; m_pdLibraryFiles = m_pdLibraryVolume = m_pdLibraryHashRemaining = NULL; SetCaptionmark( _T("CHomeLibraryBox.Caption") ); CXMLElement* pXML = Skin.GetDocument( _T("CHomeLibraryBox") ); if ( pXML == NULL ) return; SetCaption( pXML->GetAttributeValue( _T("title"), _T("Library") ) ); HICON hIcon = CoolInterface.ExtractIcon( IDR_LIBRARYFRAME, Settings.General.LanguageRTL ); if ( hIcon ) SetIcon( hIcon ); m_pDocument = new CRichDocument(); CMap< CString, const CString&, CRichElement*, CRichElement* > pMap; if ( ! m_pDocument->LoadXML( pXML, &pMap ) ) return; pMap.Lookup( _T("LibraryFiles"), m_pdLibraryFiles ); pMap.Lookup( _T("LibraryVolume"), m_pdLibraryVolume ); pMap.Lookup( _T("LibraryHashRemaining"), m_pdLibraryHashRemaining ); SetDocument( m_pDocument ); Update(); // Update Dropshadow (Note: Caused app freeze when allowing hovered item during skin change) m_wndTip.DestroyWindow(); m_wndTip.Create( this, &Settings.Interface.TipLibrary ); }
BOOL CFavouritesProfilePage::OnInitDialog() { CSettingsPage::OnInitDialog(); m_gdiImageList.Create( 16, 16, ILC_COLOR16|ILC_MASK, 1, 1 ); HICON hIcon = AfxGetApp()->LoadIcon( IDI_WEB_URL ); if ( theApp.m_bRTL ) hIcon = CreateMirroredIcon( hIcon ); m_gdiImageList.Add( hIcon ); CRect rc; m_wndList.GetClientRect( &rc ); rc.right -= GetSystemMetrics( SM_CXVSCROLL ) + 1; m_wndList.SetImageList( &m_gdiImageList, LVSIL_SMALL ); m_wndList.InsertColumn( 0, _T("Name"), LVCFMT_LEFT, rc.right / 2, -1 ); m_wndList.InsertColumn( 1, _T("URL"), LVCFMT_LEFT, rc.right / 2, 0 ); m_wndList.SendMessage( LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT ); if ( CXMLElement* pBookmarks = MyProfile.GetXML( _T("bookmarks") ) ) { for ( POSITION pos = pBookmarks->GetElementIterator() ; pos ; ) { CXMLElement* pBookmark = pBookmarks->GetNextElement( pos ); if ( pBookmark->IsNamed( _T("bookmark") ) ) { CString strTitle = pBookmark->GetAttributeValue( _T("title") ); CString strURL = pBookmark->GetAttributeValue( _T("url") ); if ( theApp.m_bRTL ) strURL = _T("\x202A") + strURL; int nItem = m_wndList.InsertItem( LVIF_TEXT|LVIF_IMAGE, m_wndList.GetItemCount(), strTitle, 0, 0, 0, 0 ); m_wndList.SetItemText( nItem, 1, strURL ); } } } Skin.Translate( _T("CFavouritesProfileList"), m_wndList.GetHeaderCtrl() ); UpdateData( FALSE ); m_wndAdd.EnableWindow( FALSE ); m_wndRemove.EnableWindow( FALSE ); return TRUE; }
BOOL CSkin::LoadCommandBitmap(CXMLElement* pBase, const CString& strPath) { static LPCTSTR pszNames[] = { _T("id"), _T("id1"), _T("id2"), _T("id3"), _T("id4"), _T("id5"), _T("id6"), _T("id7"), _T("id8"), _T("id9"), NULL }; CString strFile = strPath; strFile += pBase->GetAttributeValue( _T("id") ); strFile += pBase->GetAttributeValue( _T("path") ); HBITMAP hBitmap = LoadBitmap( strFile ); if ( hBitmap == NULL ) return TRUE; strFile = pBase->GetAttributeValue( _T("mask") ); COLORREF crMask = RGB( 0, 255, 0 ); if ( strFile.GetLength() == 6 ) { int nRed, nGreen, nBlue; _stscanf( strFile.Mid( 0, 2 ), _T("%x"), &nRed ); _stscanf( strFile.Mid( 2, 2 ), _T("%x"), &nGreen ); _stscanf( strFile.Mid( 4, 2 ), _T("%x"), &nBlue ); crMask = RGB( nRed, nGreen, nBlue ); } CoolInterface.ConfirmImageList(); int nBase = ImageList_AddMasked( CoolInterface.m_pImages.m_hImageList, hBitmap, crMask ); if ( nBase < 0 ) { DeleteObject( hBitmap ); return FALSE; } int nIndex = 0; for ( POSITION pos = pBase->GetElementIterator() ; pos ; ) { CXMLElement* pXML = pBase->GetNextElement( pos ); if ( ! pXML->IsNamed( _T("image") ) ) continue; strFile = pXML->GetAttributeValue( _T("index") ); if ( strFile.GetLength() ) _stscanf( strFile, _T("%i"), &nIndex ); nIndex += nBase; for ( int nName = 0 ; pszNames[ nName ] ; nName++ ) { UINT nID = LookupCommandID( pXML, pszNames[ nName ] ); if ( nID ) CoolInterface.m_pImageMap.SetAt( (LPVOID)nID, (LPVOID)nIndex ); if ( nName && ! nID ) break; } nIndex -= nBase; nIndex ++; } DeleteObject( hBitmap ); return TRUE; }
BOOL CSkin::LoadCommandImages(CXMLElement* pBase, const CString& strPath) { for ( POSITION pos = pBase->GetElementIterator() ; pos ; ) { CXMLElement* pXML = pBase->GetNextElement( pos ); if ( pXML->IsNamed( _T("icon") ) ) { UINT nID = LookupCommandID( pXML ); if ( nID == 0 ) continue; CString strFile = strPath; strFile += pXML->GetAttributeValue( _T("res") ); strFile += pXML->GetAttributeValue( _T("path") ); int nPos = strFile.Find( '$' ); HICON hIcon = NULL; if ( nPos < 0 ) { if ( ExtractIconEx( strFile, 0, NULL, &hIcon, 1 ) != NULL && hIcon != NULL ) { CoolInterface.AddIcon( nID, hIcon ); } } else { HINSTANCE hInstance = NULL; UINT nIconID = 0; if ( _stscanf( strFile.Left( nPos ), _T("%lu"), &hInstance ) != 1 ) return TRUE; if ( _stscanf( strFile.Mid( nPos + 1 ), _T("%lu"), &nIconID ) != 1 ) return TRUE; hIcon = (HICON)LoadImage( hInstance, MAKEINTRESOURCE(nIconID), IMAGE_ICON, 16, 16, 0 ); if ( hIcon != NULL ) CoolInterface.AddIcon( nID, hIcon ); } } else if ( pXML->IsNamed( _T("bitmap") ) ) { if ( ! LoadCommandBitmap( pXML, strPath ) ) return FALSE; } } return TRUE; }
void CHomeConnectionBox::OnSkinChange() { if ( m_pDocument ) delete m_pDocument; m_pDocument = NULL; m_pdConnectedHours = m_pdConnectedMinutes = NULL; for ( PROTOCOLID nP = PROTOCOL_NULL ; nP < PROTOCOL_LAST ; ++nP ) { for ( int nT = ntNode ; nT <= ntLeaf ; nT++ ) { m_pdCount[ nP ][ nT ] = NULL; m_sCount[ nP ][ nT ].Empty(); } } SetCaptionmark( _T("CHomeConnectionBox.Caption") ); CXMLElement* pXML = Skin.GetDocument( _T("CHomeConnectionBox") ); if ( pXML == NULL ) return; SetCaption( pXML->GetAttributeValue( _T("title"), _T("Connection") ) ); HICON hIcon = CoolInterface.ExtractIcon( IDR_NEIGHBOURSFRAME, Settings.General.LanguageRTL ); if ( hIcon ) SetIcon( hIcon ); m_pDocument = new CRichDocument(); CMap< CString, const CString&, CRichElement*, CRichElement* > pMap; if ( ! m_pDocument->LoadXML( pXML, &pMap ) ) return; pMap.Lookup( _T("ConnectedHours"), m_pdConnectedHours ); pMap.Lookup( _T("ConnectedMinutes"), m_pdConnectedMinutes ); pMap.Lookup( _T("G1Peers"), m_pdCount[PROTOCOL_G1][ntNode] ); pMap.Lookup( _T("G1Hubs"), m_pdCount[PROTOCOL_G1][ntHub] ); pMap.Lookup( _T("G1Leaves"), m_pdCount[PROTOCOL_G1][ntLeaf] ); pMap.Lookup( _T("G2Peers"), m_pdCount[PROTOCOL_G2][ntNode] ); pMap.Lookup( _T("G2Hubs"), m_pdCount[PROTOCOL_G2][ntHub] ); pMap.Lookup( _T("G2Leaves"), m_pdCount[PROTOCOL_G2][ntLeaf] ); pMap.Lookup( _T("EDServers"), m_pdCount[PROTOCOL_ED2K][ntHub] ); pMap.Lookup( _T("DCHubs"), m_pdCount[PROTOCOL_DC][ntHub] ); for ( PROTOCOLID nP = PROTOCOL_NULL ; nP < PROTOCOL_LAST ; ++nP ) { for ( int nT = ntNode ; nT < ntLast ; nT++ ) { if ( m_pdCount[ nP ][ nT ] != NULL ) m_sCount[ nP ][ nT ] = m_pdCount[ nP ][ nT ]->m_sText; } } SetDocument( m_pDocument ); Update(); }
DWORD CHisReport::GetToday() const { if ( ! IsEnabled() ) return 0; CXMLElement* pXML = FindToday(); CString strValue = pXML->GetAttributeValue( "Total" ); return _ttol( strValue ); }
BOOL CSkin::CreateMenu(CXMLElement* pRoot, HMENU hMenu) { for ( POSITION pos = pRoot->GetElementIterator() ; pos ; ) { CXMLElement* pXML = pRoot->GetNextElement( pos ); CString strText = pXML->GetAttributeValue( _T("text") ); int nAmp = strText.Find( '_' ); if ( nAmp >= 0 ) strText.SetAt( nAmp, '&' ); if ( pXML->IsNamed( _T("item") ) ) { if ( UINT nID = LookupCommandID( pXML ) ) { CString strKeys = pXML->GetAttributeValue( _T("shortcut") ); if ( strKeys.GetLength() ) strText += '\t' + strKeys; AppendMenu( hMenu, MF_STRING, nID, strText ); } } else if ( pXML->IsNamed( _T("menu") ) ) { HMENU hSubMenu = CreatePopupMenu(); if ( ! CreateMenu( pXML, hSubMenu ) ) { DestroyMenu( hSubMenu ); return FALSE; } AppendMenu( hMenu, MF_STRING|MF_POPUP, (UINT)hSubMenu, strText ); } else if ( pXML->IsNamed( _T("separator") ) ) { AppendMenu( hMenu, MF_SEPARATOR, ID_SEPARATOR, NULL ); } } return TRUE; }
BOOL CSkin::LoadCommandMap(CXMLElement* pBase) { for ( POSITION pos = pBase->GetElementIterator() ; pos ; ) { CXMLElement* pXML = pBase->GetNextElement( pos ); if ( pXML->IsNamed( _T("command") ) ) { CString strTemp = pXML->GetAttributeValue( _T("code") ); UINT nID; if ( _stscanf( strTemp, _T("%lu"), &nID ) != 1 ) return FALSE; strTemp = pXML->GetAttributeValue( _T("id") ); CoolInterface.NameCommand( nID, strTemp ); } } return TRUE; }
BOOL CSecurity::FromXML(CXMLElement* pXML) { if ( ! pXML->IsNamed( _T("security") ) ) return FALSE; int nCount = 0; for ( POSITION pos = pXML->GetElementIterator() ; pos ; ) { CXMLElement* pElement = pXML->GetNextElement( pos ); if ( pElement->IsNamed( _T("rule") ) ) { CQuickLock oLock( m_pSection ); CSecureRule* pRule = NULL; CString strGUID = pElement->GetAttributeValue( _T("guid") ); BOOL bExisting = FALSE; GUID pGUID; if ( Hashes::fromGuid( strGUID, &pGUID ) ) { if ( ( pRule = GetGUID( pGUID ) ) != NULL ) bExisting = TRUE; if ( pRule == NULL ) { pRule = new CSecureRule( FALSE ); pRule->m_pGUID = pGUID; } } else { pRule = new CSecureRule(); } if ( pRule->FromXML( pElement ) ) { if ( ! bExisting ) m_pRules.AddTail( pRule ); nCount++; } else { if ( ! bExisting ) delete pRule; } } } return nCount > 0; }
BOOL CNetworkMonitorBox::ClearProcess(POSITION posNext) { CXMLElement* pXML = Profiles.FindProcess( NULL, posNext ); if ( pXML == NULL ) return FALSE; CSingleLock pLock( &Network.m_pSection, TRUE ); CString strValue = pXML->GetAttributeValue( "Host" ); CChannel* pChannel = Network.FindChannel( strValue ); if ( pChannel ) pChannel->Release(); if ( posNext ) return ProcessXML( posNext ); return TRUE; }
BOOL CRichDocument::LoadXMLStyles(CXMLElement* pParent) { for ( POSITION pos = pParent->GetElementIterator() ; pos ; ) { CXMLElement* pXML = pParent->GetNextElement( pos ); if ( ! pXML->IsNamed( _T("style") ) ) continue; CString strName = pXML->GetAttributeValue( _T("name") ); CharLower( strName.GetBuffer() ); strName.ReleaseBuffer(); CString strFontFace = theApp.m_sDefaultFont; int nFontSize = theApp.m_nDefaultFontSize + 1; int nFontWeight = FW_BOLD; if ( CXMLElement* pFont = pXML->GetElementByName( _T("font") ) ) { strFontFace = pFont->GetAttributeValue( _T("face") ); CString strTemp = pFont->GetAttributeValue( _T("size") ); _stscanf( strTemp, _T("%i"), &nFontSize ); strTemp = pFont->GetAttributeValue( _T("weight") ); _stscanf( strTemp, _T("%i"), &nFontWeight ); } CXMLElement* pColours = pXML->GetElementByName( _T("colours") ); if ( pColours == NULL ) pColours = pXML; if ( strName == _T("default") || strName.IsEmpty() ) { LoadXMLColour( pColours, _T("text"), &m_crText ); LoadXMLColour( pColours, _T("link"), &m_crLink ); LoadXMLColour( pColours, _T("hover"), &m_crHover ); CreateFonts( strFontFace, nFontSize ); } else if ( strName == _T("heading") ) { LoadXMLColour( pColours, _T("text"), &m_crHeading ); if ( m_fntHeading.m_hObject ) m_fntHeading.DeleteObject(); m_fntHeading.CreateFont( -nFontSize, 0, 0, 0, nFontWeight, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE, strFontFace ); } } return TRUE; }
void CHomeUploadsBox::OnSkinChange() { if ( m_pDocument ) delete m_pDocument; m_pDocument = NULL; m_pdUploadsNone = m_pdUploadsOne = m_pdUploadsMany = NULL; m_pdUploadedNone = m_pdUploadedOne = m_pdUploadedMany = NULL; m_pdTorrentsOne = m_pdTorrentsMany = NULL; SetCaptionmark( _T("CHomeUploadsBox.Caption") ); CXMLElement* pXML = Skin.GetDocument( _T("CHomeUploadsBox") ); if ( pXML == NULL ) return; SetCaption( pXML->GetAttributeValue( _T("title"), _T("Uploads") ) ); HICON hIcon = CoolInterface.ExtractIcon( IDR_UPLOADSFRAME, Settings.General.LanguageRTL ); if ( hIcon ) SetIcon( hIcon ); m_pDocument = new CRichDocument(); CMap< CString, const CString&, CRichElement*, CRichElement* > pMap; if ( ! m_pDocument->LoadXML( pXML, &pMap ) ) return; pMap.Lookup( _T("UploadsNone"), m_pdUploadsNone ); pMap.Lookup( _T("UploadsOne"), m_pdUploadsOne ); pMap.Lookup( _T("UploadsMany"), m_pdUploadsMany ); pMap.Lookup( _T("UploadedNone"), m_pdUploadedNone ); pMap.Lookup( _T("UploadedOne"), m_pdUploadedOne ); pMap.Lookup( _T("UploadedMany"), m_pdUploadedMany ); pMap.Lookup( _T("TorrentsOne"), m_pdTorrentsOne ); pMap.Lookup( _T("TorrentsMany"), m_pdTorrentsMany ); if ( m_pdUploadedOne ) m_sUploadedOne = m_pdUploadedOne->m_sText; if ( m_pdUploadedMany ) m_sUploadedMany = m_pdUploadedMany->m_sText; if ( m_pdUploadsMany ) m_sUploadsMany = m_pdUploadsMany->m_sText; if ( m_pdTorrentsMany ) m_sTorrentsMany = m_pdTorrentsMany->m_sText; SetDocument( m_pDocument ); Update(); }
void CHomeDownloadsBox::OnSkinChange() { if ( m_pDocument ) delete m_pDocument; m_pDocument = NULL; m_pdDownloadsNone = m_pdDownloadsOne = m_pdDownloadsMany = NULL; m_pdDownloadedNone = m_pdDownloadedOne = m_pdDownloadedMany = m_pdDownloadedVolume = NULL; SetCaptionmark( _T("CHomeDownloadsBox.Caption") ); CXMLElement* pXML = Skin.GetDocument( _T("CHomeDownloadsBox") ); if ( pXML == NULL ) return; SetCaption( pXML->GetAttributeValue( _T("title"), _T("Downloads") ) ); HICON hIcon = CoolInterface.ExtractIcon( IDR_DOWNLOADSFRAME, Settings.General.LanguageRTL ); if ( hIcon ) SetIcon( hIcon ); m_pDocument = new CRichDocument(); CMap< CString, const CString&, CRichElement*, CRichElement* > pMap; if ( ! m_pDocument->LoadXML( pXML, &pMap ) ) return; pMap.Lookup( _T("DownloadsNone"), m_pdDownloadsNone ); pMap.Lookup( _T("DownloadsOne"), m_pdDownloadsOne ); pMap.Lookup( _T("DownloadsMany"), m_pdDownloadsMany ); pMap.Lookup( _T("DownloadedNone"), m_pdDownloadedNone ); pMap.Lookup( _T("DownloadedOne"), m_pdDownloadedOne ); pMap.Lookup( _T("DownloadedMany"), m_pdDownloadedMany ); pMap.Lookup( _T("DownloadedVolume"), m_pdDownloadedVolume ); if ( m_pdDownloadsMany ) m_sDownloadsMany = m_pdDownloadsMany->m_sText; if ( m_pdDownloadedMany ) m_sDownloadedMany = m_pdDownloadedMany->m_sText; SetDocument( m_pDocument ); // Was GetView().SetDocument( m_pDocument ); Update(); // Update Dropshadow m_wndTip.DestroyWindow(); m_wndTip.Create( this, &Settings.Interface.TipDownloads ); }
CString CBitziDownloader::LookupValue(LPCTSTR pszPath) { CString strName, strPath( pszPath ); CXMLElement* pXML = m_pXML; BOOL bFirst = TRUE; while ( strPath.GetLength() ) { strName = strPath.SpanExcluding( _T("/") ); strPath = strPath.Mid( strName.GetLength() ); if ( strPath.IsEmpty() ) { return pXML->GetAttributeValue( strName, NULL ); } if ( bFirst ) { bFirst = FALSE; if ( strName.CompareNoCase( pXML->GetName() ) ) pXML = NULL; } else { pXML = pXML->GetElementByName( strName ); } if ( ! pXML ) { strName.Empty(); return strName; } strPath = strPath.Mid( 1 ); } strName.Empty(); if ( pXML ) strName = pXML->GetValue(); return strName; }
BOOL CSkin::CreateToolBar(CXMLElement* pBase) { CCoolBarCtrl* pBar = new CCoolBarCtrl(); for ( POSITION pos = pBase->GetElementIterator() ; pos ; ) { CXMLElement* pXML = pBase->GetNextElement( pos ); if ( pXML->IsNamed( _T("button") ) ) { if ( UINT nID = LookupCommandID( pXML ) ) { CCoolBarItem* pItem = pBar->Add( nID, pXML->GetAttributeValue( _T("text") ) ); CString strTemp = pXML->GetAttributeValue( _T("colour") ); if ( strTemp.GetLength() == 6 ) { int nRed, nGreen, nBlue; _stscanf( strTemp.Mid( 0, 2 ), _T("%x"), &nRed ); _stscanf( strTemp.Mid( 2, 2 ), _T("%x"), &nGreen ); _stscanf( strTemp.Mid( 4, 2 ), _T("%x"), &nBlue ); pItem->m_crText = RGB( nRed, nGreen, nBlue ); } strTemp = pXML->GetAttributeValue( _T("tip") ); if ( strTemp.GetLength() ) pItem->SetTip( strTemp ); strTemp = pXML->GetAttributeValue( _T("visible") ); if ( strTemp.GetLength() ) pItem->Show( FALSE ); } } else if ( pXML->IsNamed( _T("separator") ) ) { pBar->Add( ID_SEPARATOR ); } else if ( pXML->IsNamed( _T("rightalign") ) ) { pBar->Add( ID_RIGHTALIGN ); } else if ( pXML->IsNamed( _T("control") ) ) { UINT nID, nWidth, nHeight = 0; CString strTemp; strTemp = pXML->GetAttributeValue( _T("id") ); if ( _stscanf( strTemp, _T("%lu"), &nID ) == 1 ) { strTemp = pXML->GetAttributeValue( _T("width") ); if ( _stscanf( strTemp, _T("%lu"), &nWidth ) == 1 ) { strTemp = pXML->GetAttributeValue( _T("height") ); _stscanf( strTemp, _T("%lu"), &nHeight ); pBar->Add( nID, nWidth, nHeight ); } } } else if ( pXML->IsNamed( _T("label") ) ) { CCoolBarItem* pItem = pBar->Add( 1, pXML->GetAttributeValue( _T("text") ) ); pItem->m_crText = 0; pItem->SetTip( pXML->GetAttributeValue( _T("tip") ) ); } } CString strName = pBase->GetAttributeValue( _T("name") ); CCoolBarCtrl* pOld = NULL; if ( m_pToolbars.Lookup( strName, (void*&)pOld ) && pOld ) delete pOld; m_pToolbars.SetAt( strName, pBar ); return TRUE; }
BOOL CEmoticons::LoadXML(LPCTSTR pszFile) { CString strPath, strValue; CXMLElement* pXML = CXMLElement::FromFile( pszFile, TRUE ); if ( pXML == NULL ) return FALSE; strPath = pszFile; int nSlash = strPath.ReverseFind( '\\' ); if ( nSlash >= 0 ) strPath = strPath.Left( nSlash + 1 ); CXMLElement* pBitmap = pXML->GetElementByName( _T("bitmap") ); if ( pBitmap == NULL ) { delete pXML; return FALSE; } strValue = pBitmap->GetAttributeValue( _T("file") ); nSlash = strValue.ReverseFind( '/' ); if ( nSlash >= 0 ) strValue = strValue.Mid( nSlash + 1 ); strValue = strPath + strValue; CImageFile pImage; if ( ! pImage.LoadFromFile( strValue ) || ! pImage.EnsureRGB( GetSysColor( COLOR_WINDOW ) ) || ! pImage.SwapRGB() ) { delete pXML; return FALSE; } COLORREF crBack = RGB( pImage.m_pImage[2], pImage.m_pImage[1], pImage.m_pImage[0] ); for ( POSITION pos = pXML->GetElementIterator() ; pos ; ) { CXMLElement* pEmoticon = pXML->GetNextElement( pos ); if ( ! pEmoticon->IsNamed( _T("emoticon") ) ) continue; CXMLElement* pSource = pEmoticon->GetElementByName( _T("source") ); CString strText = pEmoticon->GetAttributeValue( _T("text") ); CRect rc( 0, 0, 0, 0 ); strValue = pSource->GetAttributeValue( _T("left"), _T("0") ); _stscanf( strValue, _T("%i"), &rc.left ); strValue = pSource->GetAttributeValue( _T("top"), _T("0") ); _stscanf( strValue, _T("%i"), &rc.top ); strValue = pSource->GetAttributeValue( _T("right"), _T("0") ); _stscanf( strValue, _T("%i"), &rc.right ); strValue = pSource->GetAttributeValue( _T("bottom"), _T("0") ); _stscanf( strValue, _T("%i"), &rc.bottom ); BOOL bButton = pEmoticon->GetAttributeValue( _T("button") ).CompareNoCase( _T("yes") ) == 0; AddEmoticon( strText, &pImage, &rc, crBack, bButton ); } delete pXML; return TRUE; }
BOOL CRichDocument::LoadXML(CXMLElement* pBase, CMapStringToPtr* pMap, int nGroup) { CSingleLock pLock( &m_pSection, TRUE ); if ( pBase == NULL ) return FALSE; CString strTemp; if ( pBase->IsNamed( _T("document") ) ) { strTemp = pBase->GetAttributeValue( _T("fontFace") ); if ( strTemp.GetLength() ) CreateFonts( strTemp ); LoadXMLColour( pBase, _T("crBackground"), &m_crBackground ); LoadXMLColour( pBase, _T("crText"), &m_crText ); LoadXMLColour( pBase, _T("crLink"), &m_crLink ); LoadXMLColour( pBase, _T("crHover"), &m_crHover ); LoadXMLColour( pBase, _T("crHeading"), &m_crHeading ); strTemp = pBase->GetAttributeValue( _T("leftMargin") ); if ( strTemp.GetLength() ) _stscanf( strTemp, _T("%i"), &m_szMargin.cx ); strTemp = pBase->GetAttributeValue( _T("topMargin") ); if ( strTemp.GetLength() ) _stscanf( strTemp, _T("%i"), &m_szMargin.cy ); } for ( POSITION pos = pBase->GetElementIterator() ; pos ; ) { CXMLElement* pXML = pBase->GetNextElement( pos ); CRichElement* pElement = NULL; if ( pXML->IsNamed( _T("text") ) ) { pElement = new CRichElement( retText ); } else if ( pXML->IsNamed( _T("link") ) ) { pElement = new CRichElement( retLink ); } else if ( pXML->IsNamed( _T("heading") ) ) { pElement = new CRichElement( retHeading ); } else if ( pXML->IsNamed( _T("newline") ) ) { pElement = new CRichElement( retNewline ); strTemp = pXML->GetAttributeValue( _T("gap") ); if ( strTemp.GetLength() ) { pElement->m_sText = strTemp; strTemp = pXML->GetAttributeValue( _T("indent") ); if ( strTemp.GetLength() ) pElement->m_sText += '.' + strTemp; } else { strTemp = pXML->GetAttributeValue( _T("indent") ); if ( strTemp.GetLength() ) pElement->m_sText = _T("0.") + strTemp; } } else if ( pXML->IsNamed( _T("gap") ) ) { pElement = new CRichElement( retGap ); strTemp = pXML->GetAttributeValue( _T("size") ); if ( strTemp ) pElement->m_sText = strTemp; } else if ( pXML->IsNamed( _T("bitmap") ) ) { pElement = new CRichElement( retBitmap ); } else if ( pXML->IsNamed( _T("icon") ) ) { pElement = new CRichElement( retIcon ); } else if ( pXML->IsNamed( _T("anchor") ) ) { pElement = new CRichElement( retAnchor ); } else if ( pXML->IsNamed( _T("para") ) ) { Add( pElement = new CRichElement( retAlign, pXML->GetAttributeValue( _T("align") ) ) ); if ( pXML->GetElementCount() ) { if ( ! LoadXML( pXML, pMap, nGroup ) ) return FALSE; if ( pElement->m_sText.CompareNoCase( _T("left") ) ) { Add( new CRichElement( retAlign, _T("left") ) ); } } continue; } else if ( pXML->IsNamed( _T("group") ) ) { int nSubGroup = 0; if ( _stscanf( pXML->GetAttributeValue( _T("id") ), _T("%i"), &nSubGroup ) != 1 ) return FALSE; if ( ! LoadXML( pXML, pMap, nSubGroup ) ) return FALSE; continue; } else if ( pXML->IsNamed( _T("styles") ) ) { if ( ! LoadXMLStyles( pXML ) ) return FALSE; } else { return FALSE; } if ( pElement == NULL ) continue; strTemp = pXML->GetValue(); if ( strTemp.GetLength() ) pElement->m_sText = strTemp; pElement->m_nGroup = nGroup; strTemp = pXML->GetAttributeValue( _T("group") ); if ( strTemp.GetLength() ) _stscanf( strTemp, _T("%i"), &pElement->m_nGroup ); strTemp = pXML->GetAttributeValue( _T("format") ); CharLower( strTemp.GetBuffer() ); strTemp.ReleaseBuffer(); if ( strTemp.Find( 'b' ) >= 0 ) pElement->m_nFlags |= retfBold; if ( strTemp.Find( 'i' ) >= 0 ) pElement->m_nFlags |= retfItalic; if ( strTemp.Find( 'u' ) >= 0 ) pElement->m_nFlags |= retfUnderline; strTemp = pXML->GetAttributeValue( _T("align") ); CharLower( strTemp.GetBuffer() ); strTemp.ReleaseBuffer(); if ( strTemp == _T("middle") ) pElement->m_nFlags |= retfMiddle; strTemp = pXML->GetAttributeValue( _T("colour") ); if ( strTemp.GetLength() == 6 ) { pElement->m_nFlags |= retfColour; LoadXMLColour( pXML, _T("colour"), &pElement->m_cColour ); } if ( pElement->m_nType == retIcon ) { strTemp = pXML->GetAttributeValue( _T("command") ); if ( strTemp.GetLength() ) { pElement->m_nType = retCmdIcon; pElement->m_sText = strTemp; } } if ( pElement->m_nType == retIcon || pElement->m_nType == retBitmap || pElement->m_nType == retAnchor ) { strTemp = pXML->GetAttributeValue( _T("res") ); if ( strTemp.GetLength() ) pElement->m_sText = strTemp; strTemp = pXML->GetAttributeValue( _T("path") ); if ( strTemp.GetLength() ) pElement->m_sText = strTemp; strTemp = pXML->GetAttributeValue( _T("width") ); if ( strTemp.GetLength() ) { if ( pElement->m_sText.GetLength() ) pElement->m_sText += '.'; pElement->m_sText += strTemp; strTemp = pXML->GetAttributeValue( _T("height") ); if ( strTemp.GetLength() ) pElement->m_sText += '.' + strTemp; } } pElement->m_sLink = pXML->GetAttributeValue( _T("target") ); if ( pMap ) { strTemp = pXML->GetAttributeValue( _T("id") ); if ( strTemp.GetLength() ) pMap->SetAt( strTemp, pElement ); } Add( pElement ); } return TRUE; }