Exemplo n.º 1
0
int AbstractSyncSource::addItem(SyncItem& item)
{
    QByteArray data((char *)item.getData());
    QUniqueId id = m_model->addRecord(data, QPimSource(), m_type);
    item.setKey(id.toString().toAscii().data());
    m_model->updateRecord(id, data, m_type);
    //qDebug() << "AbstractSyncSource::addItem() " << toString(item) << "Id:" << id.toString();
    if (!id.isNull())
        return 201;    //ok, the requested item was added
    else
        return 500;    //failed, the recipient encountered an error
}
Exemplo n.º 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 );
    }
}
Exemplo n.º 3
0
TaskDialog::TaskDialog( const QTask& task, QWidget *parent,
        Qt::WFlags fl )
    : QDialog( parent, fl), todo( task ),
    inputNotes(0), inputNotesQC(0),
    dueCheck(0), startedCheck(0), completedCheck(0),
    dueEdit(0), startedEdit(0), completedEdit(0),
    inputDescription(0), comboPriority(0), comboStatus(0),
    spinComplete(0), comboCategory(0), recurDetails(0), reminderPicker(0),
    recurStack(0), recurControls(0)
{
    QUniqueId id = todo.dependentChildrenOfType(QString("duedate")).value(0);

    newTask = false;

    // grab the reminder defaults from Datebook
    bool setAlarm = true;

    {
        QSettings config("Trolltech","DateBook");
        config.beginGroup("Main");
        defaultReminderTime = QTime(config.value("startviewtime", 8).toInt(), 0);
        setAlarm = config.value("alarmpreset").toBool();
    }

    if (!id.isNull()) {
        QAppointmentModel am;
        todoAppt = am.appointment(id);

        // Preload this, since alarm minutes for NoAlarm aren't stored in the db
        if (todoAppt.alarm() == QAppointment::NoAlarm)
            todoAppt.setAlarm(-(defaultReminderTime.hour() * 60 + defaultReminderTime.minute()), QAppointment::NoAlarm);
    } else {
        todoAppt.setAlarm(-(defaultReminderTime.hour() * 60 + defaultReminderTime.minute()), setAlarm ? QAppointment::Audible : QAppointment::NoAlarm);
        todoAppt.setAllDay();
    }

    init();
}
Exemplo n.º 4
0
void DialerControl::callStateChanged( const QPhoneCall& call )
{
    // Set value space appropriately
    // XXX Optimize for redundancy!
    if(hasIncomingCall()) {
        QPhoneCall icall = incomingCall();
        QString number = icall.number();
        QString name;
        QUniqueId contact = icall.contact();
        QContactModel *m = ServerContactModel::instance();
        if(!contact.isNull()) {
            QContact cnt = m->contact(contact);
            if (!cnt.uid().isNull())
                name = cnt.label();
        } else if(!number.isEmpty()) {
            QContact cnt = m->matchPhoneNumber(number);
            if (!cnt.uid().isNull())
                name = cnt.label();
        } else {
            number = tr("Unknown", "Unknown caller");
        }
        phoneValueSpace.setAttribute("Incoming/Number", QVariant(number.trimmed()));
        phoneValueSpace.setAttribute("Incoming/Name", QVariant(name));

        if(!aaTid && mProfiles->activeProfile().autoAnswer())
            aaTid = startTimer(auto_answer_gap);
    } else {
        if(aaTid)
            killTimer(aaTid);
        phoneValueSpace.removeAttribute("Incoming");
    }

    // emit useful signals
    if( call.state() == QPhoneCall::Connected )
    {
        emit callConnected( call );
        // update cached call info.
        updateCachedCall( call );
    }
    else if( call.state() == QPhoneCall::Hold )
    {
        emit callPutOnHold( call );
    }
    else if( call.dialing() )
    {
        emit callDialing( call );
    }
    else if( call.incoming() )
    {
        // Turn off screen saver so the incoming call will be visible.
        QtopiaPowerManager::setActive(false);

        emit callIncoming( call );
    }
    else if ( call.dropped()  )
    {
        emit callDropped( call );
    }
    doActiveCalls();

    // Disable screen saver if in a call
    if (hasIncomingCall() || hasActiveCalls() || hasCallsOnHold())
        QtopiaApplication::setPowerConstraint(QtopiaApplication::DisableLightOff);
    else
        QtopiaApplication::setPowerConstraint(QtopiaApplication::Enable);

    emit stateChanged();
}
Exemplo n.º 5
0
SyncItem *AbstractSyncSource::getNext(ItemSet set, bool withData)
{
    //qDebug() << "AbstractSyncSource::getNext(" << set << "," << withData << ")";
    QUniqueId id;
    SyncState state = SYNC_STATE_NONE;
    bool endTransaction = false;

    if (set == All) {
        m_indexAll++;
        if (m_indexAll >= m_model->count()) {
            //qDebug() << "AbstractSyncSource::getNext() No further item available";
            endTransaction = true;
        } else {
            id = m_model->id(m_indexAll);
        }
    } else if (set == New) {
        m_indexNew++;
        if (m_indexNew >= added.size()) {
            //qDebug() << "AbstractSyncSource::getNext() No further new item available";
            endTransaction = true;
        } else {
            state = SYNC_STATE_NEW;
            id = added[m_indexNew];
        }
    } else if (set == Updated) {
        m_indexUpdated++;
        if (m_indexUpdated >= modified.size()) {
            //qDebug() << "AbstractSyncSource::getNext() No further updated item available";
            endTransaction = true;
        } else {
            state = SYNC_STATE_UPDATED;
            id = modified[m_indexUpdated];
        }
    } else if (set == Deleted) {
        m_indexDeleted++;
        if (m_indexDeleted >= removed.size()) {
            //qDebug() << "AbstractSyncSource::getNext() No further deleted item available";
            endTransaction = true;
        } else {
            state = SYNC_STATE_DELETED;
            id = removed[m_indexDeleted];
        }
    }

    if (endTransaction && m_transactionRunning) {
        if (m_model->commitSyncTransaction()) {
            m_transactionRunning = false;
            m_lastSync = m_currentSync;
            //qDebug() << "AbstractSyncSource::getNext() Commit sync";
        } else {
            //qDebug() << "AbstractSyncSource::getNext() Commit sync failed";
        }
    } else {
        if (!id.isNull()) {
            return createSyncItem(id, withData, state);
        } else {
            //qDebug() << "AbstractSyncSource::getNext() Invalid Id";
        }
    }
    return 0;
}