/*!
    Dispatch the SMS datagram \a msg according to its SMS port number
    or WAP Push MIME type.  This is used by telephony services that
    accept incoming SMS messages to dispatch them according to the
    installed services.  Returns true if the message was dispatched,
    or false if no service exists that can handle the message.

    See the documentation for QSMSMessage::destinationPort() for more
    information on how WAP push messages and SMS datagrams are dispatched.

    \sa QSMSMessage::destinationPort()
*/
bool QTelephonyService::dispatchDatagram( const QSMSMessage& msg )
{
    QString chan, type;
    QDSServiceInfo info;
    QByteArray payload;
    QByteArray raw;

    // If the message does not have a port number, then it isn't a datagram.
    int port = msg.destinationPort();
    if ( port == -1 )
        return dispatchFlashMessage( msg );

    // Recognise port numbers that may contain WAP push datagrams.
    // We want to check the content type to see if we have a
    // specialised handler for it before dispatching by port number.
    if ( port == 2948 || port == 49999 ) {
        type = QWspPush::quickContentType( msg.applicationData() );
        qLog(Modem) << "WAP push message of type " << type;
        QDSServices services( type, QString(), QStringList() << "push" );
        if ( !services.isEmpty() ) {
            info = services.first();
            QByteArray a = msg.applicationData();
            QBuffer pushpdu(&a);
            pushpdu.open(QIODevice::ReadOnly);
            QWspPduDecoder decoder(&pushpdu);
            QWspPush push = decoder.decodePush();
            payload = push.data();
        }
    }

    // See if we have a registered service for this port number.
    if ( !info.isValid() ) {
        qLog(Modem) << "SMS datagram on port " << port;
        type = "application/x-smsapp-" + QString::number(port);
        QDSServices services( type, QString(), QStringList() << "push" );
        if ( !services.isEmpty() ) {
            info = services.first();
            payload = msg.applicationData();
        } else {
            return dispatchFlashMessage( msg );
        }
    }

    // Pack the entire SMS message into a raw datastream, to be sent
    // along with the message as auxillary data.  This allows programs
    // that need the full SMS/WAP headers to access them.
    {
        QDataStream stream
            ( &raw, QIODevice::WriteOnly | QIODevice::Append );
        stream << msg;
    }

    // Send the datagram to the specified QDS service for processing.
    QDSAction action( info );
    action.invoke( QDSData( payload, QMimeType( type ) ), raw );

    // The datagram has been dispatched.
    return true;
}
Exemple #2
0
/*!
    Constructs an action request for a service with no request data. The service
    responding to the request is provided in \a serviceInfo and the channel
    for responding to the client is provided in \a channel. The request is
    attached to \a parent.
*/
QDSActionRequest::QDSActionRequest( const QDSServiceInfo& serviceInfo,
                                    const QString& channel,
                                    QObject* parent )
:   QObject( parent ),
    d( 0 )
{
    d = new QDSActionRequestPrivate( serviceInfo, QDSData(), QByteArray(), channel );

    if ( !d->mServiceInfo.supportsRequestDataType( QMimeType(QString()) ) )
        respond( QString( tr( "request didn't contain data" ) ) );
}
// Check for and dispatch flash sms messages.
static bool dispatchFlashMessage( const QSMSMessage& msg )
{
    if ( msg.messageClass() != 0 )
        return false;
    qLog(Modem) << "SMS flash message";
    QString type = "application/x-sms-flash";
    QDSServices services( type, QString(), QStringList() << "push" );
    if ( !services.isEmpty() ) {
        QDSAction action( services.first() );
        QByteArray payload;
        {
            QDataStream stream
                ( &payload, QIODevice::WriteOnly | QIODevice::Append );
            stream << msg;
        }
        action.invoke( QDSData( payload, QMimeType( type ) ) );
        return true;
    } else {
        return false;
    }
}
Exemple #4
0
template <typename Stream> void QDSActionRequest::deserialize(Stream &stream)
{
    // Service info
    QDSServiceInfo info;
    stream >> info;
    d->mServiceInfo = info;

    // Request data
    bool validRequestData = false;
    stream >> validRequestData;
    if ( validRequestData ) {
        QDSData data;
        stream >> data;
        d->mRequestData = data;
    } else {
        d->mRequestData = QDSData();
    }

    // Response Data
    bool validResponseData = false;
    stream >> validResponseData;
    if ( validResponseData ) {
        QDSData data;
        stream >> data;
        d->mResponseData = data;
    } else {
        d->mResponseData = QDSData();
    }

    // Auxiliary data
    QByteArray auxData;