void MessageEvent::toVariantMap(QVariantMap &map) const { NetworkEvent::toVariantMap(map); map["messageType"] = msgType(); map["messageFlags"] = (int)msgFlags(); map["bufferType"] = bufferType(); map["text"] = text(); map["sender"] = sender(); map["target"] = target(); }
// ----------------------------------------------------------------------------- // CCbsRecEtelMonitor::RunL // Becomes active when EPOC Telephony Server has copied a CB message to // iMsgData. The message is then given to CCbsRecEtel for // processing. // Finally this function re-issues the ReceiveMessage request. // (other items were commented in a header). // ----------------------------------------------------------------------------- // void CCbsRecEtelMonitor::RunL() { CBSLOGSTRING2("CBSSERVER: >>> CCbsRecEtelMonitor::RunL(), iStatus: %d", iStatus.Int() ); if ( iStatus == KErrNone ) { CCbsMessage* currentMessage = NULL; TCbsMessageType msgType( ECbsMessageTypeUnspecified ); CBSLOGSTRING("CBSSERVER: CCbsRecEtelMonitor::RunL(): Calling CreateMessageL()..." ); currentMessage = iFactory.CreateMessageL( iMsgData, iAttributes, msgType ); CBSLOGSTRING("CBSSERVER: CCbsRecEtelMonitor::RunL(): CreateMessageL() called OK." ); if ( currentMessage ) { if ( msgType == ECbsMessageLivecast ) { CBSLOGSTRING("CBSSERVER: CCbsRecEtelMonitor::RunL(): LC message" ); if ( iNewstickerSupported ) { // Ownership of currentMessage transferred to iLivecastHandler CBSLOGSTRING("CBSSERVER: CCbsRecEtelMonitor::RunL(): Calling HandleLivecastMessageL()..." ); TInt lcResult( KErrNone ); TRAP( lcResult, iLivecastHandler.HandleLivecastMessageL( currentMessage ) ); CBSLOGSTRING2("CBSSERVER: CCbsRecEtelMonitor::RunL(): HandleLivecastMessageL() finished, result: %d", lcResult ); } else { CBSLOGSTRING("CBSSERVER: CCbsRecEtelMonitor::RunL(): NewsSticker is not supported" ); } } else { CBSLOGSTRING("CBSSERVER: CCbsRecEtelMonitor::RunL(): Normal message" ); // Ownership of currentMessage transferred to iEtel CBSLOGSTRING("CBSSERVER: CCbsRecEtelMonitor::RunL(): Calling HandleMessageReceivedL()..." ); TInt result( KErrNone ); TRAP( result, iEtel.HandleMessageReceivedL( currentMessage ) ); CBSLOGSTRING2("CBSSERVER: CCbsRecEtelMonitor::RunL(): HandleMessageReceivedL() finished, result: %d", result ); } } // Renew the request IssueRequest(); } CBSLOGSTRING("CBSSERVER: <<< CCbsRecEtelMonitor::RunL()"); }
Foam::IPstream::IPstream ( const commsTypes commsType, const int fromProcNo, const label bufSize, streamFormat format, versionNumber version ) : Pstream(commsType, bufSize), Istream(format, version), fromProcNo_(fromProcNo), messageSize_(0) { setOpened(); setGood(); MPI_Status status; // If the buffer size is not specified, probe the incomming message // and set it if (!bufSize) { MPI_Probe(procID(fromProcNo_), msgType(), MPI_COMM_WORLD, &status); MPI_Get_count(&status, MPI_BYTE, &messageSize_); buf_.setSize(messageSize_); } messageSize_ = read(commsType, fromProcNo_, buf_.begin(), buf_.size()); if (!messageSize_) { FatalErrorIn ( "IPstream::IPstream(const int fromProcNo, " "const label bufSize, streamFormat format, versionNumber version)" ) << "read failed" << Foam::abort(FatalError); } }
int GmpProtocol::frameFieldCount() const { int type = msgType(); // frameFieldCountMap contains the frameFieldCounts for each // msgType - this is built on demand and cached for subsequent use // lookup if we have already cached ... if (frameFieldCountMap.contains(type)) return frameFieldCountMap.value(type); // ... otherwise calculate and cache int count = 0; for (int i = 0; i < FIELD_COUNT; i++) { if (fieldFlags(i).testFlag(AbstractProtocol::FrameField)) count++; } frameFieldCountMap.insert(type, count); return count; }
QVariant IgmpProtocol::fieldData(int index, FieldAttrib attrib, int streamIndex) const { switch (index) { case kRsvdMrtCode: { uint mrt = 0; quint8 mrcode = 0; if (msgType() == kIgmpV3Query) { mrt = data.max_response_time(); mrcode = quint8(mrc(mrt)); } else if (msgType() == kIgmpV2Query) { mrt = data.max_response_time(); mrcode = mrt & 0xFF; } switch(attrib) { case FieldName: if (isQuery()) return QString("Max Response Time"); else return QString("Reserved"); case FieldValue: return mrt; case FieldTextValue: return QString("%1").arg(mrt); case FieldFrameValue: return QByteArray(1, mrcode); default: break; } break; } case kGroupAddress: { quint32 grpIp = ipUtils::ipAddress( data.group_address().v4(), data.group_prefix(), ipUtils::AddrMode(data.group_mode()), data.group_count(), streamIndex); switch(attrib) { case FieldName: return QString("Group Address"); case FieldValue: case FieldTextValue: return QHostAddress(grpIp).toString(); case FieldFrameValue: { QByteArray fv; fv.resize(4); qToBigEndian(grpIp, (uchar*) fv.data()); return fv; } default: break; } break; } case kSources: { switch(attrib) { case FieldName: return QString("Source List"); case FieldValue: { QStringList list; for (int i = 0; i < data.sources_size(); i++) list.append(QHostAddress(data.sources(i).v4()).toString()); return list; } case FieldFrameValue: { QByteArray fv; fv.resize(4 * data.sources_size()); for (int i = 0; i < data.sources_size(); i++) qToBigEndian(data.sources(i).v4(), (uchar*)(fv.data()+4*i)); return fv; } case FieldTextValue: { QStringList list; for (int i = 0; i < data.sources_size(); i++) list.append(QHostAddress(data.sources(i).v4()).toString()); return list.join(", "); } default: break; } break; } case kGroupRecords: { switch(attrib) { case FieldValue: { QVariantList grpRecords = GmpProtocol::fieldData( index, attrib, streamIndex).toList(); for (int i = 0; i < data.group_records_size(); i++) { QVariantMap grpRec = grpRecords.at(i).toMap(); OstProto::Gmp::GroupRecord rec = data.group_records(i); grpRec["groupRecordAddress"] = QHostAddress( rec.group_address().v4()).toString(); QStringList sl; for (int j = 0; j < rec.sources_size(); j++) sl.append(QHostAddress(rec.sources(j).v4()).toString()); grpRec["groupRecordSourceList"] = sl; grpRecords.replace(i, grpRec); } return grpRecords; } case FieldFrameValue: { QVariantList list = GmpProtocol::fieldData( index, attrib, streamIndex).toList(); QByteArray fv; for (int i = 0; i < data.group_records_size(); i++) { OstProto::Gmp::GroupRecord rec = data.group_records(i); QByteArray rv = list.at(i).toByteArray(); rv.insert(4, QByteArray(4+4*rec.sources_size(), char(0))); qToBigEndian(rec.group_address().v4(), (uchar*)(rv.data()+4)); for (int j = 0; j < rec.sources_size(); j++) { qToBigEndian(rec.sources(j).v4(), (uchar*)(rv.data()+8+4*j)); } fv.append(rv); } return fv; } case FieldTextValue: { QStringList list = GmpProtocol::fieldData( index, attrib, streamIndex).toStringList(); for (int i = 0; i < data.group_records_size(); i++) { OstProto::Gmp::GroupRecord rec = data.group_records(i); QString recStr = list.at(i); QString str; str.append(QString("Group: %1").arg( QHostAddress(rec.group_address().v4()).toString())); str.append("; Sources: "); QStringList sl; for (int j = 0; j < rec.sources_size(); j++) sl.append(QHostAddress(rec.sources(j).v4()).toString()); str.append(sl.join(", ")); recStr.replace("XXX", str); list.replace(i, recStr); } return list.join("\n").insert(0, "\n"); } default: break; } break; } default: break; } return GmpProtocol::fieldData(index, attrib, streamIndex); }
Foam::label Foam::IPstream::read ( const commsTypes commsType, const int fromProcNo, char* buf, const std::streamsize bufSize ) { if (commsType == blocking || commsType == scheduled) { MPI_Status status; if ( MPI_Recv ( buf, bufSize, MPI_PACKED, procID(fromProcNo), msgType(), MPI_COMM_WORLD, &status ) ) { FatalErrorIn ( "IPstream::read" "(const int fromProcNo, char* buf, std::streamsize bufSize)" ) << "MPI_Recv cannot receive incomming message" << Foam::abort(FatalError); return 0; } // Check size of message read label messageSize; MPI_Get_count(&status, MPI_BYTE, &messageSize); if (messageSize > bufSize) { FatalErrorIn ( "IPstream::read" "(const int fromProcNo, char* buf, std::streamsize bufSize)" ) << "buffer (" << label(bufSize) << ") not large enough for incomming message (" << messageSize << ')' << Foam::abort(FatalError); } return messageSize; } else if (commsType == nonBlocking) { MPI_Request request; if ( MPI_Irecv ( buf, bufSize, MPI_PACKED, procID(fromProcNo), msgType(), MPI_COMM_WORLD, &request ) ) { FatalErrorIn ( "IPstream::read" "(const int fromProcNo, char* buf, std::streamsize bufSize)" ) << "MPI_Recv cannot start non-blocking receive" << Foam::abort(FatalError); return 0; } PstreamGlobals::IPstream_outstandingRequests_.append(request); return 1; } else { FatalErrorIn ( "IPstream::read" "(const int fromProcNo, char* buf, std::streamsize bufSize)" ) << "Unsupported communications type " << commsType << Foam::abort(FatalError); return 0; } }
bool Foam::OPstream::write ( const commsTypes commsType, const int toProcNo, const char* buf, const std::streamsize bufSize ) { bool transferFailed = true; if (commsType == blocking) { transferFailed = MPI_Bsend ( const_cast<char*>(buf), bufSize, MPI_PACKED, procID(toProcNo), msgType(), MPI_COMM_WORLD ); } else if (commsType == scheduled) { transferFailed = MPI_Send ( const_cast<char*>(buf), bufSize, MPI_PACKED, procID(toProcNo), msgType(), MPI_COMM_WORLD ); } else if (commsType == nonBlocking) { MPI_Request request; transferFailed = MPI_Isend ( const_cast<char*>(buf), bufSize, MPI_PACKED, procID(toProcNo), msgType(), MPI_COMM_WORLD, &request ); PstreamGlobals::OPstream_outstandingRequests_.append(request); } else { FatalErrorIn ( "OPstream::write" "(const int fromProcNo, char* buf, std::streamsize bufSize)" ) << "Unsupported communications type " << commsType << Foam::abort(FatalError); } return !transferFailed; }
IPstream::IPstream ( const int fromProcNo, const label bufSize, streamFormat format, versionNumber version ) : Pstream(bufSize), Istream(format, version), fromProcNo_(fromProcNo), messageSize_(0) { setOpened(); setGood(); int bufid, tag, tid; // If the buffer size is not specified then probe the incomming message if (!bufSize) { // Probe read buffer until message arrives. while (!(bufid = pvm_probe(procID(fromProcNo_), msgType()))); // When the message arrives find its size pvm_bufinfo(bufid, &messageSize_, &tag, &tid); // Resize buffer to message size buf_.setSize(messageSize_); } // Read message into buffer if ( pvm_precv ( procID(fromProcNo_), msgType(), buf_.begin(), buf_.size(), PVM_BYTE, &tid, &tag, &messageSize_ ) != PvmOk ) { FatalErrorIn("IPstream::IPstream(const int fromProcNo)") << "pvm_precv cannot receive incomming message" << ::abort; } // Check size of message read if (messageSize_ > buf_.size()) { FatalErrorIn("IPstream::IPstream(const int fromProcNo)") << "buffer (" << buf_.size() << ") not large enough for incomming message (" << messageSize_ << ')' << ::abort; } }