CMemSpyEngineFileHolder::~CMemSpyEngineFileHolder()
    {
    TPtrC pFileName( KNullDesC );
    if  ( iFileName != NULL )
        {
        pFileName.Set( *iFileName );
        }
    TRACE( RDebug::Print( _L("CMemSpyEngineFileHolder::~CMemSpyEngineFileHolder() - START - this: 0x%08x, iFileName: %S, handle: 0x%08x, iEntireFileBuffer: 0x%08x, iIsMainLog: %d"), this, &pFileName, iFile.SubSessionHandle(), iEntireFileBuffer, iIsMainLog ) );

    if  ( iEntireFileBuffer || iWorkingBuffer )
        {
        // This may actually open the file
        TRACE( RDebug::Printf( "CMemSpyEngineFileHolder::~CMemSpyEngineFileHolder() - disabling file buffers..." ) );
        TRAP_IGNORE( DisableBufferL() );
        }

    // Now close the file, deleting anything that is empty
    if  ( iFile.SubSessionHandle() != KNullHandle )
        {
        TRACE( RDebug::Printf( "CMemSpyEngineFileHolder::~CMemSpyEngineFileHolder() - flushing file..." ) );

        // Flush anything that is pending and then check whether 
        // the file is empty. If so, delete it.
        iFile.Flush(); // Ignore error
       
        // Delete empty files
        TInt size = 0;
        TInt err = iFile.Size( size );
        TRACE( RDebug::Printf( "CMemSpyEngineFileHolder::~CMemSpyEngineFileHolder() - size: %d, err: %d", size, err ) );

        if  ( err == KErrNone && size == 0 )
            {
            // Close the file and get F32 to delete it...
            TRACE( RDebug::Printf( "CMemSpyEngineFileHolder::~CMemSpyEngineFileHolder() - deleting empty file!" ) );
            iFile.Close();
            err = FsSession().Delete( *iFileName );
            TRACE( RDebug::Printf( "CMemSpyEngineFileHolder::~CMemSpyEngineFileHolder() - delete err: %d", err ) );
            }
        }
    //
    iFile.Close();
    //
    delete iLineBuffer;
    delete iWorkingBuffer;
    delete iEntireFileBuffer;
    TRACE( RDebug::Print( _L("CMemSpyEngineFileHolder::~CMemSpyEngineFileHolder() - END - this: 0x%08x, iFileName: %S, iIsMainLog: %d"), this, &pFileName, iIsMainLog ) );
    delete iFileName;
    delete iMetaData;
    }
Example #2
0
HRESULT CDropTarget::Drop(IDataObject* pDataObj, DWORD grfKeyState, POINTL pt, DWORD* pdwEffect)
{
	HRESULT hr;
	FORMATETC format = {};
	STGMEDIUM medium = {};

	format.cfFormat = CF_HDROP;
	format.ptd = nullptr;
	format.dwAspect = DVASPECT_CONTENT;
	format.lindex = -1;
	format.tymed = TYMED_HGLOBAL;
	hr = pDataObj->QueryGetData(&format);
	if (FAILED(hr))
	{
		OutputDebugString(L"Format Error.\n");
		return hr;
	}
	hr = pDataObj->GetData(&format, &medium);
	if (FAILED(hr))
	{
		OutputDebugString(L"GetData Error.\n");
		return hr;
	}

	auto hDrop = static_cast<HDROP>(GlobalLock(medium.hGlobal));
	auto nDrops = DragQueryFile(hDrop, 0xffffffff, nullptr, 0);
	for (uint32_t i = 0; i < nDrops; i++)
	{
		auto fnSize = DragQueryFile(hDrop, i, nullptr, 0);
		std::unique_ptr<wchar_t[]> pFileName(new wchar_t[fnSize + 1]);
		DragQueryFile(hDrop, i, pFileName.get(), fnSize + 1);

		//getCurrentContext().getProjectManager()->getCurrent()->loadSound(pFileName.get());
		getCurrentContext().getSoundLoaderThread()->sendToLoad(pFileName.get());
	}

	GlobalUnlock(medium.hGlobal);
	ReleaseStgMedium(&medium);

	OutputDebugString(L"Drop\n");
	getCurrentContext().getDragScreenOverlay()->falloffEffect();
	return S_OK;
}
Example #3
0
static void PrintEntryL(const TDesC& aPrompt, const CHlpFileEntry& aEntry, TInt aNumber = -1)
	{
	TFileName pFileName(aEntry.FileName());
	TChar driveLetter = '?';
	RFs::DriveToChar(aEntry.Drive(), driveLetter);

	//HBufC* buf = HBufC::NewLC(aPrompt.Length() + pFileName.Length() + KHlpFileSearchPath().Length() + 40);
	//TDes pBuf(buf->Des());
	TBuf<256> pBuf;		//Tempory fix to allow this to work in Code Warrior builds.

	
	if	(aNumber >= KErrNone)
		pBuf.Format(_L("\n%S %d: %c:%S%S\n"), &aPrompt, aNumber, static_cast<TUint>(driveLetter), &KHlpFileSearchPath(), &pFileName);
	else
		pBuf.Format(_L("\n%S: %c:%S%S\n"), &aPrompt, static_cast<TUint>(driveLetter), &KHlpFileSearchPath(), &pFileName);

	TheTest.Printf(pBuf);

	//CleanupStack::PopAndDestroy();
	}
