wlanutilities/wlanwizard/src/wlanwizardpagessid.cpp
author hgs
Fri, 09 Jul 2010 10:38:19 +0300
changeset 43 72ebcbb64834
parent 39 7b3e49e4608a
child 58 301aeb18ae47
permissions -rw-r--r--
201027
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
31
hgs
parents:
diff changeset
     1
/*
39
hgs
parents: 31
diff changeset
     2
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
hgs
parents: 31
diff changeset
     3
* All rights reserved.
hgs
parents: 31
diff changeset
     4
* This component and the accompanying materials are made available
hgs
parents: 31
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
hgs
parents: 31
diff changeset
     6
* which accompanies this distribution, and is available
hgs
parents: 31
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
hgs
parents: 31
diff changeset
     8
*
hgs
parents: 31
diff changeset
     9
* Initial Contributors:
hgs
parents: 31
diff changeset
    10
* Nokia Corporation - initial contribution.
hgs
parents: 31
diff changeset
    11
*
hgs
parents: 31
diff changeset
    12
* Contributors:
hgs
parents: 31
diff changeset
    13
*
hgs
parents: 31
diff changeset
    14
* Description: 
hgs
parents: 31
diff changeset
    15
* WLAN Wizard Page: SSID Selection.
hgs
parents: 31
diff changeset
    16
*/
31
hgs
parents:
diff changeset
    17
hgs
parents:
diff changeset
    18
// System includes
hgs
parents:
diff changeset
    19
#include <HbDocumentLoader>
hgs
parents:
diff changeset
    20
#include <HbMainWindow>
hgs
parents:
diff changeset
    21
#include <HbWidget>
hgs
parents:
diff changeset
    22
#include <HbLineEdit>
hgs
parents:
diff changeset
    23
#include <HbEditorInterface>
hgs
parents:
diff changeset
    24
#include <HbLabel>
hgs
parents:
diff changeset
    25
#include <wlanqtutils.h>
hgs
parents:
diff changeset
    26
hgs
parents:
diff changeset
    27
// User includes
hgs
parents:
diff changeset
    28
#include "wlanwizardpagessid.h"
hgs
parents:
diff changeset
    29
#include "wlanwizard_p.h"
hgs
parents:
diff changeset
    30
#include "wlanwizardutils.h"
hgs
parents:
diff changeset
    31
#include "OstTraceDefinitions.h"
hgs
parents:
diff changeset
    32
#ifdef OST_TRACE_COMPILER_IN_USE
hgs
parents:
diff changeset
    33
#include "wlanwizardpagessidTraces.h"
hgs
parents:
diff changeset
    34
#endif
hgs
parents:
diff changeset
    35
hgs
parents:
diff changeset
    36
/*!
39
hgs
parents: 31
diff changeset
    37
 * Constructor method for the SSID query view object.
hgs
parents: 31
diff changeset
    38
 * @param [in] parent pointer to parent object.
31
hgs
parents:
diff changeset
    39
 */
hgs
parents:
diff changeset
    40
WlanWizardPageSsid::WlanWizardPageSsid(WlanWizardPrivate* parent) :
hgs
parents:
diff changeset
    41
    WlanWizardPageInternal(parent),
hgs
parents:
diff changeset
    42
    mWidget(NULL),
hgs
parents:
diff changeset
    43
    mLabel(NULL),
hgs
parents:
diff changeset
    44
    mSsid(NULL),
hgs
parents:
diff changeset
    45
    mLoader(NULL)
hgs
parents:
diff changeset
    46
{
43
hgs
parents: 39
diff changeset
    47
    OstTraceFunctionEntry0( WLANWIZARDPAGESSID_WLANWIZARDPAGESSID_ENTRY );
31
hgs
parents:
diff changeset
    48
43
hgs
parents: 39
diff changeset
    49
    OstTraceFunctionExit0( WLANWIZARDPAGESSID_WLANWIZARDPAGESSID_EXIT );
31
hgs
parents:
diff changeset
    50
}
hgs
parents:
diff changeset
    51
hgs
parents:
diff changeset
    52
/*!
hgs
parents:
diff changeset
    53
 * Destructor. Loader widget is deleted.
hgs
parents:
diff changeset
    54
 * All document widgets are deleted by wlanwizard_p destructor.
hgs
parents:
diff changeset
    55
 */
hgs
parents:
diff changeset
    56
