LONG CuDlgIpmPageProcesses::OnUpdateData (WPARAM wParam, LPARAM lParam) { BOOL bOK = FALSE; CPtrList listInfoStruct; LOGPROCESSDATAMIN* pData; LPIPMUPDATEPARAMS pUps = (LPIPMUPDATEPARAMS)lParam; CString strID; CString strPID; CString strType; CString strOpenDB; CString strWrite; CString strForce; CString strWait; CString strBegin; CString strEnd; ASSERT (pUps); switch (pUps->nIpmHint) { case 0: break; default: return 0L; } try { LOGPROCESSDATAMIN structData; CdIpmDoc* pDoc = (CdIpmDoc*)wParam; ResetDisplay(); CaIpmQueryInfo queryInfo(pDoc, OT_MON_LOGPROCESS, pUps, (LPVOID)&structData, sizeof(structData)); bOK = IPM_QueryInfo (&queryInfo, listInfoStruct); if (bOK) { while (!listInfoStruct.IsEmpty()) { pData = (LOGPROCESSDATAMIN*)listInfoStruct.RemoveHead(); GetDisplayInfo (pData, strID, strPID, strType, strOpenDB, strWrite, strForce, strWait, strBegin, strEnd); AddProcess (strID, strPID, strType, strOpenDB, strWrite, strForce, strWait, strBegin, strEnd, pData); } } return 0L; } catch (CMemoryException* e) { theApp.OutOfMemoryMessage(); e->Delete(); } catch (CeIpmException e) { AfxMessageBox (e.GetReason(), MB_ICONEXCLAMATION|MB_OK); } while (!listInfoStruct.IsEmpty()) delete (LOGPROCESSDATAMIN*)listInfoStruct.RemoveHead(); return 0L; }
LONG CuDlgIpmPageLockLists::OnUpdateData (WPARAM wParam, LPARAM lParam) { BOOL bOK = FALSE; CPtrList listInfoStruct; LOCKLISTDATAMIN* pData; LPIPMUPDATEPARAMS pUps = (LPIPMUPDATEPARAMS)lParam; CString strID; CString strSession; CString strCount; CString strLogical; CString strMaxL; CString strStatus; ASSERT (pUps); switch (pUps->nIpmHint) { case 0: case FILTER_SYSTEM_LOCK_LISTS: break; default: return 0L; } try { LOCKLISTDATAMIN structData; CdIpmDoc* pDoc = (CdIpmDoc*)wParam; ResetDisplay(); CaIpmQueryInfo queryInfo(pDoc, OT_MON_LOCKLIST, pUps, (LPVOID)&structData, sizeof(structData)); bOK = IPM_QueryInfo (&queryInfo, listInfoStruct); if (bOK) { while (!listInfoStruct.IsEmpty()) { pData = (LOCKLISTDATAMIN*)listInfoStruct.RemoveHead(); GetDisplayInfo (pData, strID, strSession, strCount, strLogical, strMaxL, strStatus); AddLockList (strID, strSession, strCount, strLogical, strMaxL, strStatus, pData); } } return 0L; } catch (CMemoryException* e) { MessageBeep (-1); theApp.OutOfMemoryMessage (); e->Delete(); } catch (CeIpmException e) { AfxMessageBox (e.GetReason(), MB_ICONEXCLAMATION|MB_OK); } while (!listInfoStruct.IsEmpty()) delete (LOCKLISTDATAMIN*)listInfoStruct.RemoveHead(); return 0L; }
int CLocalSearch::ExecuteSharedFiles(int nMaximum) { CQuickLock oLock( Library.m_pSection ); CPtrList* pFiles = Library.Search( m_pSearch, nMaximum ); if ( pFiles == NULL ) return 0; int nHits = pFiles->GetCount(); while ( pFiles->GetCount() ) { int nInThisPacket = min( pFiles->GetCount(), (int)Settings.Gnutella.HitsPerPacket ); CreatePacket( nInThisPacket ); int nHitB = 0; for ( int nHitA = 0 ; nHitA < nInThisPacket ; nHitA++ ) { CLibraryFile* pFile = (CLibraryFile*)pFiles->RemoveHead(); if ( AddHit( pFile, nHitB ) ) nHitB ++; } WriteTrailer(); if ( nHitB > 0 ) DispatchPacket(); else DestroyPacket(); } delete pFiles; return nHits; }
int CGenethonDoc::GetPIRFile( CString PathName, int Append ) { CPtrList CommentList; CPtrList SequenceList; if ( !ReadPIRFile( &CommentList, &SequenceList, PathName ) ) { while ( !CommentList.IsEmpty() ) { delete (CString *)CommentList.RemoveHead(); } while ( !SequenceList.IsEmpty() ) { delete (SeqNameStruct *)SequenceList.RemoveHead(); } return 0; } // gMaxStrSize; return ProcessRows( CommentList, SequenceList, Append ); }
LONG CuDlgReplicationServerPageAssignment::OnUpdateData (WPARAM wParam, LPARAM lParam) { LPIPMUPDATEPARAMS pUps = (LPIPMUPDATEPARAMS)lParam; CPtrList listInfoStruct; switch (pUps->nIpmHint) { case 0: break; default: return 0L; } ASSERT (pUps); try { REPLICSERVERDATAMIN RepSvrdta = *((LPREPLICSERVERDATAMIN)pUps->pStruct); // // Empty the control: m_cListCtrl.DeleteAllItems(); CdIpmDoc* pIpmDoc = (CdIpmDoc*)wParam; CaIpmQueryInfo queryInfo(pIpmDoc, OT_MON_REPLIC_CDDS_ASSIGN,pUps); queryInfo.SetNode((LPCTSTR)RepSvrdta.LocalDBNode); queryInfo.SetDatabase ((LPCTSTR)RepSvrdta.LocalDBName); BOOL bOK = IPM_QueryInfo (&queryInfo, listInfoStruct); if (bOK) { POSITION pos = listInfoStruct.GetHeadPosition(); while (pos != NULL) { REPLICCDDSASSIGNDATAMIN* pCdds = (REPLICCDDSASSIGNDATAMIN*)listInfoStruct.GetNext(pos); AddItem (pCdds); } } } catch (CMemoryException* e) { theApp.OutOfMemoryMessage(); e->Delete(); } catch (CeIpmException e) { AfxMessageBox (e.GetReason(), MB_ICONEXCLAMATION|MB_OK); } while (!listInfoStruct.IsEmpty()) delete (REPLICCDDSASSIGNDATAMIN*)listInfoStruct.RemoveHead(); return 0L; }
int CGenethonDoc::GetTextFile( CString PathName, int Append, const CString& SeqName, double SeqWeight, DWORD TextStart, const CString& Descr, int IUPAC ) { CPtrList CommentList; CPtrList SequenceList; gMaxStrSize = 0L; if ( !ReadTextFile ( &CommentList, &SequenceList, PathName, SeqName, SeqWeight, TextStart, Descr, IUPAC ) ) { while ( !SequenceList.IsEmpty() ) { delete (SeqNameStruct *)SequenceList.RemoveHead(); } return 0; } return ProcessRows( CommentList, SequenceList, Append ); }
bool CORDBList::ReadDBInfo() { CDBInfo *db; CStdioFile listfile, infofile; CFileStatus fstatus; CFileException e; CPtrList plist; char data[1025]; char *tmp; if (infofile.Open(m_ordbinfo, CFile::modeRead)) { while (1) { memset(data, 0x00, 1024); TRY { if (infofile.ReadString(data, 1024) == NULL) break; data[strlen(data)-1] = NULL; db = new CDBInfo(); tmp = strtok(data, " "); // db name if (tmp) { db->m_dbname.Format("%s", tmp); } tmp = strtok(NULL, " "); // permanent if (tmp) { if (!strcmp(tmp, "1")) db->m_permanent = true; else db->m_permanent = false; } plist.AddTail(db); } CATCH_ALL(e) { break; } END_CATCH_ALL } infofile.Close(); } if (listfile.Open(m_ordblist, CFile::modeRead)) { listfile.GetStatus(fstatus); m_LastTime = fstatus.m_mtime; } else { return false; } while (1) { memset(data, 0x00, 1024); TRY { if (listfile.ReadString(data, 1024) == NULL) break; data[strlen(data)-1] = NULL; db = new CDBInfo(); tmp = strtok(data, " "); // db name if (tmp) { db->m_dbname.Format("%s", tmp); } tmp = strtok(NULL, " "); // db path if (tmp) { db->m_dbpath.Format("%s", tmp); } tmp = strtok(NULL, " "); // host if (tmp) { db->m_host.Format("%s", tmp); } tmp = strtok(NULL, " "); // log path if (tmp) { db->m_logpath.Format("%s", tmp); } int cnt = (int) plist.GetCount(); if (cnt > 0) { for (int i = 0; i < cnt; i++) { CDBInfo *p = (CDBInfo *)plist.GetAt(plist.FindIndex(i)); if (db->m_dbname == p->m_dbname) { db->m_permanent = p->m_permanent; break; } } } m_List.AddTail(db); } CATCH_ALL(e) { break; } END_CATCH_ALL } listfile.Close(); while (!plist.IsEmpty()) { CDBInfo *p = (CDBInfo *)plist.RemoveHead(); delete p; } return true; }
void CDlgTimedMessageBox::GetWindowHandles(void) { HWND hWnd; CWnd *pWnd; CString title; CPtrList allButtons; // // Handle of the messageBox // if( !m_hMsgBox ) { hWnd = ::GetWindow(::GetDesktopWindow(), GW_CHILD); while( (hWnd!=NULL) && (m_hMsgBox==NULL) ) { pWnd = CWnd::FromHandle(hWnd); pWnd->GetWindowText(title); if( ::AfxIsDescendant(m_hParent, hWnd) && ::IsWindowVisible(hWnd) && (m_Title.CompareNoCase(title)==0) ) { m_hMsgBox = hWnd; break; } hWnd = ::GetWindow(hWnd, GW_HWNDNEXT); } } // // Handle of the static text // TODO only if text-replace is needed // if( m_hMsgBox && !m_hStaticText ) { // not sure if this will work always // under Win2000 it did //m_hStaticText = ::GetDlgItem(m_hMsgBox, 0xFFFF); // not sure, so lets find it dynamically! char className[_MAX_PATH]; CString classNameOk("STATIC"); LONG id; hWnd = ::GetWindow(m_hMsgBox, GW_CHILD); while( (hWnd!=NULL) && (m_hStaticText==NULL) ) { id = ::GetWindowLong(hWnd, GWL_ID); // small ids only for buttons if( id > IDHELP ) { if( ::GetClassName(hWnd, className, _MAX_PATH) ) { // looking only for a static if( classNameOk.CompareNoCase(className) == 0 ) { // not check the text pWnd = CWnd::FromHandle(hWnd); pWnd->GetWindowText(title); if( m_CurrentMessage.CompareNoCase(title) == 0 ) { m_hStaticText = hWnd; break; } } } } else { allButtons.AddTail(hWnd); } hWnd = ::GetWindow(hWnd, GW_HWNDNEXT); } } // // Handle of the default button // if( m_hMsgBox && !m_hDefaultButton ) { m_hDefaultButton = ::GetDlgItem(m_hMsgBox, m_DefaultReturn); // Problem: (reported from Keith Brown) // if generated with MB_OK the button has NOT IDOK, but IDCANCEL !! // then lets take the first button we find ! // (with and IDCANCEL this works, because it is the only button // if this problem encounters also with 2 buttons, I have no chance // to find out which one is the better one!) while( allButtons.GetCount()>0 && !m_hDefaultButton ) { m_hDefaultButton = (HWND) allButtons.GetHead(); allButtons.RemoveHead(); if( m_hDefaultButton ) m_DefaultReturn = ::GetWindowLong(m_hDefaultButton, GWL_ID); } } }
BOOL IPM_BuildItemPath (CdIpmDoc* pDoc, CTypedPtrList<CObList, CuIpmTreeFastItem*>& listItemPath) { ASSERT(!pDoc->GetSelectKey().IsEmpty()); if (pDoc->GetSelectKey().IsEmpty()) return FALSE; BOOL bOK = FALSE; int nLevel = 0; int nParent0type = 0; int nObjectType = 0; CString strParent0 = _T(""); CString strStaticParent = _T(""); CStringArray& arrayItemPath = pDoc->GetItemPath(); void* pStructParent = NULL; int narrayItemPathSize = arrayItemPath.GetSize(); ASSERT(narrayItemPathSize >= 1); if (narrayItemPathSize < 1) return FALSE; CString strObject = arrayItemPath.GetAt(0); // // Default (from old class CuIpmObjDesc in vdba): BOOL bObjectNeedsNameCheck = FALSE; BOOL bObjectHasStaticBranch= TRUE; BOOL bStaticParentNeedsNameCheck= FALSE; if (pDoc->GetSelectKey().CompareNoCase (_T("SERVER")) == 0) { // // Old class CuIpmObjDesc_SERVER in vdba (no overwrite the 3 default booleans above. nObjectType = OT_MON_SERVER; } else if (pDoc->GetSelectKey().CompareNoCase (_T("SESSION")) == 0) { // // Old class CuIpmObjDesc_SESSION in vdba (no overwrite the 3 default booleans above. nLevel = 1; // Parent is the SERVER. EX: ii\ingres\158 nParent0type = OT_MON_SERVER; nObjectType = OT_MON_SESSION; ASSERT(narrayItemPathSize >= 2); if (narrayItemPathSize < 2) return FALSE; strParent0 = arrayItemPath.GetAt(0); strObject = arrayItemPath.GetAt(1); } else if (pDoc->GetSelectKey().CompareNoCase (_T("REPLICSERVER")) == 0) { // // Old class CuIpmObjDesc_REPLICSERVER in vdba (overwrite the 2 default booleans above. bStaticParentNeedsNameCheck = TRUE; bObjectHasStaticBranch = FALSE; nLevel = 1; // Parent is the database name nParent0type = OT_DATABASE; nObjectType = OT_MON_REPLIC_SERVER; ASSERT(narrayItemPathSize >= 1); if (narrayItemPathSize < 1) return FALSE; strStaticParent = _T("Replication"); strParent0 = arrayItemPath.GetAt(0); if (narrayItemPathSize > 1) strObject = arrayItemPath.GetAt(1); } else if (pDoc->GetSelectKey().CompareNoCase (_T("LOGINFO")) == 0) { // // Old class CuIpmObjDesc_LOGINFO in vdba (overwrite the 1 default boolean above. bObjectNeedsNameCheck = TRUE; strObject.LoadString(IDS_TM_LOGINFO); // "Log information" } if (nLevel > 0) { ASSERT (nParent0type); ASSERT (!strParent0.IsEmpty()); // Static parent if (bStaticParentNeedsNameCheck) { // // Only for replication: listItemPath.AddTail(new CaTreeItemPath(TRUE, nParent0type, NULL, TRUE, strStaticParent)); } else { listItemPath.AddTail(new CaTreeItemPath(TRUE, nParent0type)); } int reqSize = IPM_StructSize(nParent0type); CPtrList listInfoStruct; IPMUPDATEPARAMS ups; memset (&ups, 0, sizeof(ups)); CaIpmQueryInfo queryInfo(pDoc, nParent0type, &ups, (LPVOID)NULL, reqSize); queryInfo.SetReportError(FALSE); bOK = IPM_QueryInfo (&queryInfo, listInfoStruct); if (bOK) { POSITION p = NULL, pos = listInfoStruct.GetHeadPosition(); while (pos != NULL) { p = pos; LPVOID pObject = listInfoStruct.GetNext(pos); if (MatchedStruct (nParent0type, strParent0, pObject)) { pStructParent = pObject; listInfoStruct.RemoveAt (p); listItemPath.AddTail(new CaTreeItemPath(FALSE, nParent0type, pObject)); // non-static break; } } while (!listInfoStruct.IsEmpty()) delete listInfoStruct.RemoveHead(); } if (!pStructParent) return FALSE; } // // Object itself: if (strObject.IsEmpty()) return bOK; if (bObjectNeedsNameCheck) { listItemPath.AddTail(new CaTreeItemPath(TRUE, nObjectType, NULL, TRUE, strObject)); // Root item bOK = TRUE; } else { if (bObjectHasStaticBranch) listItemPath.AddTail(new CaTreeItemPath(TRUE, nObjectType)); // static int reqSize = IPM_StructSize(nObjectType); CPtrList listInfoStruct; IPMUPDATEPARAMS ups; memset (&ups, 0, sizeof(ups)); ups.nType = nParent0type; ups.pStruct = pStructParent; ups.pSFilter= NULL; CaIpmQueryInfo queryInfo(pDoc, nObjectType, &ups, (LPVOID)NULL, reqSize); queryInfo.SetReportError(FALSE); BOOL bHasObjects = IPM_QueryInfo (&queryInfo, listInfoStruct); if (bHasObjects) { #if !defined (_IGNORE_NOT_MATCHED_ITEM) bOK = FALSE; #endif POSITION p = NULL, pos = listInfoStruct.GetHeadPosition(); while (pos != NULL) { p = pos; LPVOID pObject = listInfoStruct.GetNext(pos); if (MatchedStruct (nObjectType, strObject, pObject)) { bOK = TRUE; listInfoStruct.RemoveAt (p); listItemPath.AddTail(new CaTreeItemPath(FALSE, nObjectType, pObject)); // non-static break; } } while (!listInfoStruct.IsEmpty()) delete listInfoStruct.RemoveHead(); } } return bOK; }