camerauis/cameraxui/cxui/src/cxuierrormanager.cpp
author hgs
Thu, 15 Jul 2010 01:49:11 +0300
changeset 40 2922f70fca82
parent 28 3075d9b614e6
child 37 64817133cd1d
permissions -rw-r--r--
201023
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/*
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
     2
* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
* All rights reserved.
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
*
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     9
* Initial Contributors:
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    11
*
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    12
* Contributors:
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
*
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    14
* Description:
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    15
*
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
*/
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    18
#include <QCoreApplication>
40
hgs
parents: 28
diff changeset
    19
#include <HbAction>
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    20
#include <HbDialog>
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    21
#include <HbMessageBox>
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    22
#include <HbLabel>
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    23
#include <HbPushButton>
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    24
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    25
#include "cxutils.h"
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    26
#include "cxeerror.h"
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    27
#include "cxeengine.h"
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    28
#include "cxuienums.h"
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    29
#include "cxuierrormanager.h"
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    30
#include "cxuidocumentloader.h"
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    31
#include "cxecameradevicecontrol.h"
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    32
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    33
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    34
/*!
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    35
* Constructor
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    36
*/
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    37
CxuiErrorManager::CxuiErrorManager(CxuiCaptureKeyHandler &keyHandler,CxuiDocumentLoader *documentLoader) :
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    38
    mKeyHandler(keyHandler),
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    39
    mDocumentLoader(documentLoader),
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    40
    mErrorMsgPopup(NULL),
40
hgs
parents: 28
diff changeset
    41
    mErrorId(CxeError::None),
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    42
    mErrorSeverity(CxuiErrorManager::None)
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    43
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    44
    CX_DEBUG_ENTER_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    45
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    46
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    47
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    48
/*!
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    49
* Destructor
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    50
*/
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    51
CxuiErrorManager::~CxuiErrorManager()
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    52
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    53
    CX_DEBUG_ENTER_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    54
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    55
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    56
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    57
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    58
/*!
40
hgs
parents: 28
diff changeset
    59
* Show error popup based on the error id.
hgs
parents: 28
diff changeset
    60
* @param error Error id.
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    61
*/
40
hgs
parents: 28
diff changeset
    62
void CxuiErrorManager::showPopup(CxeError::Id error)
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    63
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    64
    CX_DEBUG_ENTER_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    65
    mErrorSeverity = CxuiErrorManager::None;
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    66
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    67
    if (error != CxeError::None) {
40
hgs
parents: 28
diff changeset
    68
        CxeError::Id oldError = mErrorId;
hgs
parents: 28
diff changeset
    69
        mErrorId = error;
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    70
40
hgs
parents: 28
diff changeset
    71
        // start evaluating the error.
hgs
parents: 28
diff changeset
    72
        QString errorText;
hgs
parents: 28
diff changeset
    73
        QString buttonText;
hgs
parents: 28
diff changeset
    74
        getErrorDetails(errorText, buttonText);
hgs
parents: 28
diff changeset
    75
hgs
parents: 28
diff changeset
    76
        if (mErrorSeverity != CxuiErrorManager::None) {
hgs
parents: 28
diff changeset
    77
            // Clear the old error if one for some reason exists.
hgs
parents: 28
diff changeset
    78
            hidePopup(oldError);
hgs
parents: 28
diff changeset
    79
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    80
            // show the error note to the user.
40
hgs
parents: 28
diff changeset
    81
            launchPopup(errorText, buttonText);
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    82
        } else {
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    83
            // ignore
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    84
        }
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    85
    }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    86
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    87
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    88
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    89
40
hgs
parents: 28
diff changeset
    90
/*!
hgs
parents: 28
diff changeset
    91
* Close the open error popup, if it is shown for the same error as requested here.
hgs
parents: 28
diff changeset
    92
* @param error Error id, for which we are closing the error dialog.
hgs
parents: 28
diff changeset
    93
*/
hgs
parents: 28
diff changeset
    94