WlanWizardPageSsid::~WlanWizardPageSsid()
hgs
parents:
diff changeset
    57
{
43
hgs
parents: 39
diff changeset
    58
    OstTraceFunctionEntry0( DUP1_WLANWIZARDPAGESSID_WLANWIZARDPAGESSID_ENTRY );
31
hgs
parents:
diff changeset
    59
    delete mLoader;
43
hgs
parents: 39
diff changeset
    60
    OstTraceFunctionExit0( DUP1_WLANWIZARDPAGESSID_WLANWIZARDPAGESSID_EXIT );
31
hgs
parents:
diff changeset
    61
}
hgs
parents:
diff changeset
    62
hgs
parents:
diff changeset
    63
/*!
hgs
parents:
diff changeset
    64
 * Page initialization. If view is already loaded, does nothing.
39
hgs
parents: 31
diff changeset
    65
 * @return pointer to widget "occ_add_wlan_01".
31
hgs
parents:
diff changeset
    66
 */
hgs
parents:
diff changeset
    67
HbWidget* WlanWizardPageSsid::initializePage()
hgs
parents:
diff changeset
    68
{
43
hgs
parents: 39
diff changeset
    69
    OstTraceFunctionEntry0( WLANWIZARDPAGESSID_INITIALIZEPAGE_ENTRY );
31
hgs
parents:
diff changeset
    70
    OstTrace0( TRACE_NORMAL, WLANWIZARDPAGESSID_INITIALIZEPAGE,
hgs
parents:
diff changeset
    71
        "WlanWizardPageSsid::initializePage" );
hgs
parents:
diff changeset
    72
39
hgs
parents: 31
diff changeset
    73
    // It is not possible for this method to be called more than once during
hgs
parents: 31
diff changeset
    74
    // wizard lifetime.
hgs
parents: 31
diff changeset
    75
    Q_ASSERT(mWidget == NULL);
31
hgs
parents:
diff changeset
    76
39
hgs
parents: 31
diff changeset
    77
    bool ok;
31
hgs
parents:
diff changeset
    78
39
hgs
parents: 31
diff changeset
    79
    mLoader = new HbDocumentLoader(mWizard->mainWindow());
31
hgs
parents:
diff changeset
    80
39
hgs
parents: 31
diff changeset
    81
    mLoader->load(":/docml/occ_add_wlan_01_04.docml", &ok);
hgs
parents: 31
diff changeset
    82
    Q_ASSERT(ok);
hgs
parents: 31
diff changeset
    83
hgs
parents: 31
diff changeset
    84
    // Load orientation
hgs
parents: 31
diff changeset
    85
    loadDocmlSection(mWizard->mainWindow()->orientation());
31
hgs
parents:
diff changeset
    86
39
hgs
parents: 31
diff changeset
    87
    // Load widgets
hgs
parents: 31
diff changeset
    88
    mWidget = qobject_cast<HbWidget*> (mLoader->findWidget(
hgs
parents: 31
diff changeset
    89
        "occ_add_wlan_01"));
hgs
parents: 31
diff changeset
    90
    Q_ASSERT(mWidget != NULL);
31
hgs
parents:
diff changeset
    91
39
hgs
parents: 31
diff changeset
    92
    mLabel = qobject_cast<HbLabel*> (mLoader->findWidget("dialog"));
hgs
parents: 31
diff changeset
    93
    Q_ASSERT(mLabel != NULL);
31
hgs
parents:
diff changeset
    94
39
hgs
parents: 31
diff changeset
    95
    mSsid = qobject_cast<HbLineEdit*> (mLoader->findWidget("lineEditKey"));
hgs
parents: 31
diff changeset
    96
    Q_ASSERT(mSsid != NULL);
hgs
parents: 31
diff changeset
    97
hgs
parents: 31
diff changeset
    98
    mLabel->setPlainText(hbTrId(
hgs
parents: 31
diff changeset
    99
        "txt_occ_dialog_insert_the_name_of_the_new_wlan_net"));
31
hgs
parents:
diff changeset
   100
39
hgs
parents: 31
diff changeset
   101
    // Connect orientation signal from the main window to orientation
hgs
parents: 31
diff changeset
   102
    // loader.
hgs
parents: 31
diff changeset
   103
    ok = connect(mWizard->mainWindow(),
hgs
parents: 31
diff changeset
   104
        SIGNAL(orientationChanged(Qt::Orientation)), this,
hgs
parents: 31
diff changeset
   105
        SLOT(loadDocmlSection(Qt::Orientation)));
hgs
parents: 31
diff changeset
   106
    Q_ASSERT(ok);
31
hgs
parents:
diff changeset
   107
39
hgs
parents: 31
diff changeset
   108
    // Connect text change-signal from input dialog to handler function
hgs
parents: 31
diff changeset
   109
    ok = connect(mSsid, SIGNAL(textChanged(const QString &)), this,
hgs
parents: 31
diff changeset
   110
        SLOT(textChanged(const QString &)));
hgs
parents: 31
diff changeset
   111
    Q_ASSERT(ok);
31
hgs
parents:
diff changeset
   112
39
hgs
parents: 31
diff changeset
   113
    HbEditorInterface editInterface(mSsid);
hgs
parents: 31
diff changeset
   114
    
hgs
parents: 31
diff changeset
   115
    // TODO: remove (HbEditorConstraints) type cast when 
hgs
parents: 31
diff changeset
   116
    // Q_DECLARE_OPERATORS_FOR_FLAGS(HbEditorConstraints) is defined (SDK xxx)
hgs
parents: 31
diff changeset
   117
    editInterface.setInputConstraints(
hgs
parents: 31
diff changeset
   118
        (HbEditorConstraints)(HbEditorConstraintAutoCompletingField |
hgs
parents: 31
diff changeset
   119
            HbEditorConstraintLatinAlphabetOnly));
hgs
parents: 31
diff changeset
   120
    
hgs
parents: 31
diff changeset
   121
    editInterface.setSmileyTheme(HbSmileyTheme());
hgs
parents: 31
diff changeset
   122
    editInterface.setEditorClass(HbInputEditorClassNetworkName);
hgs
parents: 31
diff changeset
   123
    mSsid->setInputMethodHints(
hgs
parents: 31
diff changeset
   124
        Qt::ImhNoPredictiveText | Qt::ImhPreferLowercase);
hgs
parents: 31
diff changeset
   125
    mSsid->setMaxLength(WlanWizardUtils::SsidMaxLength);
31
hgs
parents:
diff changeset
   126
43
hgs
parents: 39
diff changeset
   127
	OstTraceFunctionExit0( WLANWIZARDPAGESSID_INITIALIZEPAGE_EXIT );
39
hgs
parents: 31
diff changeset
   128
	return mWidget;
31
hgs
parents:
diff changeset
   129
}
hgs
parents:
diff changeset
   130
