Esempio n. 1
0
CString CLocalSearch::GetXMLString()
{
	CString strXML;

	for ( POSITION pos1 = m_pSchemas.GetStartPosition() ; pos1 ; )
	{
		CXMLElement* pGroup;
		CSchema* pSchema;

		m_pSchemas.GetNextAssoc( pos1, (void*&)pSchema, (void*&)pGroup );

		strXML += _T("<?xml version=\"1.0\"?>\r\n");
		pGroup->ToString( strXML, TRUE );

		for ( POSITION pos2 = pGroup->GetElementIterator() ; pos2 ; )
		{
			CXMLElement* pChild = pGroup->GetNextElement( pos2 );
			pChild->DeleteAttribute( _T("index") );
			pChild->Detach();
		}

		delete pGroup;
	}

	m_pSchemas.RemoveAll();

	return strXML;
}
Esempio n. 2
0
void CGroupingDlg::OnSelChangeGroup()
{
	m_wndList.DeleteAllItems();
	CWaitCursor pCursor;
	
	int nItem = m_wndGroup.GetCurSel();
	if ( nItem < 0 ) return;
	
	CXMLElement* pXML = (CXMLElement*)m_wndGroup.GetItemDataPtr( nItem );
	ASSERT( pXML != NULL );
	
	for ( POSITION posNext = pXML->GetElementIterator(); posNext; )
	{
		CXMLElement* pSync = pXML->GetNextElement( posNext );
		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() ) != nItem ) continue;
		
		static LPCTSTR pszSuffix[] = { _T("xphone"), _T("xname"), NULL };
		
		int nItem = m_wndList.InsertItem( LVIF_TEXT|LVIF_PARAM,
				m_wndList.GetItemCount(), NULL, 0, 0, 0, (LPARAM)pSync );
		
		for ( int i = 0; pszSuffix[i] != NULL; i ++ )
		{
			CXMLAttribute* pAttri = pSync->GetAttribute( pszSuffix[i] );
			if ( pAttri ) m_wndList.SetItemText( nItem, i, pAttri->GetValue() );
		}
	}
}
Esempio n. 3
0
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();
}
Esempio n. 4
0
CXMLElement* CCollectionFile::CloneMetadata(CXMLElement* pMetadata)
{
	CString strURI = pMetadata->GetAttributeValue( L"xmlns:s" );
	if ( strURI.IsEmpty() ) return NULL;

	CXMLElement* pCore = pMetadata->GetFirstElement();
	if ( pCore == NULL ) return NULL;

	if ( CSchemaPtr pSchema = SchemaCache.Get( strURI ) )
	{
		pMetadata = pSchema->Instantiate();
	}
	else
	{
		pMetadata = new CXMLElement( NULL, pCore->GetName() + 's' );
		pMetadata->AddAttribute( CXMLAttribute::schemaName, strURI );
	}

	pCore = pCore->Clone();
	pMetadata->AddElement( pCore );

	CString strName = pMetadata->GetName();
	if ( _tcsnicmp( strName, L"s:", 2 ) == 0 )
		pMetadata->SetName( strName.Mid( 2 ) );

	strName = pCore->GetName();
	if ( _tcsnicmp( strName, L"s:", 2 ) == 0 )
		pCore->SetName( strName.Mid( 2 ) );

	for ( POSITION pos = pCore->GetElementIterator(); pos; )
	{
		CXMLNode* pNode = pCore->GetNextElement( pos );
		CString strNodeName = pNode->GetName();
		if ( _tcsnicmp( strNodeName, L"s:", 2 ) == 0 )
			pNode->SetName( strNodeName.Mid( 2 ) );
	}

	for ( POSITION pos = pCore->GetAttributeIterator(); pos; )
	{
		CXMLNode* pNode = pCore->GetNextAttribute( pos );
		CString strNodeName = pNode->GetName();
		if ( _tcsnicmp( strNodeName, L"s:", 2 ) == 0 )
			pNode->SetName( strNodeName.Mid( 2 ) );
	}

	return pMetadata;
}
Esempio n. 5
0
CXMLElement* CXMLElement::Prefix(const CString& sPrefix, CXMLElement* pParent) const
{
	CXMLElement* pCloned = Clone( pParent );
	if ( pCloned )
	{
		pCloned->SetName( sPrefix + pCloned->GetName() );

		for ( POSITION pos = pCloned->GetElementIterator() ; pos ; )
		{
			CXMLElement* pNode = pCloned->GetNextElement( pos );
			pNode->SetName( sPrefix + pNode->GetName() );
		}

		for ( POSITION pos = pCloned->GetAttributeIterator() ; pos ; )
		{
			CXMLAttribute* pNode = pCloned->GetNextAttribute( pos );
			pNode->SetName( sPrefix + pNode->GetName() );
		}
	}
	return pCloned;
}
Esempio n. 6
0
BOOL CRulerSettingsPage::LoadXML()
{
	CString strValue;
	CXMLElement* pXML = NULL;
	CXMLAttribute* pAttri = NULL;
	
	if ( pXML = m_pXML->GetElementByName( _T("BlackList") ) )
	{
		for ( POSITION pos = pXML->GetElementIterator() ; pos ; )
		{
			CXMLElement* pMap = pXML->GetNextElement( pos );
			if ( ! pMap->IsNamed( _T("Map") ) ) continue;

			if ( pAttri = pMap->GetAttribute( _T("ID") ) )
			{
				strValue = pAttri->GetValue();
				m_wndExtList.AddString( strValue );
			}
		}
	}

	return TRUE;
}
Esempio n. 7
0
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;
}
Esempio n. 8
0
BOOL CCollectionFile::LoadCollection(LPCTSTR pszFile)
{
	m_nType = EnvyCollection;

	CZIPFile pZIP;
	if ( ! pZIP.Open( pszFile ) ) return FALSE;

	CZIPFile::File* pFile = pZIP.GetFile( L"Collection.xml", TRUE );
	if ( ! pFile ) return FALSE;

	if ( pZIP.GetCount() == 1 )		// xml-only
		m_nType = SimpleCollection;

	augment::auto_ptr< CBuffer > pBuffer ( pFile->Decompress() );
	if ( ! pBuffer.get() ) return FALSE;

	augment::auto_ptr< CXMLElement > pXML ( CXMLElement::FromString( pBuffer->ReadString( pBuffer->m_nLength, CP_UTF8 ), TRUE ) );
	if ( ! pXML.get() ) return FALSE;
	if ( ! pXML->IsNamed( L"collection" ) ) return FALSE;

	CXMLElement* pProperties = pXML->GetElementByName( L"properties" );
	if ( ! pProperties ) return FALSE;

	CXMLElement* pContents = pXML->GetElementByName( L"contents" );
	if ( ! pContents ) return FALSE;

	for ( POSITION pos = pContents->GetElementIterator(); pos; )
	{
		CXMLElement* pElement = pContents->GetNextElement( pos );
		if ( pElement->IsNamed( L"file" ) )
		{
			augment::auto_ptr< File > pNewFile( new File( this ) );
			if ( pNewFile.get() && pNewFile->Parse( pElement ) )
				m_pFiles.AddTail( pNewFile.release() );
		}
	}

	if ( CXMLElement* pMetadata = pProperties->GetElementByName( L"metadata" ) )
	{
		m_pMetadata = CloneMetadata( pMetadata );
		if ( m_pMetadata )
			m_sThisURI = m_pMetadata->GetAttributeValue( CXMLAttribute::schemaName );
	}

	if ( CXMLElement* pTitle = pProperties->GetElementByName( L"title" ) )
		m_sTitle = pTitle->GetValue();

	if ( CXMLElement* pMounting = pProperties->GetElementByName( L"mounting" ) )
	{
		if ( CXMLElement* pParent = pMounting->GetElementByName( L"parent" ) )
			m_sParentURI = pParent->GetAttributeValue( L"uri" );

		if ( CXMLElement* pThis = pMounting->GetElementByName( L"this" ) )
			m_sThisURI = pThis->GetAttributeValue( L"uri" );
	}

	if ( m_sThisURI.IsEmpty() )
	{
		Close();
		return FALSE;
	}

	return TRUE;
}