// --------------------------------------------------------------------------- // CWmDrmDlaUiNotifierImpl::InitializeL // --------------------------------------------------------------------------- // void CWmDrmDlaUiNotifierImpl::InitializeL( TDesC8& aOpaqueData ) { TInt err( KErrNotFound ); LOGFNR( "CWmDrmDlaUiNotifierImpl::InitializeL", err ); LOGHEX( aOpaqueData.Ptr(), aOpaqueData.Length() ); delete iUiPlugin; iUiPlugin = NULL; RImplInfoPtrArray implArray; CleanupStack::PushL( TCleanupItem( DoResetDestroyAndClose, &implArray ) ); REComSession::ListImplementationsL( KWmDrmDlaUiPluginIfUid, implArray ); for ( TInt i( 0 ); i < implArray.Count() && err == KErrNotFound; ++i ) { if ( aOpaqueData.CompareF( implArray[i]->OpaqueData() ) == 0 && implArray[i]->VendorId() == VID_DEFAULT ) { err = KErrNone; iUiPlugin = CWmDrmDlaUiPluginIf::NewL( implArray[i]->ImplementationUid() ); } } if ( err == KErrNotFound ) { err = KErrNone; iUiPlugin = CWmDrmDlaUiPluginIf::NewL( KWmDrmDlaDefaultUiPluginUid ); } CleanupStack::PopAndDestroy( &implArray ); }
bool CWSAThread::parsePacketToRecvQueue(SOCKET_SET *psockset, char *buf, int buflen) { if (psockset == NULL || psockset->key == NULL) { LOG(_ERROR_, "CWSAThread::parsePacketToRecvQueue() error, psockset == NULL || psockset->key == NULL"); return false; } if (buf == NULL || buflen <= 0) { LOG(_ERROR_, "CWSAThread::parsePacketToRecvQueue() error, buf == NULL || buflen <= 0"); //TODO check here, return true or false ? return true; } LOGHEX(_DEBUG_, "recv message:", buf, buflen); int curpos = 0; while (curpos < buflen) { if (buflen - curpos < NET_HEAD_SIZE) { memcpy(psockset->part_buf, buf, buflen - curpos); psockset->part_len = buflen - curpos; return true; } unsigned short nmsgsize = *((unsigned short*)(buf + curpos)); unsigned short nlen = ntohs(nmsgsize); if (nlen > MAX_SEND_SIZE || nlen < NET_HEAD_SIZE) { LOG(_ERROR_, "CWSAThread::parsePacketToRecvQueue() error, invalid message size, fd=%d, time=%u, peerip=%s, port=%d", psockset->key->fd, psockset->key->connect_time, GETNULLSTR(psockset->peer_ip), psockset->peer_port); return false; } if (nlen > buflen - curpos) { //TODO check here, buf or buf + curpos ? memcpy(psockset->part_buf, buf + curpos, buflen - curpos); psockset->part_len = buflen - curpos; return true; } NET_DATA* pdata = new NET_DATA; if (pdata == NULL) { LOG(_ERROR_, "CWSAThread::parsePacketToRecvQueue() error, _new NET_DATA failed, fd=%d, time=%u, peerip=%s, port=%d", psockset->key->fd, psockset->key->connect_time, GETNULLSTR(psockset->peer_ip), psockset->peer_port); //TODO check here, buf or buf + curpos LOGHEX(_DEBUG_, "recv message:", buf + curpos, buflen); exit(-1); } if (!pdata->init(psockset->key->fd, psockset->key->connect_time, psockset->peer_ip, psockset->peer_port, psockset->type, nlen)) { LOG(_ERROR_, "CWSAThread::parsePacketToRecvQueue() error, pdata->init() failed, fd=%d, time%u, peerip=%s, port=%d", psockset->key->fd, psockset->key->connect_time, GETNULLSTR(psockset->peer_ip), psockset->peer_port); LOGHEX(_DEBUG_, "recv message:", buf, buflen); delete pdata; return false; } memcpy(pdata->pdata, buf + curpos, nlen); pdata->data_len = nlen; m_recvtmplst.push_back(pdata); curpos += nlen; }//end while return true; }
// ----------------------------------------------------------------------------- // CDpPn2Rx::Read // Reserves space from rx buffer and makes new PipeReceive // to Isc Api. Checks if flow control high water mark is reached. // Extracts paritybits if 7-bit data.Signals Rx2Dte. // ----------------------------------------------------------------------------- // TInt CDpPn2Rx::Read() { OstTrace0( TRACE_NORMAL, CDPPN2RX_READ, "CDpPn2Rx::Read" ); OstTrace1( TRACE_NORMAL, DUP1_CDPPN2RX_READ, "CDpPn2Rx::Read %x", &iDataPort ); OstTraceExt2( TRACE_NORMAL, DUP2_CDPPN2RX_READ, "CDpPn2Rx:: (Read from ISC) - Port: %u, iRx.Length: %d", iDataPort.PortUnit(), iRx.Length() ); LOGM1("CDpPn2Rx::Read %x", &iDataPort); LOGM2("CDpPn2Rx::Read (Read from ISC) - Port %d, iRx.Length: %d", iDataPort.PortUnit(), iRx.Length() ); TInt ret( KErrNone ); // We've been listening pn_pipe if ( EDpReadWait == iState ) { LOGHEX(iRx, EFalse); OstTraceExt1( TRACE_NORMAL, DUP10_CDPPN2RX_READ, "CDpPn2Rx:: RX = %s", iRx ); ret = iBufferRx.WriteElement().Release( iRx.Length() ); if ( KErrNone == ret ) { #ifdef USE_FILE_SERIAL_TRUST_DEBUG iDataPort.DebugBytesFromPn( iRx.Length() ); #endif if ( 0 < iRx.Length() ) { // 7-bit data extract parity bits if ( EData7 == iDataConfig.DataBits() ) { iParityHandler.ExtractParityBits( iRx ); } //no else if ( iDataPort.IsRx2DteReadPending() ) { // Signal RX2DTE iDataPort.SignalRx2Dte(); } //no else // New data is available. is client interested about that if ( iInBufHasDataNotify ) { // We should notify client iInBufHasDataNotify = EFalse; iDataPort.NotifyDataAvailableCompleted( KErrNone ); } //no else } //no else } //no else } //no else // Check pipe state if ( KErrNone == ret && CDpPif::EDpPipeEnabled != iPifDcs.PipeState() ) { ret = KErrNotReady; } else if ( KErrNone == ret ) { // Try reserve element for writing TPtr8 nullPtr( 0, 0 ); // Check if reserved buffer was too small // => override MaxReservationSize for next read request. if ( KErrNoMemory == iStatus.Int() && iLen > iBufferRx.MaxReservationSize() ) { OstTrace0( TRACE_NORMAL, DUP4_CDPPN2RX_READ, "CDpPn2Rx::KErrNoMemory from ISC =>" ); OstTraceExt1( TRACE_NORMAL, DUP5_CDPPN2RX_READ, "CDpPn2Rx:: -- Try to read more than MaxReservationSize, %hu --", iLen ); LOG(" CDpPn2Rx::Read, KErrNoMemory from ISC =>"); LOG1(" -- Try to read more than MaxReservationSize, %d --", iLen ); ret = iBufferRx.WriteElement().Reserve( iLen, iRx, nullPtr, ETrue ); // Set iLen to zero (required buffer lenght for read, // received from ISC if buffer was too small) iLen = 0; } else { ret = iBufferRx.WriteElement().Reserve( iBufferRx.MaxReservationSize(), iRx, nullPtr ); } // Is flowctrl off and rx "high watermark" reached if ( EFlowControlOff == iFlowCtrl.FlowCtrlDcs2Dp() ) { if ( IsHighWaterMarkReached() ) { // Buffer is almost full set flowcontrol on LOG(" CDpPn2Rx::Read, Rx High WaterMarkReached"); OstTrace0( TRACE_NORMAL, DUP6_CDPPN2RX_READ, "CDpPn2Rx:: Rx High WaterMark reached" ); iFlowCtrl.WaterMarkHighReached(); } //no else } //no else switch ( ret ) { // Reservation successed case KErrNone: { LOG1(" CDpPn2Rx::Read, ISAHandle Pipe Receive. iRx.MaxLength: %d", iRx.MaxLength() ); OstTrace1( TRACE_NORMAL, DUP7_CDPPN2RX_READ, "CDpPn2Rx:: ISAHandle Pipe Receive. iRx.MaxLength: %d", iRx.MaxLength() ); // Set pipe receive if ( !IsActive() ) { iDataPort.ISAHandle().DataReceive( iStatus, iRx, iLen ); iRequestActive = ETrue; // Change state iState = EDpReadWait; SetActive(); } //no else break; } // Reservation failed case KErrNotReady: { LOG(" ERROR, CDpPn2Rx::Read, Element reservation failed (KErrNotReady)."); OstTrace0( TRACE_NORMAL, DUP8_CDPPN2RX_READ, "ERROR, CDpPn2Rx::Read, Element reservation failed (KErrNotReady)" ); // Change state iState = EElementWait; // Better done here if ( !IsActive() ) { iStatus = KRequestPending; SetActive(); } //no else iRequestActive = ETrue; ret = KErrNone; break; } default: { // An error value returned LOG1(" ERROR, CDpPn2Rx::Read, Fail to reserve Element, error code: %d", ret ); OstTrace1( TRACE_NORMAL, DUP9_CDPPN2RX_READ, "CDpPn2Rx:: ERROR, CDpPn2Rx::Read, Fail to reserve Element, error code: %d", ret ); } } } //no else return ret; }
int CWSAThread::doSendMessage(SOCKET_KEY* pkey) { if (pkey == NULL) return 0; map<int, SOCKET_SET*>::iterator itersockmap = m_socketmap.find(pkey->fd); if (itersockmap == m_socketmap.end() || itersockmap->second == NULL || itersockmap->second->key == NULL) { LOG(_ERROR_, "CWSAThread::doSendMessage() error, do not find socket in m_socketmap, fd=%d", pkey->fd); deleteSendMsgFromSendMap(pkey->fd); return 0; } int num = 0; int buflen = 0; map<int, list<NET_DATA*>*>* psendmap = CGlobalMgr::getInstance()->getBakSendMap(); map<int, list<NET_DATA*>*>::iterator itersendmap = psendmap->find(pkey->fd); if (itersendmap == psendmap->end()) { LOG(_ERROR_, "CWSAThread::doSendMessage() error, do not find data in m_sendmap, fd=%d", pkey->fd); return 0; } if (itersendmap->second == NULL) { LOG(_ERROR_, "CWSAThread::doSendMessage() error, data in m_sendmap is NULL, fd=%d", pkey->fd); psendmap->erase(itersend); return 0; } while (itersendmap->second->size() > 0) { NET_DATA* pdata = itersendmap->second->front(); if (pdata == NULL) { itersendmap->second->pop_front(); continue; } if (!((itersockmap->second->key->fd == pdata->fd) && (itersockmap->second->key->connect_time == pdata->connect_time))) { LOG(_ERROR_, "CWSAThread::doSendMessage() error, data and socket don't match in fd and connect_time, data fd=%d", pdata->fd); LOGHEX(_ERROR_, "the send message:", pdata->pdata, pdata->data_len); delete pdata; itersendmap->second->pop_front(); continue; } buflen = pdata->data_len; int nsend = send_msg(pdata->fd, pdata->pdata, buflen); if (nsend < 0) { LOG(_ERROR_, "CWSAThread::doSendMessage() error, send_msg() failed, fd=%d", pdata->fd); LOGHEX(_DEBUG_, "send message failed:", pdata->pdata, pdata->data_len); deleteSendMsgFromSendMap(pkey->fd); return -1; } else if (nsend == 0) { //TODO, check here num = pdata->data_len - buflen; if (num > 0) { LOG(_INFO_, "CWSAThread::doSendMessage() error, send_msg() send part of data, fd=%d, len=%d", pdata->fd, buflen); LOGHEX(_DEBUG_, "send part message:", pdata->pdata, buflen); pdata->data_len = num; memmove(pdata->pdata, pdata->pdata + buflen, num); } else { LOG(_INFO_, "CWSAThread::doSendMessage() successed, fd=%d, time=%u, peerip=%s, port=%d", pdata->fd, pdata->connect_time, GETNULLSTR(pdata->peer_ip), pdata->peer_port); LOGHEX(_DEBUG_, "send message:", pdata->pdata, buflen); delete pdata; itersendmap->second->pop_front(); } break; } else { LOG(_INFO_, "CWSAThread::doSendMessage() successed, fd=%d, time=%u, peerip=%s, port=%d", pdata->fd, pdata->connect_time, GETNULLSTR(pdata->peer_ip), pdata->peer_port); LOGHEX(_DEBUG_, "send message:", pdata->pdata, buflen); delete pdata; itersendmap->second->pop_front(); continue; } }//end while if (itersendmap->second->size() <= 0) { delete itersendmap->second; itersendmap->second = NULL; psendmap->erase(itersendmap); } return 1; }