Ejemplo n.º 1
0
/*
 * Instruct the I/O Queue to write to the handle.
 */
PJ_DEF(pj_status_t) pj_ioqueue_send( pj_ioqueue_key_t *key,
                                     pj_ioqueue_op_key_t *op_key,
                                     const void *data,
                                     pj_ssize_t *length,
                                     pj_uint32_t flags )
{
    TRequestStatus reqStatus;
    TPtrC8 aBuffer((const TUint8*)data, (TInt)*length);
    TSockXfrLength aLen;

    PJ_UNUSED_ARG(op_key);

    // Forcing pending operation is not supported.
    PJ_ASSERT_RETURN((flags & PJ_IOQUEUE_ALWAYS_ASYNC)==0, PJ_EINVAL);

    // Return failure if access point is marked as down by app.
    PJ_SYMBIAN_CHECK_CONNECTION();

    // Clear flag
    flags &= ~PJ_IOQUEUE_ALWAYS_ASYNC;

    key->cbObj->get_pj_socket()->Socket().Send(aBuffer, flags, reqStatus, aLen);
    User::WaitForRequest(reqStatus);

    if (reqStatus.Int() != KErrNone)
        return PJ_RETURN_OS_ERROR(reqStatus.Int());

    //At least in UIQ Emulator, aLen.Length() reports incorrect length
    //for UDP (some newlc.com users seem to have reported this too).
    //*length = aLen.Length();
    return PJ_SUCCESS;
}
Ejemplo n.º 2
0
IXMLNode::TXMLNodePtr CXMLEngineMI::LoadFile(const tstring& rsFileName)const
{
// 	struct mir_safe_string
// 	{
// 		mir_safe_string(LPTSTR p) : m_p(p){}
// 		~mir_safe_string(){mir_free(m_p);}
// 
// 		LPTSTR m_p;
// 	};


	IXMLNode::TXMLNodePtr pResult;
	FILE* stream;
	if(0 == ::_tfopen_s(&stream,rsFileName.c_str(),_T("r")))
	{
		struct _stat st;
		if(-1 != ::_fstat(::_fileno(stream),&st))
		{
			std::vector<char> aBuffer(st.st_size+1);
			char* pBuffer = &*(aBuffer.begin());
			size_t cBytes = ::fread(pBuffer,sizeof(char),st.st_size,stream);
			if(cBytes > 0 && cBytes <= static_cast<size_t>(st.st_size))
			{
				pBuffer[cBytes] = '\0';

				int nLen = (int)cBytes;	
				mir_safe_string<TCHAR> ss(mir_utf8decodeT(pBuffer));
				if(ss.m_p)
				{
					HXML h = xi.parseString(ss.m_p,&nLen,NULL);
					if(h)
					{
						pResult = IXMLNode::TXMLNodePtr(new CXMLNodeMI(h,true));
					}
				}
			}
		}
		::fclose(stream);
	}

	return pResult;
}
Ejemplo n.º 3
0
//
// IContextMenu::GetCommandString
//
// Invoked by the shell to get a text description for our menu item.
//
// @param p_CmdId Offset of ID of command for which to query text, relative
//                to our first command ID.
// @param p_Flags Type of information or action requested; see MSDN for details.
// @param p_pReserved Reserved; unused.
// @param p_pBuffer Pointer to memory buffer where to copy a null-terminated string.
//                  Note: if GCS_UNICODE is found in p_Flags, the string must
//                  be cast to a LPWSTR and a Unicode string must be stored there.
// @param p_BufferSize Max size of p_pBuffer, in characters. 
// @return S_OK if successful, otherwise an error code.
//
STDMETHODIMP CLevelZapContextMenuExt::GetCommandString(
	UINT_PTR p_CmdId,
	UINT p_Flags,
	UINT* p_pReserved,
	LPSTR p_pBuffer,
	UINT p_BufferSize)
{
	HRESULT hRes = S_OK;

	try {
		// Check what is requested.
		if ((p_Flags == GCS_VERBA) || (p_Flags == GCS_VERBW)) {
			// We do not support verb invokation.
			hRes = E_NOTIMPL;
		} else if ((p_Flags == GCS_VALIDATEA) || (p_Flags == GCS_VALIDATEW)) {
			// We need to validate command ID.
			if (m_FirstCmdId.HasValue() && m_ZapCmdId.HasValue() && m_ZapCmdId == (m_FirstCmdId + p_CmdId)) {
				hRes = S_OK;
			} else {
				hRes = S_FALSE;
			}
		} else if (p_Flags == GCS_HELPTEXTA) {
			// Call this method to get the Unicode version.
			ArrayAutoPtr<wchar_t> wBuffer(new wchar_t[p_BufferSize]);
			hRes = this->GetCommandString(p_CmdId,
										  GCS_HELPTEXTW,
										  p_pReserved,
										  reinterpret_cast<LPSTR>(wBuffer.Get()),
										  p_BufferSize);
			if (SUCCEEDED(hRes)) {
				// Convert it to a single-byte string and return it.
				CStringA aBuffer(wBuffer.Get());
				if (::strcpy_s(p_pBuffer, p_BufferSize, aBuffer) == 0) {
					hRes = S_OK;
				} else {
					hRes = E_FAIL;
				}
			}
		} else if (p_Flags == GCS_HELPTEXTW) {
			// A Unicode help string is requested.
			if (p_pBuffer != 0) {
				if (m_FirstCmdId.HasValue() && m_ZapCmdId.HasValue() && m_ZapCmdId == (m_FirstCmdId + p_CmdId)) {
					// Return help text for our zap item.
					CStringW zapItemHint(MAKEINTRESOURCE(IDS_ZAP_MENU_ITEM_HINT));
					if (::wcscpy_s((LPWSTR) p_pBuffer, p_BufferSize, zapItemHint) != 0) {
						hRes = E_FAIL;
					}
				} else {
					hRes = E_INVALIDARG;
				}
			} else {
				hRes = E_INVALIDARG;
			}
		} else {
			// Unknown, unsupported flag.
			hRes = E_NOTIMPL;
		}
	} catch (...) {
		hRes = E_UNEXPECTED;
	}

	return hRes;
}