Пример #1
0
bool
CPing::Start( const CORE::CString& remoteHost           ,
              const Int32 maxPings /* = 0 */            ,
              const UInt32 bytesToSend /* = 32 */       ,
              const UInt32 timeout /* = 1000 */         ,
              const UInt32 minimalPingDelta /* = 500 */ )
{GUCEF_TRACE;

    TStringVector hostList;
    hostList.push_back( remoteHost );
    return Start( hostList         ,
                  maxPings         ,
                  bytesToSend      ,
                  timeout          ,
                  minimalPingDelta );
}
bool
CComboboxImp::GetListItems( TStringVector& items ) const
{GUCE_TRACE;

    if ( NULL != m_combobox )
    {
        CEGUI::ListboxItem* item = NULL;
        size_t itemCount = m_combobox->getItemCount();
        for ( size_t i=0; i<itemCount; ++i )
        {
            item = m_combobox->getListboxItemFromIndex( i );
            items.push_back( item->getText().c_str() );
        }
        return true;
    }
    return false;
}
Пример #3
0
void CAppWindow::TruncateLastReported()
{
	ASSERT(m_lpView != NULL);

	const TWaveMap & vReported = m_lpReportedView->GetWaves();
	const TWaveMap & vCurrent = m_lpView->GetWaves()->GetWaves();
	TStringVector vRemove;

	for (TWaveMapConstIter iter = vReported.begin(); iter != vReported.end(); iter++)
	{
		if (vCurrent.find(iter->first) == vCurrent.end())
		{
			vRemove.push_back(iter->first);
		}
	}

	m_lpReportedView->RemoveWaves(vRemove);
}
Пример #4
0
void CommManager::ListAvailableClient( TStringVector& clientidList, DWORD dwDiffS /*= 60 * 5*/ )
{
	__time64_t now;
	_time64(&now);

	m_mapSection.Enter();
	{
		HeartbeatMap::iterator iter = m_heartbeatMap.begin();
		for (; iter != m_heartbeatMap.end(); iter++)
		{
			__time64_t lastHeartbeat = iter->second.time;
			if (now >= lastHeartbeat && now - lastHeartbeat < dwDiffS)
			{
				clientidList.push_back(iter->first);
			}
		}
	}
	m_mapSection.Leave();
}
Пример #5
0
CDataNode::TStringVector
CDataNode::GetChildrenValuesByName( const CString& name ) const
{
    TStringVector results;
    
    TConstDataNodeSet childNodes = FindChildrenOfType( name, false );
    TConstDataNodeSet::iterator i = childNodes.begin();
    while ( i != childNodes.end() )
    {
        const CString& childValue = (*i)->GetValue();
        if ( !childValue.IsNULLOrEmpty() )
        {
            results.push_back( childValue );
        }
        ++i;
    }

    return results;
}
Пример #6
0
void splitByChar(LPCTSTR str, TStringVector& parts, TCHAR sepChar)
{
	if (NULL == str) return;

	tstring temp = str;
	temp += sepChar;

	tstring::size_type begin = 0;
	tstring::size_type pos = temp.find(sepChar);

	while (pos != tstring::npos)
	{
		tstring part;
		if (pos > begin)
		{
			part = temp.substr(begin, pos - begin);
		}

		parts.push_back(part);

		begin = pos + 1;
		pos = temp.find(sepChar, begin);
	}
}
Пример #7
0
HRESULT CTsTeleportShellExt::GetFileNames(
    IDataObject *pDataObj,
    TStringVector& vFileNames)
{
    HRESULT hr;

    //
    // init for cleanup
    //

    STGMEDIUM mdm;
    mdm.pUnkForRelease = NULL;
    mdm.hGlobal = NULL;

    HDROP hdrop = NULL;

    STRRET strret;
    strret.pOleStr = NULL;

    LPTSTR szFileName = NULL;

    try
    {
        FORMATETC fmt = { CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };

        hr = pDataObj->GetData(&fmt, &mdm);
        LEAVE_IF_FAILED("pDataObj->GetData failed");

        hdrop = (HDROP) GlobalLock(mdm.hGlobal);

        if (!hdrop)
        {
            hr = HRESULT_FROM_WIN32(GetLastError());
        }
        LEAVE_IF_FAILED("GetFileNames failed");

        UINT nFiles = DragQueryFile(hdrop, (UINT)-1, NULL, 0);

        for(UINT nNames = 0; nNames < nFiles; nNames++)
        {
            UINT   cchFileName = DragQueryFile(hdrop, 
                nNames, 
                NULL,
                0);

            ASSERT(cchFileName);

            szFileName = new TCHAR[cchFileName+1]; 

            ASSERT(szFileName); // using C++ throwing new 

            UINT tmp = DragQueryFile(hdrop, 
                nNames, 
                szFileName,
                cchFileName+1);

            DBG_UNREFERENCED_LOCAL_VARIABLE(tmp); // for fre builds

            ASSERT(tmp == cchFileName);
            ASSERT(szFileName[cchFileName] == '\0');

            TString strFileName(szFileName);

            vFileNames.push_back(strFileName);
            
            delete [] szFileName;
            szFileName = NULL;
        }
    }
    catch (std::bad_alloc&)
    {
        hr = E_OUTOFMEMORY;
    }
    catch (std::exception&)
    {
        hr = E_UNEXPECTED;
    }

_Function_Exit:

    //
    // Cleanup
    // 

    if (hdrop)
    {
        GlobalUnlock(hdrop);
    }

    if (mdm.hGlobal)
    {
        ReleaseStgMedium(&mdm);
    }

    if (strret.pOleStr)
    {
        CoTaskMemFree(strret.pOleStr);
    }

    if (szFileName)
    {
        delete [] szFileName;
    }

    return hr;
}
Пример #8
0
void DecodeCSVString( TStringVector &strings, const TString& astring, char adelimiter )
{
  TString str;
  str.SetLength( astring.Length() );

  strings.clear();

  if( astring.Length()==0 )
    return;

  enum { normal, parenthesis } state;
  state = normal;

  const char *beg = astring.c_str();
  const char *c = beg;
  char *destbeg = str.c_str();
  char *dest = destbeg;

  while( *c )
  {
    switch( state )
    {
      case normal:
        switch( *c )
        {
          case '"':
            state = parenthesis;
            c++;
            break;
          default:
            if( *c == adelimiter )
            {
              strings.push_back( TString( destbeg, dest-destbeg ) );
              dest = destbeg;
            }
            else {
              *dest = *c;
              dest++;
            }
            c++;
        }
        break;
      case parenthesis:
        if( *c == '"' )
        {
          c++;
          state = normal;
        }
        else {
          *dest = *c;
          c++;
          dest++;
        }
        break;
      default:
        strings.clear();
/* TODO : Nen� upln� jasn�, zda v p��pad� failu smazat to, co se dosud ud�lalo... */
        throw TException( "Unknown error in DecodeCSVString." );
    }
  }
  strings.push_back( TString( destbeg, dest-destbeg ) );

  unsigned int nstrings = strings.size();
  unsigned int ui;
  for( ui=0; ui<nstrings; ui++ )
    ReplaceHexFormWithOrdinals( strings[ui] );
}
Пример #9
0
void CAppWindow::SynchronisePopups(CUnreadWaveCollection * lpUnreads, BOOL fManual)
{
	ASSERT(lpUnreads != NULL);

	BOOL fQueuedNewWaves = FALSE;
	TPopupVector vMustCancel;
	TStringVector vSeen;

	if (CPopupWindow::Instance() != NULL)
	{
		TPopupVector vPopups;
		
		CPopupWindow::Instance()->GetPopups(vPopups);

		for (TPopupVectorIter iter = vPopups.begin(); iter != vPopups.end(); iter++)
		{
			if (((CPopupBase *)(*iter))->GetType() == PT_WAVE)
			{
				CUnreadWavePopup * lpPopup = (CUnreadWavePopup *)*iter;
				wstring szPopupWaveId = lpPopup->GetUnread()->GetID();
				CUnreadWave * lpNewUnreadWave = lpUnreads->GetChange(szPopupWaveId);

				if (lpNewUnreadWave == NULL)
				{
					// Cancel the popup if it isn't changed anymore.

					vMustCancel.push_back(lpPopup);
				}
				else
				{
					// Else, update with the current changed status.

					lpPopup->UpdateUnread(lpNewUnreadWave);

					vSeen.push_back(szPopupWaveId);
				}
			}
		}
	}

	// Cancel all popups.

	for (TPopupVectorIter iter = vMustCancel.begin(); iter != vMustCancel.end(); iter++)
	{
		CPopup * lpPopup = *iter;

		if (!lpPopup->IsDisplaying())
		{
			lpPopup->Cancel();
		}
	}

	// Add all new popups.

	TUnreadWaveVector vUnreads = lpUnreads->GetChanges();

	// Waves can only be reported if has been reported within the
	// timeout period.

	CDateTime dtRereportLimit(CDateTime::Now() - CTimeSpan::FromMilliseconds((DOUBLE)TIMER_REREPORT_TIMEOUT));

	for (TUnreadWaveVectorIter iter1 = vUnreads.begin(); iter1 != vUnreads.end(); iter1++)
	{
		// If we haven't seen this before ...

		wstring szId((*iter1)->GetID());

		if (find(vSeen.begin(), vSeen.end(), szId) == vSeen.end())
		{
			// ... create a new popup

			TStringDateTimeMapIter pos = m_vReportedTimes.find(szId);

			// Verify whether this popup hasn't been reported for
			// the required time.

			if (pos == m_vReportedTimes.end() || pos->second < dtRereportLimit)
			{
				CUnreadWavePopup * lpPopup = new CUnreadWavePopup(*iter1);

				lpPopup->Show();

				if (pos != m_vReportedTimes.end())
				{
					m_vReportedTimes.erase(pos);
				}

				// We've queued a new popup, so make a noise.

				fQueuedNewWaves = TRUE;
			}
			else
			{
				// Silence the wave by reporting it as reported.

				HaveReportedWave(szId);

				// Delete the unread wave because we're going
				// to detach everything lateron.

				delete *iter1;
			}
		}
	}

	// Detach all unread objects because the popups have taken
	// them over

	lpUnreads->DetachAll();

	// Re-index the popups to correctly display the index and count number
	// shown of the popups.

	if (CPopupWindow::Instance() != NULL)
	{
		TPopupVector vPopups;
		
		CPopupWindow::Instance()->GetPopups(vPopups);

		UINT uCount = 0;

		for (TPopupVectorIter iter = vPopups.begin(); iter != vPopups.end(); iter++)
		{
			if (((CPopupBase *)(*iter))->GetType() == PT_WAVE)
			{
				uCount++;
			}
		}

		UINT uIndex = 1;

		for (TPopupVectorIter iter1 = vPopups.begin(); iter1 != vPopups.end(); iter1++)
		{
			if (((CPopupBase *)(*iter1))->GetType() == PT_WAVE)
			{
				CUnreadWavePopup * lpPopup = (CUnreadWavePopup *)*iter1;

				lpPopup->SetCountIndex(uIndex, uCount);

				uIndex++;
			}
		}
	}

	if (fManual)
	{
		// When the check was queued manually, we will report it when
		// there were no unread waves to report.

		if (!fQueuedNewWaves)
		{
			(new CMessagePopup(L"No unread Waves."))->Show();
		}
	}
	else
	{
		// When the check was not done manually, we will play a sound
		// when there were unread waves to report.

		if (fQueuedNewWaves && CNotifierApp::Instance()->GetPlaySoundOnNewWave())
		{
			PlaySound(
				MAKEINTRESOURCE(IDR_NEWWAVE),
				CNotifierApp::Instance()->GetInstance(),
				SND_ASYNC | SND_NOSTOP | SND_NOWAIT | SND_RESOURCE);
		}
	}
}