emailuis/nmailui/src/nmeditorview.cpp
author hgs
Fri, 09 Jul 2010 12:17:13 +0300
changeset 51 d845db10c0d4
parent 49 00c7ae862740
child 56 15bc1d5d6267
permissions -rw-r--r--
201027
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/*
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     2
* Copyright (c) 2009 - 2010 Nokia Corporation and/or its subsidiary(-ies).
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
* All rights reserved.
578830873419 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
578830873419 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"
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
578830873419 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".
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
*
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     9
* Initial Contributors:
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    11
*
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    12
* Contributors:
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
*
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    14
* Description: Message editor view
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    15
*
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
#include "nmuiheaders.h"
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    19
// Layout file and view
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
static const char *NMUI_EDITOR_VIEW_XML = ":/docml/nmeditorview.docml";
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    21
static const char *NMUI_EDITOR_VIEW= "editorview";
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    22
47
hgs
parents: 44
diff changeset
    23
static const QString NmDelimiter("; ");
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    24
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    25
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    26
	\class NmEditorView
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    27
	\brief Mail editor view
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    28
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    29
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    30
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    31
    Constructor
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    32
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    33
NmEditorView::NmEditorView(
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    34
    NmApplication &application,
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    35
    NmUiStartParam* startParam,
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    36
    NmUiEngine &uiEngine,
43
hgs
parents: 40
diff changeset
    37
    NmAttachmentManager &attaManager,
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    38
    QGraphicsItem *parent)
40
hgs
parents: 23
diff changeset
    39
    : NmBaseView(startParam, application, parent),
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    40
      mApplication(application),
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    41
      mUiEngine(uiEngine),
43
hgs
parents: 40
diff changeset
    42
      mAttaManager(attaManager),
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    43
      mDocumentLoader(NULL),
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    44
      mHeaderWidget(NULL),
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    45
      mMessage(NULL),
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
    46
      mContent(NULL),
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    47
      mAttachmentListContextMenu(NULL),
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    48
      mMessageCreationOperation(NULL),
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    49
      mAddAttachmentOperation(NULL),
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    50
      mRemoveAttachmentOperation(NULL),
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    51
      mWaitDialog(NULL),
40
hgs
parents: 23
diff changeset
    52
      mQueryDialog(NULL),
hgs
parents: 23
diff changeset
    53
      mAttachmentPicker(NULL),
43
hgs
parents: 40
diff changeset
    54
      mCcBccFieldVisible(false),
hgs
parents: 40
diff changeset
    55
      mServiceSendingDialog(NULL)
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    56
{
43
hgs
parents: 40
diff changeset
    57
    NM_FUNCTION;
hgs
parents: 40
diff changeset
    58
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    59
    mDocumentLoader	= new HbDocumentLoader();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    60
    // Set object name
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    61
    setObjectName("NmEditorView");
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
    62
    // Set mailbox name to title pane
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
    63
    setMailboxName();
44
hgs
parents: 43
diff changeset
    64
    // call the createToolBar on load view layout
hgs
parents: 43
diff changeset
    65
    createToolBar();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    66
    // Load view layout
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    67
    loadViewLayout();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    68
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    69
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    70
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    71
    Destructor
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    72
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    73
NmEditorView::~NmEditorView()
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    74
{
43
hgs
parents: 40
diff changeset
    75
    NM_FUNCTION;
hgs
parents: 40
diff changeset
    76
    
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
    77
    if (mRemoveAttachmentOperation && mRemoveAttachmentOperation->isRunning()) {
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
    78
        mRemoveAttachmentOperation->cancelOperation();
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
    79
    }
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
    80
    if (mAddAttachmentOperation && mAddAttachmentOperation->isRunning()) {
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
    81
        mAddAttachmentOperation->cancelOperation();
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
    82
    }
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
    83
    if (mMessageCreationOperation && mMessageCreationOperation->isRunning()) {
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
    84
        mMessageCreationOperation->cancelOperation();
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
    85
    }
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    86
    delete mMessage;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    87
    mWidgetList.clear();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    88
    delete mDocumentLoader;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    89
    delete mPrioritySubMenu;
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    90
    
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    91
    if (mAttachmentListContextMenu) {
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    92
        mAttachmentListContextMenu->clearActions();
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    93
        delete mAttachmentListContextMenu;
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    94
    }
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    95
    delete mWaitDialog;
40
hgs
parents: 23
diff changeset
    96
    delete mQueryDialog;
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
    97
    delete mAttachmentPicker;    
43
hgs
parents: 40
diff changeset
    98
    mAttaManager.clearObserver();
hgs
parents: 40
diff changeset
    99
    mAttaManager.cancelFetch();
44
hgs
parents: 43
diff changeset
   100
    
hgs
parents: 43
diff changeset
   101
    // make sure virtual keyboard is closed
hgs
parents: 43
diff changeset
   102
    QInputContext *ic = qApp->inputContext();
hgs
parents: 43
diff changeset
   103
    if (ic) {
hgs
parents: 43
diff changeset
   104
        QEvent *closeEvent = new QEvent(QEvent::CloseSoftwareInputPanel);
hgs
parents: 43
diff changeset
   105
        ic->filterEvent(closeEvent);
hgs
parents: 43
diff changeset
   106
        delete closeEvent;
hgs
parents: 43
diff changeset
   107
    }
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   108
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   109
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   110
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   111
    View layout loading from XML
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   112
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   113
void NmEditorView::loadViewLayout()
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   114
{
43
hgs
parents: 40
diff changeset
   115
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   116
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   117
    mPrioritySubMenu = NULL;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   118
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   119
    // Use document loader to load the view
47
hgs
parents: 44
diff changeset
   120
    bool ok(false);
49
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
   121
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
   122
    setObjectName(QString(NMUI_EDITOR_VIEW));
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
   123
    QObjectList objectList;
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
   124
    objectList.append(this);
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
   125
    // Pass the view to documentloader. Document loader uses this view
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
   126
    // when docml is parsed, instead of creating new view.
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
   127
    // documentloader is created in constructor
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
   128
    mDocumentLoader->setObjectTree(objectList);
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
   129
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   130
    mWidgetList = mDocumentLoader->load(NMUI_EDITOR_VIEW_XML, &ok);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   131
49
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
   132
   if (ok) {
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   133
        mContent = new NmEditorContent(this, mDocumentLoader, 
47
hgs
parents: 44
diff changeset
   134
            mApplication.networkAccessManager(), mApplication);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   135
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   136
        mHeaderWidget = mContent->header();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   137
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   138
        // Set default color for user - entered text if editor is in re/reAll/fw mode
44
hgs
parents: 43
diff changeset
   139
        if (mStartParam) {
hgs
parents: 43
diff changeset
   140
            NmUiEditorStartMode mode = mStartParam->editorStartMode();
hgs
parents: 43
diff changeset
   141
            if (mode == NmUiEditorReply
hgs
parents: 43
diff changeset
   142
                || mode == NmUiEditorReplyAll 
hgs
parents: 43
diff changeset
   143
                || mode == NmUiEditorForward) {
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   144
                mContent->editor()->setCustomTextColor(true, Qt::blue);
44
hgs
parents: 43
diff changeset
   145
            }
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   146
        }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   147
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   148
        // the rest of the view initialization is done in viewReady()
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   149
    }
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   150
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   151
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   152
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   153
    Reload view contents with new start parameters
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   154
    Typically when view is already open and external view activation occurs
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   155
    for this same view
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   156
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   157
void NmEditorView::reloadViewContents(NmUiStartParam* startParam)
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   158
{
43
hgs
parents: 40
diff changeset
   159
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   160
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   161
    // Check start parameter validity.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   162
    if (startParam&&startParam->viewId()==NmUiViewMessageEditor) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   163
        // Delete existing start parameter data
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   164
        delete mStartParam;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   165
        mStartParam=NULL;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   166
        // Store new start parameter data
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   167
        mStartParam=startParam;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   168
        // Store existing edited message to drafts and reload
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   169
        // editor with new start parameters.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   170
        // ..
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   171
        // Reload editor with new message data
44
hgs
parents: 43
diff changeset
   172
        fetchMessageIfNeeded(*mStartParam);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   173
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   174
    else {
43
hgs
parents: 40
diff changeset
   175
        NM_ERROR(1,"nmailui: Invalid editor start parameter");
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   176
        // Unused start parameter needs to be deleted
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   177
        delete startParam;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   178
        startParam = NULL;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   179
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   180
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   181
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   182
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   183
   Screen orientation changed. Editor view needs to be scaled when
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   184
   landscape <-> portrait switch occurs because text needs to
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   185
   be wrapped again.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   186
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   187
void NmEditorView::orientationChanged(Qt::Orientation orientation)
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   188
{
43
hgs
parents: 40
diff changeset
   189
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   190
    
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   191
    Q_UNUSED(orientation);
47
hgs
parents: 44
diff changeset
   192
    
hgs
parents: 44
diff changeset
   193
    // content widget height needs to be set according to the new orientation to get the scroll
hgs
parents: 44
diff changeset
   194
	// area work correctly
hgs
parents: 44
diff changeset
   195
	mHeaderWidget->sendDelayedHeaderHeightChanged();
51
hgs
parents: 49
diff changeset
   196
	mHeaderWidget->adjustHeaderWidth();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   197
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   198
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   199
/*!
47
hgs
parents: 44
diff changeset
   200
    This slot is signaled by VKB when it opens
hgs
parents: 44
diff changeset
   201
 */
hgs
parents: 44
diff changeset
   202
void NmEditorView::vkbOpened()
hgs
parents: 44
diff changeset
   203
{
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   204
    showChrome(false);	
47
hgs
parents: 44
diff changeset
   205
}
hgs
parents: 44
diff changeset
   206
hgs
parents: 44
diff changeset
   207
/*!
hgs
parents: 44
diff changeset
   208
    This slot is signaled by VKB when it closes.
hgs
parents: 44
diff changeset
   209
 */
hgs
parents: 44
diff changeset
   210
void NmEditorView::vkbClosed()
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   211
{
47
hgs
parents: 44
diff changeset
   212
	showChrome(true);
hgs
parents: 44
diff changeset
   213
}
hgs
parents: 44
diff changeset
   214
hgs
parents: 44
diff changeset
   215
/*!
hgs
parents: 44
diff changeset
   216
    Hide or show chrome.
hgs
parents: 44
diff changeset
   217
 */
hgs
parents: 44
diff changeset
   218
