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