bool CDittoCopyBuffer::PastCopyBuffer(long lCopyBuffer)
{
	//Can't paste while another is still active
	if(WaitForSingleObject(m_Pasting, 1) == WAIT_TIMEOUT)
	{
		Log(_T("Copy Buffer pasted to fast"));
		return false;
	}

	m_RestoreTimer.ResetEvent();
	m_Pasting.ResetEvent();
	bool bRet = false;

	Log(StrF(_T("Start - PastCopyBuffer buffer = %d"), m_lCurrentDittoBuffer));

	try
	{
		CppSQLite3Query q = theApp.m_db.execQueryEx(_T("SELECT Main.lID FROM Main ")
													_T("INNER JOIN CopyBuffers ON CopyBuffers.lClipID = Main.lID ")
													_T("WHERE CopyBuffers.lCopyBuffer = %d"), lCopyBuffer);

		if(q.eof() == false)
		{
			m_pClipboard = new CClipboardSaveRestoreCopyBuffer;
			if(m_pClipboard)
			{
				//Save the clipboard, 
				//then put the new data on the clipboard
				//then send a paste
				//then wait a little and restore the original clipboard data
				if(m_pClipboard->Save())
				{
					CProcessPaste paste;
					paste.m_bSendPaste = true;
					paste.m_bActivateTarget = false;
					paste.GetClipIDs().Add(q.getIntField(_T("lID")));
					paste.DoPaste();

					m_pClipboard->m_lRestoreDelay = g_Opt.GetDittoRestoreClipboardDelay();

					Log(StrF(_T("PastCopyBuffer sent paste, starting thread to restore clipboard, Delay = %d"), m_pClipboard->m_lRestoreDelay));

					AfxBeginThread(CDittoCopyBuffer::DelayRestoreClipboard, (LPVOID)this, THREAD_PRIORITY_LOWEST);

					bRet = true;
				}
				else
				{
					Log(_T("PastCopyBuffer failed to save clipboard"));
				}
			}
		}
	}
	CATCH_SQLITE_EXCEPTION

	if(bRet == false)
		m_Pasting.SetEvent();

	return bRet;
}
//---------------------------------------------------------------
// bind window data and DB data
//---------------------------------------------------------------
void Input_PTranDialog::BindData_Periodical(DB_periodical &db)
{
	dbperiod = db;
	DB_day tmpdbday = dbperiod.GetBudget();
	wxString label;
	DB_expense expense = wxGetApp().AppDB.GetExpense(tmpdbday.GetExpense(),tmpdbday.GetIO());
	DB_items items = wxGetApp().AppDB.GetItems(tmpdbday.GetItems(),tmpdbday.GetExpense());
	DB_account hand = wxGetApp().AppDB.GetAccount(tmpdbday.GetHandling());
	if (tmpdbday.GetIO() == in_it) {
		label.Append(StrF(_("Income: %d\n"),tmpdbday.GetIncome()));
	}else if (tmpdbday.GetIO() == out_it) {
		label.Append(StrF(_("Expenditure: %d\n"),tmpdbday.GetExpenditure()));
	}
	label.Append(StrF(_T("%s(%s)\n"),expense.GetName().c_str(),items.GetName().c_str()));
	label.Append(StrF(_T("%s\n"),hand.GetName().c_str()));
	label.Append(tmpdbday.GetMemo());
	ipt_InputedBaseInfoLabel->SetLabel(label);

	ipt_PeriodicalTiming->SetSelection(dbperiod.GetTiming());
	wxCommandEvent evt;
	ipt_PeriodicalTiming_selected(evt);
	ipt_TimingDay->SetValue(dbperiod.GetTimingDay());
	ipt_SetAfterInputValue->SetValue(dbperiod.GetInputValue());
	ipt_SetAfterInputMemo->SetValue(dbperiod.GetInputMemo());
	ipt_CaseHolidayTiming->SetSelection(dbperiod.GetHoliday());

	ipt_PeriodicalTiming_selected(evt);
}
void CQListCtrl::OnSelectionChange(NMHDR* pNMHDR, LRESULT* pResult)
{
	NMLISTVIEW *pnmv = (NMLISTVIEW *) pNMHDR;

	if((pnmv->uNewState == 3) ||
		(pnmv->uNewState == 1))
	{
		if(g_Opt.m_bAllwaysShowDescription)
		{
			KillTimer(TIMER_SHOW_PROPERTIES);
			SetTimer(TIMER_SHOW_PROPERTIES, 300, NULL);
		}
		if(GetSelectedCount() > 0 )
			theApp.SetStatus(NULL, FALSE);
	}

	if(GetSelectedCount() == this->GetItemCount())
	{
		if(m_allSelected == false)
		{
			Log(StrF(_T("List box Select All")));

			GetParent()->SendMessage(NM_ALL_SELECTED, 0, 0);
			m_allSelected = true;
		}
	}
	else if(m_allSelected == true)
	{
		Log(StrF(_T("List box REMOVED Select All")));
		m_allSelected = false;
	}
}
LRESULT CMainFrame::OnLoadClipOnClipboard(WPARAM wParam, LPARAM lParam)
{
	CClip *pClip = (CClip*)wParam;
    if(pClip == NULL)
    {
        LogSendRecieveInfo("---------ERROR OnLoadClipOnClipboard pClip == NULL");
        return FALSE;
    }

    if(pClip)
    {
		CProcessPaste paste;
		paste.m_bSendPaste = false;
		paste.m_bActivateTarget = false;

		LogSendRecieveInfo("---------OnLoadClipOnClipboard - Before PutFormats on clipboard");

		paste.m_pOle->PutFormatOnClipboard(&pClip->m_Formats);
		paste.m_pOle->CacheGlobalData(theApp.m_cfIgnoreClipboard, NewGlobalP("Ignore", sizeof("Ignore")));

		LogSendRecieveInfo("---------OnLoadClipOnClipboard - After PutFormats on clipboard");

		LogSendRecieveInfo(StrF(_T("---------OnLoadClipOnClipboard - Setting clip id: %d on ole clipboard"), pClip->m_id));
		paste.GetClipIDs().Add(pClip->m_id);
		paste.DoPaste();

		LogSendRecieveInfo(StrF(_T("---------OnLoadClipOnClipboard - After paste clip id: %d on ole clipboard"), pClip->m_id));
	}

	delete pClip;

	return TRUE;
}
void CQPasteWndThread::OnEvent(int eventId, void *param)
{
	DWORD startTick = GetTickCount();
	Log(StrF(_T("Start of OnEvent, eventId: %s"), EnumName((eCQPasteWndThreadEvents)eventId)));

    switch((eCQPasteWndThreadEvents)eventId)
    {
        case DO_SET_LIST_COUNT:
            OnSetListCount(param);
            break;
        case LOAD_ACCELERATORS:
            OnLoadAccelerators(param);
            break;
        case UNLOAD_ACCELERATORS:
            OnUnloadAccelerators(param);
            break;
        case LOAD_ITEMS:
            OnLoadItems(param);
            break;
        case LOAD_EXTRA_DATA:
            OnLoadExtraData(param);
            break;
    }

	DWORD length = GetTickCount() - startTick;
	Log(StrF(_T("End of OnEvent, eventId: %s, Time: %d(ms)"), EnumName((eCQPasteWndThreadEvents)eventId), length));
}
Exemple #6
0
BOOL CClient::SendClipFormat(CClipFormat* pCF)
{
	CSendInfo Info;
	LPVOID pvData = GlobalLock(pCF->m_hgData);
	INT_PTR length = GlobalSize(pCF->m_hgData);
	UCHAR* pOutput = NULL;
	int nLenOutput = 0;
	CTextConvert Convert;
	BOOL bRet = FALSE;

	LogSendRecieveInfo(StrF(_T("BEFORE Encrypt clip data %d"), length));

	if(m_SendSocket.m_pEncryptor)
	{
		if(m_SendSocket.m_pEncryptor->Encrypt((UCHAR*)pvData, (int)length, g_Opt.m_csPassword, pOutput, nLenOutput))
		{
			LogSendRecieveInfo(StrF(_T("AFTER Encrypt clip data %d"), nLenOutput));

			Info.m_lParameter1 = nLenOutput;

			//Send over as UTF-8
			CStringA dest;
			if(CTextConvert::ConvertToUTF8(GetFormatName(pCF->m_cfType), dest))
			{
				strncpy(Info.m_cDesc, dest, sizeof(Info.m_cDesc));
				Info.m_cDesc[sizeof(Info.m_cDesc)-1] = 0;
			}

			if(m_SendSocket.SendCSendData(Info, MyEnums::DATA_START) == FALSE)
				return FALSE;

			m_SendSocket.SendExactSize((char*)pOutput, nLenOutput, false);

			m_SendSocket.m_pEncryptor->FreeBuffer(pOutput);

			bRet = TRUE;
		}
		else
		{
			LogSendRecieveInfo("Failed to encrypt data");
			return FALSE;
		}
	}
	else
	{
		ASSERT(!"SendItem::Encryption not initialized");
		LogSendRecieveInfo("SendItem::Encryption not initialized");	
	}

	GlobalUnlock(pCF->m_hgData);
	
	if(m_SendSocket.SendCSendData(Info, MyEnums::DATA_END) == FALSE)
		return FALSE;

	return bRet;
}
CUAC_Thread::CUAC_Thread(int processId)
{
	m_processId = processId;

	AddEvent(UAC_PASTE, StrF(_T("Global\\UAC_PASTE_%d"), m_processId));
	AddEvent(UAC_COPY, StrF(_T("Global\\UAC_COPY_%d"), m_processId));
	AddEvent(UAC_CUT, StrF(_T("Global\\UAC_CUT_%d"), m_processId));

	AddEvent(UAC_EXIT, StrF(_T("Global\\UAC_EXIT_%d"), m_processId));

	m_waitTimeout = 30000;
}
bool CDittoCopyBuffer::StartCopy(long lCopyBuffer, bool bCut)
{
	Log(StrF(_T("Start of Ditto Copy buffer = %d"), lCopyBuffer));

	//Tell the timer thread to exit
	m_ActiveTimer.SetEvent();
	//Make sure the end copy thread has exited
	EndRestoreThread();

	if(m_SavedClipboard.Save(FALSE))
	{
		if(bCut)
		{
			theApp.m_activeWnd.SendCut();
		}
		else
		{
			theApp.m_activeWnd.SendCopy(CopyReasonEnum::COPY_TO_BUFFER);
		}

		//Create a thread to track if they have copied anything, if thread has exited before they have
		//copied something then the copy buffer copy is canceled
		AfxBeginThread(CDittoCopyBuffer::StartCopyTimer, (LPVOID)this, THREAD_PRIORITY_LOWEST);

		m_bActive = true;
		m_lCurrentDittoBuffer = lCopyBuffer;
	}
	else
	{
		Log(_T("Start of Ditto Failed to save buffer"));
	}

	return true;
}
void CQPasteWndThread::OnSetListCount(void *param)
{
    CQPasteWnd *pasteWnd = (CQPasteWnd*)param;

    static CEvent UpdateTimeEvent(TRUE, TRUE, _T("Ditto_Update_Clip_Time"), NULL);
    //If we pasted then wait for the time on the pasted event to be updated before we query the db
    DWORD dRet = WaitForSingleObject(UpdateTimeEvent, 2000);

    ResetEvent(m_SearchingEvent);
    long lTick = GetTickCount();

	CString CountSQL;
	{
		ATL::CCritSecLock csLock(pasteWnd->m_CritSection.m_sect);
	    CountSQL = pasteWnd->m_CountSQL;
	}

    long lRecordCount = 0;

    try
    {
        lRecordCount = theApp.m_db.execScalar(CountSQL);
        ::PostMessage(pasteWnd->m_hWnd, NM_SET_LIST_COUNT, lRecordCount, 0);
    }
    CATCH_SQLITE_EXCEPTION 

    SetEvent(m_SearchingEvent);

    Log(StrF(_T("Set list count = %d, time = %d"), lRecordCount, GetTickCount() - lTick));
}
void CUAC_Thread::OnTimeOut(void *param)
{
	bool close = false;
	DWORD exitCode = 0;

	HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, m_processId);
	if(hProcess == NULL)
	{
		close = true;
	}
	else
	{
		if(GetExitCodeProcess(hProcess, &exitCode) == 0)
		{
			close = true;
		}
		else if(exitCode != STILL_ACTIVE)
		{
			close = true;
		}
	}

	if(close)
	{
		Log(StrF(_T("Found parent process id (%d) is not running, Exit Code %d closing uac aware app"), m_processId, exitCode));
		this->CancelThread();
	}

	CloseHandle(hProcess);
}
Exemple #11
0
void CMainFrmThread::OnSaveClips()
{
	CClipList *pLocalClips = new CClipList();

	//Save the clips locally
	{
		ATL::CCritSecLock csLock(m_cs.m_sect);

		POSITION pos;
		CClip* pClip;

		pos = m_saveClips.GetHeadPosition();
		while(pos)
		{
			pClip = m_saveClips.GetNext(pos);
			pLocalClips->AddTail(pClip);
		}

		//pLocalClips now own, the clips
		m_saveClips.RemoveAll();
	}

	Log(_T("SaveCopyClips Before AddToDb")); 

	int count = pLocalClips->AddToDB(true);

	Log(StrF(_T("SaveCopyclips After AddToDb, Count: %d"), count));

	if(count > 0)
	{
		int Id = pLocalClips->GetTail()->m_id;

		Log(StrF(_T("SaveCopyclips After AddToDb, Id: %d Before OnCopyCopyCompleted"), Id));

		theApp.OnCopyCompleted(Id, count);

		Log(StrF(_T("SaveCopyclips After AddToDb, Id: %d After OnCopyCopyCompleted"), Id));
	
		if(g_Opt.m_lAutoSendClientCount > 0)
		{
			m_sendToClientThread.FireSendToClient(pLocalClips);
		}
	}

	delete pLocalClips;
}
//---------------------------------------------------------------
// pt_ModPeriodic button event
//---------------------------------------------------------------
void PeriodicalTranDialog::pt_ModPeriodic_clicked(wxCommandEvent &event)
{
	if (dbperiod.GetCount() == 0) {
		wxMessageBox(_("Periodical transaction not found."),APPTITLE,wxOK|wxICON_EXCLAMATION,this);
		return;
	}
	ipt_dialog->BindData_Periodical(dbperiod.Item(listselect));
	ipt_dialog->CenterOnParent();
	if (ipt_dialog->ShowModal() == input_ptran_ok) {
		dbperiod.Item(listselect) = ipt_dialog->GetData_Periodical();
		dbperiod.Item(listselect).SetFlag(mod_mt);
		//for Control
		wxString arr[5];
		//---set timing
		if (dbperiod.Item(listselect).GetTiming() < 2) {
			arr[0] = GetTimingString(dbperiod.Item(listselect).GetTiming()) +
				StrF(_T(": %d %s"),dbperiod.Item(listselect).GetTimingDay(),_("-th day"));
		}else{
			arr[0] = GetTimingString(dbperiod.Item(listselect).GetTiming());
		}
		//---set account
		arr[1] = wxGetApp().AppDB.GetAccount(dbperiod.Item(listselect).GetBudget().GetHandling()).GetName();
		//---set expense and item of expense
		wxString sql = StrF(_T("select ex_name, it_name from db_expense, db_items where ex_id = %d and it_id = %d and ex_id = it_expense;"),
			dbperiod.Item(listselect).GetBudget().GetExpense(),dbperiod.Item(listselect).GetBudget().GetItems());
		wxSQLite3ResultSet rset = wxGetApp().SQLDB().ExecuteQuery(sql);
		while (rset.NextRow()) {
			arr[2] = rset.GetString(0) + _T(", ") +
				rset.GetString(1);
		}
		//---set income or expenditure
		if (dbperiod.Item(listselect).GetBudget().GetIncome() > 0) {
			arr[3] = IntToStr(dbperiod.Item(listselect).GetBudget().GetIncome());
		}else if (dbperiod.Item(listselect).GetBudget().GetExpenditure() > 0) {
			arr[3] = IntToStr(dbperiod.Item(listselect).GetBudget().GetExpenditure());
		}else{
			arr[3] = _T("0");
		}
		//---set memo
		arr[4] = dbperiod.Item(listselect).GetBudget().GetMemo();

		ChangeRow(pt_PeriodicalList,listselect,arr,5);
	}

}
//---------------------------------------------------------------
// pt_InputBaseInfo button event
//---------------------------------------------------------------
void Input_PTranDialog::ipt_InputBaseInfo_clicked(wxCommandEvent &event)
{
	de_dialog->bindData_InputDate(wxDateTime::UNow());
	//if (isinputbase) {
		de_dialog->SetAccount(-1);
		de_dialog->bindData_ExistData(tmpdbday);
	/*}else{
		de_dialog->SetExpense(in_it);
		de_dialog->SetItems(0);
		de_dialog->SetAccount(-1);
		de_dialog->ChangeEnable(-1,true);
		de_dialog->ClearControl();
	}*/
	isinputbase = false;
	de_dialog->CenterOnParent();
	if (de_dialog->ShowModal() == detaile_ok) {
		isinputbase = true;

		tmpdbday.SetDate(de_dialog->GetDataDate());
		tmpdbday.SetId(-1);
		tmpdbday.SetIO((InoutType)de_dialog->GetDataIncome());
		tmpdbday.SetExpense(de_dialog->GetDataExpense());
		tmpdbday.SetItems(de_dialog->GetDataItems());
		tmpdbday.SetHandling(de_dialog->GetDataHandling());
		if (de_dialog->GetDataIncome() == 0) {
			tmpdbday.SetIncome(de_dialog->GetDataValue());
			tmpdbday.SetExpenditure(0);
		}else{
			tmpdbday.SetIncome(0);
			tmpdbday.SetExpenditure(de_dialog->GetDataValue());
		}
		tmpdbday.SetMemo(de_dialog->GetDataMemo());
		wxString label;
		if (tmpdbday.GetIO() == in_it) {
			label.Append(StrF(_("Income: %d\n"),de_dialog->GetDataValue()));
		}else if (tmpdbday.GetIO() == out_it) {
			label.Append(StrF(_("Expenditure: %d\n"),de_dialog->GetDataValue()));
		}
		label.Append(StrF(_T("%s(%s)\n"),de_dialog->GetDataExpenseString().c_str(),de_dialog->GetDataItemsString().c_str()));
		label.Append(StrF(_T("%s\n"),de_dialog->GetDataHandlingString().c_str()));
		label.Append(tmpdbday.GetMemo());
		ipt_InputedBaseInfoLabel->SetLabel(label);
		//dbperiod.SetBudget(db);
	}
}
EXPORT_C
THTTPHdrVal THTTPHdrVal::Copy() const
	{
	THTTPHdrVal ret = *this;
	if (iType == KStrVal)
		Str().Copy();
	if (iType == KStrFVal)
		StrF().Copy();
	return ret;
	}