hgs
parents:
diff changeset
   131
/*!
39
hgs
parents: 31
diff changeset
   132
 * This method is overrides the default implementation from WlanWizardPage.
hgs
parents: 31
diff changeset
   133
 * It indicates whether the Next-button should be enabled or not.
hgs
parents: 31
diff changeset
   134
 * @return true, if mSsid edit field is not empty.
hgs
parents: 31
diff changeset
   135
 */
hgs
parents: 31
diff changeset
   136
bool WlanWizardPageSsid::showPage()
hgs
parents: 31
diff changeset
   137
{
43
hgs
parents: 39
diff changeset
   138
    OstTraceFunctionEntry0( WLANWIZARDPAGESSID_SHOWPAGE_ENTRY );
39
hgs
parents: 31
diff changeset
   139
    // Initiate the scanning of public APs here.
hgs
parents: 31
diff changeset
   140
    mWizard->wlanQtUtils()->scanWlanAps();
hgs
parents: 31
diff changeset
   141
    
hgs
parents: 31
diff changeset
   142
    // Open virtual keyboard by setting focus to line edit
hgs
parents: 31
diff changeset
   143
    mSsid->setFocus();
43
hgs
parents: 39
diff changeset
   144
    OstTraceFunctionExit0( WLANWIZARDPAGESSID_SHOWPAGE_EXIT );
39
hgs
parents: 31
diff changeset
   145
    return !(mSsid->text().isEmpty());
hgs
parents: 31
diff changeset
   146
}
hgs
parents: 31
diff changeset
   147
hgs
parents: 31
diff changeset
   148
/*!
hgs
parents: 31
diff changeset
   149
 * Stores the SSID selection in the configuration.
hgs
parents: 31
diff changeset
   150
 * @param [out] removeFromStack returns false.
hgs
parents: 31
diff changeset
   151
 * @return WlanWizardPageScanning page id.
31
hgs
parents:
diff changeset
   152
 */
hgs
parents:
diff changeset
   153