void CxuiErrorManager::hidePopup(CxeError::Id error)
hgs
parents: 28
diff changeset
    95
{
hgs
parents: 28
diff changeset
    96
    CX_DEBUG_ENTER_FUNCTION();
hgs
parents: 28
diff changeset
    97
    if (mErrorId == error) {
hgs
parents: 28
diff changeset
    98
        if (mErrorMsgPopup) {
hgs
parents: 28
diff changeset
    99
            mErrorMsgPopup->close();
hgs
parents: 28
diff changeset
   100
            mErrorMsgPopup = NULL;
hgs
parents: 28
diff changeset
   101
        }
hgs
parents: 28
diff changeset
   102
    }
hgs
parents: 28
diff changeset
   103
    CX_DEBUG_EXIT_FUNCTION();
hgs
parents: 28
diff changeset
   104
}
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   105
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   106
/*!
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   107
* Slot that gets called when error note is closed.
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   108
*/
40
hgs
parents: 28
diff changeset
   109
void CxuiErrorManager::popupClosed(HbAction *action)
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   110
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   111
    CX_DEBUG_ENTER_FUNCTION();
40
hgs
parents: 28
diff changeset
   112
    // Dialog or action instance cannot be used anymore.
hgs
parents: 28
diff changeset
   113
    mErrorMsgPopup = NULL;
hgs
parents: 28
diff changeset
   114
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   115
    // handle any use-cases when the error can be recovered
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   116
    emit errorRecovered();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   117
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   118
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   119
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   120
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   121
/*!
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   122
* Helper method for closing the application.
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   123
*/
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   124
void CxuiErrorManager::closeApp()
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   125
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   126
    CX_DEBUG_ENTER_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   127
    QCoreApplication::quit();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   128
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   129
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   130
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   131
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   132
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   133
/*!
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   134
* Helper method to get the error message to use for showing note to user,
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   135
* and set the severity level, based on given error code.
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   136
* @param error Error code to be analyzed.
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   137
*/
40
hgs
parents: 28
diff changeset
   138
void CxuiErrorManager::getErrorDetails(QString &errorText, QString &buttonText)
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   139
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   140
    CX_DEBUG_ENTER_FUNCTION();
40
hgs
parents: 28
diff changeset
   141
    switch (mErrorId) {
hgs
parents: 28
diff changeset
   142
        case CxeError::MemoryNotAccessible:
hgs
parents: 28
diff changeset
   143
            mErrorSeverity = CxuiErrorManager::Severe;
hgs
parents: 28
diff changeset
   144
            errorText = hbTrId("txt_cam_info_error_usb_disconnected");
hgs
parents: 28
diff changeset
   145
            buttonText = hbTrId("txt_cam_info_error_usb_disconnected_button");
hgs
parents: 28
diff changeset
   146
            break;
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   147
        case CxeError::Died:
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   148
        case CxeError::InitializationFailed:
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   149
        case CxeError::HwNotAvailable:
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   150
        case CxeError::NotReady:
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   151
            mErrorSeverity = CxuiErrorManager::Severe;
40
hgs
parents: 28
diff changeset
   152
            errorText = hbTrId("txt_cam_info_error");
hgs
parents: 28
diff changeset
   153
            buttonText = hbTrId("txt_common_button_close");
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   154
            break;
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   155
        case CxeError::InUse:
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   156
            mErrorSeverity = CxuiErrorManager::Severe;
40
hgs
parents: 28
diff changeset
   157
            errorText = hbTrId("txt_cam_info_camera_already_in_use");
hgs
parents: 28
diff changeset
   158
            buttonText = hbTrId("txt_common_button_close");
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   159
            break;
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   160
        case CxeError::DiskFull:
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   161
            mErrorSeverity = CxuiErrorManager::Warning;
40
hgs
parents: 28
diff changeset
   162
            errorText = hbTrId("txt_cam_info_memory_full");
hgs
parents: 28
diff changeset
   163
            break;
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   164
        default:
40
hgs
parents: 28
diff changeset
   165
            errorText = "No Error";
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   166
            break;
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   167
    }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   168
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   169
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   170
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   171
/*!
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   172
*
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   173
*/
40
hgs
parents: 28
diff changeset
   174
