//-----------------------------------------------------------------------------
// SatAppToneProvider::playStandardTone
//-----------------------------------------------------------------------------
void SatAppToneProvider::playStandardTone(
    const QString& text,
    const QByteArray& sequence,
    int duration)
{
    qDebug("SATAPP: SatAppToneProvider::playStandardTone >");

    if (text.length() > 0) {
        mPermanentNote = new HbMessageBox(HbMessageBox::MessageTypeInformation);
        SAT_ASSERT(connect(mPermanentNote, SIGNAL(aboutToClose()),
                this, SLOT(stopPlayTone())));
        mPermanentNote->setText(text);
        mPermanentNote->setStandardButtons(HbMessageBox::Cancel);
        if (duration > 0 ) {
            mPermanentNote->setTimeout(duration);
        }
        mPermanentNote->setDismissPolicy(HbPopup::TapAnywhere);
        qDebug("SatAppToneProvider::playStandardTone show before");
        mPermanentNote->show();
        qDebug("SatAppToneProvider::playStandardTone show after");
    }

    TPtrC8 seq((unsigned char*)sequence.constData(), sequence.length());
    qDebug("SATAPP: SatAppToneProvider::playStandardTone TPtrC8 seq: %S", &seq);
    QT_TRAP_THROWING(SymbianPrepareAudioToneUtilityL(seq));

    if (duration > 0) {
        mTimer = new QTimer(this);
        SAT_ASSERT(connect(mTimer, SIGNAL(timeout()),
                this, SLOT(stopPlayTone())));
        mTimer->start(duration);
    }
    
    qDebug("SATAPP: SatAppToneProvider::playStandardTone <");
}
// ----------------------------------------------------------------------------
// SatAppMenuProvider::loadMainView
// ----------------------------------------------------------------------------
//
void SatAppMenuProvider::loadMainView()
{
    qDebug("SATAPP: SatAppMenuProvider::loadMainView >");

    // create actions
    mSoftKeyQuitAction = new HbAction(Hb::QuitNaviAction,this);
    mSoftKeyBackAction = new HbAction(Hb::BackNaviAction,this);

    bool docmlLoad = false;
    HbDocumentLoader loader;
    // ownership of the objects are transferred to caller
    mObjects = loader.load(SATAPP_DOCML,&docmlLoad);
    Q_ASSERT(docmlLoad);
    qDebug("SATAPP: SatAppMenuProvider main view found");
    // load setupmenu view
    mSetupMenuView = qobject_cast<HbView *>(loader.findWidget
            (SATAPP_SETUPMENU_VIEW));
    // find setupmenu view items
    mListWidget = qobject_cast<HbListWidget *>
        ( loader.findWidget(SATAPP_MENUITEM ));
    // connect setupmenu view menu
    HbAction *menuAction = mSetupMenuView->menu()->addAction(
        hbTrId("txt_common_menu_exit"));
    SAT_ASSERT(connect(menuAction, SIGNAL(triggered()),
        mMainWindow, SLOT(close())));
    SAT_ASSERT(connect(mSoftKeyQuitAction, SIGNAL(triggered()),
        mMainWindow, SLOT(close())));
    // set this view as current view
    mMainWindow->addView(mSetupMenuView);
    mMainWindow->setCurrentView(mSetupMenuView);

    // load selectitem view
    mSelectItemView = qobject_cast<HbView *>(loader.findWidget
            (SATAPP_SELECTITEM_VIEW));
    // find selectitem view items
    mSubTitle = qobject_cast<HbLabel *>
        ( loader.findWidget(SATAPP_SUBTITLE) );
    mSelectListWidget = qobject_cast<HbListWidget *>
        ( loader.findWidget(SATAPP_SELECTITEM ));
    // connect selectitem view menu
    HbAction *menuBack = mSelectItemView->menu()->addAction(
        hbTrId("txt_common_opt_back"));
    SAT_ASSERT(connect(menuBack, SIGNAL(triggered()),
        mSoftKeyBackAction, SIGNAL(triggered())));
    HbAction *menuQuit = mSelectItemView->menu()->addAction(
        hbTrId("txt_common_menu_exit"));

    SAT_ASSERT(connect(menuQuit, SIGNAL(triggered()),
        mMainWindow, SLOT(close())));
    qDebug("SATAPP: SatAppMenuProvider::loadMainView <");

}
// ----------------------------------------------------------------------------
// SatAppMenuProvider::selectItem
// Constructs a SETECT ITEM view
// ----------------------------------------------------------------------------
//
void SatAppMenuProvider::selectItem( SatAppAction &action)
{
    qDebug("SATAPP: SatAppMenuProvider::selectItem >");
    
    if (!mSetupMenuView) {
        loadMainView();
    }
    
    resetState();
    mCurrentAction = &action;
    switchView();
    action.setResponse(ESatSuccess);

    // Set sub title
    QString text = action.value(KeyText).toString();
    if (!text.isEmpty()) {
        mSubTitle->setPlainText(text);
    } else {
        mSubTitle->setPlainText(hbTrId("txt_long_caption_sim_services"));
    }
    qDebug() << "SATAPP: selectItem text=" << text;

    // Set List widget
    QList<QVariant> menu = action.value(KeyMenu).toList();
    mSelectListWidget->clear();
    for(int i = 0; i < menu.count(); i++ ) {
        mSelectListWidget->addItem(menu.at( i ).toString());
    }
    qDebug() << "SATAPP: selectItem menu=" << menu;

    // timeout completes action with ESatNoResponseFromUser
    QTimer::singleShot(KDefaultSelectionTimeoutMseconds,
        mCurrentAction,SLOT(completeWithNoResponse()));
    // back-key completes action with ESatBackwardModeRequestedByUser
    mSelectItemView->setNavigationAction(mSoftKeyBackAction);
    SAT_ASSERT(connect(mSoftKeyBackAction, SIGNAL(triggered()),
        mCurrentAction, SLOT(completeWithBackRequested())));
    SAT_ASSERT(connect(mSelectItemView->menu()->actions().at(1), 
        SIGNAL(triggered()),
        mCurrentAction, SLOT(completeWithSessionTerminated())));
    
    // completes action with ESatSuccess and selected item
    connectItem();

    qDebug("SATAPP: SatAppMenuProvider::selectItem <");
}
Esempio n. 4
0
void ConfigEntry::GetValue(int pos, Vector<T,D> &value)
  const throw(ConfigFileException)
{
  SAT_ASSERT (pos < GetLength ());
  ConfigEntry &entry = operator[](pos);
  for (int i=0; i<D; ++i)
    value[i] = (T)entry[i];
}
//-----------------------------------------------------------------------------
// SatAppToneProvider::playUserSelectedTone
//-----------------------------------------------------------------------------
void SatAppToneProvider::playUserSelectedTone(
    const QString& text,
    int tone,
    int duration)
{
    qDebug("SatAppToneProvider::playUserSelectedTone >");

    // If several messages/calls arrive during a small amount of time and if the
    // message received or incoming call tone is already being played we do not 
    // restart it.
    if (mAudioPlayer) {
        qDebug( "SatAppToneProvider::\
            PlayUserSelectedToneL Error - already played" );
        mCurrentAction->complete(ESatFailure);
        mCurrentAction = 0;
        mState = Idle;
        return;
    }

    if (text.length() > 0) {
        mPermanentNote = new HbMessageBox(HbMessageBox::MessageTypeInformation);
        mPermanentNote->setText(text);
        mPermanentNote->setStandardButtons(HbMessageBox::Cancel);
        if (duration) {
            mPermanentNote->setTimeout(duration);
        }
        mPermanentNote->setDismissPolicy(HbPopup::TapAnywhere);
        qDebug("SatAppToneProvider::PlayUserSelectedToneL show before");
        mPermanentNote->show();
        qDebug("SatAppToneProvider::PlayUserSelectedToneL show after");
    }

    QT_TRAP_THROWING(SymbianPrepareAudioPlayerL(tone,duration));
    
    if (duration > 0) {
        qDebug( "SATAPP: SatAppToneProvider::PlayUserSelectedToneL\
            duration not 0" );
        mTimer = new QTimer(this);
        mTimer->start(duration);
        SAT_ASSERT(connect(mTimer, SIGNAL(timeout()), this, SLOT(stopPlayTone())));

        if (mPermanentNote) {
            SAT_ASSERT(connect(mPermanentNote, SIGNAL(aboutToClose()),
                    this, SLOT(stopPlayTone())));
        }
    }