void QPhoneCallDummy::dial( const QDialOptions& options )
{
    // Change to the "Dialing" state and notify everyone who is interested.
    setNumber( options.number() );
    setState( QPhoneCall::Dialing );

    // Start a timer to transition to the hangup state after 3 seconds.
    QTimer::singleShot( 3000, this, SLOT(dialTimeout()) );
}
Exemple #2
0
/*!
  Dials a \a number if there are no currently active calls. If a
  \a contact is specified, it is used as the contact to display and
  insert into the call history. Before calling this function,
  you should check that there are no incoming calls, or active calls.
  If \a sendcallerid is true, then send the caller's identifier as part
  of the dial sequence.

  If \a callType is "Voice" a GSM call will be dialed.  If \a callType is
  "VoIP" a VoIP call will be dialed.
*/
void DialerControl::dial( const QString &number, bool sendcallerid, const QString& callType, const QUniqueId &contact )
{

    QUniqueId matchedContact;
    if (contact.isNull() && !number.isEmpty())
        matchedContact = ServerContactModel::instance()->matchPhoneNumber(number).uid();
    else
        matchedContact = contact;

    if ( isDialing() ) {
        //qWarning("BUG! Attempt to dial while there is already a dialing call");
    }
    if( !hasActiveCalls() && !isDialing() )
    {
        // Collect up the dial options.
        QDialOptions dialopts;
        dialopts.setNumber( number );
        if ( sendcallerid )
            dialopts.setCallerId( QDialOptions::SendCallerId );
        else
            dialopts.setCallerId( QDialOptions::DefaultCallerId );
        dialopts.setContact( matchedContact );

        // Allow other parts of the server (e.g. GsmKeyActions) to
        // modify the dial options to account for supplementary services.
        bool handledAlready = false;
        emit modifyDial( dialopts, handledAlready );
        if ( handledAlready )
            return;

        // Call the specified number.
        QPhoneCall call = createCall(callType);
        phoneValueSpace.setAttribute( "LastDialedCall", QVariant(number) );
        call.dial( dialopts );

        // cache call here to preserve the information even if the battery run out.
        cacheCall( call );
    }
}
Exemple #3
0
void FsoPhoneCall::dial( const QDialOptions& options )
{
    QString number = options.number();
    setNumber( number );
    
    qDebug() << "FsoPhoneCall::dial(" << number << ")";

    // If the number starts with '*' or '#', then this is a request
    // for a supplementary service, not an actual phone call.
    // So we dial and then immediately hang up, allowing the network
    // to send us the SS/USSD response when it is ready.
    if ( number.startsWith("*") || number.startsWith("#") ) {
        service->suppl_services.sendSupplementaryServiceData(number);
        setState( QPhoneCall::ServiceHangup );
        return;
    }
    
    QFsoDBusPendingCall call = service->gsmCall.Initiate(number, "voice");
    watchFsoCall(call, this, SLOT(initiateFinished(QFsoDBusPendingCall &)));
    setState(QPhoneCall::Dialing);
}
Exemple #4
0
void TestPhoneCallImpl::dial( const QDialOptions& options )
{
    provider().beginStateTransaction();
    if ( hasCall( QPhoneCall::Dialing ) ) {
        // There is already a dialing call.
        setState( QPhoneCall::HangupLocal );
        provider().endStateTransaction();
        return;
    }
    if ( hasCall( QPhoneCall::Connected ) ) {
        if ( hasCall( QPhoneCall::Hold ) ) {
            // No free slots for the dialing call.
            setState( QPhoneCall::HangupLocal );
            provider().endStateTransaction();
            return;
        }
        findCall( QPhoneCall::Connected )->setState( QPhoneCall::Hold );
    }
    setNumber( options.number() );
    setState( QPhoneCall::Dialing );
    provider().endStateTransaction();
    QTimer::singleShot( 1000, this, SLOT(connectTimeout()) );
}
Exemple #5
0
bool DialupImpl::start( const QVariant /*options*/ )
{
    if ( ifaceStatus != QtopiaNetworkInterface::Down ) {
        switch ( ifaceStatus )
        {
            case QtopiaNetworkInterface::Unknown:
                updateTrigger( QtopiaNetworkInterface::NotInitialized,
                        tr("Interface hasn't been initialized yet.") );
                break;
            case QtopiaNetworkInterface::Unavailable:
                updateTrigger( QtopiaNetworkInterface::NotAvailable,
                        tr("Interface is not available.") );
                break;
            case QtopiaNetworkInterface::Up:
            case QtopiaNetworkInterface::Pending:
            case QtopiaNetworkInterface::Demand:
                updateTrigger( QtopiaNetworkInterface::NotConnected,
                        tr("Interface already started/active.") );
                break;
            default:
                break;
        }
        qLog(Network) << "ppp interface cannot be started "
            <<configIface->configFile();
        return false;
    }

    QtopiaNetworkProperties prop = configIface->getProperties();
    QStringList args;

    const bool demand = prop.value("Properties/Autostart").toString() == "y";
    const QtopiaNetwork::Type t = type();
#ifdef QTOPIA_CELL
    if ( t & QtopiaNetwork::PhoneModem ) {
        if ( regState != QTelephony::RegistrationHome &&
                regState != QTelephony::RegistrationRoaming ) {
            //we want to start the network but we don't have a network
            //registration yet. wait till registration is done then go ahead
            //and start iface
            qLog(Network) << "Cannot start dialup yet due to missing"
                << "network registration. try again later";
            registrationStateChanged(); //ask for first update
            updateTrigger( QtopiaNetworkInterface::NotConnected,
                    tr("Missing network registration. Try again later.") );
            return false;

        }
    }
#endif
    if ( t & QtopiaNetwork::NamedModem || t & QtopiaNetwork::PCMCIA ) {
        QString dev = device();
        if ( dev.isEmpty() || dev == "internal") {
            qLog(Network) << "No external device";
            updateTrigger( QtopiaNetworkInterface::NotConnected,
                    tr("Missing external serial device.") );
            return false;
        }
        if ( dev.startsWith("/dev/") )
            dev = dev.mid(5);
        args << dev;
        args << "updetach";
    }
#ifdef QTOPIA_CELL
    else {
        args << "nodetach";
    }
#endif

    args << "debug";
    args << "call";
    const QString peerID = prop.value("Serial/PeerID").toString();
    if ( peerID.isEmpty() ) {
        qLog(Network) << "Missing peer ID";
        updateTrigger( QtopiaNetworkInterface::NotConnected,
                tr("Missing peer ID. Please reconfigure device.") );
        return false;
    }
    args << peerID;

    QString password = prop.value("Properties/Password").toString();
    if (!password.isEmpty()) {
        args << "password";
        args << password;
    }

    const QString logfile = Qtopia::tempDir() + "qpe-pppd-log-"+peerID;
    args << "logfile";
    args << logfile;
    QFile::remove( logfile ) ;

    if ( t & QtopiaNetwork::NamedModem || t & QtopiaNetwork::PCMCIA ) {
        qLog(Network) << "###################################";
        qLog(Network) << "Starting ppp using external modem: " <<
            args.join(" ");
        args.prepend("start"); //cmd for network script

        thread.addScriptToRun( pppScript, args );
    } else { //QtopiaNetwork::PhoneModem
#ifdef QTOPIA_CELL
        const QString path = Qtopia::applicationFileName("Network", "chat");
        const QString connectF = path+"/connect-"+peerID;
        const QString disconnectF = path+"/disconnect-"+peerID;


        //Create a data call
        qLog(Network) << "###################################";
        qLog(Network) << "Starting ppp using internal modem: " <<
            args.join(" ");
        qLog(Network) << "connect: " << connectF;
        qLog(Network) << "disconnect: " << disconnectF;
        qLog(Network) << "demand dialing: " << (demand ? "yes" : "no");

        QDialOptions pppd;
        pppd.setUseIpModule( true );
        pppd.setIpProgramName( PPPD_BINARY );

        pppd.setIpConnectScript( connectF );
        pppd.setIpDisconnectScript( disconnectF );
        pppd.setIpDemandDialing( demand );
        pppd.setIpArgs( args );

        //Make sure that an existing call is stopped.
        if ( !dataCall.isNull() ) {
            dataCall.hangup();
        }

        if ( !callManager )
            callManager = new QPhoneCallManager( this );
        //Dial the new call.
        if ( callManager ) {
            dataCall = callManager->create( "IP" );
            dataCall.connectNotification( this, 
                    SLOT(connectNotification(QPhoneCall,QPhoneCall::Notification,QString)));
            dataCall.connectStateChanged( this, SLOT(phoneCallStateChanged(QPhoneCall)) );

            dataCall.dial( pppd );
        } else {
            qLog(Network) << "No call manager created";
        }
#endif
    }

    state = Initialize;
    logIndex = 0;
    tidStateUpdate = startTimer( 1000 );
    if ( demand )
        ifaceStatus = QtopiaNetworkInterface::Demand;
    else
        ifaceStatus = QtopiaNetworkInterface::Pending;
    netSpace->setAttribute( "State", ifaceStatus );
    updateTrigger();
    delayedGatewayInstall = true;
    return true;
}