Esempio n. 1
0
void QModemService::init( QSerialIODeviceMultiplexer *mux )
{
    d = new QModemServicePrivate();
    d->mux = mux;
    d->primaryAtChat = mux->channel( "primary" )->atchat();
    d->secondaryAtChat = mux->channel( "secondary" )->atchat();

    // Make sure that the primary command channel is open and valid.
    QSerialIODevice *primary = d->mux->channel( "primary" );
    if ( !primary->isOpen() )
        primary->open( QIODevice::ReadWrite );

    // Set a slightly different debug mode for the secondary channel,
    // to make it easier to see which command goes where.
    if ( d->primaryAtChat != d->secondaryAtChat )
        d->secondaryAtChat->setDebugChars( 'f', 't', 'n', '?' );

    connectToPost( "needsms", this, SLOT(needSms()) );
    connectToPost( "simready", this, SLOT(firstTimeInit()) );

    d->indicators = new QModemIndicators( this );

    // Listen for suspend() and wake() messages on QPE/ModemSuspend.
    QtopiaIpcAdaptor *suspend =
        new QtopiaIpcAdaptor( "QPE/ModemSuspend", this );
    QtopiaIpcAdaptor::connect( suspend, MESSAGE(suspend()),
                               this, SLOT(suspend()) );
    QtopiaIpcAdaptor::connect( suspend, MESSAGE(wake()),
                               this, SLOT(wake()) );
}
Esempio n. 2
0
void NeoModemService::suspend()
{
    qLog(Modem) << " Gta04ModemService::suspend()";
    //chat("AT_OSQI=0");          // unsolicited reporting of antenna signal strength, e.g. "_OSIGQ: 3,0"
    
    primaryAtChat()->suspend();
    QSerialIODevice *port = multiplexer()->channel("primary");
    port->close();

    suspendDone();
}
Esempio n. 3
0
void NeoModemService::wake()
{
    qLog(Modem) << " Gta04ModemService::wake()";
    
    QSerialIODevice *port = multiplexer()->channel("primary");
    port->open(QIODevice::ReadWrite);
    primaryAtChat()->resume();
    
    //primaryAtChat()->resume();
    //chat("AT_OSQI=1");          // unsolicited reporting of antenna signal strength, e.g. "_OSIGQ: 3,0"
    wakeDone();
}
Esempio n. 4
0
/*!
    Creates and returns a vendor-specific modem service handler called \a service
    (the default is \c modem) and attaches it to \a parent.

    The \a device parameter specifies the serial device and baud
    rate to use to communicate with the modem (for example,
    \c{/dev/ttyS0:115200}).

    If \a device is empty, the default serial device specified
    by the \c QTOPIA_PHONE_DEVICE environment variable is used.

    This function will load vendor-specific plug-ins to handle
    extended modem functionality as required.  If the
    \c QTOPIA_PHONE_VENDOR environment variable is set, then that
    vendor plug-in will be loaded.  Otherwise this function will
    issue the \c{AT+CGMI} command and ask each vendor plug-in if
    it supports the returned manufacturer value.

    \sa QModemServicePlugin
*/
QModemService *QModemService::createVendorSpecific
        ( const QString& service, const QString& device, QObject *parent )
{
    QSerialIODeviceMultiplexer *mux;
    QSerialIODevice *dev;
    char *env;

    // Create a multiplexer.  This will consult QTOPIA_PHONE_VENDOR
    // to load a vendor-specific multiplexer plug-in if appropriate.
    if ( device.isEmpty() ) {
        // Create a multiplexer for the default serial device.
        mux = QSerialIODeviceMultiplexer::create();
    } else {
        // Create a multiplexer for the specified serial device.
        dev = QSerialPort::create( device );
        if ( !dev )
            dev = new QNullSerialIODevice();
        mux = QSerialIODeviceMultiplexer::create( dev );
    }

    // Get the name of the vendor modem plug-in to load.
    env = getenv( "QTOPIA_PHONE_VENDOR" );
#ifdef QTOPIA_PHONE_VENDOR
    if ( !env || *env == '\0' )
        env = QTOPIA_PHONE_VENDOR;  // Allow custom.h to override.
#endif

    // Handle vendor-specific modem plug-ins.
    static QPluginManager *pluginLoader = 0;
    if (!pluginLoader)
        pluginLoader = new QPluginManager( "phonevendors" );
    QModemServicePluginInterface *plugin;
    QModemService *serv = 0;
    QString name;
    QObject *obj;
    if ( env && *env != '\0' ) {

        // Load the specified plug-in and call its creation function.
        name = QString(env) + "vendor";
        qLog(Modem) << "querying single modem plug-in" << name;
        obj = pluginLoader->instance( name );
        if( ( plugin = qobject_cast<QModemServicePluginInterface*>( obj ) )
                    != 0 ) {
            if( plugin->keys().contains( "QModemServicePluginInterface" ) ) {
                serv = plugin->create( service, mux, parent );
            }
        }

    } else {

        // Send AT+CGMI to the modem to determine its type.
        QSerialIODevice *primary = mux->channel( "primary" );
        if ( !primary->isOpen() )
            primary->open( QIODevice::ReadWrite );
        QString manufacturer =
            QSerialIODeviceMultiplexer::chatWithResponse( primary, "AT+CGMI" );
        if ( !manufacturer.isEmpty() ) {

            // Scan all modem plug-ins until one says it supports the value.
            QStringList list = pluginLoader->list();
            QStringList::Iterator it;
            for ( it = list.begin(); it != list.end(); ++it ) {
                name = *it;
                qLog(Modem) << "querying modem plug-in" << name;
                obj = pluginLoader->instance( name );
                if( ( plugin = qobject_cast
                        <QModemServicePluginInterface*>( obj ) ) != 0 ) {
                    if( plugin->keys().contains
                            ( "QModemServicePluginInterface" ) &&
                        plugin->supports( manufacturer ) ) {
                        serv = plugin->create( service, mux, parent );
                        break;
                    }
                }
            }

        }

    }

    // If we don't have a service yet, then create the default implementation.
    if ( !serv ) {
        qLog(Modem) << "No modem vendor plug-in found - using default";
        serv = new QModemService( service, mux, parent );
    }

    // Return the new service to the caller.
    return serv;
}
Esempio n. 5
0
/*!
    \reimp
*/
void QModemService::initialize()
{
    // If the modem does not exist, then tell clients via QServiceChecker.
    if ( !supports<QServiceChecker>() ) {
        QSerialIODevice *primary = d->mux->channel( "primary" );
        addInterface( new QServiceCheckerServer
            ( service(), primary->isValid(), this ) );
    }

    if ( !supports<QSimInfo>() )
        addInterface( new QModemSimInfo( this ) );

    if ( !supports<QPinManager>() )
        addInterface( new QModemPinManager( this ) );

    if ( !supports<QNetworkRegistration>() )
        addInterface( new QModemNetworkRegistration( this ) );

    if ( !supports<QPreferredNetworkOperators>() )
        addInterface( new QModemPreferredNetworkOperators( this ) );

    if ( !supports<QCallBarring>() )
        addInterface( new QModemCallBarring( this ) );

    if ( !supports<QCallForwarding>() )
        addInterface( new QModemCallForwarding( this ) );

    if ( !supports<QCallSettings>() )
        addInterface( new QModemCallSettings( this ) );

    if ( !supports<QSMSReader>() )
        addInterface( new QModemSMSReader( this ) );

    if ( !supports<QSMSSender>() )
        addInterface( new QModemSMSSender( this ) );

    if ( !supports<QSimToolkit>() )
        addInterface( new QModemSimToolkit( this ) );

    if ( !supports<QSimFiles>() )
        addInterface( new QModemSimFiles( this ) );

    if ( !supports<QSimGenericAccess>() )
        addInterface( new QModemSimGenericAccess( this ) );

    if ( !supports<QPhoneBook>() )
        addInterface( new QModemPhoneBook( this ) );

    if ( !supports<QCellBroadcast>() )
        addInterface( new QModemCellBroadcast( this ) );

    if ( !supports<QServiceNumbers>() )
        addInterface( new QModemServiceNumbers( this ) );

    if ( !supports<QSupplementaryServices>() )
        addInterface( new QModemSupplementaryServices( this ) );

    if ( !supports<QTelephonyConfiguration>() )
        addInterface( new QModemConfiguration( this ) );

    if ( !supports<QPhoneRfFunctionality>() )
        addInterface( new QModemRfFunctionality( this ) );

    if ( !supports<QVibrateAccessory>() )
        addInterface( new QModemVibrateAccessory( this ) );

    if ( !supports<QGprsNetworkRegistration>() )
        addInterface( new QModemGprsNetworkRegistration( this ) );

    if ( !supports<QCallVolume>() )
        addInterface( new QModemCallVolume( this ) );

    // Create a default modem call provider if necessary.
    if ( !callProvider() )
        setCallProvider( new QModemCallProvider( this ) );

    QTelephonyService::initialize();
}