Example #4
0
void __cdecl CJabberProto::FileServerThread(filetransfer *ft)
{
	debugLogA("Thread started: type=file_send");

	ThreadData info(this, NULL);
	ft->type = FT_OOB;

	NETLIBBIND nlb = { 0 };
	nlb.cbSize = sizeof(NETLIBBIND);
	nlb.pfnNewConnectionV2 = JabberFileServerConnection;
	nlb.pExtra = this;
	nlb.wPort = 0;	// Use user-specified incoming port ranges, if available
	info.s = (HANDLE)CallService(MS_NETLIB_BINDPORT, (WPARAM)m_hNetlibUser, (LPARAM)&nlb);
	if (info.s == NULL) {
		debugLogA("Cannot allocate port to bind for file server thread, thread ended.");
		ProtoBroadcastAck(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0);
		delete ft;
		return;
	}

	ft->s = info.s;
	debugLogA("ft->s = %d", info.s);

	HANDLE hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
	ft->hFileEvent = hEvent;

	TCHAR szPort[20];
	mir_sntprintf(szPort, _countof(szPort), _T("%d"), nlb.wPort);
	JABBER_LIST_ITEM *item = ListAdd(LIST_FILE, szPort);
	item->ft = ft;

	TCHAR *ptszResource = ListGetBestClientResourceNamePtr(ft->jid);
	if (ptszResource != NULL) {
		ft->state = FT_CONNECTING;
		for (int i = 0; i < ft->std.totalFiles && ft->state != FT_ERROR && ft->state != FT_DENIED; i++) {
			ft->std.currentFileNumber = i;
			ft->state = FT_CONNECTING;
			if (ft->httpPath) mir_free(ft->httpPath);
			ft->httpPath = NULL;

			TCHAR *p;
			if ((p = _tcschr(ft->std.ptszFiles[i], '\\')) != NULL)
				p++;
			else
				p = ft->std.ptszFiles[i];

			ptrA pFileName(mir_urlEncode(T2Utf(p)));
			if (pFileName != NULL) {
				ft->szId = JabberId2string(SerialNext());

				ptrA myAddr;
				if (m_options.BsDirect && m_options.BsDirectManual)
					myAddr = getStringA("BsDirectAddr");
				if (myAddr == NULL)
					myAddr = (char*)CallService(MS_NETLIB_ADDRESSTOSTRING, 1, nlb.dwExternalIP);

				char szAddr[256];
				mir_snprintf(szAddr, _countof(szAddr), "http://%s:%d/%s", myAddr, nlb.wPort, pFileName);

				size_t len = mir_tstrlen(ptszResource) + mir_tstrlen(ft->jid) + 2;
				TCHAR *fulljid = (TCHAR *)alloca(sizeof(TCHAR) * len);
				mir_sntprintf(fulljid, len, _T("%s/%s"), ft->jid, ptszResource);

				XmlNodeIq iq(_T("set"), ft->szId, fulljid);
				HXML query = iq << XQUERY(JABBER_FEAT_OOB);
				query << XCHILD(_T("url"), _A2T(szAddr));
				query << XCHILD(_T("desc"), ft->szDescription);
				m_ThreadInfo->send(iq);

				debugLogA("Waiting for the file to be sent...");
				WaitForSingleObject(hEvent, INFINITE);
			}
			debugLogA("File sent, advancing to the next file...");
			ProtoBroadcastAck(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_NEXTFILE, ft, 0);
		}
		CloseHandle(hEvent);
		ft->hFileEvent = NULL;
		debugLogA("Finish all files");
	}

	ft->s = NULL;
	debugLogA("ft->s is NULL");

	ListRemove(LIST_FILE, szPort);

	switch (ft->state) {
	case FT_DONE:
		debugLogA("Finish successfully");
		ProtoBroadcastAck(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_SUCCESS, ft, 0);
		break;
	case FT_DENIED:
		ProtoBroadcastAck(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_DENIED, ft, 0);
		break;
	default: // FT_ERROR:
		debugLogA("Finish with errors");
		ProtoBroadcastAck(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0);
		break;
	}

	debugLogA("Thread ended: type=file_send");
	delete ft;
}