void NmEditorView::showChrome(bool show)
hgs
parents: 44
diff changeset
   219
{
hgs
parents: 44
diff changeset
   220
    if (show) {
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   221
        showItems(Hb::StatusBarItem | Hb::TitleBarItem | Hb::ToolBarItem);
47
hgs
parents: 44
diff changeset
   222
    }
hgs
parents: 44
diff changeset
   223
    else {
hgs
parents: 44
diff changeset
   224
        hideItems(Hb::StatusBarItem | Hb::TitleBarItem | Hb::ToolBarItem);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   225
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   226
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   227
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   228
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   229
    View id
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   230
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   231
NmUiViewId NmEditorView::nmailViewId() const
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   232
{
43
hgs
parents: 40
diff changeset
   233
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   234
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   235
    return NmUiViewMessageEditor;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   236
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   237
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   238
/*
40
hgs
parents: 23
diff changeset
   239
   Launch dialog for query user if we want to exit the editor
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   240
*/
40
hgs
parents: 23
diff changeset
   241
void NmEditorView::okToExitView()
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   242
{
43
hgs
parents: 40
diff changeset
   243
    NM_FUNCTION;
47
hgs
parents: 44
diff changeset
   244
       
hgs
parents: 44
diff changeset
   245
    bool okToExit(true);
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   246
    
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   247
    if (mContent) {
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   248
        NmEditorHeader *header = mContent->header();
47
hgs
parents: 44
diff changeset
   249
        // show the query if the message has not been sent
hgs
parents: 44
diff changeset
   250
        if (mMessage && header) {
hgs
parents: 44
diff changeset
   251
            // see if editor has any content
hgs
parents: 44
diff changeset
   252
            int subjectLength = 0;
hgs
parents: 44
diff changeset
   253
            if (header->subjectEdit()) {
hgs
parents: 44
diff changeset
   254
                subjectLength = header->subjectEdit()->text().length();
40
hgs
parents: 23
diff changeset
   255
            }
47
hgs
parents: 44
diff changeset
   256
            
hgs
parents: 44
diff changeset
   257
            QList<NmMessagePart*> attachmentList;
hgs
parents: 44
diff changeset
   258
            mMessage->attachmentList(attachmentList);
hgs
parents: 44
diff changeset
   259
            
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   260
            if (mContent->editor()) {
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   261
                okToExit = (subjectLength == 0 && mContent->editor()->document()->isEmpty());            
47
hgs
parents: 44
diff changeset
   262
            }
hgs
parents: 44
diff changeset
   263
    
hgs
parents: 44
diff changeset
   264
            // content exists, verify exit from user
hgs
parents: 44
diff changeset
   265
            if (!okToExit) {
hgs
parents: 44
diff changeset
   266
                if (mQueryDialog) {
hgs
parents: 44
diff changeset
   267
                    delete mQueryDialog;
hgs
parents: 44
diff changeset
   268
                    mQueryDialog = 0;
hgs
parents: 44
diff changeset
   269
                }
hgs
parents: 44
diff changeset
   270
                // Launch query dialog.
hgs
parents: 44
diff changeset
   271
                mQueryDialog = 
hgs
parents: 44
diff changeset
   272
                    NmUtilities::displayQuestionNote(hbTrId("txt_mail_dialog_save_message_to_drafts"),
hgs
parents: 44
diff changeset
   273
                                                                this,
hgs
parents: 44
diff changeset
   274
                                                                SLOT(okToExitQuery(HbAction*)));
hgs
parents: 44
diff changeset
   275
            }
hgs
parents: 44
diff changeset
   276
        }    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   277
    }
40
hgs
parents: 23
diff changeset
   278
    
hgs
parents: 23
diff changeset
   279
    // no need to query anything, just exit.
hgs
parents: 23
diff changeset
   280
    if(okToExit) {
hgs
parents: 23
diff changeset
   281
        QMetaObject::invokeMethod(&mApplication,
hgs
parents: 23
diff changeset
   282
                                  "popView",
hgs
parents: 23
diff changeset
   283
                                  Qt::QueuedConnection);
hgs
parents: 23
diff changeset
   284
    }
hgs
parents: 23
diff changeset
   285
}
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   286
40
hgs
parents: 23
diff changeset
   287
/*!
hgs
parents: 23
diff changeset
   288
    Handle the user selection is it ok to exit.
hgs
parents: 23
diff changeset
   289
*/
47
hgs
parents: 44
diff changeset
   290
void NmEditorView::okToExitQuery(HbAction *action)
40
hgs
parents: 23
diff changeset
   291
{
43
hgs
parents: 40
diff changeset
   292
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   293
    
hgs
parents: 40
diff changeset
   294
    HbMessageBox *dlg = static_cast<HbMessageBox*>(sender());
hgs
parents: 40
diff changeset
   295
    // The first action in dialogs action list is for the "Yes"-button.
hgs
parents: 40
diff changeset
   296
    if (action == dlg->actions().at(0)) {
hgs
parents: 40
diff changeset
   297
        
44
hgs
parents: 43
diff changeset
   298
        // Update draft message with content.
hgs
parents: 43
diff changeset
   299
        updateMessageWithEditorContents();
hgs
parents: 43
diff changeset
   300
43
hgs
parents: 40
diff changeset
   301
        // Save message to drafts
hgs
parents: 40
diff changeset
   302
        QList<NmOperation *> preliminaryOperations;
hgs
parents: 40
diff changeset
   303
        if (mAddAttachmentOperation && mAddAttachmentOperation->isRunning()) {
hgs
parents: 40
diff changeset
   304
            preliminaryOperations.append(mAddAttachmentOperation);
hgs
parents: 40
diff changeset
   305
        }
hgs
parents: 40
diff changeset
   306
        if (mRemoveAttachmentOperation && mRemoveAttachmentOperation->isRunning()) {
hgs
parents: 40
diff changeset
   307
            preliminaryOperations.append(mRemoveAttachmentOperation);
hgs
parents: 40
diff changeset
   308
        }
hgs
parents: 40
diff changeset
   309
        // ownership of mMessage is transferred
hgs
parents: 40
diff changeset
   310
        // NmOperations are automatically deleted after completion
hgs
parents: 40
diff changeset
   311
        mUiEngine.saveDraftMessage(mMessage, preliminaryOperations);
hgs
parents: 40
diff changeset
   312
        mMessage = NULL;
hgs
parents: 40
diff changeset
   313
        preliminaryOperations.clear();
hgs
parents: 40
diff changeset
   314
    }    
hgs
parents: 40
diff changeset
   315
    
hgs
parents: 40
diff changeset
   316
    // Close the view
hgs
parents: 40
diff changeset
   317
    QMetaObject::invokeMethod(&mApplication,
hgs
parents: 40
diff changeset
   318
                              "popView",
hgs
parents: 40
diff changeset
   319
                              Qt::QueuedConnection);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   320
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   321
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   322
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   323
    About to exit view. Application calls this function when user has
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   324
    pressed back key and editor needs to delete the draft message. This is
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   325
    called when "auto-exiting" after a successful mail sending.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   326
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   327
void NmEditorView::aboutToExitView()
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   328
{
43
hgs
parents: 40
diff changeset
   329
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   330
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   331
    // These operations need to be stopped before message can be deleted
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   332
    if (mAddAttachmentOperation && mAddAttachmentOperation->isRunning()) {
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   333
        mAddAttachmentOperation->cancelOperation();
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   334
    }
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   335
    if (mRemoveAttachmentOperation && mRemoveAttachmentOperation->isRunning()) {
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   336
        mRemoveAttachmentOperation->cancelOperation();
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   337
    }
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   338
44
hgs
parents: 43
diff changeset
   339
    if (mMessage) { // this is NULL if sending or saving is started
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   340
        // Delete message from drafts
43
hgs
parents: 40
diff changeset
   341
        mUiEngine.removeDraftMessage(mMessage);
hgs
parents: 40
diff changeset
   342
        mMessage = NULL;
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   343
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   344
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   345
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   346
/*!
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   347
    Lazy loading when view layout has been loaded
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   348
*/
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   349
void NmEditorView::viewReady()
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   350
{
43
hgs
parents: 40
diff changeset
   351
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   352
    
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   353
    // Connect options menu about to show to create options menu function
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   354
    // Menu needs to be create "just-in-time"
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   355
    connect(menu(), SIGNAL(aboutToShow()), this, SLOT(createOptionsMenu()));
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   356
    NmAction *dummy = new NmAction(0);
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   357
    menu()->addAction(dummy);
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   358
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   359
    mVkbHost = new HbShrinkingVkbHost(this);
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   360
    
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   361
    initializeVKB();
47
hgs
parents: 44
diff changeset
   362
    
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   363
    //start to listen VKB open and close signals for hiding the chrome.
47
hgs
parents: 44
diff changeset
   364
    connect(mVkbHost, SIGNAL(keypadOpened()), this, SLOT(vkbOpened()));
hgs
parents: 44
diff changeset
   365
    connect(mVkbHost, SIGNAL(keypadClosed()), this, SLOT(vkbClosed()));
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   366
    
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   367
    connect(mContent->header(), SIGNAL(recipientFieldsHaveContent(bool)),
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   368
            this, SLOT(setButtonsDimming(bool)) );
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   369
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   370
    // Connect to observe orientation change events
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   371
    connect(mApplication.mainWindow(), SIGNAL(orientationChanged(Qt::Orientation)),
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   372
            this, SLOT(orientationChanged(Qt::Orientation)));
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   373
    // Signal for handling the attachment list selection
44
hgs
parents: 43
diff changeset
   374
    connect(mHeaderWidget, SIGNAL(attachmentShortPressed(NmId)),
hgs
parents: 43
diff changeset
   375
            this, SLOT(openAttachmentTriggered(NmId)));
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   376
    connect(mHeaderWidget, SIGNAL(attachmentLongPressed(NmId, QPointF)),
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   377
            this, SLOT(attachmentLongPressed(NmId, QPointF)));
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   378
    
44
hgs
parents: 43
diff changeset
   379
    if (mStartParam) {
hgs
parents: 43
diff changeset
   380
        fetchMessageIfNeeded(*mStartParam);
hgs
parents: 43
diff changeset
   381
    }
hgs
parents: 43
diff changeset
   382
    else { // execution cannot proceed without start param 
hgs
parents: 43
diff changeset
   383
        QMetaObject::invokeMethod(&mApplication, "popView", Qt::QueuedConnection);
hgs
parents: 43
diff changeset
   384
    }
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   385
}
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   386
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   387
/*!
43
hgs
parents: 40
diff changeset
   388
    If entering editor for forwarding or replying, use attachment manager
hgs
parents: 40
diff changeset
   389
    to check that we have all message parts fetched. Also show dialog for
hgs
parents: 40
diff changeset
   390
    fetching progress.
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   391
*/
44
hgs
parents: 43
diff changeset
   392
void NmEditorView::fetchMessageIfNeeded(NmUiStartParam &startParam)
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   393
{
43
hgs
parents: 40
diff changeset
   394
    NM_FUNCTION;
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   395
    
44
hgs
parents: 43
diff changeset
   396
    if (startParam.editorStartMode() == NmUiEditorForward
hgs
parents: 43
diff changeset
   397
        || startParam.editorStartMode()== NmUiEditorReply
hgs
parents: 43
diff changeset
   398
        || startParam.editorStartMode() == NmUiEditorReplyAll) {
43
hgs
parents: 40
diff changeset
   399
        
hgs
parents: 40
diff changeset
   400
        fetchProgressDialogShow();
hgs
parents: 40
diff changeset
   401
        mAttaManager.clearObserver();
hgs
parents: 40
diff changeset
   402
        mAttaManager.setObserver(this);
hgs
parents: 40
diff changeset
   403
        mAttaManager.fetchAllMessageParts(
44
hgs
parents: 43
diff changeset
   404
            startParam.mailboxId(),
hgs
parents: 43
diff changeset
   405
            startParam.folderId(),
hgs
parents: 43
diff changeset
   406
            startParam.messageId());
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   407
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   408
    else {
44
hgs
parents: 43
diff changeset
   409
        startMessageCreation(startParam);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   410
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   411
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   412
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   413
/*!
43
hgs
parents: 40
diff changeset
   414
    Slot. Called when attachments fetch progress changes.
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   415
*/
43
hgs
parents: 40
diff changeset
   416
void NmEditorView::progressChanged(int value)
hgs
parents: 40
diff changeset
   417
{
hgs
parents: 40
diff changeset
   418
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   419
    
hgs
parents: 40
diff changeset
   420
    Q_UNUSED(value);
hgs
parents: 40
diff changeset
   421
}
hgs
parents: 40
diff changeset
   422
hgs
parents: 40
diff changeset
   423
/*!
hgs
parents: 40
diff changeset
   424
    Slot. Called when attachments fetch is completed. We can start
hgs
parents: 40
diff changeset
   425
    message creation. 
hgs
parents: 40
diff changeset
   426
*/
hgs
parents: 40
diff changeset
   427
void NmEditorView::fetchCompleted(int result)
hgs
parents: 40
diff changeset
   428
{
hgs
parents: 40
diff changeset
   429
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   430
    
44
hgs
parents: 43
diff changeset
   431
    if (result == NmNoError && mStartParam) {
hgs
parents: 43
diff changeset
   432
        startMessageCreation(*mStartParam);
43
hgs
parents: 40
diff changeset
   433
    }
hgs
parents: 40
diff changeset
   434
    else {
47
hgs
parents: 44
diff changeset
   435
        // Show the fetching failed note only when
hgs
parents: 44
diff changeset
   436
        // the error is not Device/System errors, 
hgs
parents: 44
diff changeset
   437
        if (result != NmNoError && 
hgs
parents: 44
diff changeset
   438
            result != NmNotFoundError &&
hgs
parents: 44
diff changeset
   439
            result != NmGeneralError &&
hgs
parents: 44
diff changeset
   440
            result != NmCancelError &&
hgs
parents: 44
diff changeset
   441
            result != NmAuthenticationError &&
hgs
parents: 44
diff changeset
   442
            result != NmServerConnectionError &&
hgs
parents: 44
diff changeset
   443
            result != NmConnectionError) {
hgs
parents: 44
diff changeset
   444
            
hgs
parents: 44
diff changeset
   445
            HbNotificationDialog *note = new HbNotificationDialog(); 
hgs
parents: 44
diff changeset
   446
            
hgs
parents: 44
diff changeset
   447
            bool enalbeAttribute(true);
hgs
parents: 44
diff changeset
   448
            note->setAttribute(Qt::WA_DeleteOnClose, enalbeAttribute);
hgs
parents: 44
diff changeset
   449
            
hgs
parents: 44
diff changeset
   450
            note->setIcon(HbIcon(QLatin1String("note_warning")));
hgs
parents: 44
diff changeset
   451
            
hgs
parents: 44
diff changeset
   452
            note->setTitle(hbTrId("txt_mail_dpopinfo_loading_failed"));
hgs
parents: 44
diff changeset
   453
            note->setTitleTextWrapping(Hb::TextWordWrap);
hgs
parents: 44
diff changeset
   454
            
hgs
parents: 44
diff changeset
   455
            note->setDismissPolicy(HbNotificationDialog::TapAnywhere);
hgs
parents: 44
diff changeset
   456
            note->setTimeout(HbNotificationDialog::StandardTimeout);
hgs
parents: 44
diff changeset
   457
            
hgs
parents: 44
diff changeset
   458
            note->setSequentialShow(true);
hgs
parents: 44
diff changeset
   459
            note->show();
hgs
parents: 44
diff changeset
   460
        }
44
hgs
parents: 43
diff changeset
   461
        
47
hgs
parents: 44
diff changeset
   462
        mWaitDialog->close();         
43
hgs
parents: 40
diff changeset
   463
        QMetaObject::invokeMethod(&mApplication, "popView", Qt::QueuedConnection);
hgs
parents: 40
diff changeset
   464
    }
hgs
parents: 40
diff changeset
   465
}
hgs
parents: 40
diff changeset
   466
hgs
parents: 40
diff changeset
   467
void NmEditorView::fetchProgressDialogShow()
hgs
parents: 40
diff changeset
   468
{
hgs
parents: 40
diff changeset
   469
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   470
    
hgs
parents: 40
diff changeset
   471
    delete mWaitDialog;
hgs
parents: 40
diff changeset
   472
    mWaitDialog = NULL;
hgs
parents: 40
diff changeset
   473
    // Create new wait dialog and set it to me modal with dimmed background
hgs
parents: 40
diff changeset
   474
    mWaitDialog = new HbProgressDialog(HbProgressDialog::WaitDialog);
hgs
parents: 40
diff changeset
   475
    mWaitDialog->setModal(true);
hgs
parents: 40
diff changeset
   476
    mWaitDialog->setBackgroundFaded(true);
hgs
parents: 40
diff changeset
   477
    connect(mWaitDialog, SIGNAL(cancelled()), this, SLOT(fetchProgressDialogCancelled()));
hgs
parents: 40
diff changeset
   478
    mWaitDialog->setText(hbTrId("txt_mail_dialog_loading_mail_content"));
hgs
parents: 40
diff changeset
   479
    // Display wait dialog
hgs
parents: 40
diff changeset
   480
    mWaitDialog->show();
hgs
parents: 40
diff changeset
   481
}
hgs
parents: 40
diff changeset
   482
hgs
parents: 40
diff changeset
   483
/*!
hgs
parents: 40
diff changeset
   484
    This is called by mFetchProgressDialog when the note is cancelled
hgs
parents: 40
diff changeset
   485
 */
hgs
parents: 40
diff changeset
   486
void NmEditorView::fetchProgressDialogCancelled()
hgs
parents: 40
diff changeset
   487
{
hgs
parents: 40
diff changeset
   488
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   489
    
hgs
parents: 40
diff changeset
   490
    if (mAttaManager.isFetching()) {
hgs
parents: 40
diff changeset
   491
        mAttaManager.cancelFetch();
hgs
parents: 40
diff changeset
   492
        mAttaManager.clearObserver();
hgs
parents: 40
diff changeset
   493
    }
hgs
parents: 40
diff changeset
   494
    QMetaObject::invokeMethod(&mApplication, "popView", Qt::QueuedConnection);
hgs
parents: 40
diff changeset
   495
}
hgs
parents: 40
diff changeset
   496
44
hgs
parents: 43
diff changeset
   497
void NmEditorView::startMessageCreation(NmUiStartParam &startParam)
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   498
{
43
hgs
parents: 40
diff changeset
   499
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   500
    
44
hgs
parents: 43
diff changeset
   501
    NmUiEditorStartMode startMode = startParam.editorStartMode();
hgs
parents: 43
diff changeset
   502
    NmId mailboxId = startParam.mailboxId();
hgs
parents: 43
diff changeset
   503
    NmId folderId = startParam.folderId();
hgs
parents: 43
diff changeset
   504
    NmId msgId = startParam.messageId();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   505
    
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   506
    if (mMessageCreationOperation && mMessageCreationOperation->isRunning()) {
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   507
        mMessageCreationOperation->cancelOperation();
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   508
    }
47
hgs
parents: 44
diff changeset
   509
	  
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   510
    // original message is now fetched so start message creation
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   511
    if (startMode == NmUiEditorForward) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   512
        mMessageCreationOperation = mUiEngine.createForwardMessage(mailboxId, msgId);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   513
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   514
    else if (startMode == NmUiEditorReply || startMode == NmUiEditorReplyAll) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   515
        mMessageCreationOperation = mUiEngine.createReplyMessage(mailboxId, 
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   516
            msgId, 
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   517
            startMode == NmUiEditorReplyAll);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   518
    }
44
hgs
parents: 43
diff changeset
   519
    else if (startMode == NmUiEditorFromDrafts) {
hgs
parents: 43
diff changeset
   520
        // Draft opened, so reload message and fill editor with message data.
hgs
parents: 43
diff changeset
   521
        mMessage = mUiEngine.message(
hgs
parents: 43
diff changeset
   522
            mStartParam->mailboxId(), 
hgs
parents: 43
diff changeset
   523
            mStartParam->folderId(), 
hgs
parents: 43
diff changeset
   524
            mStartParam->messageId());
hgs
parents: 43
diff changeset
   525
        fillEditorWithMessageContents();
hgs
parents: 43
diff changeset
   526
    }
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   527
    else {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   528
        mMessageCreationOperation = mUiEngine.createNewMessage(mailboxId);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   529
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   530
    
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   531
    // operation continues in messageCreated() once it finishes ok
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   532
    if (mMessageCreationOperation) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   533
        connect(mMessageCreationOperation,
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   534
                SIGNAL(operationCompleted(int)),
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   535
                this,
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   536
                SLOT(messageCreated(int)));
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   537
    }    
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   538
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   539
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   540
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   541
    Starting the message sending is handled here.
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   542
*/
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   543
void NmEditorView::startSending()
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   544
{
43
hgs
parents: 40
diff changeset
   545
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   546
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   547
    // The message contents should be verified
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   548
    updateMessageWithEditorContents();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   549
    
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   550
    // verify addresses before sending
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   551
    QList<NmAddress> invalidAddresses;
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   552
    if (mMessage) {
47
hgs
parents: 44
diff changeset
   553
        NmUtilities::getRecipientsFromMessage(*mMessage, invalidAddresses, NmUtilities::NmInvalidAddress);
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   554
    }
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   555
    
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   556
    if (invalidAddresses.count() > 0) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   557
        
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   558
        // invalid addresses found, verify send from user
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   559
        QString noteText = hbTrId("txt_mail_dialog_invalid_mail_address_send");
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   560
        // set the first failing address to the note
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   561
        noteText = noteText.arg(invalidAddresses.at(0).address());
40
hgs
parents: 23
diff changeset
   562
        
hgs
parents: 23
diff changeset
   563
        if (mQueryDialog) {
hgs
parents: 23
diff changeset
   564
            delete mQueryDialog;
hgs
parents: 23
diff changeset
   565
            mQueryDialog = 0;
hgs
parents: 23
diff changeset
   566
        }
hgs
parents: 23
diff changeset
   567
        // Launch query dialog. Pressing "yes" will finalize the sending.
hgs
parents: 23
diff changeset
   568
        mQueryDialog = NmUtilities::displayQuestionNote(noteText,
hgs
parents: 23
diff changeset
   569
                                                        this,
hgs
parents: 23
diff changeset
   570
                                                        SLOT(invalidAddressQuery(HbAction*)));
hgs
parents: 23
diff changeset
   571
    }
hgs
parents: 23
diff changeset
   572
    else {
hgs
parents: 23
diff changeset
   573
        // no need to ask anything, just send
hgs
parents: 23
diff changeset
   574
        finalizeSending();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   575
    }
40
hgs
parents: 23
diff changeset
   576
}
hgs
parents: 23
diff changeset
   577
hgs
parents: 23
diff changeset
   578
/*!
hgs
parents: 23
diff changeset
   579
    Send the message after all checks have been done.
hgs
parents: 23
diff changeset
   580
*/
hgs
parents: 23
diff changeset
   581
void NmEditorView::finalizeSending()
hgs
parents: 23
diff changeset
   582
{
43
hgs
parents: 40
diff changeset
   583
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   584
    
40
hgs
parents: 23
diff changeset
   585
    QList<NmOperation *> preliminaryOperations;
43
hgs
parents: 40
diff changeset
   586
    if (mAddAttachmentOperation && mAddAttachmentOperation->isRunning()) {
hgs
parents: 40
diff changeset
   587
        preliminaryOperations.append(mAddAttachmentOperation);
hgs
parents: 40
diff changeset
   588
    }
hgs
parents: 40
diff changeset
   589
    if (mRemoveAttachmentOperation && mRemoveAttachmentOperation->isRunning()) {
hgs
parents: 40
diff changeset
   590
        preliminaryOperations.append(mRemoveAttachmentOperation);
hgs
parents: 40
diff changeset
   591
    }
40
hgs
parents: 23
diff changeset
   592
    // ownership of mMessage is transferred
hgs
parents: 23
diff changeset
   593
    // NmOperations are automatically deleted after completion
hgs
parents: 23
diff changeset
   594
    mUiEngine.sendMessage(mMessage, preliminaryOperations);
hgs
parents: 23
diff changeset
   595
    mMessage = NULL;
hgs
parents: 23
diff changeset
   596
    preliminaryOperations.clear();
43
hgs
parents: 40
diff changeset
   597
hgs
parents: 40
diff changeset
   598
    bool service = XQServiceUtil::isService();
hgs
parents: 40
diff changeset
   599
hgs
parents: 40
diff changeset
   600
    // If sending is started as a service, progress dialog needs to be shown
hgs
parents: 40
diff changeset
   601
    // so long that sending is finished otherwise we can close pop current view.
44
hgs
parents: 43
diff changeset
   602
    if (service && mStartParam && mStartParam->service() && 
hgs
parents: 43
diff changeset
   603
        mUiEngine.isSendingMessage()) {
43
hgs
parents: 40
diff changeset
   604
        connect(&mUiEngine, SIGNAL(sendOperationCompleted()),
hgs
parents: 40
diff changeset
   605
            this, SLOT(handleSendOperationCompleted()), Qt::UniqueConnection);
hgs
parents: 40
diff changeset
   606
hgs
parents: 40
diff changeset
   607
        // Construct and setup the wait dialog.
hgs
parents: 40
diff changeset
   608
        mServiceSendingDialog = new HbProgressDialog(HbProgressDialog::WaitDialog);
hgs
parents: 40
diff changeset
   609
        mServiceSendingDialog->setAttribute(Qt::WA_DeleteOnClose);
hgs
parents: 40
diff changeset
   610
        mServiceSendingDialog->setText(hbTrId("txt_mail_shareui_sending_please_wait"));
hgs
parents: 40
diff changeset
   611
        connect(mServiceSendingDialog, SIGNAL(cancelled()),
hgs
parents: 40
diff changeset
   612
            this, SLOT(sendProgressDialogCancelled()));
hgs
parents: 40
diff changeset
   613
hgs
parents: 40
diff changeset
   614
        if (!XQServiceUtil::isEmbedded()) {
hgs
parents: 40
diff changeset
   615
            // Hide the application.
hgs
parents: 40
diff changeset
   616
            XQServiceUtil::toBackground(true);
hgs
parents: 40
diff changeset
   617
        }
hgs
parents: 40
diff changeset
   618
         // Display the wait dialog.
hgs
parents: 40
diff changeset
   619
         mServiceSendingDialog->setModal(true);
hgs
parents: 40
diff changeset
   620
         mServiceSendingDialog->setBackgroundFaded(true);
hgs
parents: 40
diff changeset
   621
         mServiceSendingDialog->show();
hgs
parents: 40
diff changeset
   622
    } else {
hgs
parents: 40
diff changeset
   623
        // Must use delayed editor view destruction so that query dialog
hgs
parents: 40
diff changeset
   624
        // (which has signaled this) gets time to complete.
hgs
parents: 40
diff changeset
   625
        QMetaObject::invokeMethod(&mApplication, "popView", Qt::QueuedConnection);
hgs
parents: 40
diff changeset
   626
    }
40
hgs
parents: 23
diff changeset
   627
}
hgs
parents: 23
diff changeset
   628
hgs
parents: 23
diff changeset
   629
/*!
hgs
parents: 23
diff changeset
   630
    Handle the user selection for invalid address query which was started by startSending.
hgs
parents: 23
diff changeset
   631
*/
hgs
parents: 23
diff changeset
   632
void NmEditorView::invalidAddressQuery(HbAction* action)
hgs
parents: 23
diff changeset
   633
{
43
hgs
parents: 40
diff changeset
   634
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   635
hgs
parents: 40
diff changeset
   636
    HbMessageBox *dlg = static_cast<HbMessageBox*>(sender());
hgs
parents: 40
diff changeset
   637
    // The first action in dialogs action list is for the "Yes"-button.
hgs
parents: 40
diff changeset
   638
    if (action == dlg->actions().at(0)) {
40
hgs
parents: 23
diff changeset
   639
        finalizeSending();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   640
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   641
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   642
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   643
/*!
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   644
    This is called when the view's geometry size has been changed, eg. when VKB is opened/closed.
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   645
*/
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   646
void NmEditorView::resizeEvent(QGraphicsSceneResizeEvent *event)
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   647
{
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   648
    NM_FUNCTION;
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   649
    
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   650
    NmBaseView::resizeEvent(event);
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   651
    
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   652
    emit sizeChanged();
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   653
}
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   654
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   655
/*!
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   656
    This is signalled by mMessageCreationOperation when message is created.
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   657
*/
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   658
void NmEditorView::messageCreated(int result)
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   659
{
43
hgs
parents: 40
diff changeset
   660
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   661
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   662
    delete mMessage;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   663
    mMessage = NULL;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   664
43
hgs
parents: 40
diff changeset
   665
    // Close wait dialog here
hgs
parents: 40
diff changeset
   666
    if (mWaitDialog) {
hgs
parents: 40
diff changeset
   667
        mWaitDialog->close();
hgs
parents: 40
diff changeset
   668
    }
hgs
parents: 40
diff changeset
   669
    
44
hgs
parents: 43
diff changeset
   670
    if (result == NmNoError && mStartParam && mMessageCreationOperation) {
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   671
        NmUiEditorStartMode startMode = mStartParam->editorStartMode();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   672
        
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   673
        // get message "again" from engine to update the message contents 
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   674
        mMessage = mUiEngine.message(
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   675
            mStartParam->mailboxId(), 
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   676
            mStartParam->folderId(), 
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   677
            mMessageCreationOperation->getMessageId());
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   678
        
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   679
        fillEditorWithMessageContents();       
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   680
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   681
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   682
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   683
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   684
   Updates the message with the editor contents.
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   685
*/
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   686
void NmEditorView::updateMessageWithEditorContents()
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   687
{
43
hgs
parents: 40
diff changeset
   688
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   689
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   690
    if (mMessage) {
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   691
        if (mContent && mContent->editor()) {
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   692
            NmMessagePart* bodyPart = mMessage->htmlBodyPart();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   693
            if (bodyPart) {
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   694
                bodyPart->setTextContent(mContent->editor()->toHtml(), NmContentTypeTextHtml);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   695
            }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   696
            bodyPart = mMessage->plainTextBodyPart();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   697
            if (bodyPart) {
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   698
                bodyPart->setTextContent(mContent->editor()->toPlainText(), NmContentTypeTextPlain);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   699
            }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   700
        }
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   701
        if (mContent && mContent->header() ) {
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   702
            if (mContent->header()->subjectEdit()) {
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   703
                mMessage->envelope().setSubject(
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   704
                    mContent->header()->subjectEdit()->text());
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   705
            }
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   706
            if (mContent->header()->toEdit()) {
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   707
                QString toFieldText =
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   708
                    mContent->header()->toEdit()->text();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   709
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   710
                // This verification of zero length string isn't needed
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   711
                // after list of addresses
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   712
                if (toFieldText.length() > 0) {
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   713
                    mMessage->envelope().setToRecipients(mContent->header()->toEdit()->emailAddressList());  
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   714
                }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   715
            }
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   716
            if (mContent->header()->ccEdit()) {
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   717
                QString ccFieldText =
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   718
                    mContent->header()->ccEdit()->text();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   719
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   720
                if (ccFieldText.length() > 0) {
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   721
                    mMessage->envelope().setCcRecipients(mContent->header()->ccEdit()->emailAddressList());      
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   722
                }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   723
            }
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   724
            if (mContent->header()->bccEdit()) {
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   725
                QString bccFieldText =
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   726
                    mContent->header()->bccEdit()->text();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   727
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   728
                if (bccFieldText.length() > 0) {
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   729
                    mMessage->envelope().setBccRecipients(mContent->header()->bccEdit()->emailAddressList());  
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   730
                }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   731
            }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   732
        }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   733
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   734
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   735
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   736
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   737
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   738
    Updates the message with the editor contents. Called only once when the
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   739
    editor is launched.
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   740
*/
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   741
void NmEditorView::fillEditorWithMessageContents()
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   742
{
43
hgs
parents: 40
diff changeset
   743
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   744
    
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   745
    if (!mStartParam || !mMessage || !mContent) {
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   746
        return;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   747
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   748
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   749
    NmMessageEnvelope messageEnvelope(mMessage->envelope());
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   750
    bool useStartParam(false);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   751
44
hgs
parents: 43
diff changeset
   752
    NmUiEditorStartMode editorStartMode = mStartParam->editorStartMode();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   753
44
hgs
parents: 43
diff changeset
   754
    if (editorStartMode == NmUiEditorMailto) {
hgs
parents: 43
diff changeset
   755
        // Retrieve the message header data e.g. recipients from mStartParam.
hgs
parents: 43
diff changeset
   756
        useStartParam = true;        
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   757
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   758
    
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   759
    // Set recipients (to, cc and bcc).
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   760
    QString toAddressesString;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   761
    QString ccAddressesString;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   762
    QString bccAddressesString;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   763
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   764
    if (useStartParam) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   765
        toAddressesString = addressListToString(mStartParam->mailtoAddressList());
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   766
        ccAddressesString = addressListToString(mStartParam->ccAddressList());
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   767
        bccAddressesString = addressListToString(mStartParam->bccAddressList());
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   768
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   769
    else {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   770
        toAddressesString = addressListToString(messageEnvelope.toRecipients());
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   771
        ccAddressesString = addressListToString(messageEnvelope.ccRecipients());
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   772
        bccAddressesString = addressListToString(messageEnvelope.bccRecipients());
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   773
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   774
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   775
    mContent->header()->toEdit()->setPlainText(toAddressesString);
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   776
    mContent->header()->ccEdit()->setPlainText(ccAddressesString);
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   777
    mContent->header()->bccEdit()->setPlainText(bccAddressesString);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   778
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   779
    if (ccAddressesString.length() || bccAddressesString.length()) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   780
        // Since cc or/and bcc recipients exist, expand the group box to display
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   781
        // the addresses by expanding the group box.
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   782
        mContent->header()->setFieldVisibility(true);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   783
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   784
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   785
    // Set subject.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   786
    if (useStartParam) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   787
        QString *subject = mStartParam->subject();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   788
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   789
        if (subject) {
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   790
            mContent->header()->subjectEdit()->setPlainText(*subject);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   791
        }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   792
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   793
    else {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   794
        // Construct the subject field.
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   795
        mContent->header()->subjectEdit()->setPlainText(
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   796
            addSubjectPrefix(editorStartMode, messageEnvelope.subject()));
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   797
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   798
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   799
    // Set priority.
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   800
    if (editorStartMode==NmUiEditorReply || editorStartMode==NmUiEditorReplyAll) {
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   801
        //Clear the importance flag. Replied messages dont keep the importance
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   802
        setPriority(NmActionResponseCommandNone);
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   803
    }
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   804
    mHeaderWidget->setPriority(messageEnvelope.priority());
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   805
    
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   806
    // Set the message body.
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   807
    if (editorStartMode==NmUiEditorReply||
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   808
        editorStartMode==NmUiEditorReplyAll||
44
hgs
parents: 43
diff changeset
   809
        editorStartMode==NmUiEditorForward||
hgs
parents: 43
diff changeset
   810
        editorStartMode==NmUiEditorFromDrafts){
43
hgs
parents: 40
diff changeset
   811
hgs
parents: 40
diff changeset
   812
        // Use the body from the original message.
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   813
        NmMessage *originalMessage = mUiEngine.message(mStartParam->mailboxId(), 
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   814
                                                       mStartParam->folderId(), 
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   815
                                                       mStartParam->messageId());
43
hgs
parents: 40
diff changeset
   816
hgs
parents: 40
diff changeset
   817
        if (originalMessage) {
hgs
parents: 40
diff changeset
   818
            NmMessagePart *plainPart = originalMessage->plainTextBodyPart();
hgs
parents: 40
diff changeset
   819
hgs
parents: 40
diff changeset
   820
            if (plainPart) {
hgs
parents: 40
diff changeset
   821
                mUiEngine.contentToMessagePart(originalMessage->envelope().mailboxId(),
hgs
parents: 40
diff changeset
   822
                                               originalMessage->envelope().folderId(),
hgs
parents: 40
diff changeset
   823
                                               originalMessage->envelope().messageId(),
hgs
parents: 40
diff changeset
   824
                                               *plainPart);
hgs
parents: 40
diff changeset
   825
            }
hgs
parents: 40
diff changeset
   826
hgs
parents: 40
diff changeset
   827
            NmMessagePart *htmlPart = originalMessage->htmlBodyPart();
hgs
parents: 40
diff changeset
   828
hgs
parents: 40
diff changeset
   829
            if (htmlPart) {
hgs
parents: 40
diff changeset
   830
                mUiEngine.contentToMessagePart(originalMessage->envelope().mailboxId(),
hgs
parents: 40
diff changeset
   831
                                               originalMessage->envelope().folderId(),
hgs
parents: 40
diff changeset
   832
                                               originalMessage->envelope().messageId(),
hgs
parents: 40
diff changeset
   833
                                               *htmlPart);
hgs
parents: 40
diff changeset
   834
            }
hgs
parents: 40
diff changeset
   835
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
   836
		mContent->setMessageData(*originalMessage, editorStartMode);
43
hgs
parents: 40
diff changeset
   837
        }
hgs
parents: 40
diff changeset
   838
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   839
        delete originalMessage;
43
hgs
parents: 40
diff changeset
   840
        originalMessage = NULL;
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   841
    }
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   842
    
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   843
    // Get list of attachments from the message and set those into UI attachment list
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   844
    QList<NmMessagePart*> attachments;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   845
    mMessage->attachmentList(attachments);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   846
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   847
    for (int i=0; i<attachments.count(); i++) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   848
        mHeaderWidget->addAttachment(
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   849
            attachments[i]->attachmentName(),
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   850
            QString::number(attachments[i]->size()),
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   851
            attachments[i]->partId());
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   852
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   853
44
hgs
parents: 43
diff changeset
   854
    // Attach passed files to the message.
hgs
parents: 43
diff changeset
   855
    QStringList *fileList = mStartParam->attachmentList();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   856
44
hgs
parents: 43
diff changeset
   857
    if (fileList) {
hgs
parents: 43
diff changeset
   858
        addAttachments(*fileList);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   859
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   860
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   861
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   862
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   863
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   864
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   865
    createToolBar. Function asks menu commands from extension
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   866
    to be added to toolbar owned by the HbView.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   867
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   868
void NmEditorView::createToolBar()
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   869
{
43
hgs
parents: 40
diff changeset
   870
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   871
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   872
    HbToolBar *tb = toolBar();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   873
    NmUiExtensionManager &extMngr = mApplication.extManager();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   874
    if (tb && &extMngr && mStartParam) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   875
        tb->clearActions();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   876
        NmActionRequest request(this, NmActionToolbar, NmActionContextViewEditor,
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   877
                NmActionContextDataNone, mStartParam->mailboxId(), mStartParam->folderId() );
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   878
        QList<NmAction *> list;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   879
        extMngr.getActions(request, list);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   880
        for (int i = 0; i < list.count(); i++) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   881
            tb->addAction(list[i]);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   882
            // If action has NmSendable condition, it is shown only when send action
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   883
            // is available, i.e. when at least one recipient field has data.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   884
            if( list[i]->availabilityCondition() == NmAction::NmSendable ) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   885
                list[i]->setEnabled(false);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   886
            }
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   887
            else if (list[i]->availabilityCondition() == NmAction::NmAttachable) {
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   888
                HbToolBarExtension* extension = new HbToolBarExtension();
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   889
                mAttachmentPicker = new NmAttachmentPicker(this);
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   890
                
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   891
                if (extension && mAttachmentPicker) {
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   892
                    connect(mAttachmentPicker, SIGNAL(attachmentsFetchOk(const QVariant &)),
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   893
                        this, SLOT(onAttachmentReqCompleted(const QVariant &)));            
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   894
                                                
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   895
                    HbAction* actionPhoto = 
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   896
                        extension->addAction(hbTrId("txt_mail_list_photo"), extension, SLOT(close()));
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   897
                    connect(actionPhoto, SIGNAL(triggered()), mAttachmentPicker, SLOT(fetchImage()));
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   898
                    
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   899
                    HbAction* actionMusic = 
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   900
                        extension->addAction(hbTrId("txt_mail_list_music"), extension, SLOT(close()));
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   901
                    connect(actionMusic, SIGNAL(triggered()), mAttachmentPicker, SLOT(fetchAudio()));
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   902
                    
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   903
                    HbAction* actionVideo = 
43
hgs
parents: 40
diff changeset
   904
                        extension->addAction(hbTrId("txt_mail_list_video"), extension, SLOT(close()));
hgs
parents: 40
diff changeset
   905
                    connect(actionVideo, SIGNAL(triggered()), mAttachmentPicker, SLOT(fetchVideo()));
hgs
parents: 40
diff changeset
   906
                    
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   907
                    HbAction* actionOther = 
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   908
                        extension->addAction(hbTrId("txt_mail_list_other"), extension, SLOT(close()));
43
hgs
parents: 40
diff changeset
   909
                    connect(actionOther, SIGNAL(triggered()), mAttachmentPicker, SLOT(fetchOther()));
hgs
parents: 40
diff changeset
   910
                    
hgs
parents: 40
diff changeset
   911
                    HbAction* actionCameraStill = 
hgs
parents: 40
diff changeset
   912
                       extension->addAction(hbTrId("txt_mail_list_new_photo"), extension, SLOT(close()));
hgs
parents: 40
diff changeset
   913
                    connect(actionCameraStill, SIGNAL(triggered()), mAttachmentPicker, SLOT(fetchCameraStill()));
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   914
            
43
hgs
parents: 40
diff changeset
   915
                    HbAction* actionCameraVideo = 
hgs
parents: 40
diff changeset
   916
                        extension->addAction(hbTrId("txt_mail_list_new_video"), extension, SLOT(close()));
hgs
parents: 40
diff changeset
   917
                    connect(actionCameraVideo, SIGNAL(triggered()), mAttachmentPicker, SLOT(fetchCameraVideo()));
hgs
parents: 40
diff changeset
   918
                                        
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   919
                    list[i]->setToolBarExtension(extension);
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   920
                }
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   921
            }            
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   922
        }        
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   923
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   924
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   925
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   926
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   927
    createOptionsMenu. Functions asks menu commands from extension
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   928
    to be added to options menu.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   929
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   930
void NmEditorView::createOptionsMenu()
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   931
{
43
hgs
parents: 40
diff changeset
   932
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   933
    
40
hgs
parents: 23
diff changeset
   934
    menu()->clearActions();
hgs
parents: 23
diff changeset
   935
hgs
parents: 23
diff changeset
   936
	// Create CC/BCC options menu object
hgs
parents: 23
diff changeset
   937
    if (mCcBccFieldVisible) {
hgs
parents: 23
diff changeset
   938
        menu()->addAction(hbTrId("txt_mail_opt_hide_cc_bcc"), this, SLOT(switchCcBccFieldVisibility()));
hgs
parents: 23
diff changeset
   939
    }
hgs
parents: 23
diff changeset
   940
    else {
hgs
parents: 23
diff changeset
   941
        menu()->addAction(hbTrId("txt_mail_opt_show_cc_bcc"), this, SLOT(switchCcBccFieldVisibility()));
hgs
parents: 23
diff changeset
   942
    }
hgs
parents: 23
diff changeset
   943
hgs
parents: 23
diff changeset
   944
	// Create Priority options menu object
hgs
parents: 23
diff changeset
   945
	if (!mPrioritySubMenu) {
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   946
        mPrioritySubMenu = new HbMenu();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   947
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   948
    mPrioritySubMenu->clearActions();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   949
    NmActionRequest request(this, NmActionOptionsMenu, NmActionContextViewEditor,
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   950
            NmActionContextDataMessage, mStartParam->mailboxId(), mStartParam->folderId(),
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   951
            mStartParam->messageId());
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   952
    NmUiExtensionManager &extMngr = mApplication.extManager();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   953
    QList<NmAction*> list;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   954
    extMngr.getActions(request, list);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   955
    for (int i = 0; i < list.count(); i++) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   956
        mPrioritySubMenu->addAction(list[i]);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   957
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   958
    mPrioritySubMenu->setObjectName("editorPrioritySubMenu");
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   959
    mPrioritySubMenu->setTitle(hbTrId("txt_mail_opt_add_priority"));
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   960
    menu()->addMenu(mPrioritySubMenu);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   961
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   962
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   963
/*!
40
hgs
parents: 23
diff changeset
   964
    Show or hide Cc field
hgs
parents: 23
diff changeset
   965
*/
hgs
parents: 23
diff changeset
   966
void NmEditorView::switchCcBccFieldVisibility()
hgs
parents: 23
diff changeset
   967
{
43
hgs
parents: 40
diff changeset
   968
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   969
    
40
hgs
parents: 23
diff changeset
   970
    if (mCcBccFieldVisible) {
hgs
parents: 23
diff changeset
   971
    	mCcBccFieldVisible = false;
hgs
parents: 23
diff changeset
   972
    }
hgs
parents: 23
diff changeset
   973
    else {
hgs
parents: 23
diff changeset
   974
    	mCcBccFieldVisible = true;
hgs
parents: 23
diff changeset
   975
    }
hgs
parents: 23
diff changeset
   976
    mHeaderWidget->setFieldVisibility( mCcBccFieldVisible );
hgs
parents: 23
diff changeset
   977
}
hgs
parents: 23
diff changeset
   978
hgs
parents: 23
diff changeset
   979
/*!
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   980
    handleActionCommand. From NmActionObserver, extension manager calls this
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   981
    call to handle menu command in the UI.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   982
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   983
void NmEditorView::handleActionCommand(NmActionResponse &actionResponse)
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   984
{
43
hgs
parents: 40
diff changeset
   985
    NM_FUNCTION;
hgs
parents: 40
diff changeset
   986
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   987
    NmActionResponseCommand responseCommand = actionResponse.responseCommand();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   988
    
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   989
    // Handle options menu
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   990
    if (actionResponse.menuType() == NmActionOptionsMenu) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   991
        setPriority(responseCommand);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   992
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   993
    else if (actionResponse.menuType() == NmActionToolbar) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   994
        switch (responseCommand) {
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   995
        case NmActionResponseCommandSendMail: {
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   996
            // Just in case send mail would be somehow accessible during message creation or
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   997
            // outobox checking
43
hgs
parents: 40
diff changeset
   998
            if (!mMessageCreationOperation || !mMessageCreationOperation->isRunning()) {
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   999
                startSending();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1000
            }
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1001
            break;
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1002
        }
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1003
        default:
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1004
            break;
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1005
        }
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1006
    }
40
hgs
parents: 23
diff changeset
  1007
    else if (actionResponse.menuType() == NmActionContextMenu) {
hgs
parents: 23
diff changeset
  1008
        switch (responseCommand) {
hgs
parents: 23
diff changeset
  1009
        case NmActionResponseCommandRemoveAttachment: {
hgs
parents: 23
diff changeset
  1010
            removeAttachmentTriggered();
hgs
parents: 23
diff changeset
  1011
            break;
hgs
parents: 23
diff changeset
  1012
        }
hgs
parents: 23
diff changeset
  1013
        case NmActionResponseCommandOpenAttachment: {
44
hgs
parents: 43
diff changeset
  1014
            openAttachmentTriggered(mSelectedAttachment);
40
hgs
parents: 23
diff changeset
  1015
            break;
hgs
parents: 23
diff changeset
  1016
        }
hgs
parents: 23
diff changeset
  1017
        default:
hgs
parents: 23
diff changeset
  1018
            break;
hgs
parents: 23
diff changeset
  1019
        }
hgs
parents: 23
diff changeset
  1020
    }
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1021
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1022
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1023
/*!
43
hgs
parents: 40
diff changeset
  1024
    Slot. Cancelled sending progress dialog.
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1025
*/
43
hgs
parents: 40
diff changeset
  1026
void NmEditorView::sendProgressDialogCancelled()
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1027
{
43
hgs
parents: 40
diff changeset
  1028
    // Must use delayed editor view destruction so that dialog
hgs
parents: 40
diff changeset
  1029
    // gets time to complete, closes also nmail.
hgs
parents: 40
diff changeset
  1030
    QMetaObject::invokeMethod(&mApplication, "popView", Qt::QueuedConnection);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1031
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1032
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1033
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1034
   Sets all toolbar and VKB buttons dimmed state. All actions that have the
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1035
   availability condition NmSendable set, will be enabled/disabled.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1036
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1037
void NmEditorView::setButtonsDimming(bool enabled)
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1038
{
43
hgs
parents: 40
diff changeset
  1039
    NM_FUNCTION;
hgs
parents: 40
diff changeset
  1040
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1041
    // Set the toolbar action states
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1042
    HbToolBar *tb = toolBar();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1043
    if (tb) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1044
        QList<QAction *> toolbarList = tb->actions();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1045
        int count = toolbarList.count();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1046
        for (int i = 0; i < count; i++) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1047
            NmAction *action = static_cast<NmAction *>(toolbarList[i]);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1048
            if (action->availabilityCondition() == NmAction::NmSendable) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1049
                action->setEnabled(enabled);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1050
            }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1051
        }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1052
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1053
        // Set the VKB action states
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1054
        // All editors of the view share the same action, so it is enough to set
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1055
        // this only to one of them.
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
  1056
        HbEditorInterface editorInterface(mContent->editor());
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1057
        QList<HbAction *> vkbList = editorInterface.actions();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1058
        count = vkbList.count();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1059
        for (int i = 0; i < count; i++) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1060
            NmAction *action = static_cast<NmAction *>(vkbList[i]);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1061
            if (action->availabilityCondition() == NmAction::NmSendable) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1062
                action->setEnabled(enabled);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1063
            }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1064
        }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1065
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1066
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1067
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1068
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1069
    Initialize the Virtual Keyboard to show the "Send" button
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1070
    for all editors of the view.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1071
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1072
void NmEditorView::initializeVKB()
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1073
{
43
hgs
parents: 40
diff changeset
  1074
    NM_FUNCTION;
hgs
parents: 40
diff changeset
  1075
    
44
hgs
parents: 43
diff changeset
  1076
    if (!mStartParam) {
hgs
parents: 43
diff changeset
  1077
        return;
hgs
parents: 43
diff changeset
  1078
    }
hgs
parents: 43
diff changeset
  1079
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1080
    NmActionRequest request(this, NmActionVKB, NmActionContextViewEditor,
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1081
         NmActionContextDataNone, mStartParam->mailboxId(), mStartParam->folderId() );
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1082
    NmUiExtensionManager &extMngr = mApplication.extManager();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1083
    if (&extMngr) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1084
        QList<NmAction *> list;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1085
        extMngr.getActions(request, list);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1086
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1087
        // VKB only supports one application key, but the responsibility of giving only one
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1088
        // action is left to the extension plugin. The rest are still attached to the VKB, but
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1089
        // they are not shown (unless VKB starts supporting more than one).
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1090
        for (int i = 0; i < list.count(); i++) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1091
            if( list[i]->availabilityCondition() == NmAction::NmSendable ) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1092
                list[i]->setEnabled(false);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1093
            }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1094
            list[i]->setIcon(NmIcons::getIcon(NmIcons::NmIconSend));
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1095
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1096
            // Link VKB to the action. This must be done to all
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1097
            // editors that show the button in VKB.
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
  1098
            HbEditorInterface editorInterface(mContent->editor());
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1099
            editorInterface.addAction(list[i]);
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
  1100
            HbEditorInterface toEditorInterface(mContent->header()->toEdit());
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1101
            toEditorInterface.addAction(list[i]);
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
  1102
            HbEditorInterface ccEditorInterface(mContent->header()->ccEdit());
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1103
            ccEditorInterface.addAction(list[i]);
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
  1104
            HbEditorInterface bccEditorInterface(mContent->header()->bccEdit());
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1105
            bccEditorInterface.addAction(list[i]);
48
10eaf342f539 201025_1
hgs
parents: 47
diff changeset
  1106
            HbEditorInterface subjectEditorInterface(mContent->header()->subjectEdit());
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1107
            subjectEditorInterface.addAction(list[i]);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1108
        }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1109
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1110
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1111
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1112
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1113
    Set mailbox name to title
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1114
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1115
void NmEditorView::setMailboxName()
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1116
{
43
hgs
parents: 40
diff changeset
  1117
    NM_FUNCTION;
hgs
parents: 40
diff changeset
  1118
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1119
    if (mStartParam){
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1120
        NmMailboxMetaData *meta = mUiEngine.mailboxById(mStartParam->mailboxId());
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1121
        if (meta){
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1122
            setTitle(meta->name());
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1123
        }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1124
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1125
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1126
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1127
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1128
   Adds a prefix to the subject for reply or forward. 
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1129
   Strips other occurrences of the prefix from the beginning.
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1130
*/
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1131
QString NmEditorView::addSubjectPrefix( NmUiEditorStartMode startMode, const QString &subject )
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1132
{
43
hgs
parents: 40
diff changeset
  1133
    NM_FUNCTION;
hgs
parents: 40
diff changeset
  1134
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1135
    QString newSubject(subject.trimmed());
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1136
    
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1137
    if (startMode == NmUiEditorReply || startMode == NmUiEditorReplyAll || 
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1138
        startMode == NmUiEditorForward) {
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1139
        QString rePrefix(hbTrId("txt_nmailui_reply_subject_prefix"));
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1140
        QString fwPrefix(hbTrId("txt_nmailui_forward_subject_prefix"));
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1141
        
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1142
        // strip extra prefixes from beginning
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1143
        int rePrefixLength(rePrefix.length());
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1144
        int fwPrefixLength(fwPrefix.length());
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1145
        
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1146
        bool startswithRe(newSubject.startsWith(rePrefix, Qt::CaseInsensitive));
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1147
        bool startswithFw(newSubject.startsWith(fwPrefix, Qt::CaseInsensitive));
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1148
        
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1149
        while (startswithRe || startswithFw) {            
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1150
            if (startswithRe) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1151
                newSubject.remove(0,rePrefixLength);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1152
                newSubject = newSubject.trimmed();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1153
            }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1154
            else if (startswithFw) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1155
                newSubject.remove(0,fwPrefixLength);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1156
                newSubject = newSubject.trimmed();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1157
            }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1158
            startswithRe = newSubject.startsWith(rePrefix, Qt::CaseInsensitive);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1159
            startswithFw = newSubject.startsWith(fwPrefix, Qt::CaseInsensitive);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1160
        }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1161
        
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1162
        if (startMode == NmUiEditorReply || startMode == NmUiEditorReplyAll) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1163
            newSubject = rePrefix + " " + newSubject;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1164
        }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1165
        else if (startMode == NmUiEditorForward) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1166
            newSubject = fwPrefix + " " + newSubject;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1167
        }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1168
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1169
    
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1170
    return newSubject;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1171
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1172
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1173
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1174
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1175
    This slot is called when 'attachment picker' request has been performed succesfully
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1176
    Parameter 'value' contains file currently one file name but later list of the files. 
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1177
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1178
void NmEditorView::onAttachmentReqCompleted(const QVariant &value)
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1179
{
43
hgs
parents: 40
diff changeset
  1180
    NM_FUNCTION;
hgs
parents: 40
diff changeset
  1181
    
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1182
    //temporary fix for music picker back button:
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1183
    //it shouldn't emit requestOk signal when nothing is selected
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1184
	if (value.canConvert<QStringList>()) {
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1185
	    QStringList list = value.toStringList();
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1186
        if (!list.at(0).isEmpty()) {
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1187
            addAttachments(list);
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1188
        }
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1189
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1190
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1191
43
hgs
parents: 40
diff changeset
  1192
/*!
hgs
parents: 40
diff changeset
  1193
    This slot is called when 'attachment picker' request has been unsuccesfull
hgs
parents: 40
diff changeset
  1194
    Parameter 'errorCode' is the error code returned by the service
hgs
parents: 40
diff changeset
  1195
    Parameter 'errorMessage' is the error message returned by the service
hgs
parents: 40
diff changeset
  1196
*/
hgs
parents: 40
diff changeset
  1197
void NmEditorView::onAttachmentsFetchError(int errorCode, const QString& errorMessage)
hgs
parents: 40
diff changeset
  1198
{
hgs
parents: 40
diff changeset
  1199
    NM_FUNCTION;
44
hgs
parents: 43
diff changeset
  1200
    Q_UNUSED(errorCode);
hgs
parents: 43
diff changeset
  1201
    Q_UNUSED(errorMessage);
43
hgs
parents: 40
diff changeset
  1202
    NM_COMMENT(QString("Error code: %1").arg(errorCode));
hgs
parents: 40
diff changeset
  1203
    NM_COMMENT(QString("Error message: %1").arg(errorMessage));
hgs
parents: 40
diff changeset
  1204
}
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1205
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1206
/*!
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1207
    Closes the wait dialog if one exists.
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1208
    
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1209
    This slot is called if the mail application has been started as a service
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1210
    and is about to close. Closing the application while still sending a message
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1211
    may cause unwanted cancelling of the operation.
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1212
*/
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1213
void NmEditorView::handleSendOperationCompleted()
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1214
{
43
hgs
parents: 40
diff changeset
  1215
    NM_FUNCTION;
hgs
parents: 40
diff changeset
  1216
hgs
parents: 40
diff changeset
  1217
    if (mServiceSendingDialog) {
hgs
parents: 40
diff changeset
  1218
        mServiceSendingDialog->close();
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1219
    }
43
hgs
parents: 40
diff changeset
  1220
    // Must use delayed editor view destruction so that dialog
hgs
parents: 40
diff changeset
  1221
    // gets time to complete, closes also nmail.
hgs
parents: 40
diff changeset
  1222
    QMetaObject::invokeMethod(&mApplication, "popView", Qt::QueuedConnection);
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1223
}
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1224
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1225
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1226
    Add list of attachments
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1227
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1228
void NmEditorView::addAttachments(const QStringList& fileNames) 
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1229
{
43
hgs
parents: 40
diff changeset
  1230
    NM_FUNCTION;
hgs
parents: 40
diff changeset
  1231
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1232
    // Add attachment name into UI
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1233
    foreach (QString fileName, fileNames)  {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1234
        // At this phase attachment size and nmid are not known
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1235
        mHeaderWidget->addAttachment(fileName, QString("0"), NmId(0));
43
hgs
parents: 40
diff changeset
  1236
        NM_COMMENT(fileName);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1237
    }
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1238
    //  Cancel previous operation if it's not running.
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1239
    if (mAddAttachmentOperation) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1240
        if (!mAddAttachmentOperation->isRunning()) {
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1241
            mAddAttachmentOperation->cancelOperation();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1242
        }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1243
    }
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1244
    // Start operation to attach file or list of files into mail message.
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1245
    // This will also copy files into message store.
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1246
    mAddAttachmentOperation = mUiEngine.addAttachments(*mMessage, fileNames);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1247
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1248
    if (mAddAttachmentOperation) {
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1249
        enableToolBarAttach(false);
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1250
        // Signal to inform completion of one attachment
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1251
        connect(mAddAttachmentOperation,
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1252
                SIGNAL(operationPartCompleted(const QString &, const NmId &, int)),
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1253
                this,
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1254
                SLOT(oneAttachmentAdded(const QString &, const NmId &, int)));
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1255
    
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1256
        // Signal to inform the completion of the whole operation
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1257
        connect(mAddAttachmentOperation,
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1258
                SIGNAL(operationCompleted(int)),
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1259
                this,
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1260
                SLOT(allAttachmentsAdded(int)));
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1261
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1262
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1263
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1264
/*!
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1265
    This slot is called to create context menu when attachment has been selected
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1266
    from UI by longpress.
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1267
*/
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1268
void NmEditorView::attachmentLongPressed(NmId attachmentPartId, QPointF point)
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1269
{
43
hgs
parents: 40
diff changeset
  1270
    NM_FUNCTION;
hgs
parents: 40
diff changeset
  1271
    
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1272
    // Store id of the attachment to be removed into member.
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1273
    // It is used by removeAttachmentTriggered later if 'remove' selected.
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1274
    mSelectedAttachment = attachmentPartId;
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1275
	
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1276
    if (!mAttachmentListContextMenu) {
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1277
        mAttachmentListContextMenu = new HbMenu();
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1278
    }
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1279
    mAttachmentListContextMenu->clearActions();
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1280
    NmActionRequest request(this, NmActionContextMenu, NmActionContextViewEditor,
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1281
        NmActionContextDataMessage, mStartParam->mailboxId(), mStartParam->folderId(),
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1282
        mStartParam->messageId());
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1283
    NmUiExtensionManager &extensionManager = mApplication.extManager();
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1284
    if (&extensionManager) {
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1285
        QList<NmAction*> actionList;
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1286
        extensionManager.getActions(request, actionList);
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1287
        for (int i = 0; i < actionList.count(); ++i) {
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1288
            mAttachmentListContextMenu->addAction(actionList[i]);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1289
        }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1290
    }
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1291
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1292
    // Add menu position check here, so that it does not go outside of the screen
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1293
    QPointF menuPos(point.x(),point.y());
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1294
    mAttachmentListContextMenu->setPreferredPos(menuPos);
40
hgs
parents: 23
diff changeset
  1295
    mAttachmentListContextMenu->open();
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1296
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1297
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1298
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1299
    This is signalled by mAddAttachmentOperation when the operation is
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1300
    completed for one attachment.
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1301
*/
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1302
void NmEditorView::oneAttachmentAdded(const QString &fileName, const NmId &msgPartId, int result)
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1303
{
43
hgs
parents: 40
diff changeset
  1304
    NM_FUNCTION;
hgs
parents: 40
diff changeset
  1305
    
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1306
    if (result == NmNoError && mMessage) {
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1307
        // Need to get the message again because new attachment part has been added.
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1308
        NmId mailboxId = mMessage->envelope().mailboxId();
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1309
        NmId folderId = mMessage->envelope().folderId();
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1310
        NmId msgId = mMessage->envelope().messageId();
49
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
  1311
        NmMessagePriority messagePriority = mMessage->envelope().priority();        
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
  1312
        
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1313
        delete mMessage;
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1314
        mMessage = NULL;
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1315
        
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1316
        mMessage = mUiEngine.message(mailboxId, folderId, msgId);
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1317
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1318
        if (mMessage) {
49
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
  1319
            mMessage->envelope().setPriority(messagePriority);
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
  1320
            mMessage->envelope().setHasAttachments(true);
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1321
            // Get attachment list from the message
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1322
            QList<NmMessagePart*> attachmentList;
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1323
            mMessage->attachmentList(attachmentList);
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1324
        
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1325
            // Search newly added attachment from the list
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1326
            for (int i=0; i<attachmentList.count(); i++) {
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1327
                if (attachmentList[i]->partId() == msgPartId) {
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1328
                    // Get attachment file size and set it into UI
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1329
                    mHeaderWidget->setAttachmentParameters(fileName,
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1330
                        msgPartId,
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1331
                        QString().setNum(attachmentList[i]->size()),
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1332
                        result);
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1333
                }
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1334
            }
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1335
        }
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1336
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1337
    else {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1338
        // Attachment adding failed. Show an error note and remove from UI attachment list.
43
hgs
parents: 40
diff changeset
  1339
        NM_ERROR(1,QString("nmailui: attachment adding into message failed: %1").arg(fileName));
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1340
        mHeaderWidget->removeAttachment(fileName);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1341
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1342
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1343
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1344
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1345
    This is signalled by mAddAttachmentOperation when the operation is
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1346
    completed totally.
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1347
*/
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1348
void NmEditorView::allAttachmentsAdded(int result)
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1349
{
43
hgs
parents: 40
diff changeset
  1350
    NM_FUNCTION;
hgs
parents: 40
diff changeset
  1351
    
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1352
    enableToolBarAttach(true);
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1353
    if (result != NmNoError) {
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1354
        NmUtilities::displayWarningNote(hbTrId("txt_mail_dialog_unable_to_add_attachment"));
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1355
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1356
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1357
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1358
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1359
   Sets priority for the message object that is being edited 
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1360
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1361
void NmEditorView::setPriority(NmActionResponseCommand priority)
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1362
{
43
hgs
parents: 40
diff changeset
  1363
    NM_FUNCTION;
hgs
parents: 40
diff changeset
  1364
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1365
    mHeaderWidget->setPriority(priority);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1366
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1367
    if (mMessage) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1368
        NmMessagePriority messagePriority = NmMessagePriorityNormal;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1369
        
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1370
        if (priority == NmActionResponseCommandPriorityHigh) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1371
            messagePriority = NmMessagePriorityHigh;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1372
        }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1373
        else if (priority == NmActionResponseCommandPriorityLow) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1374
            messagePriority = NmMessagePriorityLow;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1375
        }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1376
        mMessage->envelope().setPriority(messagePriority);
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1377
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1378
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1379
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1380
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1381
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1382
    Extracts the addresses from the given list into a string separated with a
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1383
    delimiter.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1384
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1385
    \param list The list containing the addresses.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1386
    \return String containing the addresses.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1387
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1388
QString NmEditorView::addressListToString(const QList<NmAddress*> &list) const
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1389
{
43
hgs
parents: 40
diff changeset
  1390
    NM_FUNCTION;
hgs
parents: 40
diff changeset
  1391
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1392
    QString addressesString;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1393
    QList<NmAddress*>::const_iterator i = list.constBegin();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1394
    
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1395
    while (i != list.constEnd() && *i) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1396
        if (i > list.constBegin()) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1397
            // Add the delimiter.
47
hgs
parents: 44
diff changeset
  1398
            addressesString += NmDelimiter;
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1399
        }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1400
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1401
        addressesString += (*i)->address();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1402
        ++i;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1403
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1404
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1405
    return addressesString;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1406
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1407
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1408
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1409
/*!
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1410
    Extracts the addresses from the given list into a string separated with a
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1411
    delimiter.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1412
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1413
    \param list The list containing the addresses.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1414
    \return String containing the addresses.
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1415
*/
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1416
QString NmEditorView::addressListToString(const QList<NmAddress> &list) const
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1417
{
43
hgs
parents: 40
diff changeset
  1418
    NM_FUNCTION;
hgs
parents: 40
diff changeset
  1419
    
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1420
    QString addressesString;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1421
    QList<NmAddress>::const_iterator i = list.constBegin();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1422
    
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1423
    while (i != list.constEnd()) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1424
        if (i > list.constBegin()) {
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1425
            // Add the delimiter.
47
hgs
parents: 44
diff changeset
  1426
            addressesString += NmDelimiter;
18
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1427
        }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1428
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1429
        addressesString += (*i).address();
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1430
        ++i;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1431
    }
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1432
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1433
    return addressesString;
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1434
}
578830873419 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1435
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1436
/*!
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1437
    This slot is called when 'remove' is selected from attachment list context menu.
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1438
*/
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1439
void NmEditorView::removeAttachmentTriggered()
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1440
{
43
hgs
parents: 40
diff changeset
  1441
    NM_FUNCTION;
hgs
parents: 40
diff changeset
  1442
    
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1443
    // Cancel will delete previous operation
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1444
    if (mRemoveAttachmentOperation) {
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1445
        if (!mRemoveAttachmentOperation->isRunning()) {
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1446
            mRemoveAttachmentOperation->cancelOperation();
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1447
        }
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1448
    }
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1449
    // Remove from UI
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1450
    mHeaderWidget->removeAttachment(mSelectedAttachment);
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1451
    // Remove from message store
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1452
    mRemoveAttachmentOperation = mUiEngine.removeAttachment(*mMessage, mSelectedAttachment);
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1453
    if (mRemoveAttachmentOperation) {
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1454
        // Signal to inform the remove operation completion
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1455
        connect(mRemoveAttachmentOperation,
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1456
                SIGNAL(operationCompleted(int)),
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1457
                this,
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1458
                SLOT(attachmentRemoved(int)));
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1459
    }
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1460
}
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1461
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1462
/*!
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1463
    This slot is called by mRemoveAttachmentOperation when the operation is
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1464
    completed. There is no need to update UI because it was already updated.
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1465
 */
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1466
void NmEditorView::attachmentRemoved(int result)
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1467
{
43
hgs
parents: 40
diff changeset
  1468
    NM_FUNCTION;
hgs
parents: 40
diff changeset
  1469
    
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1470
    // It is not desided yet what to do if operation fails
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1471
    Q_UNUSED(result);
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1472
    
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1473
    if (mMessage) {
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1474
        // Reload message because one attachment has been removed
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1475
        NmId mailboxId = mMessage->envelope().mailboxId();
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1476
        NmId folderId = mMessage->envelope().folderId();
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1477
        NmId msgId = mMessage->envelope().messageId();
49
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
  1478
        NmMessagePriority messagePriority = mMessage->envelope().priority();    
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1479
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1480
        delete mMessage;
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1481
        mMessage = NULL;
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1482
    
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1483
        mMessage = mUiEngine.message(mailboxId, folderId, msgId);
49
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
  1484
        
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
  1485
        if(mMessage) {
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
  1486
            // Set the correct priority
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
  1487
            mMessage->envelope().setPriority(messagePriority);    
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
  1488
            
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
  1489
            // If there is no more attachments in the message, set the correct value
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
  1490
            QList<NmMessagePart*> attachmentList;
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
  1491
            mMessage->attachmentList(attachmentList);
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
  1492
            if(attachmentList.count() == 0) {
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
  1493
                mMessage->envelope().setHasAttachments(false);
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
  1494
            }
00c7ae862740 201025_2
hgs
parents: 48
diff changeset
  1495
        }
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1496
    }
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1497
}
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1498
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1499
/*!
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1500
    This slot is called when 'open' is selected from attachment list context menu.
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1501
*/
44
hgs
parents: 43
diff changeset
  1502
void NmEditorView::openAttachmentTriggered(NmId attachmentId)
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1503
{
43
hgs
parents: 40
diff changeset
  1504
    NM_FUNCTION;
44
hgs
parents: 43
diff changeset
  1505
    NmId mailboxId = mMessage->envelope().mailboxId();
hgs
parents: 43
diff changeset
  1506
    NmId folderId = mMessage->envelope().folderId();
hgs
parents: 43
diff changeset
  1507
    NmId msgId = mMessage->envelope().messageId();
hgs
parents: 43
diff changeset
  1508
hgs
parents: 43
diff changeset
  1509
    XQSharableFile file = mUiEngine.messagePartFile(mailboxId, folderId,
hgs
parents: 43
diff changeset
  1510
    		msgId, attachmentId);
hgs
parents: 43
diff changeset
  1511
    int error = NmUtilities::openFile(file);
hgs
parents: 43
diff changeset
  1512
    file.close();
hgs
parents: 43
diff changeset
  1513
    if ( error == NmNotFoundError ) {
hgs
parents: 43
diff changeset
  1514
        NmUtilities::displayErrorNote(hbTrId("txt_mail_dialog_unable_to_open_attachment_file_ty")); 
hgs
parents: 43
diff changeset
  1515
    }
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1516
}
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1517
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1518
/*!
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1519
   Enables/disables toolbar extension for attach
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1520
*/
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1521
void NmEditorView::enableToolBarAttach(bool enable)
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1522
{
43
hgs
parents: 40
diff changeset
  1523
    NM_FUNCTION;
hgs
parents: 40
diff changeset
  1524
    
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1525
    HbToolBar *tb = toolBar();
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1526
    if (tb) {
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1527
        QList<QAction *> toolbarList = tb->actions();
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1528
        int count = toolbarList.count();
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1529
        for (int i = 0; i < count; i++) {
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1530
            NmAction *action = static_cast<NmAction *>(toolbarList[i]);
23
2dc6caa42ec3 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
  1531
            if (action->availabilityCondition() == NmAction::NmAttachable) {
20
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1532
                action->setEnabled(enable);
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1533
            }
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1534
        }
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1535
    }
ecc8def7944a Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  1536
}