INT_PTR COleClipSource::PutFormatOnClipboard(CClipFormats *pFormats)
{
	Log(_T("Start of put format on clipboard"));

	CClipFormat* pCF;
	INT_PTR	count = pFormats->GetSize();
	bool bDelayedRenderCF_HDROP = false;
	INT_PTR i = 0;

	//see if the html format is in the list
	//if it is the list we will not paste CF_TEXT
	for(i = 0; i < count; i++)
	{
		pCF = &pFormats->ElementAt(i);

		if(pCF->m_cfType == theApp.m_RemoteCF_HDROP)
		{
			bDelayedRenderCF_HDROP = true;
		}
	}

	for(i = 0; i < count; i++)
	{
		pCF = &pFormats->ElementAt(i);

		if(bDelayedRenderCF_HDROP)
		{
			if(pCF->m_cfType == CF_HDROP)
			{
				LogSendRecieveInfo("Added delayed cf_hdrop to clipboard");
				DelayRenderData(pCF->m_cfType);
			}

			continue;
		}

		wchar_t * stringData = (wchar_t *) GlobalLock(pCF->m_hgData);
		int size = (int) GlobalSize(pCF->m_hgData);
		CString cs(stringData);
		GlobalUnlock(pCF->m_hgData);
		
		Log(StrF(_T("Setting clipboard type: %s to the clipboard"), GetFormatName(pCF->m_cfType)));

		CacheGlobalData(pCF->m_cfType, pCF->m_hgData);
		pCF->m_hgData = 0; // OLE owns it now
	}

	pFormats->RemoveAll();

	m_bLoadedFormats = true;

	Log(_T("End of put format on clipboard"));

	return count;
}  
//---------------------------------------------------------------
// pt_AddPeriodic button event
//---------------------------------------------------------------
void PeriodicalTranDialog::pt_AddPeriodic_clicked(wxCommandEvent &event)
{
	ipt_dialog->ClearControl();
	ipt_dialog->CenterOnParent();
	if (ipt_dialog->ShowModal() == input_ptran_ok) {
		DB_periodical newrow = ipt_dialog->GetData_Periodical();
		newrow.SetFlag(add_mt);
		dbperiod.Add(newrow);
		//for Control
		wxString arr[5];
		//---set timing
		if (newrow.GetTiming() < 2) {
			arr[0] = GetTimingString(newrow.GetTiming()) +
				StrF(_T(": %d %s"),newrow.GetTimingDay(),_("-th day"));
		}else{
			arr[0] = GetTimingString(newrow.GetTiming());
		}
		//---set account
		arr[1] = wxGetApp().AppDB.GetAccount(newrow.GetBudget().GetHandling()).GetName();
		//---set expense and item of expense
		wxString sql = StrF(WXSQL_GET_EXPENSE_AND_ITEM,
			newrow.GetBudget().GetExpense(),newrow.GetBudget().GetItems());
		wxSQLite3ResultSet rset = wxGetApp().SQLDB().ExecuteQuery(sql);
		while (rset.NextRow()) {
			arr[2] = rset.GetString(0) + _T(", ") +
				rset.GetString(1);
		}
		//---set income or expenditure
		if (newrow.GetBudget().GetIncome() > 0) {
			arr[3] = IntToStr(newrow.GetBudget().GetIncome());
		}else if (newrow.GetBudget().GetExpenditure() > 0) {
			arr[3] = IntToStr(newrow.GetBudget().GetExpenditure());
		}else{
			arr[3] = _T("0");
		}
		//---set memo
		arr[4] = newrow.GetBudget().GetMemo();

		InsertRow(pt_PeriodicalList,arr,5);

	}
}
//---------------------------------------------------------------
// bind window data and DB data
//---------------------------------------------------------------
void PeriodicalTranDialog::BindData_Periodical(DBL_periodical &db)
{
	wxString timing_items[] = {
		_("Indicated ordered day of week"),_("Indicated ordered day of month"),
		_("last day of month")
	};
	dbperiod = db;
	//insert DB data in listctrl
	pt_PeriodicalList->DeleteAllItems();
	for (int i = 0; i < (int)dbperiod.GetCount(); i++) {
		if (dbperiod.Item(i).GetTiming() == 3) continue;
		wxString arr[5];
		//---set timing
		if (dbperiod.Item(i).GetTiming() < 2) {
			arr[0] = GetTimingString(dbperiod.Item(i).GetTiming()) +
				StrF(_T(": %d %s"),dbperiod.Item(i).GetTimingDay(),_("-th day"));
		}else{
			arr[0] = timing_items[dbperiod.Item(i).GetTiming()];
		}
		//---set account
		arr[1] = wxGetApp().AppDB.GetAccount(dbperiod.Item(i).GetBudget().GetHandling()).GetName();
		//---set expense and item of expense
		wxString sql = StrF(_T("select ex_name, it_name from db_expense, db_items where ex_id = %d and it_id = %d and ex_id = it_expense;"),
			dbperiod.Item(i).GetBudget().GetExpense(),dbperiod.Item(i).GetBudget().GetItems());
		wxSQLite3ResultSet rset = wxGetApp().SQLDB().ExecuteQuery(sql);
		while (rset.NextRow()) {
			arr[2] = rset.GetString(0) + _T(", ") +
				rset.GetString(1);
		}
		//---set income or expenditure
		if (dbperiod.Item(i).GetBudget().GetIncome() > 0) {
			arr[3] = IntToStr(dbperiod.Item(i).GetBudget().GetIncome());
		}else if (dbperiod.Item(i).GetBudget().GetExpenditure() > 0) {
			arr[3] = IntToStr(dbperiod.Item(i).GetBudget().GetExpenditure());
		}else{
			arr[3] = _T("0");
		}
		//---set memo
		arr[4] = dbperiod.Item(i).GetBudget().GetMemo();
		InsertRow(pt_PeriodicalList,arr,5);
	}
}
void CEventThread::Stop(int waitTime) 
{
	Log(StrF(_T("Start of CEventThread::Stop(int waitTime) %d - Name: %s"), waitTime, m_threadName));

	if(m_threadRunning)
	{
		m_exitThread = true;	
		FireEvent(EXIT_EVENT);

		if(waitTime > 0)
		{
			if (WAIT_OBJECT_0 != WaitForSingleObject(m_hEvt, waitTime))
			{
				Log(_T("Start of TerminateThread CEventThread::Stop(int waitTime) "));
				TerminateThread(m_thread, 0);
				Log(_T("End of TerminateThread CEventThread::Stop(int waitTime) "));
				m_threadRunning = false;
			}
		}
	}

	Log(StrF(_T("End of CEventThread::Stop(int waitTime) %d - Name: %s"), waitTime, m_threadName));
};
bool CDittoCopyBuffer::EndCopy(long lID)
{
	if(m_lCurrentDittoBuffer < 0 || m_lCurrentDittoBuffer >= 10)
	{
		Log(_T("tried to save copy buffer but copy buffer is empty"));
		return false;
	}

	if(m_bActive == false)
	{
		Log(_T("Current buffer is not active can't save copy buffer to db"));
		return false;
	}

	m_ActiveTimer.SetEvent();
	m_bActive = false;

	Log(StrF(_T("Start - Ditto EndCopy buffer = %d"), m_lCurrentDittoBuffer));

	bool bRet = false;

	//put the data that we stored at the start of this action back on the standard clipboard
	m_SavedClipboard.Restore();
	
	if(PutClipOnDittoCopyBuffer(lID, m_lCurrentDittoBuffer))
	{
		Log(StrF(_T("Ditto end copy, saved clip successfully Clip ID = %d"), lID));	

		bRet = true;
	}
	else
	{
		Log(StrF(_T("Ditto end copy, ERROR associating clip to Copy buffer ID = %d"), lID));
	}

	return bRet;
}
void CUAC_Thread::OnEvent(int eventId, void *param)
{
	DWORD startTick = GetTickCount();
	Log(StrF(_T("Start of OnEvent, eventId: %s"), EnumName((eUacThreadEvents)eventId)));

	switch((eUacThreadEvents)eventId)
	{
	case UAC_PASTE:
		theApp.m_activeWnd.SendPaste(false);
		break; 
	case UAC_COPY:
		theApp.m_activeWnd.SendCopy(CopyReasonEnum::COPY_TO_UNKOWN);
		break; 
	case UAC_CUT:
		theApp.m_activeWnd.SendCut();
		break; 
	case UAC_EXIT:
		this->CancelThread();
		break;
	}

	DWORD length = GetTickCount() - startTick;
	Log(StrF(_T("End of OnEvent, eventId: %s, Time: %d(ms)"), EnumName((eUacThreadEvents)eventId), length));
}
BOOL CreateBackup(CString csPath)
{
	CString csOriginal;
	int count = 0;
	// create a backup of the existing database
	do
	{
		count++;
		csOriginal = csPath + StrF(_T(".%03d"), count);
		// in case of some weird infinite loop
		if( count > 50 )
		{
			ASSERT(0);
			return FALSE;
		}
	} while( !::CopyFile(csPath, csOriginal, TRUE));
	
	return TRUE;
}
bool CDittoRulerRichEditCtrl::LoadTextData(CClip &Clip)
{
	CString csText = GetText();
	if(csText.IsEmpty())
	{
		for(int i = 0; i < 20; i++)
		{
			Sleep(100);
			csText = GetText();
			if(csText.IsEmpty() == FALSE)
				break;

			Log(StrF(_T("Get Text still empty pass = %d"), i));
		}
		if(csText.IsEmpty())
		{
			Log(_T("Get Text still empty pass returning"));
			return false;
		}
	}

	CClipFormat format;

#ifdef _UNICODE
	format.m_cfType = CF_UNICODETEXT;
#else
	format.m_cfType = CF_TEXT;
#endif

	int nLength = csText.GetLength() * sizeof(TCHAR) + sizeof(TCHAR);
	format.m_hgData = NewGlobalP(csText.GetBuffer(nLength), nLength);

	Clip.SetDescFromText(format.m_hgData, true);
	m_csDescription = Clip.m_Desc;
	m_csDescription = m_csDescription.Left(15);

	Clip.m_Formats.Add(format);
	format.m_hgData = NULL; //Clip.m_formats owns data now

	return true;
}
void CMainFrame::ShowErrorMessage(CString csTitle, CString csMessage)
{
    Log(StrF(_T("ShowErrorMessage %s - %s"), csTitle, csMessage));

    CToolTipEx *pErrorWnd = new CToolTipEx;
    pErrorWnd->Create(this);
    pErrorWnd->SetToolTipText(csTitle + "\n\n" + csMessage);

    CPoint pt;
    CRect rcScreen;
    GetMonitorRect(0, &rcScreen);
    pt = rcScreen.BottomRight();

    CRect cr = pErrorWnd->GetBoundsRect();

    pt.x -= max(cr.Width() + 50, 150);
    pt.y -= max(cr.Height() + 50, 150);

    pErrorWnd->Show(pt);
    pErrorWnd->HideWindowInXMilliSeconds(4000);
}
void CMainFrame::DoTextOnlyPaste()
{
	CClipboardSaveRestore textOnlyPaste;

	Log(_T("Text Only paste, saving clipboard to be restored later"));
	textOnlyPaste.Save(TRUE);

	Log(_T("Text Only paste, Add cf_text or cf_unicodetext to clipboard"));
	textOnlyPaste.RestoreTextOnly();

	DWORD pasteDelay = g_Opt.GetTextOnlyPasteDelay();

	Log(StrF(_T("Text Only paste, delaying %d ms before sending paste"), pasteDelay));

	Sleep(pasteDelay);

	Log(_T("Text Only paste, Sending paste"));
	theApp.m_activeWnd.SendPaste(false);

	Log(_T("Text Only paste, Post sending paste"));
}
UINT CProcessPaste::MarkAsPastedThread(LPVOID pParam)
{
	DWORD startTick = GetTickCount();

	static CEvent UpdateTimeEvent(TRUE, TRUE, _T("Ditto_Update_Clip_Time"), NULL);
	UpdateTimeEvent.ResetEvent();

	Log(_T("Start of MarkAsPastedThread"));

	//If running from a U3 device then wait a little before updating the db
	//updating the db can take a second or two and it delays the act of pasting
	if(g_Opt.m_bU3)
	{
		Sleep(350);
	}

	BOOL bRet = FALSE;
	int clipId = 0;

	try
	{
		MarkAsPastedData* pData = (MarkAsPastedData*)pParam;
		if(pData)
		{
			clipId = pData->clipId;
			if(g_Opt.m_bUpdateTimeOnPaste)
			{
				try
				{
					if(pData->pastedFromGroup)
					{
						CppSQLite3Query q = theApp.m_db.execQuery(_T("SELECT clipGroupOrder FROM Main ORDER BY clipGroupOrder DESC LIMIT 1"));

						if(q.eof() == false)
						{
							double latestDate = q.getFloatField(_T("clipGroupOrder"));
							latestDate += 1;

							Log(StrF(_T("Setting clipId: %d, GroupOrder: %f"), pData->clipId, latestDate));

							theApp.m_db.execDMLEx(_T("UPDATE Main SET clipGroupOrder = %f where lID = %d;"), latestDate, pData->clipId);

							theApp.RefreshClipOrder(pData->clipId);
						}
					}
					else
					{
						CppSQLite3Query q = theApp.m_db.execQuery(_T("SELECT clipOrder FROM Main ORDER BY clipOrder DESC LIMIT 1"));

						if(q.eof() == false)
						{
							double latestDate = q.getFloatField(_T("clipOrder"));
							latestDate += 1;

							Log(StrF(_T("Setting clipId: %d, order: %f"), pData->clipId, latestDate));

							theApp.m_db.execDMLEx(_T("UPDATE Main SET clipOrder = %f where lID = %d;"), latestDate, pData->clipId);

							theApp.RefreshClipOrder(pData->clipId);
						}
					}
				}
				CATCH_SQLITE_EXCEPTION
			}

			try
			{
				theApp.m_db.execDMLEx(_T("UPDATE Main SET lastPasteDate = %d where lID = %d;"), (int)CTime::GetCurrentTime().GetTime(), pData->clipId);
			}
			CATCH_SQLITE_EXCEPTION

			delete pData;
			bRet = TRUE;
		}
	}
	CATCH_SQLITE_EXCEPTION

	Log(_T("End of MarkAsPastedThread"));

	DWORD endTick = GetTickCount();
	if((endTick-startTick) > 350)
		Log(StrF(_T("Paste Timing MarkAsPastedThread: %d, ClipId: %d"), endTick-startTick, clipId));

	UpdateTimeEvent.SetEvent();
	return bRet;
}
Exemple #26
0
void CQPasteWndThread::OnLoadExtraData(void *param)
{
    ResetEvent(m_SearchingEvent);

    CQPasteWnd *pasteWnd = (CQPasteWnd*)param;

    Log(_T("Start of load extra data, Bitmaps/rtf"));

    std::list<CClipFormatQListCtrl> localFormats;
	{
		ATL::CCritSecLock csLock(pasteWnd->m_CritSection.m_sect);

		for (std::list<CClipFormatQListCtrl>::iterator it = pasteWnd->m_ExtraDataLoadItems.begin(); it != pasteWnd->m_ExtraDataLoadItems.end(); it++)
		{
			localFormats.push_back(*it);
		}
	    pasteWnd->m_ExtraDataLoadItems.clear();
	}

	for (std::list<CClipFormatQListCtrl>::iterator it = localFormats.begin(); it != localFormats.end(); it++)
    {
        if(theApp.GetClipData(it->m_dbId, *it))
        {
            Log(StrF(_T("Loaded, extra data for clip %d, type: %d"), it->m_dbId, it->m_cfType));

			ATL::CCritSecLock csLock(pasteWnd->m_CritSection.m_sect);

            if(it->m_cfType == CF_DIB)
            {
                pasteWnd->m_cf_dibCache[it->m_dbId] = *it;
                //the cache now owns the format data, set it to delete the data in the destructor
                pasteWnd->m_cf_dibCache[it->m_dbId].m_autoDeleteData = true;
            }
            else if(it->m_cfType == theApp.m_RTFFormat)
            {
                pasteWnd->m_cf_rtfCache[it->m_dbId] = *it;
                //the cache now owns the format data, set it to delete the data in the destructor
                pasteWnd->m_cf_rtfCache[it->m_dbId].m_autoDeleteData = true;
            }

            ::PostMessage(pasteWnd->m_hWnd, NM_REFRESH_ROW, it->m_dbId, it->m_clipRow);
        }
        else
        {
			ATL::CCritSecLock csLock(pasteWnd->m_CritSection.m_sect);

            if(it->m_cfType == CF_DIB)
            {
                CClipFormatQListCtrl localFormat;
                pasteWnd->m_cf_dibCache[it->m_dbId] = *it;
            }
            else if(it->m_cfType == theApp.m_RTFFormat)
            {
                CClipFormatQListCtrl localFormat;
                pasteWnd->m_cf_rtfCache[it->m_dbId] = *it;
            }
        }
    }

    SetEvent(m_SearchingEvent);
    Log(_T("End of load extra data, Bitmaps/rtf"));
}
void CMainFrame::OnTimer(UINT_PTR nIDEvent)
{
    switch(nIDEvent)
    {
        case HIDE_ICON_TIMER:
            {
                m_TrayIcon.HideIcon();
                KillTimer(nIDEvent);
            }
			break;

        case CLOSE_WINDOW_TIMER:
            {
                //m_quickPaste.CloseQPasteWnd();
            }
			break;

        case REMOVE_OLD_ENTRIES_TIMER:
			{
                m_thread.FireDeleteEntries();
            }
			break;

		case REMOVE_OLD_REMOTE_COPIES:
			{
            	m_thread.FireRemoveRemoteFiles();
			}
			break;

        case KEY_STATE_MODIFIERS:
            m_keyModifiersTimerCount++;
            if(m_keyStateModifiers != 0)
            {
                BYTE keyState = CAccels::GetKeyStateModifiers();
                //Have they release the key state modifiers yet(ctrl, shift, alt)
                if((m_keyStateModifiers &keyState) == 0)
                {
                    KillTimer(KEY_STATE_MODIFIERS);
                    long waitTime = (long)(GetTickCount() - m_startKeyStateTime);

                    if(m_bMovedSelectionMoveKeyState || m_keyModifiersTimerCount > g_Opt.GetKeyStateWaitTimerCount())
                    {
                        Log(StrF(_T("Timer KEY_STATE_MODIFIERS timeout count hit(%d), count (%d), time (%d), Move Selection from Modifer (%d) sending paste"), g_Opt.GetKeyStateWaitTimerCount(), m_keyModifiersTimerCount, waitTime, m_bMovedSelectionMoveKeyState));
                        m_quickPaste.OnKeyStateUp();
                    }
                    else
                    {
                        Log(StrF(_T("Timer KEY_STATE_MODIFIERS count NOT hit(%d), count (%d) time (%d)"), g_Opt.GetKeyStateWaitTimerCount(), m_keyModifiersTimerCount, waitTime));
                        m_quickPaste.SetKeyModiferState(false);
                    }

                    m_keyStateModifiers = 0;
                    m_keyModifiersTimerCount = 0;
                    m_bMovedSelectionMoveKeyState = 0;
                }
            }
            else
            {
                KillTimer(KEY_STATE_MODIFIERS);
            }
            break;

        case ACTIVE_WINDOW_TIMER:
			{
				if(theApp.m_bShowingQuickPaste)
				{
					theApp.m_activeWnd.TrackActiveWnd(false);
				}
			}
			break;

		case READ_RANDOM_DB_FILE:
			{
				m_thread.FireReadDbFile();
			}
		break;
    }

    CFrameWnd::OnTimer(nIDEvent);
}
LRESULT CMainFrame::OnHotKey(WPARAM wParam, LPARAM lParam)
{
    if(theApp.m_pDittoHotKey && wParam == theApp.m_pDittoHotKey->m_Atom)
    {
        //If they still have the shift/ctrl keys down
        if(m_keyStateModifiers != 0 && m_quickPaste.IsWindowVisibleEx())
        {
            Log(_T("On Show Ditto HotKey, key state modifiers are still down, moving selection"));

            if(m_bMovedSelectionMoveKeyState == false)
            {
                Log(_T("Setting flag m_bMovedSelectionMoveKeyState to true, will paste when modifer keys are up"));
            }

            m_quickPaste.MoveSelection(true);
            m_bMovedSelectionMoveKeyState = true;
        }
        else if(g_Opt.m_HideDittoOnHotKeyIfAlreadyShown && m_quickPaste.IsWindowTopLevel() && g_Opt.GetShowPersistent() == FALSE)
        {
            Log(_T("On Show Ditto HotKey, window is alread visible, hiding window"));
            m_quickPaste.HideQPasteWnd();
        }
        else
        {
            Log(_T("On Show Ditto HotKey, showing window"));

			StartKeyModifyerTimer();

			//Before we show our window find the current focused window for paste into
			theApp.m_activeWnd.TrackActiveWnd(true);

            m_quickPaste.ShowQPasteWnd(this, false, true, FALSE);
        }

        //KillTimer(CLOSE_WINDOW_TIMER);
        //SetTimer(CLOSE_WINDOW_TIMER, ONE_HOUR *24, 0);
    }
    else if(theApp.m_pPosOne && wParam == theApp.m_pPosOne->m_Atom)
    {
        Log(_T("Pos 1 hot key"));
        DoFirstTenPositionsPaste(0);
    }
    else if(theApp.m_pPosTwo && wParam == theApp.m_pPosTwo->m_Atom)
    {
        Log(_T("Pos 2 hot key"));
        DoFirstTenPositionsPaste(1);
    }
    else if(theApp.m_pPosThree && wParam == theApp.m_pPosThree->m_Atom)
    {
        Log(_T("Pos 3 hot key"));
        DoFirstTenPositionsPaste(2);
    }
    else if(theApp.m_pPosFour && wParam == theApp.m_pPosFour->m_Atom)
    {
        Log(_T("Pos 4 hot key"));
        DoFirstTenPositionsPaste(3);
    }
    else if(theApp.m_pPosFive && wParam == theApp.m_pPosFive->m_Atom)
    {
        Log(_T("Pos 5 hot key"));
        DoFirstTenPositionsPaste(4);
    }
    else if(theApp.m_pPosSix && wParam == theApp.m_pPosSix->m_Atom)
    {
        Log(_T("Pos 6 hot key"));
        DoFirstTenPositionsPaste(5);
    }
    else if(theApp.m_pPosSeven && wParam == theApp.m_pPosSeven->m_Atom)
    {
        Log(_T("Pos 7 hot key"));
        DoFirstTenPositionsPaste(6);
    }
    else if(theApp.m_pPosEight && wParam == theApp.m_pPosEight->m_Atom)
    {
        Log(_T("Pos 8 hot key"));
        DoFirstTenPositionsPaste(7);
    }
    else if(theApp.m_pPosNine && wParam == theApp.m_pPosNine->m_Atom)
    {
        Log(_T("Pos 9 hot key"));
        DoFirstTenPositionsPaste(8);
    }
    else if(theApp.m_pPosTen && wParam == theApp.m_pPosTen->m_Atom)
    {
        Log(_T("Pos 10 hot key"));
        DoFirstTenPositionsPaste(9);
    }
    else if(theApp.m_pCopyBuffer1 && wParam == theApp.m_pCopyBuffer1->m_Atom)
    {
        Log(_T("Copy buffer 1 hot key"));
        theApp.m_CopyBuffer.StartCopy(0);
    }
    else if(theApp.m_pPasteBuffer1 && wParam == theApp.m_pPasteBuffer1->m_Atom)
    {
        Log(_T("Paste buffer 1 hot key"));
        theApp.m_CopyBuffer.PastCopyBuffer(0);
    }
    else if(theApp.m_pCutBuffer1 && wParam == theApp.m_pCutBuffer1->m_Atom)
    {
        Log(_T("Cut buffer 1 hot key"));
        theApp.m_CopyBuffer.StartCopy(0, true);
    }
    else if(theApp.m_pCopyBuffer2 && wParam == theApp.m_pCopyBuffer2->m_Atom)
    {
        Log(_T("Copy buffer 2 hot key"));
        theApp.m_CopyBuffer.StartCopy(1);
    }
    else if(theApp.m_pPasteBuffer2 && wParam == theApp.m_pPasteBuffer2->m_Atom)
    {
        Log(_T("Paste buffer 2 hot key"));
        theApp.m_CopyBuffer.PastCopyBuffer(1);
    }
    else if(theApp.m_pCutBuffer2 && wParam == theApp.m_pCutBuffer2->m_Atom)
    {
        Log(_T("Cut buffer 2 hot key"));
        theApp.m_CopyBuffer.StartCopy(1, true);
    }
    else if(theApp.m_pCopyBuffer3 && wParam == theApp.m_pCopyBuffer3->m_Atom)
    {
        Log(_T("Copy buffer 3 hot key"));
        theApp.m_CopyBuffer.StartCopy(2);
    }
    else if(theApp.m_pPasteBuffer3 && wParam == theApp.m_pPasteBuffer3->m_Atom)
    {
        Log(_T("Paste buffer 3 hot key"));
        theApp.m_CopyBuffer.PastCopyBuffer(2);
    }
    else if(theApp.m_pCutBuffer3 && wParam == theApp.m_pCutBuffer3->m_Atom)
    {
        Log(_T("Cut buffer 3 hot key"));
        theApp.m_CopyBuffer.StartCopy(2, true);
    }
	else if(theApp.m_pTextOnlyPaste && wParam == theApp.m_pTextOnlyPaste->m_Atom)
	{
		DoTextOnlyPaste();
	}
	else if(theApp.m_pSaveClipboard && wParam == theApp.m_pSaveClipboard->m_Atom)
	{
		OnFirstSavecurrentclipboard();
	}
	else
	{
		for(int i = 0; i < g_HotKeys.GetCount(); i++)
		{
			if(g_HotKeys[i] != NULL && 
				g_HotKeys[i]->m_Atom == wParam && 
				g_HotKeys[i]->m_clipId > 0)
			{

				Log(StrF(_T("Pasting clip from global shortcut, clipId: %d"), g_HotKeys[i]->m_clipId));
				PasteOrShowGroup(g_HotKeys[i]->m_clipId, -1, FALSE, TRUE);

				break;
			}
		}
	}

    return TRUE;
}
Exemple #29
0
void CQPasteWndThread::OnLoadItems(void *param)
{
    CQPasteWnd *pasteWnd = (CQPasteWnd*)param;

    ResetEvent(m_SearchingEvent);

	while(true)
	{
		long startTick = GetTickCount();
	    int loadItemsIndex = 0;
	    int loadItemsCount = 0;
	    int loadCount = 0;
	    CString localSql;
	    bool clearFirstLoadItem = false;
		bool firstLoad = false;

		{
			ATL::CCritSecLock csLock(pasteWnd->m_CritSection.m_sect);

		    if(pasteWnd->m_loadItems.size() > 0)
		    {
				firstLoad = (pasteWnd->m_loadItems.begin()->x == -1);
		        loadItemsIndex = max(pasteWnd->m_loadItems.begin()->x, 0);
		        loadItemsCount = pasteWnd->m_loadItems.begin()->y - pasteWnd->m_loadItems.begin()->x;
		        localSql = pasteWnd->m_SQL;
		        pasteWnd->m_bStopQuery = false;
		        clearFirstLoadItem = true;
		    }
		}

	    if(clearFirstLoadItem)
	    {
			try
			{
				Log(StrF(_T("Load Items start = %d, count = %d"), loadItemsIndex, loadItemsCount));

				CString limit;
				limit.Format(_T(" LIMIT %d OFFSET %d"), loadItemsCount, loadItemsIndex);
				localSql += limit;

				CMainTable table;

				CppSQLite3Query q = theApp.m_db.execQuery(localSql);
				while(!q.eof())
				{
					pasteWnd->FillMainTable(table, q);

					{
						ATL::CCritSecLock csLock(pasteWnd->m_CritSection.m_sect);

						pasteWnd->m_listItems.push_back(table);
					}

					if(pasteWnd->m_bStopQuery)
					{
						Log(StrF(_T("StopQuery called exiting filling cache count = %d"), loadItemsIndex));
						break;
					}

					q.nextRow();

					if(firstLoad == false)
					{
	            		::PostMessage(pasteWnd->m_hWnd, NM_REFRESH_ROW, table.m_lID, loadItemsIndex);
					}

					loadItemsIndex++;
					loadCount++;
				}

				if(firstLoad)
				{
					::PostMessage(pasteWnd->m_hWnd, NM_REFRESH_ROW, -2, 0);
					//allow the next thread message to process, this should be the message to set the list count

					OnSetListCount(param);
					OnLoadAccelerators(param);
				}
				else
				{
					::PostMessage(pasteWnd->m_hWnd, NM_REFRESH_ROW, -1, 0);
				}

				if(clearFirstLoadItem)
				{
					ATL::CCritSecLock csLock(pasteWnd->m_CritSection.m_sect);

					pasteWnd->m_loadItems.erase(pasteWnd->m_loadItems.begin());
				}

				Log(StrF(_T("Load items End count = %d, time = %d"), loadCount, GetTickCount() - startTick));
			}
			catch (CppSQLite3Exception& e)	\
			{								\
				Log(StrF(_T("ONLoadItems - SQLITE Exception %d - %s"), e.errorCode(), e.errorMessage()));	\
				ASSERT(FALSE);				\
				break;
			}	
		}
		else
		{
			break;
		}
	}

    SetEvent(m_SearchingEvent);
}
Exemple #30
0
HGLOBAL CClient::RequestCopiedFiles(CClipFormat &HDropFormat, CString csIP, CString csComputerName)
{
	CSendInfo Info;
	bool bBreak = false;
	HGLOBAL hReturn = NULL;
	CString csErrorString;

	CFileTransferProgressDlg *pProgress = new CFileTransferProgressDlg;
	if(pProgress == NULL)
		return NULL;

	LogSendRecieveInfo(StrF(_T("************** START of requesting files from cpu %s, ip: %s **************"), csComputerName, csIP));

	pProgress->Create(IDD_DIALOG_REMOTE_FILE);
	pProgress->ShowWindow(SW_SHOW);
	pProgress->SetMessage(StrF(_T("Opening Connection to %s (%s)"), csComputerName, csIP));
	pProgress->PumpMessages();

	CString requestFrom;
	if(g_Opt.GetRequestFilesUsingIP())
	{
		requestFrom = csIP;
	}
	else
	{
		requestFrom = csComputerName;
	}

	do 
	{
		if(OpenConnection(requestFrom) == FALSE)
		{
			csErrorString.Format(_T("Error Opening Connection to %s (%s)"), csComputerName, csIP);
			break;
		}

		m_SendSocket.SetSocket(m_Connection);
		m_SendSocket.SetProgressBar(pProgress);

		if(m_SendSocket.SendCSendData(Info, MyEnums::START) == FALSE)
			break;

		if(SendClipFormat(&HDropFormat) == FALSE)
		{
			csErrorString = _T("Error sending data request.");
			break;
		}

		if(m_SendSocket.SendCSendData(Info, MyEnums::END) == FALSE)
			break;
			
		pProgress->SetMessage(StrF(_T("Requesting Files from %s (%s)"), csComputerName, csIP));

		if(m_SendSocket.SendCSendData(Info, MyEnums::REQUEST_FILES) == FALSE)
			break;

		CFileRecieve Recieve;
		long lRet = Recieve.RecieveFiles(m_Connection, csIP, pProgress);
		if(lRet == TRUE)
		{
			hReturn = Recieve.CreateCF_HDROPBuffer();
		}
		else if(lRet == FALSE)
		{
			if(pProgress != NULL && pProgress->Cancelled())
			{
				//Don't show an error message the user canceled things
			}
			else	
			{
				csErrorString = _T("Error recieving files.");
			}
		}

	} while(false);

	CloseConnection();

	if(hReturn == NULL && csErrorString.IsEmpty() == FALSE)
	{
		MessageBox(pProgress->m_hWnd, csErrorString, _T("Ditto"), MB_OK|MB_ICONEXCLAMATION);
	}

	pProgress->DestroyWindow();

	LogSendRecieveInfo(StrF(_T("************** END of requesting files from cpu %s, ip: %s **************************"), csComputerName, csIP));

	return hReturn;
}