void CxuiErrorManager::launchPopup(const QString &errorText, const QString &buttonText)
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   175
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   176
    CX_DEBUG_ENTER_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   177
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   178
    switch (mErrorSeverity) {
40
hgs
parents: 28
diff changeset
   179
    case CxuiErrorManager::None:
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   180
        break;
40
hgs
parents: 28
diff changeset
   181
    case CxuiErrorManager::Warning:
hgs
parents: 28
diff changeset
   182
        showLowSeverityNote(errorText);
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   183
        break;
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   184
    default:
40
hgs
parents: 28
diff changeset
   185
        showHighSeverityNote(errorText, buttonText);
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   186
        break;
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   187
    }
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   188
40
hgs
parents: 28
diff changeset
   189
    mErrorSeverity = CxuiErrorManager::None;
hgs
parents: 28
diff changeset
   190
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   191
    CX_DEBUG_EXIT_FUNCTION();
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   192
}
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   193
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   194
/*!
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   195
* Show error note for high severity error.
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   196
*/
40
hgs
parents: 28
diff changeset
   197
void CxuiErrorManager::showHighSeverityNote(const QString &errorText, const QString &buttonText)
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   198
{
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   199
    // we always prepare the popup for the new message and hence we load the
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   200
    // popup everytime from document loader
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   201
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   202
    CX_ASSERT_ALWAYS(mDocumentLoader);
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   203
    bool ok = false;
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   204
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   205
    // Use document loader to create popup
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   206
    mDocumentLoader->load(CxUiLayout::ERROR_POPUP_XML, &ok);
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   207
    CX_DEBUG(("mErrorMsgPopup load ok=%d", ok));
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   208
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   209
    mErrorMsgPopup = qobject_cast<HbDialog*>(mDocumentLoader->findWidget(CxUiLayout::ERROR_POPUP));
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   210
    CX_ASSERT_ALWAYS(mErrorMsgPopup);
40
hgs
parents: 28
diff changeset
   211
    mErrorMsgPopup->setAttribute(Qt::WA_DeleteOnClose, true);
hgs
parents: 28
diff changeset
   212
    mErrorMsgPopup->setTimeout(HbDialog::NoTimeout);
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   213
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   214
    // HbDialog's default background item is replaced with black rectangle
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   215
    QGraphicsRectItem *backgroundItem = new QGraphicsRectItem();
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   216
    QBrush blackBrush = QBrush(Qt::black);
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   217
    backgroundItem->setBrush(blackBrush);
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   218
    QGraphicsItem *origBgItem = mErrorMsgPopup->backgroundItem();
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   219
    backgroundItem->setRect(origBgItem->boundingRect());
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   220
    mErrorMsgPopup->setBackgroundItem(backgroundItem);
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   221
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   222
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   223
    // color of standby text is set in the code. It cannot be done in docml
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   224
    HbLabel* label = qobject_cast<HbLabel*>(mDocumentLoader->findWidget(CxUiLayout::ERROR_TEXT_WIDGET));
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   225
    label->setTextColor(Qt::white);
40
hgs
parents: 28
diff changeset
   226
    label->setPlainText(errorText);
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   227
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   228
    HbPushButton *exitButton = qobject_cast<HbPushButton*>(mDocumentLoader->findWidget(CxUiLayout::ERROR_BUTTON_WIDGET));
40
hgs
parents: 28
diff changeset
   229
    if (!buttonText.isEmpty()) {
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   230
        // inform ui about error recovery
40
hgs
parents: 28
diff changeset
   231
        exitButton->setText(buttonText);
hgs
parents: 28
diff changeset
   232
        connect(exitButton, SIGNAL(released()), this, SLOT(closeApp()));
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   233
        exitButton->show();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   234
    } else {
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   235
        // TODO handle other severity cases here.
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   236
    }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   237
40
hgs
parents: 28
diff changeset
   238
    emit aboutToRecoverError();
hgs
parents: 28
diff changeset
   239
    mErrorMsgPopup->open(this, SLOT(popupClosed(HbAction*)));
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   240
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   241
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   242
}
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   243
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   244
/*!
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   245
* Show error note for low severity error.
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   246
*/
40
hgs
parents: 28
diff changeset
   247
void CxuiErrorManager::showLowSeverityNote(const QString &errorText)
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   248
{
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   249
    CX_DEBUG_ENTER_FUNCTION();
40
hgs
parents: 28
diff changeset
   250
    HbMessageBox::warning(errorText);
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   251
    CX_DEBUG_EXIT_FUNCTION();
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   252
}