int WlanWizardPageSsid::nextId(bool &removeFromStack) const
hgs
parents:
diff changeset
   154
{
43
hgs
parents: 39
diff changeset
   155
    OstTraceFunctionEntry0( WLANWIZARDPAGESSID_NEXTID_ENTRY );
31
hgs
parents:
diff changeset
   156
    removeFromStack = false;
hgs
parents:
diff changeset
   157
39
hgs
parents: 31
diff changeset
   158
    // SSID is stored into configuration
hgs
parents: 31
diff changeset
   159
    mWizard->setConfiguration(WlanWizardPrivate::ConfSsid, mSsid->text());
hgs
parents: 31
diff changeset
   160
    
43
hgs
parents: 39
diff changeset
   161
    OstTraceFunctionExit0( WLANWIZARDPAGESSID_NEXTID_EXIT );
39
hgs
parents: 31
diff changeset
   162
    return WlanWizardPageInternal::PageScanning;
31
hgs
parents:
diff changeset
   163
}
hgs
parents:
diff changeset
   164
hgs
parents:
diff changeset
   165
/*!
39
hgs
parents: 31
diff changeset
   166
 * Loads the document orientation information from occ_add_wlan_01_04.docml
hgs
parents: 31
diff changeset
   167
 * This is called each time phone orientation changes.
hgs
parents: 31
diff changeset
   168
 * @param [in] orientation indicates whether the phone is in portrait or
hgs
parents: 31
diff changeset
   169
 * landscape mode.
31
hgs
parents:
diff changeset
   170
 */
39
hgs
parents: 31
diff changeset
   171
void WlanWizardPageSsid::loadDocmlSection(Qt::Orientation orientation)
31
hgs
parents:
diff changeset
   172
{
43
hgs
parents: 39
diff changeset
   173
    OstTraceFunctionEntry0( WLANWIZARDPAGESSID_LOADDOCMLSECTION_ENTRY );
31
hgs
parents:
diff changeset
   174
    OstTrace1( TRACE_FLOW, WLANWIZARDPAGESSID_LOADDOCML,
hgs
parents:
diff changeset
   175
        "WlanWizardPageSsid::loadDocml - orientation ;orientation=%x",
hgs
parents:
diff changeset
   176
        ( TUint )( orientation ) );
hgs
parents:
diff changeset
   177
39
hgs
parents: 31
diff changeset
   178
    WlanWizardPageInternal::loadDocmlSection(
hgs
parents: 31
diff changeset
   179
        mLoader,
hgs
parents: 31
diff changeset
   180
        orientation,
hgs
parents: 31
diff changeset
   181
        ":/docml/occ_add_wlan_01_04.docml", 
hgs
parents: 31
diff changeset
   182
        "portrait_section",
hgs
parents: 31
diff changeset
   183
        "landscape_section");
43
hgs
parents: 39
diff changeset
   184
    OstTraceFunctionExit0( WLANWIZARDPAGESSID_LOADDOCMLSECTION_EXIT );
31
hgs
parents:
diff changeset
   185
}
hgs
parents:
diff changeset
   186
hgs
parents:
diff changeset
   187
/*!
39
hgs
parents: 31
diff changeset
   188
 * Executed when changes have been made to the mSsid field (and the field is
hgs
parents: 31
diff changeset
   189
 * not empty).
hgs
parents: 31
diff changeset
   190
 * @param [in] text is not used at this point.
31
hgs
parents:
diff changeset
   191
 */
39
hgs
parents: 31
diff changeset
   192
void WlanWizardPageSsid::textChanged(const QString &text)
31
hgs
parents:
diff changeset
   193
{
43
hgs
parents: 39
diff changeset
   194
    OstTraceFunctionEntry0( WLANWIZARDPAGESSID_TEXTCHANGED_ENTRY );
39
hgs
parents: 31
diff changeset
   195
    Q_UNUSED(text);
hgs
parents: 31
diff changeset
   196
    OstTrace0( TRACE_FLOW, WLANWIZARDPAGESSID_TEXTCHANGED,
hgs
parents: 31
diff changeset
   197
        "WlanWizardPageSsid::textChanged in text edit widget" );
31
hgs
parents:
diff changeset
   198
39
hgs
parents: 31
diff changeset
   199
    mWizard->enableNextButton(!(mSsid->text().isEmpty()));
43
hgs
parents: 39
diff changeset
   200
    OstTraceFunctionExit0( WLANWIZARDPAGESSID_TEXTCHANGED_EXIT );
31
hgs
parents:
diff changeset
   201
}