void AsyncUpdateHandler::OnDataChange(COPCGroup & group, CAtlMap<COPCItem *, OPCItemData *> & changes) { log_NOTICE("OnDataChange called, group [", group.getName(),"] change count [", pantheios::integer(changes.GetCount()),"] have callback [",(callbackFn != NULL?"Y":"N"),"]"); for(POSITION pos = changes.GetStartPosition(); pos != NULL; ) { CAtlMap<COPCItem *, OPCItemData *>::CPair* pPair = changes.GetNext(pos); ItemValueStruct itemValueStruct(pPair->m_value); const ItemValue& itemValue = itemValueStruct.getItemValue(); log_NOTICE("\t item [",pPair->m_key->getName(),"] value [", itemValueStruct.getItemValue().value,"]"); if(callbackFn != NULL) { log_NOTICE("\t OnDataChange calling callback fn"); //Update* update = createUpdate(pPair->m_key->getName().GetString(), itemValue.value, itemValue.quality, itemValue.dataType, itemValue.timestamp); callbackFn(pPair->m_key->getName().GetString(), itemValue.value, itemValue.quality, itemValue.dataType, itemValue.timestamp); log_DEBUG("\t OnDataChange called callback fn"); /* callbackFn(update); log_DEBUG("\t OnDataChange called callback fn"); destroyUpdate(update); log_DEBUG("\t OnDataChange destroyed object"); */ } } }
STDMETHODIMP CPreviewPlugin::Preview2(/* [in] */ BSTR sSource, /* [in] */ BSTR sTarget) { m_bCancel = false; if ( ! sSource || ! sTarget ) return E_POINTER; if ( ! m_pSite ) return E_UNEXPECTED; // Get extension LPCTSTR szTargetExt = PathFindExtension( sTarget ); if ( ! *szTargetExt ) return E_INVALIDARG; // Load data CAtlMap< CString, CString > oData; LoadData( oData ); // Find command line for extension for ( POSITION pos = oData.GetStartPosition(); pos; ) { CString sExt, sCommand; oData.GetNextAssoc( pos, sExt, sCommand ); TCHAR szKey[ MAX_PATH ] = { _T(".") }; for ( LPCTSTR str = sExt.GetBuffer(); ; ++str ) { LPTSTR space = StrChr( str, _T(' ') ); if ( space ) *space = _T('\0'); lstrcpyn( szKey + 1, str, _countof( szKey ) - 1 ); StrTrim( szKey + 1, _T(". /t") ); if ( lstrcmpi( szKey, szTargetExt ) == 0 ) { // Found! sExt.ReleaseBuffer(); if ( sCommand.Replace( _T("%1"), sSource ) == 0 || sCommand.Replace( _T("%2"), sTarget ) == 0 ) // Invalid command line return E_INVALIDARG; m_pSite->SetProgressMessage( CComBSTR( sCommand ) ); m_pSite->SetProgressRange( 100 ); if ( ! Execute( sCommand ) ) // Can't launch external program return E_FAIL; m_pSite->SetProgressPosition( 100 ); // Check for resulting file if ( GetFileAttributes( sTarget ) == INVALID_FILE_ATTRIBUTES ) // No file (user canceled it) return S_FALSE; // Run it m_pSite->QueueDeleteFile( sTarget ); if ( ! m_bCancel ) m_pSite->ExecuteFile( sTarget ); return S_OK; } if ( ! space ) { sExt.ReleaseBuffer(); break; } str = space; } } return E_INVALIDARG; }