messagingapp/msgui/unifiededitor/src/msgunieditorview.cpp
author hgs
Tue, 05 Oct 2010 13:58:47 +0530
changeset 73 ecf6a73a9186
parent 67 fc91263aee62
child 76 60a8a215b0ec
permissions -rw-r--r--
201039_03
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/*
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     2
 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
 * All rights reserved.
238255e8b033 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
238255e8b033 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"
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     6
 * which accompanies this distribution, and is available
238255e8b033 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".
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
 *
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     9
 * Initial Contributors:
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    10
 * Nokia Corporation - initial contribution.
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    11
 *
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    12
 * Contributors:
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
 *
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    14
 * Description:
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    15
 *
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
 */
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    18
// SYSTEM INCLUDES
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    19
#include <e32base.h>
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
#include <HbMenu>
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    21
#include <HbAction>
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    22
#include <HbToolBar>
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    23
#include <QGraphicsLinearLayout>
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    24
#include <HbGroupBox>
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    25
#include <HbScrollArea>
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    26
#include <QDateTime>
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    27
#include <QDir>
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    28
#include <QBuffer>
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    29
#include <QFile>
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    30
#include <QFileInfo>
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    31
#include <xqconversions.h>
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    32
#include <HbToolBarExtension>
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    33
#include <HbListWidget>
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    34
#include <HbFrameBackground>
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    35
#include <HbListViewItem>
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    36
#include <HbListWidgetItem>
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    37
#include <HbNotificationDialog>
48
4f501b74aeb1 201029_02
hgs
parents: 41
diff changeset
    38
#include <HbDeviceNotificationDialog>
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    39
#include <HbMessageBox>
37
hgs
parents: 25
diff changeset
    40
#include <HbAbstractVkbHost>
hgs
parents: 25
diff changeset
    41
#include <HbMainWindow>
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    42
#include <xqaiwrequest.h>
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    43
#include <xqappmgr.h>
37
hgs
parents: 25
diff changeset
    44
#include <HbStyleLoader>
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    45
// QT Mobility for fetching business card
37
hgs
parents: 25
diff changeset
    46
#include <qmobilityglobal.h>
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    47
#include <qversitwriter.h>
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    48
#include <qversitdocument.h>
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    49
#include <qcontact.h>
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    50
#include <qcontactmanager.h>
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    51
#include <qversitcontactexporter.h>
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    52
#include <cntservicescontact.h>
38
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
    53
#include <commonphoneparser.h>      // Common phone number validity checker
37
hgs
parents: 25
diff changeset
    54
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    55
// USER INCLUDES
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    56
#include "debugtraces.h"
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    57
#include "msgunieditorview.h"
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    58
#include "msgunieditoraddress.h"
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    59
#include "msgunieditorsubject.h"
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    60
#include "msgunieditorbody.h"
37
hgs
parents: 25
diff changeset
    61
#include "msgunieditormonitor.h"
hgs
parents: 25
diff changeset
    62
#include "msgunieditorattachmentcontainer.h"
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    63
#include "msgsendutil.h"
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    64
#include "convergedmessageaddress.h"
37
hgs
parents: 25
diff changeset
    65
#include "UniEditorGenUtils.h"
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    66
#include "unieditorpluginloader.h"
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    67
#include "unieditorplugininterface.h"
37
hgs
parents: 25
diff changeset
    68
#include "msgsettingsview.h"
56
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
    69
#include "msgcontacthandler.h"
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
    70
#include "msgaudiofetcherdialog.h"
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    71
37
hgs
parents: 25
diff changeset
    72
QTM_USE_NAMESPACE
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    73
// Constants
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    74
const QString SEND_ICON("qtg_mono_send");
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    75
const QString ATTACH_ICON("qtg_mono_attach");
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    76
// temporary folder for unieditor
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    77
const QString UNIFIED_EDITOR_TEMP_FOLDER("unifiededitor");
67
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
    78
// invalid chars in vcard
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
    79
const QString INVALID_FILENAME_CHARS("[?*<>/\"|\\:]");
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
    80
// replacement char for invalid char
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
    81
const QChar REPLACE_CHAR('_');
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    82
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    83
const int INVALID_MSGID = -1;
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    84
// vcard file extn.
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    85
const QString FILE_EXTN(".vcf");
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    86
// Max vcards inside a msg. Using a very large number.
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    87
// TODO: how we can avoid this?
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    88
const int MAX_VCARDS(1000);
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    89
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    90
// LOCALIZED CONSTANTS
73
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
    91
#define LOC_TITLE hbTrId("txt_messaging_title_messaging")
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    92
//To,Cc.Bcc
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    93
#define LOC_TO  hbTrId("txt_messaging_formlabel_to")
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    94
#define LOC_CC hbTrId("txt_messaging_formlabel_cc")
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    95
#define LOC_BCC hbTrId("txt_messaging_formlabel_bcc")
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    96
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    97
//attach options
48
4f501b74aeb1 201029_02
hgs
parents: 41
diff changeset
    98
#define LOC_PHOTO           hbTrId("txt_messaging_opt_attach_sub_photo")
4f501b74aeb1 201029_02
hgs
parents: 41
diff changeset
    99
#define LOC_SOUND           hbTrId("txt_messaging_opt_attach_sub_sound")
4f501b74aeb1 201029_02
hgs
parents: 41
diff changeset
   100
#define LOC_BUSINESS_CARD   hbTrId("txt_messaging_opt_sub_business_card")
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   101
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   102
//options menu.
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   103
#define LOC_ADD_SUBJECT     hbTrId("txt_messaging_opt_add_subject")
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   104
#define LOC_ADD_CC_BCC      hbTrId("txt_messaging_opt_add_cc_bcc")
37
hgs
parents: 25
diff changeset
   105
#define LOC_PRIORITY        hbTrId("txt_messaging_opt_priority")
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   106
#define LOC_DELETE_MESSAGE  hbTrId("txt_messaging_opt_delete_message")
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   107
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   108
//priority sub menu
37
hgs
parents: 25
diff changeset
   109
#define LOC_HIGH hbTrId("txt_messaging_opt_attach_sub_high")
hgs
parents: 25
diff changeset
   110
#define LOC_NORMAL hbTrId("txt_messaging_opt_attach_sub_normal")
hgs
parents: 25
diff changeset
   111
#define LOC_LOW hbTrId("txt_messaging_opt_attach_sub_low")
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   112
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   113
//group box
48
4f501b74aeb1 201029_02
hgs
parents: 41
diff changeset
   114
#define LOC_OTHER_RECIPIENTS(n) hbTrId("txt_messaging_title_ln_other_recipients",n)
37
hgs
parents: 25
diff changeset
   115
#define LOC_OTHER_RECIPIENTS_EXPAND hbTrId("txt_messaging_title_other_recipients")
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   116
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   117
//saved to draft note
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   118
#define LOC_SAVED_TO_DRAFTS    hbTrId("txt_messaging_dpopinfo_saved_to_drafts")
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   119
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   120
//delete confermation
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   121
#define LOC_NOTE_DELETE_MESSAGE hbTrId("txt_messaging_dialog_delete_message")
37
hgs
parents: 25
diff changeset
   122
hgs
parents: 25
diff changeset
   123
// attachment addition failure note
hgs
parents: 25
diff changeset
   124
#define LOC_UNABLE_TO_ADD_ATTACHMENTS hbTrId("txt_messaging_dpopinfo_unable_to_attach_l1_of_l2")
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   125
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   126
//extension list item frame.
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   127
const QString POPUP_LIST_FRAME("qtg_fr_popup_list_normal");
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   128
37
hgs
parents: 25
diff changeset
   129
//settings confirmation
hgs
parents: 25
diff changeset
   130
#define LOC_DIALOG_SMS_SETTINGS_INCOMPLETE hbTrId("txt_messaging_dialog_sms_message_centre_does_not_e")
hgs
parents: 25
diff changeset
   131
#define LOC_DIALOG_MMS_SETTINGS_INCOMPLETE hbTrId("txt_messaging_dialog_mms_access_point_not_defined")
56
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   132
#define LOC_NOTE_FILES_MISSED_DRAFTS hbTrId("txt_messaging_dpopinfo_some_files_in_the_message")
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   133
#define LOC_NOTE_FILES_MISSED_SEND hbTrId("txt_messaging_dialog_unable_to_send_message_some")
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   134
// LOCAL FUNCTIONS
37
hgs
parents: 25
diff changeset
   135
hgs
parents: 25
diff changeset
   136
//---------------------------------------------------------------
hgs
parents: 25
diff changeset
   137
// editorTempPath
hgs
parents: 25
diff changeset
   138
// @return fullPath of unified editor's temporary dir
hgs
parents: 25
diff changeset
   139
//---------------------------------------------------------------
hgs
parents: 25
diff changeset
   140
QString editorTempPath()
hgs
parents: 25
diff changeset
   141
{
hgs
parents: 25
diff changeset
   142
    QDir tempDir;
hgs
parents: 25
diff changeset
   143
    QString tempPath(QDir::toNativeSeparators(tempDir.tempPath()));
hgs
parents: 25
diff changeset
   144
    tempPath.append(QDir::separator());
hgs
parents: 25
diff changeset
   145
    tempPath.append(UNIFIED_EDITOR_TEMP_FOLDER);
hgs
parents: 25
diff changeset
   146
    tempPath.append(QDir::separator());
hgs
parents: 25
diff changeset
   147
    return tempPath;
hgs
parents: 25
diff changeset
   148
}
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   149
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   150
//---------------------------------------------------------------
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   151
// MsgUnifiedEditorView::MsgUnifiedEditorView
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   152
// @see header file
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   153
//---------------------------------------------------------------
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   154
MsgUnifiedEditorView::MsgUnifiedEditorView( QGraphicsItem *parent ) :
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   155
    MsgBaseView(parent),
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   156
    mSubjectAction(0),
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   157
    mCcBccAction(0),
37
hgs
parents: 25
diff changeset
   158
    mSendAction(0),
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   159
    mMainLayout(0),
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   160
    mSubjectField(0),
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   161
    mToField(0),
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   162
    mCcField(0),
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   163
    mBccField(0),
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   164
    mBody(0),
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   165
    mContentWidget(0),
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   166
    mMsgMonitor(0),    
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   167
    mAttachmentContainer(0),
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   168
    mPluginLoader(0),
37
hgs
parents: 25
diff changeset
   169
    mCanSaveToDrafts(true),
56
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   170
    mVkbHost(NULL),
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   171
	mDialog(NULL),
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   172
    mOriginatingSC(0),
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   173
    mOriginatingSME(0),
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   174
    mReplyPath(false)
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   175
    {
37
hgs
parents: 25
diff changeset
   176
    connect(this->mainWindow(),SIGNAL(viewReady()),this,SLOT(doDelayedConstruction()));
hgs
parents: 25
diff changeset
   177
    
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   178
    addToolBar();
37
hgs
parents: 25
diff changeset
   179
    initView();
hgs
parents: 25
diff changeset
   180
    }
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   181
37
hgs
parents: 25
diff changeset
   182
//---------------------------------------------------------------
hgs
parents: 25
diff changeset
   183
// MsgUnifiedEditorView::~MsgUnifiedEditorView
hgs
parents: 25
diff changeset
   184
// @see header file
hgs
parents: 25
diff changeset
   185
//---------------------------------------------------------------
hgs
parents: 25
diff changeset
   186
MsgUnifiedEditorView::~MsgUnifiedEditorView()
hgs
parents: 25
diff changeset
   187
{
hgs
parents: 25
diff changeset
   188
    // clean editor's temporary contents before exiting
hgs
parents: 25
diff changeset
   189
    removeTempFolder();
56
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   190
    
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   191
    //delete the popup dialog
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   192
    delete mDialog;
37
hgs
parents: 25
diff changeset
   193
}
hgs
parents: 25
diff changeset
   194
hgs
parents: 25
diff changeset
   195
//---------------------------------------------------------------
hgs
parents: 25
diff changeset
   196
// MsgUnifiedEditorView::initView
hgs
parents: 25
diff changeset
   197
// @see header file
hgs
parents: 25
diff changeset
   198
//---------------------------------------------------------------
hgs
parents: 25
diff changeset
   199
void MsgUnifiedEditorView::initView()
hgs
parents: 25
diff changeset
   200
{
hgs
parents: 25
diff changeset
   201
    if (!HbStyleLoader::registerFilePath(":/layouts")) {
hgs
parents: 25
diff changeset
   202
        QDEBUG_WRITE("ERROR: MsgUnifiedEditorView -> HbStyleLoader::registerFilePath");
hgs
parents: 25
diff changeset
   203
    }
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   204
    HbScrollArea* scrollArea = new HbScrollArea(this);
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   205
    this->setWidget(scrollArea);
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   206
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   207
    mContentWidget = new HbWidget(this);
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   208
    scrollArea->setContentWidget(mContentWidget);
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   209
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   210
    mMainLayout = new QGraphicsLinearLayout(Qt::Vertical, mContentWidget);
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   211
    qreal vTopSpacing = 0.0;
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   212
    qreal vItemSpacing = 0.0;
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   213
    style()->parameter("hb-param-margin-gene-top",vTopSpacing);    
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   214
    style()->parameter("hb-param-margin-gene-middle-vertical",vItemSpacing);
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   215
    
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   216
    mMainLayout->setContentsMargins(0,vTopSpacing,0,0);
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   217
    mMainLayout->setSpacing(vItemSpacing);
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   218
37
hgs
parents: 25
diff changeset
   219
    mMsgMonitor = new MsgUnifiedEditorMonitor(this);
hgs
parents: 25
diff changeset
   220
    connect(mMsgMonitor, SIGNAL(enableSend(bool)), this, SLOT(enableSendButton(bool)));
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   221
37
hgs
parents: 25
diff changeset
   222
    mToField = new MsgUnifiedEditorAddress( LOC_TO, mContentWidget );
hgs
parents: 25
diff changeset
   223
    
hgs
parents: 25
diff changeset
   224
    mBody = new MsgUnifiedEditorBody( mContentWidget);
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   225
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   226
    mMainLayout->addItem(mToField);
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   227
    mMainLayout->addItem(mBody);
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   228
 
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   229
    //Set the invalid msg id
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   230
    mOpenedMessageId.setId(-1);
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   231
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   232
    connect(mToField, SIGNAL(sendMessage()), this, SLOT(send()));
37
hgs
parents: 25
diff changeset
   233
    connect(mToField, SIGNAL(contentChanged()),
hgs
parents: 25
diff changeset
   234
            mMsgMonitor, SLOT(handleContentChange()));
hgs
parents: 25
diff changeset
   235
    connect(mToField, SIGNAL(contentChanged()),this,SLOT(onContentChanged()));
hgs
parents: 25
diff changeset
   236
    
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   237
    connect(mBody, SIGNAL(sendMessage()), this, SLOT(send()));
37
hgs
parents: 25
diff changeset
   238
    connect(mBody, SIGNAL(contentChanged()),this,SLOT(onContentChanged()));
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   239
    connect(mBody, SIGNAL(contentChanged()),
37
hgs
parents: 25
diff changeset
   240
            mMsgMonitor, SLOT(handleContentChange()));
hgs
parents: 25
diff changeset
   241
    connect(mBody, SIGNAL(enableSendButton(bool)), this, SLOT(enableSendButton(bool)));    
hgs
parents: 25
diff changeset
   242
    
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   243
}
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   244
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   245
void MsgUnifiedEditorView::addMenu()
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   246
{
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   247
    //Create Menu Options
73
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   248
    HbMenu* mainMenu = this->menu();
37
hgs
parents: 25
diff changeset
   249
    mainMenu->setFocusPolicy(Qt::NoFocus);
hgs
parents: 25
diff changeset
   250
	
hgs
parents: 25
diff changeset
   251
    //if subject field / cc,bcc fields are already present don't add corresponding actions.
hgs
parents: 25
diff changeset
   252
    if(!mSubjectField)
hgs
parents: 25
diff changeset
   253
    {
hgs
parents: 25
diff changeset
   254
        mSubjectAction = mainMenu->addAction(LOC_ADD_SUBJECT);
hgs
parents: 25
diff changeset
   255
    }
hgs
parents: 25
diff changeset
   256
    
hgs
parents: 25
diff changeset
   257
    if(!mCcField)
hgs
parents: 25
diff changeset
   258
    {
hgs
parents: 25
diff changeset
   259
        mCcBccAction = mainMenu->addAction(LOC_ADD_CC_BCC);
hgs
parents: 25
diff changeset
   260
    }
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   261
    
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   262
    HbMenu* prioritySubMenu = mainMenu->addMenu(LOC_PRIORITY);
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   263
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   264
    HbAction* highPriorityAction = prioritySubMenu->addAction(LOC_HIGH);
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   265
    highPriorityAction->setData(ConvergedMessage::High);
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   266
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   267
    HbAction* normalPriorityAction = prioritySubMenu->addAction(LOC_NORMAL);
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   268
    normalPriorityAction->setData(ConvergedMessage::Normal);
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   269
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   270
    HbAction* lowPriorityAction = prioritySubMenu->addAction(LOC_LOW);
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   271
    lowPriorityAction->setData(ConvergedMessage::Low);
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   272
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   273
    HbAction* deleteMsgAction = mainMenu->addAction(LOC_DELETE_MESSAGE);
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   274
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   275
    connect(mSubjectAction,SIGNAL(triggered()),this, SLOT(addSubject()));
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   276
    connect(mCcBccAction,SIGNAL(triggered()),this, SLOT(addCcBcc()));
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   277
    connect(highPriorityAction, SIGNAL(triggered()), this, SLOT(changePriority()));
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   278
    connect(normalPriorityAction, SIGNAL(triggered()), this, SLOT(changePriority()));
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   279
    connect(lowPriorityAction, SIGNAL(triggered()), this, SLOT(changePriority()));
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   280
    connect(deleteMsgAction,SIGNAL(triggered()),this, SLOT(deleteMessage()));
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   281
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   282
}
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   283
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   284
void MsgUnifiedEditorView::openDraftsMessage(const QVariantList& editorData)
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   285
{
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   286
    // unpack editor's data
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   287
    // first arg is convergedmessage
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   288
    QByteArray dataArray = editorData.at(0).toByteArray();
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   289
    ConvergedMessage* messageDetails = new ConvergedMessage;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   290
    QDataStream stream(&dataArray, QIODevice::ReadOnly);
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   291
    messageDetails->deserialize(stream);
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   292
    ConvergedMessage::MessageType messageType = messageDetails->messageType();
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   293
    ConvergedMessageId messageId = *(messageDetails->id());
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   294
    delete messageDetails;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   295
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   296
    if(!mPluginLoader)
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   297
    {
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   298
        mPluginLoader = new UniEditorPluginLoader(this);
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   299
    }
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   300
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   301
    UniEditorPluginInterface* pluginInterface =
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   302
        mPluginLoader->getUniEditorPlugin(messageType);
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   303
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   304
    mOpenedMessageId.setId(messageId.getId());
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   305
    mmOpenedMessageType = messageType;
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   306
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   307
    //Fetch the converged message from the msgId
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   308
    ConvergedMessage* msg;
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   309
    msg = pluginInterface->convertFrom(messageId.getId());
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   310
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   311
    if( msg != NULL )
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   312
    {
56
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   313
        mReplyPath = msg->replyPath();
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   314
        if(mReplyPath)
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   315
        {
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   316
            mOriginatingSC = msg->originatingSC();
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   317
            mOriginatingSME = msg->toAddressList().at(0)->address();
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   318
        }
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   319
        //Populate the content inside editor
37
hgs
parents: 25
diff changeset
   320
        populateContentIntoEditor(*msg,true); // true as it is  draft message
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   321
        delete msg;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   322
    }
37
hgs
parents: 25
diff changeset
   323
    
hgs
parents: 25
diff changeset
   324
    mCanSaveToDrafts = false;  
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   325
}
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   326
41
25fe1fe642e3 201027_02
hgs
parents: 38
diff changeset
   327
void MsgUnifiedEditorView::fetchMessageFromStore(
25fe1fe642e3 201027_02
hgs
parents: 38
diff changeset
   328
        ConvergedMessageId& messageId,
25fe1fe642e3 201027_02
hgs
parents: 38
diff changeset
   329
        ConvergedMessage::MessageType messageType,
25fe1fe642e3 201027_02
hgs
parents: 38
diff changeset
   330
        int editorOperation)
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   331
{
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   332
    if(!mPluginLoader)
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   333
    {
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   334
        mPluginLoader = new UniEditorPluginLoader(this);
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   335
    }
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   336
    UniEditorPluginInterface* pluginInterface = NULL;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   337
    if( messageType == ConvergedMessage::Mms )
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   338
    {
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   339
        pluginInterface =
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   340
                mPluginLoader->getUniEditorPlugin(ConvergedMessage::Mms);
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   341
    }
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   342
    else // For sms,vcard,vcal cases
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   343
    {
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   344
        pluginInterface =
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   345
                mPluginLoader->getUniEditorPlugin(ConvergedMessage::Sms);
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   346
    }
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   347
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   348
    //Fetch the converged message from the msgId
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   349
    ConvergedMessage* msg;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   350
    msg = pluginInterface->convertFrom(messageId.getId(),
41
25fe1fe642e3 201027_02
hgs
parents: 38
diff changeset
   351
                    (UniEditorPluginInterface::EditorOperation)editorOperation);
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   352
    if( msg != NULL )
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   353
    {
56
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   354
        if(editorOperation == UniEditorPluginInterface::Reply)
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   355
        {
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   356
            mReplyPath = msg->replyPath();
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   357
            if(mReplyPath)
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   358
            {
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   359
                mOriginatingSC = msg->originatingSC();
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   360
                mOriginatingSME = msg->toAddressList().at(0)->address();
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   361
            }
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   362
        }
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   363
        //Populate the content inside editor
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   364
        populateContentIntoEditor(*msg);
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   365
        delete msg;
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   366
    }
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   367
}
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   368
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   369
void MsgUnifiedEditorView::populateContent(const QVariantList& editorData)
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   370
{
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   371
    // unpack editor's data
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   372
    // first arg is convergedmessage
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   373
    QByteArray dataArray = editorData.at(0).toByteArray();
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   374
    ConvergedMessage* messageDetails = new ConvergedMessage;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   375
    QDataStream stream(&dataArray, QIODevice::ReadOnly);
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   376
    messageDetails->deserialize(stream);
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   377
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   378
    // get next arg i.e. editor operation command
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   379
    int editorOp = 0;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   380
    if(editorData.length() > 1)
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   381
    {
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   382
        editorOp = editorData.at(1).toInt();
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   383
    }
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   384
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   385
    // population logic based on editor Operation command
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   386
    switch(editorOp)
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   387
    {
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   388
        case MsgBaseView::ADD_SUBJECT:
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   389
        {
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   390
            addSubject();
37
hgs
parents: 25
diff changeset
   391
            setFocus(mSubjectField);
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   392
        }
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   393
        break;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   394
        case MsgBaseView::ADD_VCARD:
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   395
        {
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   396
            contactsFetched(editorData.at(2));
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   397
        }
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   398
        break;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   399
        case MsgBaseView::FORWARD_MSG:
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   400
        {
41
25fe1fe642e3 201027_02
hgs
parents: 38
diff changeset
   401
            fetchMessageFromStore(*messageDetails->id(),
25fe1fe642e3 201027_02
hgs
parents: 38
diff changeset
   402
                                   messageDetails->messageType(),
25fe1fe642e3 201027_02
hgs
parents: 38
diff changeset
   403
                                   UniEditorPluginInterface::Forward);
25fe1fe642e3 201027_02
hgs
parents: 38
diff changeset
   404
        }
25fe1fe642e3 201027_02
hgs
parents: 38
diff changeset
   405
        break;
25fe1fe642e3 201027_02
hgs
parents: 38
diff changeset
   406
        case MsgBaseView::REPLY_MSG:
25fe1fe642e3 201027_02
hgs
parents: 38
diff changeset
   407
        {
25fe1fe642e3 201027_02
hgs
parents: 38
diff changeset
   408
            fetchMessageFromStore(*messageDetails->id(),
25fe1fe642e3 201027_02
hgs
parents: 38
diff changeset
   409
                                   messageDetails->messageType(),
25fe1fe642e3 201027_02
hgs
parents: 38
diff changeset
   410
                                   UniEditorPluginInterface::Reply);
25fe1fe642e3 201027_02
hgs
parents: 38
diff changeset
   411
        }
25fe1fe642e3 201027_02
hgs
parents: 38
diff changeset
   412
        break;
25fe1fe642e3 201027_02
hgs
parents: 38
diff changeset
   413
        case MsgBaseView::REPLY_ALL_MSG:
25fe1fe642e3 201027_02
hgs
parents: 38
diff changeset
   414
        {
25fe1fe642e3 201027_02
hgs
parents: 38
diff changeset
   415
            fetchMessageFromStore(*messageDetails->id(),
25fe1fe642e3 201027_02
hgs
parents: 38
diff changeset
   416
                                   messageDetails->messageType(),
25fe1fe642e3 201027_02
hgs
parents: 38
diff changeset
   417
                                   UniEditorPluginInterface::ReplyAll);
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   418
        }
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   419
        break;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   420
        default:
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   421
        break;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   422
    }
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   423
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   424
    // additional common operations for non-forwarded messages
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   425
    if(editorOp != MsgBaseView::FORWARD_MSG)
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   426
    {
37
hgs
parents: 25
diff changeset
   427
        if(editorOp == MsgBaseView::ADD_RECIPIENTS)
hgs
parents: 25
diff changeset
   428
        {
hgs
parents: 25
diff changeset
   429
            // CV sends contact card address as the first address
hgs
parents: 25
diff changeset
   430
            ConvergedMessageAddressList toAddresses = 
hgs
parents: 25
diff changeset
   431
                    messageDetails->toAddressList();
hgs
parents: 25
diff changeset
   432
            int addrCount = toAddresses.count();
hgs
parents: 25
diff changeset
   433
            if(addrCount > 0)
hgs
parents: 25
diff changeset
   434
            {
hgs
parents: 25
diff changeset
   435
                // add contact card address first
hgs
parents: 25
diff changeset
   436
                ConvergedMessageAddress *firstAddress =
hgs
parents: 25
diff changeset
   437
                        new ConvergedMessageAddress();
hgs
parents: 25
diff changeset
   438
                firstAddress->setAlias(toAddresses.at(0)->alias());
hgs
parents: 25
diff changeset
   439
                firstAddress->setAddress(toAddresses.at(0)->address());
hgs
parents: 25
diff changeset
   440
                ConvergedMessageAddressList firstList;
hgs
parents: 25
diff changeset
   441
                firstList << firstAddress;
hgs
parents: 25
diff changeset
   442
                mToField->setAddresses(firstList);
hgs
parents: 25
diff changeset
   443
            
hgs
parents: 25
diff changeset
   444
                // add remaining contacts now
hgs
parents: 25
diff changeset
   445
                ConvergedMessageAddressList otherList;
hgs
parents: 25
diff changeset
   446
                for(int i=1; i<addrCount; i++)
hgs
parents: 25
diff changeset
   447
                {
hgs
parents: 25
diff changeset
   448
                    otherList << toAddresses.at(i);
hgs
parents: 25
diff changeset
   449
                }
hgs
parents: 25
diff changeset
   450
                mToField->setAddresses(otherList);
hgs
parents: 25
diff changeset
   451
            }
hgs
parents: 25
diff changeset
   452
        }
hgs
parents: 25
diff changeset
   453
        else
hgs
parents: 25
diff changeset
   454
        {
hgs
parents: 25
diff changeset
   455
            mToField->setAddresses(messageDetails->toAddressList());
hgs
parents: 25
diff changeset
   456
        }
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   457
        QString bodyTxt = messageDetails->bodyText();
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   458
        mBody->setText(bodyTxt);
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   459
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   460
        int attachmentCount = messageDetails->attachments().count();
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   461
        QStringList pendingAttList;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   462
        for(int i=0; i<attachmentCount; i++)
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   463
        {
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   464
            int imageSize=0;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   465
            QString mimeType;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   466
            TMsgMediaType mediaType = EMsgMediaUnknown;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   467
            QString filePath = messageDetails->attachments().at(i)->filePath();
48
4f501b74aeb1 201029_02
hgs
parents: 41
diff changeset
   468
            
51
3507212d340e 201031_02
hgs
parents: 48
diff changeset
   469
           
3507212d340e 201031_02
hgs
parents: 48
diff changeset
   470
            UniEditorGenUtils* genUtils = q_check_ptr(new UniEditorGenUtils);
48
4f501b74aeb1 201029_02
hgs
parents: 41
diff changeset
   471
            
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   472
            TRAP_IGNORE(genUtils->getFileInfoL(filePath,imageSize,
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   473
                                           mimeType,mediaType));
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   474
            delete genUtils;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   475
            switch(mediaType)
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   476
            {
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   477
                case EMsgMediaImage:
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   478
                {
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   479
                    mBody->setImage(filePath);
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   480
                }
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   481
                break;
37
hgs
parents: 25
diff changeset
   482
                 case EMsgMediaAudio:
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   483
                {
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   484
                    mBody->setAudio(filePath);
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   485
                }
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   486
                break;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   487
                default:
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   488
                {
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   489
                    pendingAttList << filePath;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   490
                }
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   491
                break;
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   492
            }
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   493
        }
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   494
        // add pending attachments in bulk
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   495
        addAttachments(pendingAttList);
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   496
    }
37
hgs
parents: 25
diff changeset
   497
    delete messageDetails; 
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   498
}
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   499
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   500
void MsgUnifiedEditorView::populateContentIntoEditor(
37
hgs
parents: 25
diff changeset
   501
    const ConvergedMessage& messageDetails,bool draftMessage)
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   502
{
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   503
    // skip first-time MMS type switch note for draft
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   504
    mMsgMonitor->setSkipNote(true);
37
hgs
parents: 25
diff changeset
   505
    mToField->skipMaxRecipientQuery(true);
hgs
parents: 25
diff changeset
   506
56
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   507
    mToField->setAddresses(messageDetails.toAddressList(),draftMessage);
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   508
    if(messageDetails.ccAddressList().count() > 0 )
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   509
    {
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   510
        if(!mCcField)
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   511
        {
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   512
        addCcBcc();
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   513
        }
56
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   514
        mCcField->setAddresses(messageDetails.ccAddressList(),draftMessage);
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   515
    }
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   516
    if(messageDetails.bccAddressList().count() > 0 )
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   517
    {
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   518
        if(!mBccField)
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   519
        {
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   520
        addCcBcc();
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   521
        }
56
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   522
        mBccField->setAddresses(messageDetails.bccAddressList(),draftMessage);
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   523
    }
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   524
    if(messageDetails.subject().size() > 0)
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   525
    {
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   526
       if(!mSubjectField)
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   527
       {
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   528
           addSubject();
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   529
       }
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   530
       mSubjectField->setText(messageDetails.subject());
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   531
    }
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   532
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   533
    if(messageDetails.priority()==ConvergedMessage::High ||
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   534
            messageDetails.priority() == ConvergedMessage::Low)
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   535
    {
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   536
        if(!mSubjectField)
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   537
        {
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   538
            addSubject();
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   539
        }
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   540
        mSubjectField->setPriority(messageDetails.priority());
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   541
    }
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   542
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   543
    QString bodyTxt = messageDetails.bodyText();
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   544
    mBody->setText(bodyTxt);
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   545
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   546
    ConvergedMessageAttachmentList attachmentList =
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   547
        messageDetails.attachments();
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   548
    int attachmentCount = attachmentList.count();
51
3507212d340e 201031_02
hgs
parents: 48
diff changeset
   549
     
3507212d340e 201031_02
hgs
parents: 48
diff changeset
   550
    UniEditorGenUtils* genUtils = q_check_ptr(new UniEditorGenUtils);
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   551
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   552
    QStringList pendingAttList;
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   553
    for( int i=0; i < attachmentCount; i++ )
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   554
    {
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   555
        QString filePath = messageDetails.attachments().at(i)->filePath();
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   556
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   557
        if(attachmentList.at(i)->attachmentType() ==
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   558
            ConvergedMessageAttachment::EInline)
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   559
        {
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   560
            int imageSize=0;
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   561
            QString mimeType;
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   562
            TMsgMediaType mediaType = EMsgMediaUnknown;
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   563
            TRAP_IGNORE(genUtils->getFileInfoL(filePath,imageSize,
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   564
                mimeType,mediaType));
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   565
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   566
            switch(mediaType)
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   567
            {
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   568
                case EMsgMediaImage:
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   569
                {
37
hgs
parents: 25
diff changeset
   570
                    mBody->setImage(filePath,draftMessage);
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   571
                    break;
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   572
                }
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   573
                case EMsgMediaAudio:
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   574
                {
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   575
                    mBody->setAudio(filePath);
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   576
                    break;
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   577
                }
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   578
                default:
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   579
                {
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   580
                    pendingAttList << filePath;
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   581
                    break;
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   582
                }
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   583
            }
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   584
        }
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   585
        else
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   586
        {
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   587
            pendingAttList << filePath;
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   588
        }
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   589
    }
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   590
    // add pending attachments to editor
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   591
    addAttachments(pendingAttList);
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   592
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   593
    delete genUtils;
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   594
    // ensure that any msg-type change after this are shown
37
hgs
parents: 25
diff changeset
   595
    mToField->skipMaxRecipientQuery(false);
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   596
    mMsgMonitor->setSkipNote(false);
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   597
}
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   598
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   599
void MsgUnifiedEditorView::addToolBar()
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   600
{
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   601
    //Create Tool Bar
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   602
    HbToolBar *toolBar = new HbToolBar();
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   603
    toolBar->setOrientation(Qt::Horizontal);
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   604
    
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   605
    //tool bar extension for attach action.
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   606
    HbToolBarExtension* attachExtension = new HbToolBarExtension();
51
3507212d340e 201031_02
hgs
parents: 48
diff changeset
   607
    mAttachAction = toolBar->addExtension(attachExtension);    
3507212d340e 201031_02
hgs
parents: 48
diff changeset
   608
    mAttachAction->setIcon(HbIcon(ATTACH_ICON));
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   609
    
37
hgs
parents: 25
diff changeset
   610
    mTBExtnContentWidget = new HbListWidget();
hgs
parents: 25
diff changeset
   611
    mTBExtnContentWidget->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Fixed);
hgs
parents: 25
diff changeset
   612
    mTBExtnContentWidget->addItem(LOC_PHOTO);
hgs
parents: 25
diff changeset
   613
    mTBExtnContentWidget->addItem(LOC_SOUND);
hgs
parents: 25
diff changeset
   614
    mTBExtnContentWidget->addItem(LOC_BUSINESS_CARD);
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   615
37
hgs
parents: 25
diff changeset
   616
    HbListViewItem *prototype = mTBExtnContentWidget->listItemPrototype();
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   617
    HbFrameBackground frame(POPUP_LIST_FRAME, HbFrameDrawer::NinePieces);
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   618
    prototype->setDefaultFrame(frame);
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   619
37
hgs
parents: 25
diff changeset
   620
    connect(mTBExtnContentWidget, SIGNAL(activated(HbListWidgetItem*)),
hgs
parents: 25
diff changeset
   621
            this, SLOT(handleViewExtnActivated(HbListWidgetItem*)));
hgs
parents: 25
diff changeset
   622
    connect(mTBExtnContentWidget, SIGNAL(activated(HbListWidgetItem*)),
hgs
parents: 25
diff changeset
   623
            attachExtension, SLOT(close()));
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   624
37
hgs
parents: 25
diff changeset
   625
    attachExtension->setContentWidget(mTBExtnContentWidget);
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   626
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   627
    //Add Action to the toolbar and show toolbar
37
hgs
parents: 25
diff changeset
   628
    mSendAction = toolBar->addAction(HbIcon(SEND_ICON),QString(),this,SLOT(send()));
hgs
parents: 25
diff changeset
   629
    mSendAction->setDisabled(true);
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   630
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   631
    setToolBar(toolBar);
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   632
}
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   633
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   634
void MsgUnifiedEditorView::addSubject()
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   635
{
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   636
    if(mSubjectField)
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   637
    { // do nothing if already present
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   638
        return;
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   639
    }
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   640
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   641
    int index =0;
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   642
    int offset = 1;
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   643
    if(mAttachmentContainer)
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   644
    {
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   645
        ++offset;
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   646
    }
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   647
    index = mMainLayout->count() - offset;
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   648
37
hgs
parents: 25
diff changeset
   649
    mSubjectField = new MsgUnifiedEditorSubject( mContentWidget);
hgs
parents: 25
diff changeset
   650
    
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   651
    mMainLayout->insertItem(index,mSubjectField);
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   652
    connect(mSubjectField, SIGNAL(contentChanged()),
37
hgs
parents: 25
diff changeset
   653
            mMsgMonitor, SLOT(handleContentChange()));
hgs
parents: 25
diff changeset
   654
    connect(mSubjectField, SIGNAL(contentChanged()),this,SLOT(onContentChanged()));
hgs
parents: 25
diff changeset
   655
    
hgs
parents: 25
diff changeset
   656
    //set focus to subject field.
hgs
parents: 25
diff changeset
   657
    HbAction* subjectAction = qobject_cast<HbAction*>(this->sender());
hgs
parents: 25
diff changeset
   658
    if(subjectAction)
hgs
parents: 25
diff changeset
   659
    {
hgs
parents: 25
diff changeset
   660
        setFocus(mSubjectField);
hgs
parents: 25
diff changeset
   661
    }
hgs
parents: 25
diff changeset
   662
    
hgs
parents: 25
diff changeset
   663
    // remove mainmenu's "Add Subject" action
hgs
parents: 25
diff changeset
   664
    if(mSubjectAction)
hgs
parents: 25
diff changeset
   665
    {
hgs
parents: 25
diff changeset
   666
        HbMenu* mainMenu = this->menu();
hgs
parents: 25
diff changeset
   667
        mainMenu->removeAction(mSubjectAction);
hgs
parents: 25
diff changeset
   668
        mSubjectAction->setParent(NULL);
hgs
parents: 25
diff changeset
   669
        delete mSubjectAction;
hgs
parents: 25
diff changeset
   670
    }
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   671
}
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   672
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   673
void MsgUnifiedEditorView::addCcBcc()
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   674
{
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   675
    if(mCcField && mBccField)
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   676
    { // do nothing if already present
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   677
        return;
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   678
    }
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   679
37
hgs
parents: 25
diff changeset
   680
    mCcField    = new MsgUnifiedEditorAddress( LOC_CC, mContentWidget );
hgs
parents: 25
diff changeset
   681
    mBccField   = new MsgUnifiedEditorAddress( LOC_BCC, mContentWidget );
hgs
parents: 25
diff changeset
   682
    mCcField->skipMaxRecipientQuery(true);
hgs
parents: 25
diff changeset
   683
    mBccField->skipMaxRecipientQuery(true);
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   684
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   685
    connect(mCcField, SIGNAL(sendMessage()), this, SLOT(send()));
37
hgs
parents: 25
diff changeset
   686
    connect(mCcField, SIGNAL(contentChanged()), mMsgMonitor, SLOT(handleContentChange()));
hgs
parents: 25
diff changeset
   687
    connect(mCcField, SIGNAL(contentChanged()),this,SLOT(onContentChanged()));
hgs
parents: 25
diff changeset
   688
    
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   689
    connect(mBccField, SIGNAL(sendMessage()), this, SLOT(send()));
37
hgs
parents: 25
diff changeset
   690
    connect(mBccField, SIGNAL(contentChanged()), mMsgMonitor, SLOT(handleContentChange()));
hgs
parents: 25
diff changeset
   691
    connect(mBccField, SIGNAL(contentChanged()),this,SLOT(onContentChanged()));
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   692
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   693
    HbWidget* groupWidget = new HbWidget(mContentWidget);
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   694
    groupWidget->setContentsMargins(0,0,0,0);
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   695
    
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   696
    QGraphicsLinearLayout* ccBccLayout = new QGraphicsLinearLayout(Qt::Vertical, groupWidget);
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   697
    ccBccLayout->setContentsMargins(0,0,0,0);
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   698
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   699
    qreal vItemSpacing = 0.0;    
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   700
    style()->parameter("hb-param-margin-gene-middle-vertical",vItemSpacing);
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   701
    ccBccLayout->setSpacing(vItemSpacing);
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   702
    ccBccLayout->addItem(mCcField);
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   703
    ccBccLayout->addItem(mBccField);
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   704
51
3507212d340e 201031_02
hgs
parents: 48
diff changeset
   705
    HbGroupBox* groupBox = new HbGroupBox(0);  
3507212d340e 201031_02
hgs
parents: 48
diff changeset
   706
    groupBox->setObjectName("groupBox");
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   707
    
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   708
    groupBox->setContentWidget(groupWidget);
37
hgs
parents: 25
diff changeset
   709
    groupBox->setHeading(LOC_OTHER_RECIPIENTS_EXPAND);
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   710
    mMainLayout->insertItem(1,groupBox);
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   711
    connect(groupBox, SIGNAL(toggled(bool)), this, SLOT(updateOtherRecipientCount(bool)));
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   712
    
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   713
    // add subject field too
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   714
    addSubject();
37
hgs
parents: 25
diff changeset
   715
hgs
parents: 25
diff changeset
   716
    //set focus to Cc field.
hgs
parents: 25
diff changeset
   717
    HbAction* ccBccAction = qobject_cast<HbAction*>(this->sender());
hgs
parents: 25
diff changeset
   718
    if(mCcBccAction)
hgs
parents: 25
diff changeset
   719
    {
hgs
parents: 25
diff changeset
   720
        setFocus(mCcField);
hgs
parents: 25
diff changeset
   721
    }
hgs
parents: 25
diff changeset
   722
    
hgs
parents: 25
diff changeset
   723
    // remove mainmenu's "Add Cc/Bcc" & "Add Subject" actions
hgs
parents: 25
diff changeset
   724
    if(mCcBccAction)
hgs
parents: 25
diff changeset
   725
    {
hgs
parents: 25
diff changeset
   726
    HbMenu* mainmenu = this->menu();
hgs
parents: 25
diff changeset
   727
    mainmenu->removeAction(mCcBccAction);
hgs
parents: 25
diff changeset
   728
    mCcBccAction->setParent(NULL);
hgs
parents: 25
diff changeset
   729
    delete mCcBccAction;
hgs
parents: 25
diff changeset
   730
    }
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   731
    
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   732
    this->updateGeometry();
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   733
}
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   734
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   735
void MsgUnifiedEditorView::updateOtherRecipientCount(bool state)
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   736
{
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   737
    HbGroupBox* groupBox = qobject_cast<HbGroupBox*>(sender());
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   738
    if(groupBox)
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   739
    {
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   740
        if(!state)
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   741
        {
37
hgs
parents: 25
diff changeset
   742
           groupBox->setHeading(LOC_OTHER_RECIPIENTS_EXPAND);
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   743
        }
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   744
        else
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   745
        {
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   746
            int addrCount = mCcField->addressCount();
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   747
            addrCount += mBccField->addressCount();
37
hgs
parents: 25
diff changeset
   748
            if(addrCount > 0)
hgs
parents: 25
diff changeset
   749
            {
hgs
parents: 25
diff changeset
   750
                groupBox->setHeading(LOC_OTHER_RECIPIENTS(addrCount));    
hgs
parents: 25
diff changeset
   751
            }
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   752
        }
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   753
    }
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   754
}
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   755
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   756
void MsgUnifiedEditorView::changePriority()
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   757
{
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   758
    HbAction* action = qobject_cast<HbAction*>(sender());
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   759
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   760
    ConvergedMessage::Priority priority = ConvergedMessage::Normal;
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   761
   if(action)
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   762
        {
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   763
        int data = action->data().toInt();
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   764
        priority = ConvergedMessage::Priority(data);
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   765
        }
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   766
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   767
    addSubject();
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   768
    mSubjectField->setPriority(priority);
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   769
}
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   770
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   771
void MsgUnifiedEditorView::deleteMessage()
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   772
{
37
hgs
parents: 25
diff changeset
   773
    HbMessageBox::question(LOC_NOTE_DELETE_MESSAGE,this,
hgs
parents: 25
diff changeset
   774
                           SLOT(onDialogDeleteMsg(HbAction*)),
hgs
parents: 25
diff changeset
   775
                           HbMessageBox::Delete | HbMessageBox::Cancel);
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   776
}
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   777
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   778
void MsgUnifiedEditorView::removeAttachmentContainer()
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   779
{
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   780
    if(mAttachmentContainer)
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   781
    {
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   782
        mMainLayout->removeItem(mAttachmentContainer);
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   783
        mAttachmentContainer->setParent(NULL);
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   784
        delete mAttachmentContainer;
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   785
        mAttachmentContainer = NULL;
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   786
    }
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   787
}
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   788
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   789
void MsgUnifiedEditorView::addAttachments(QStringList files)
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   790
{    
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   791
    int fcount = files.count();
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   792
    int i=0;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   793
    for(i=0; i<fcount; i++)
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   794
    {
37
hgs
parents: 25
diff changeset
   795
        int status = addAttachment(files.at(i));
hgs
parents: 25
diff changeset
   796
        if(status == MsgAttachmentContainer::EAddSizeExceed)
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   797
        {
37
hgs
parents: 25
diff changeset
   798
            QString displayStr = QString(LOC_UNABLE_TO_ADD_ATTACHMENTS)
hgs
parents: 25
diff changeset
   799
                    .arg(fcount-i).arg(fcount);
hgs
parents: 25
diff changeset
   800
            HbNotificationDialog::launchDialog(displayStr);
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   801
            break;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   802
        }
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   803
    }
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   804
}
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   805
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   806
int MsgUnifiedEditorView::addAttachment(const QString& filepath)
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   807
{
37
hgs
parents: 25
diff changeset
   808
    // do nothing if filepath is empty
hgs
parents: 25
diff changeset
   809
    if(filepath.isEmpty())
hgs
parents: 25
diff changeset
   810
    {
hgs
parents: 25
diff changeset
   811
        return MsgAttachmentContainer::EAddSuccess;
hgs
parents: 25
diff changeset
   812
    }
hgs
parents: 25
diff changeset
   813
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   814
    if(!mAttachmentContainer)
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   815
    {
37
hgs
parents: 25
diff changeset
   816
        mAttachmentContainer = new MsgAttachmentContainer( mContentWidget);
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   817
        connect(mAttachmentContainer, SIGNAL(emptyAttachmentContainer()),
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   818
                this, SLOT(removeAttachmentContainer()));
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   819
        connect(mAttachmentContainer, SIGNAL(contentChanged()),
37
hgs
parents: 25
diff changeset
   820
                mMsgMonitor, SLOT(handleContentChange()));
hgs
parents: 25
diff changeset
   821
        connect(mAttachmentContainer, SIGNAL(contentChanged()),
hgs
parents: 25
diff changeset
   822
                this,SLOT(onContentChanged()));
hgs
parents: 25
diff changeset
   823
        
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   824
        int index = mMainLayout->count() - 1;
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   825
        mMainLayout->insertItem(index,mAttachmentContainer);
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   826
    }
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   827
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   828
    int ret = mAttachmentContainer->addAttachment(filepath);
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   829
    if(ret != MsgAttachmentContainer::EAddSuccess)
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   830
    {
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   831
        // delete container, if it is empty
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   832
        if(mAttachmentContainer->count() == 0)
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   833
        {
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   834
            removeAttachmentContainer();
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   835
        }
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   836
    }
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   837
    return ret;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   838
}
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   839
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   840
void MsgUnifiedEditorView::send()
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   841
{
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   842
    activateInputBlocker();
37
hgs
parents: 25
diff changeset
   843
    
hgs
parents: 25
diff changeset
   844
    // first run the address validation tests
hgs
parents: 25
diff changeset
   845
    if( !mToField->validateContacts() ||
hgs
parents: 25
diff changeset
   846
        (mCcField && !mCcField->validateContacts()) ||
hgs
parents: 25
diff changeset
   847
        (mBccField && !mBccField->validateContacts()) )
hgs
parents: 25
diff changeset
   848
    {
hgs
parents: 25
diff changeset
   849
        deactivateInputBlocker();
hgs
parents: 25
diff changeset
   850
        return;
hgs
parents: 25
diff changeset
   851
    }
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   852
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   853
    // converged msg for sending
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   854
    ConvergedMessage msg;
37
hgs
parents: 25
diff changeset
   855
    ConvergedMessage::MessageType messageType = MsgUnifiedEditorMonitor::messageType();
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   856
    msg.setMessageType(messageType);
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   857
37
hgs
parents: 25
diff changeset
   858
    // we need to remove duplicate addresses
hgs
parents: 25
diff changeset
   859
    bool removeDuplicates = true;
hgs
parents: 25
diff changeset
   860
    ConvergedMessageAddressList addresses =
hgs
parents: 25
diff changeset
   861
            mToField->addresses(removeDuplicates);
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   862
    if(messageType == ConvergedMessage::Sms &&
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   863
       addresses.isEmpty())
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   864
    {
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   865
        // no recipient specified for sms, do not send msg
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   866
        deactivateInputBlocker();
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   867
        return;
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   868
    }
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   869
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   870
    ConvergedMessageAddressList ccAddresses;
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   871
    ConvergedMessageAddressList bccAddresses;
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   872
    if(mCcField)
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   873
    {
37
hgs
parents: 25
diff changeset
   874
        ccAddresses = mCcField->addresses(removeDuplicates);
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   875
    }
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   876
    if(mBccField)
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   877
    {
37
hgs
parents: 25
diff changeset
   878
        bccAddresses = mBccField->addresses(removeDuplicates);
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   879
    }
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   880
    if( messageType == ConvergedMessage::Mms &&
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   881
            addresses.isEmpty() &&
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   882
            ccAddresses.isEmpty() &&
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   883
            bccAddresses.isEmpty())
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   884
    {
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   885
        // no recipient specified for mms, do not send msg
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   886
        deactivateInputBlocker();
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   887
        return;
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   888
    }
37
hgs
parents: 25
diff changeset
   889
    
hgs
parents: 25
diff changeset
   890
    //close vkb before switching view.
hgs
parents: 25
diff changeset
   891
    mVkbHost->closeKeypad(true);
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   892
56
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   893
    int result = packMessage(msg);
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   894
    if(result == KErrNotFound)
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   895
    {
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   896
        HbMessageBox::information(LOC_NOTE_FILES_MISSED_SEND, 0, 0, HbMessageBox::Ok);
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   897
        deactivateInputBlocker();
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   898
        return;
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   899
    }
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   900
    // send message
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   901
    MsgSendUtil *sendUtil = new MsgSendUtil(this);
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   902
    int sendResult = sendUtil->send(msg);
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   903
    delete sendUtil;
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   904
    
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   905
    // all checks and validations happen before send
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   906
    if( sendResult == KErrNone)
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   907
    {
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   908
        //After sending the new content to drafts chk if the msg
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   909
        //was originally opened from drafts and delete the opened entry
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   910
        if( mOpenedMessageId.getId() != -1)
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   911
        {
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   912
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   913
            if(!mPluginLoader)
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   914
            {
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   915
                mPluginLoader = new UniEditorPluginLoader(this);
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   916
            }
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   917
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   918
            UniEditorPluginInterface* pluginInterface =
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   919
                mPluginLoader->getUniEditorPlugin(messageType);
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   920
            //TODO delete the entry
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   921
            pluginInterface->deleteDraftsEntry(mOpenedMessageId.getId());
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   922
        }
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   923
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   924
        ConvergedMessageAddressList addrList = addresses;
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   925
        QString receipient;
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   926
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   927
        int recepientCount = addrList.count();
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   928
        if(recepientCount)
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   929
        {
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   930
            receipient = addrList.at(0)->address();
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   931
        }
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   932
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   933
        if( mCcField && mBccField)
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   934
        {
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   935
            addrList = ccAddresses;
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   936
            int ccCount = addrList.count();
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   937
            recepientCount += ccCount;
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   938
            if(ccCount)
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   939
            {
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   940
                receipient = addrList.at(0)->address();
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   941
            }
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   942
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   943
            addrList = bccAddresses;
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   944
            int bccCount = addrList.count();
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   945
            recepientCount += bccCount;
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   946
            if(bccCount)
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   947
            {
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   948
                receipient = addrList.at(0)->address();
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   949
            }
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   950
        }
37
hgs
parents: 25
diff changeset
   951
        
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   952
    QVariantList params;
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   953
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   954
    if(recepientCount == 1 )
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   955
        {
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   956
        params << MsgBaseView::CV;  // target view
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   957
        params << MsgBaseView::UNIEDITOR; // source view
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   958
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   959
        params << receipient;
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   960
        }
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   961
    else
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   962
        {
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   963
        params << MsgBaseView::CLV;// target view
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   964
        params << MsgBaseView::UNIEDITOR; // source view
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   965
        }
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   966
        deactivateInputBlocker();
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   967
        emit switchView(params);
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   968
    }
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   969
    else
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   970
    {
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   971
        deactivateInputBlocker();
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   972
        if(sendResult == KErrNotFound)
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   973
        {
37
hgs
parents: 25
diff changeset
   974
            if (messageType == ConvergedMessage::Sms)
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   975
            {
37
hgs
parents: 25
diff changeset
   976
                HbMessageBox::question(LOC_DIALOG_SMS_SETTINGS_INCOMPLETE,
hgs
parents: 25
diff changeset
   977
                                       this,SLOT(onDialogSmsSettings(HbAction*)),
hgs
parents: 25
diff changeset
   978
                                       HbMessageBox::Ok | HbMessageBox::Cancel);
hgs
parents: 25
diff changeset
   979
            }
hgs
parents: 25
diff changeset
   980
            else
hgs
parents: 25
diff changeset
   981
            {
hgs
parents: 25
diff changeset
   982
                HbMessageBox::question(LOC_DIALOG_MMS_SETTINGS_INCOMPLETE,
hgs
parents: 25
diff changeset
   983
                                       this,SLOT(onDialogMmsSettings(HbAction*)),                             
hgs
parents: 25
diff changeset
   984
                                       HbMessageBox::Ok | HbMessageBox::Cancel);
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   985
            }
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   986
        }
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   987
    }
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   988
}
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   989
56
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   990
int MsgUnifiedEditorView::packMessage(ConvergedMessage &msg, bool isSave)
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   991
{
56
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   992
    // reset reply-path if originating SME constraint is broken
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   993
    if(mReplyPath && isReplyPathBroken())
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   994
    {
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   995
        mReplyPath = false;
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   996
    }
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   997
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   998
    msg.setReplyPath(mReplyPath);
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   999
    if(mReplyPath)
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1000
    {
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1001
        msg.setOriginatingSC(mOriginatingSC);
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1002
    }
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1003
37
hgs
parents: 25
diff changeset
  1004
    ConvergedMessage::MessageType messageType = MsgUnifiedEditorMonitor::messageType();
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1005
    msg.setMessageType(messageType);
37
hgs
parents: 25
diff changeset
  1006
    // If isSave is true (save to draft usecase), then don't remove duplicates
hgs
parents: 25
diff changeset
  1007
    // If isSave is false (send usecase), then remove duplicates
hgs
parents: 25
diff changeset
  1008
    bool removeDuplicates = !isSave;
hgs
parents: 25
diff changeset
  1009
    ConvergedMessageAddressList addresses = 
hgs
parents: 25
diff changeset
  1010
            mToField->addresses(removeDuplicates);
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1011
    ConvergedMessageAddressList ccAddresses;
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1012
    ConvergedMessageAddressList bccAddresses;
56
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1013
    ConvergedMessageAttachmentList mediaList;
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1014
    int errorCode = 0;
38
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
  1015
	//Don't format the addresses for save to drfats case
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
  1016
	if(!isSave)
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
  1017
	{
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
  1018
       formatAddresses(addresses);
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
  1019
    }
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
  1020
	
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1021
    msg.addToRecipients(addresses);
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1022
    msg.setBodyText(mBody->text());
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1023
    msg.setDirection(ConvergedMessage::Outgoing);
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1024
    QDateTime time = QDateTime::currentDateTime();
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1025
    msg.setTimeStamp(time.toTime_t());
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1026
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1027
    if(messageType == ConvergedMessage::Mms)
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1028
    {
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1029
        if(mCcField)
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1030
        {
37
hgs
parents: 25
diff changeset
  1031
            ccAddresses = mCcField->addresses(removeDuplicates);
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1032
        }
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1033
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1034
        if(mBccField)
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1035
        {
37
hgs
parents: 25
diff changeset
  1036
            bccAddresses = mBccField->addresses(removeDuplicates);
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1037
        }
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1038
37
hgs
parents: 25
diff changeset
  1039
        if(removeDuplicates)
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1040
        {
37
hgs
parents: 25
diff changeset
  1041
            int matchDigitsCount = MsgUnifiedEditorAddress::contactMatchDigits();
hgs
parents: 25
diff changeset
  1042
            //comapre cc and to field,remove duplicate from cc
hgs
parents: 25
diff changeset
  1043
            foreach(ConvergedMessageAddress *ccAddress,ccAddresses)
hgs
parents: 25
diff changeset
  1044
            {
hgs
parents: 25
diff changeset
  1045
                foreach(ConvergedMessageAddress *toAddress,addresses)
hgs
parents: 25
diff changeset
  1046
                {
hgs
parents: 25
diff changeset
  1047
                    if(0 == ccAddress->address().right(matchDigitsCount).compare(toAddress->address().right(matchDigitsCount)))
hgs
parents: 25
diff changeset
  1048
                    {
hgs
parents: 25
diff changeset
  1049
                        ccAddresses.removeOne(ccAddress);
hgs
parents: 25
diff changeset
  1050
                    }
hgs
parents: 25
diff changeset
  1051
                }
hgs
parents: 25
diff changeset
  1052
            }
hgs
parents: 25
diff changeset
  1053
            //comapre bcc and cc field,remove duplicate from bcc
hgs
parents: 25
diff changeset
  1054
            foreach(ConvergedMessageAddress *bccAddress,bccAddresses)
hgs
parents: 25
diff changeset
  1055
            {
hgs
parents: 25
diff changeset
  1056
                foreach(ConvergedMessageAddress *ccAddress,ccAddresses)
hgs
parents: 25
diff changeset
  1057
                {
hgs
parents: 25
diff changeset
  1058
                    if(0 == bccAddress->address().right(matchDigitsCount).compare(ccAddress->address().right(matchDigitsCount)))
hgs
parents: 25
diff changeset
  1059
                    {
hgs
parents: 25
diff changeset
  1060
                        bccAddresses.removeOne(bccAddress);
hgs
parents: 25
diff changeset
  1061
                    }
hgs
parents: 25
diff changeset
  1062
                }
hgs
parents: 25
diff changeset
  1063
            }
hgs
parents: 25
diff changeset
  1064
            //comapre bcc and to field,remove duplicate from bcc
hgs
parents: 25
diff changeset
  1065
            foreach(ConvergedMessageAddress *bccAddress,bccAddresses)
hgs
parents: 25
diff changeset
  1066
            {
hgs
parents: 25
diff changeset
  1067
                foreach(ConvergedMessageAddress *toAddress,addresses)
hgs
parents: 25
diff changeset
  1068
                {
hgs
parents: 25
diff changeset
  1069
                    if(0 == bccAddress->address().right(matchDigitsCount).compare(toAddress->address().right(matchDigitsCount)))
hgs
parents: 25
diff changeset
  1070
                    {
hgs
parents: 25
diff changeset
  1071
                        bccAddresses.removeOne(bccAddress);
hgs
parents: 25
diff changeset
  1072
                    }
hgs
parents: 25
diff changeset
  1073
                }
hgs
parents: 25
diff changeset
  1074
            }
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1075
        }
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1076
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1077
        if(ccAddresses.count()>0)
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1078
        {
38
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
  1079
		//Don't format the addresses for save to drfats case
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
  1080
	    if(!isSave)
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
  1081
	    {
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
  1082
           formatAddresses(ccAddresses);
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
  1083
        }        
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1084
        msg.addCcRecipients(ccAddresses);
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1085
        }
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1086
        if(bccAddresses.count()>0)
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1087
        {
38
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
  1088
		//Don't format the addresses for save to drfats case
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
  1089
	    if(!isSave)
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
  1090
	    {
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
  1091
           formatAddresses(bccAddresses);        
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
  1092
		}
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1093
        msg.addBccRecipients(bccAddresses);
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1094
        }
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1095
        if(mSubjectField)
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1096
        {
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1097
            msg.setSubject(mSubjectField->text());
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1098
            msg.setPriority(mSubjectField->priority());
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1099
        }
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1100
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1101
        QStringList mediafiles(mBody->mediaContent());
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1102
        if (!mediafiles.isEmpty())
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1103
        {
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1104
            for (int i = 0; i < mediafiles.size(); ++i)
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1105
            {
56
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1106
                if(QFile::exists(mediafiles.at(i)))
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1107
                {
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1108
                ConvergedMessageAttachment* attachment =
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1109
                    new ConvergedMessageAttachment(
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1110
                        mediafiles.at(i),
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1111
                        ConvergedMessageAttachment::EInline);
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1112
                mediaList << attachment;
56
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1113
                }
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1114
                else
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1115
                {   mBody->removeMediaContent(mediafiles.at(i));
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1116
                    errorCode = KErrNotFound;
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1117
                }
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1118
            }
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1119
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1120
        }
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1121
        if(mediaList.count() > 0)
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1122
        {
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1123
            msg.addAttachments(mediaList);
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1124
        }
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1125
    }
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1126
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1127
    // sms/mms attachment list
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1128
    ConvergedMessageAttachmentList attachmentList;
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1129
        if(mAttachmentContainer)
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1130
        {
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1131
            MsgUnifiedEditorAttachmentList editorAttachmentList =
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1132
                mAttachmentContainer->attachmentList();
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1133
                for (int i = 0; i < editorAttachmentList.count(); ++i)
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1134
                {
56
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1135
                    if(QFile::exists(editorAttachmentList.at(i)->path()))
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1136
                    {
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1137
                        ConvergedMessageAttachment* attachment =
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1138
                                                new ConvergedMessageAttachment(
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1139
                                                    editorAttachmentList.at(i)->path(),
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1140
                                                    ConvergedMessageAttachment::EAttachment);
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1141
                                            attachmentList << attachment;    
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1142
                    }
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1143
                    else
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1144
                    {
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1145
                        mAttachmentContainer->deleteAttachment(editorAttachmentList.at(i));
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1146
                        errorCode = KErrNotFound;
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1147
                    }   
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1148
                }
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1149
            }
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1150
        if(attachmentList.count() > 0)
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1151
        {
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1152
            msg.addAttachments(attachmentList);
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1153
        }
56
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1154
        return errorCode;
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1155
}
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1156
37
hgs
parents: 25
diff changeset
  1157
int MsgUnifiedEditorView::saveContentToDrafts()
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1158
{
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1159
    if(!mCanSaveToDrafts)
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1160
        {
37
hgs
parents: 25
diff changeset
  1161
        return mOpenedMessageId.getId(); // return currently opened message id
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1162
        }
37
hgs
parents: 25
diff changeset
  1163
    
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1164
    activateInputBlocker();
37
hgs
parents: 25
diff changeset
  1165
    ConvergedMessage::MessageType messageType = MsgUnifiedEditorMonitor::messageType();
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1166
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1167
    ConvergedMessageAddressList addresses = mToField->addresses();
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1168
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1169
    UniEditorPluginInterface* pluginInterface = NULL;
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1170
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1171
    if( mOpenedMessageId.getId() != -1)
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1172
    {
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1173
        if(!mPluginLoader)
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1174
        {
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1175
            mPluginLoader = new UniEditorPluginLoader(this);
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1176
        }
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1177
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1178
        pluginInterface =
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1179
            mPluginLoader->getUniEditorPlugin(messageType);
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1180
    }
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1181
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1182
    if(messageType == ConvergedMessage::Sms &&
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1183
            addresses.isEmpty() &&
37
hgs
parents: 25
diff changeset
  1184
            MsgUnifiedEditorMonitor::bodySize() <= 0 &&
hgs
parents: 25
diff changeset
  1185
            MsgUnifiedEditorMonitor::containerSize() <= 0)
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1186
    {
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1187
        if(mOpenedMessageId.getId() != -1)
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1188
        {
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1189
        pluginInterface->deleteDraftsEntry(mOpenedMessageId.getId());
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1190
        }
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1191
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1192
        // if empty msg, do not save
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1193
        deactivateInputBlocker();
37
hgs
parents: 25
diff changeset
  1194
        return INVALID_MSGID;
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1195
    }
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1196
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1197
    ConvergedMessageAddressList ccAddresses;
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1198
    ConvergedMessageAddressList bccAddresses;
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1199
    if(mCcField)
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1200
    {
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1201
        ccAddresses = mCcField->addresses();
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1202
    }
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1203
    if(mBccField)
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1204
    {
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1205
        bccAddresses = mBccField->addresses();
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1206
    }
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1207
    int subectSize =0;
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1208
    if(mSubjectField)
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1209
    {
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1210
        subectSize = mSubjectField->text().size();
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1211
    }
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1212
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1213
    if( messageType == ConvergedMessage::Mms &&
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1214
            addresses.isEmpty() &&
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1215
            ccAddresses.isEmpty() &&
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1216
            bccAddresses.isEmpty() &&
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1217
            subectSize <= 0 &&
37
hgs
parents: 25
diff changeset
  1218
            MsgUnifiedEditorMonitor::bodySize() <= 0 &&
hgs
parents: 25
diff changeset
  1219
            MsgUnifiedEditorMonitor::containerSize() <= 0)
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1220
    {
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1221
        if(mOpenedMessageId.getId() != -1)
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1222
        {
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1223
            pluginInterface->deleteDraftsEntry(mOpenedMessageId.getId());
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1224
        }
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1225
        // if empty msg, do not send
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1226
        deactivateInputBlocker();
37
hgs
parents: 25
diff changeset
  1227
        return INVALID_MSGID;
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1228
    }
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1229
    ConvergedMessage msg;
56
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1230
    int result = packMessage(msg, true);
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1231
    if(result == KErrNotFound)
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1232
        {
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1233
        HbNotificationDialog::launchDialog(LOC_NOTE_FILES_MISSED_DRAFTS);
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1234
        if(messageType == ConvergedMessage::Sms &&
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1235
                    addresses.isEmpty() &&
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1236
                    MsgUnifiedEditorMonitor::bodySize() <= 0 &&
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1237
                    MsgUnifiedEditorMonitor::containerSize() <= 0)
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1238
            {
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1239
                if(mOpenedMessageId.getId() != -1)
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1240
                {
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1241
                pluginInterface->deleteDraftsEntry(mOpenedMessageId.getId());
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1242
                }
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1243
56
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1244
                // if empty msg, do not save
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1245
                deactivateInputBlocker();
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1246
                return INVALID_MSGID;
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1247
            }
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1248
        }
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1249
    // save to drafts
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1250
    MsgSendUtil *sendUtil = new MsgSendUtil(this);
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1251
    int msgId = sendUtil->saveToDrafts(msg);
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1252
    delete sendUtil;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1253
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1254
    // If saving new msg to draft succeeded and also if the originally
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1255
    // opened msg was from drafts, then delete the original msg entry
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1256
    if(msgId != -1 && mOpenedMessageId.getId() != -1)
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1257
    {
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1258
        pluginInterface->deleteDraftsEntry(mOpenedMessageId.getId());
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1259
        mOpenedMessageId.setId(INVALID_MSGID);
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1260
    }
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1261
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1262
    deactivateInputBlocker();
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1263
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1264
    bool res = ((msgId > INVALID_MSGID)? true : false);
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1265
    
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1266
    if(res)
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1267
        {
48
4f501b74aeb1 201029_02
hgs
parents: 41
diff changeset
  1268
        HbDeviceNotificationDialog::notification("", LOC_SAVED_TO_DRAFTS);
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1269
        }
37
hgs
parents: 25
diff changeset
  1270
    return msgId;
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1271
}
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1272
62
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1273
bool MsgUnifiedEditorView::handleKeyEvent(int key)
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1274
{
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1275
    bool eventHandled = false;
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1276
    if (Qt::Key_Yes == key && mSendAction->isEnabled()) {
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1277
        eventHandled = true;
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1278
        send();
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1279
    }
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1280
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1281
    return eventHandled;
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1282
}
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1283
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1284
void MsgUnifiedEditorView::resizeEvent( QGraphicsSceneResizeEvent * event )
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1285
{
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1286
 Q_UNUSED(event)
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1287
 #ifdef _DEBUG_TRACES_
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1288
 qDebug()<<"resize event";
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1289
#endif
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1290
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1291
 mContentWidget->resize(this->rect().width(),this->rect().height()+1);
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1292
}
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1293
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1294
//---------------------------------------------------------------
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1295
// MsgUnifiedEditorView::createVCards
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1296
// @see header file
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1297
//---------------------------------------------------------------
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1298
int MsgUnifiedEditorView::createVCards(
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1299
        const QVariant& value, QStringList& filelist)
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1300
{
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1301
    // make sure that temp-folder is created for storing vcards
37
hgs
parents: 25
diff changeset
  1302
    if(!createTempFolder())
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1303
    {
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1304
        return KErrGeneral;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1305
    }
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1306
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1307
    // extract contact-list
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1308
    QContactManager* contactManager = new QContactManager("symbian");
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1309
    CntServicesContactList cntServicesContacts = qVariantValue<CntServicesContactList>(value);
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1310
    int cntCount = cntServicesContacts.count();
62
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1311
    
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1312
    QCRITICAL_WRITE_FORMAT("servicecontactlist count:",cntCount);
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1313
    
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1314
    QList<QtMobility::QContact> contactList;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1315
    for(int i = 0; i < cntCount; i++ )
62
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1316
    {        
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1317
        contactList << contactManager->contact( cntServicesContacts.at(i).mContactId );
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1318
    }
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1319
    delete contactManager;
62
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1320
   
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1321
    // get list of all versit-documents
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1322
    QVersitDocument::VersitType versitType(QVersitDocument::VCard21Type);
62
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1323
    
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1324
    QVersitContactExporter exporter;
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1325
    bool ret_val = exporter.exportContacts(contactList, versitType);
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1326
    
62
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1327
    if(ret_val == false)
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1328
        { 
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1329
        QCRITICAL_WRITE("QVersitContactExporter::exportContacts returned false");
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1330
        return KErrGeneral;
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1331
        }  
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1332
    
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1333
    // process the documents
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1334
	QList<QtMobility::QVersitDocument> documentList = exporter.documents();
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1335
	
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1336
    // loop though and create a vcard for each contact
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1337
    QVersitWriter* writer = new QVersitWriter();
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1338
    for(int i = 0; i < cntCount; i++ )
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1339
    {
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1340
        // buffer to hold vcard data fetched from contacts
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1341
        QBuffer contactsbuf;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1342
        contactsbuf.open(QBuffer::ReadWrite);
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1343
        writer->setDevice( &contactsbuf );
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1344
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1345
        //write document data to buffer
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1346
        QList<QtMobility::QVersitDocument> currDoc;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1347
        currDoc << documentList.at(i);
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1348
        writer->startWriting(currDoc);
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1349
        if(writer->waitForFinished())
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1350
        {
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1351
            // generate file name
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1352
            QString displayLabel = contactList.at(i).displayLabel();
67
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
  1353
            displayLabel.replace(QRegExp(INVALID_FILENAME_CHARS), REPLACE_CHAR);
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1354
            QString filepath = generateFileName(displayLabel);
67
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
  1355
            
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
  1356
            // create file
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1357
            QFile file(filepath);
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1358
            if(file.open(QIODevice::WriteOnly))
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1359
            {
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1360
                // trap ignore so that, incase of multiselection, other vcards are still created
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1361
                QByteArray bufArr;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1362
                TRAP_IGNORE(
62
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1363
                        HBufC8* contactBuf8 = XQConversions::qStringToS60Desc8(contactsbuf.data());
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1364
                        if(contactBuf8)
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1365
                            {
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1366
                            CleanupStack::PushL(contactBuf8);
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1367
                            CBufBase* contactbufbase = CBufFlat::NewL(contactsbuf.size());
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1368
                            CleanupStack::PushL(contactbufbase);
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1369
                            
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1370
                            contactbufbase->InsertL( contactbufbase->Size(), *contactBuf8);
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1371
                            
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1372
                            TPtr8 ptrbuf(contactbufbase->Ptr(0));
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1373
                            bufArr = XQConversions::s60Desc8ToQByteArray(ptrbuf);
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1374
                            
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1375
                            CleanupStack::PopAndDestroy(contactbufbase);
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1376
                            CleanupStack::PopAndDestroy(contactBuf8);
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1377
                            
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1378
                            // write to file
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1379
                            file.write(bufArr);                                            
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1380
                            filelist << filepath;
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1381
                            }
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1382
                ); // TRAP END
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1383
                
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1384
                //close file
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1385
                file.close();                
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1386
            }
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1387
        }
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1388
    }
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1389
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1390
    // cleanup & return
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1391
    delete writer;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1392
    return KErrNone;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1393
}
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1394
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1395
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1396
//---------------------------------------------------------------
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1397
// MsgUnifiedEditorView::generateFileName
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1398
// @param suggestedName suggested name of the file
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1399
// @return fullPath of the generated filename
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1400
// @algo For multiselected 'Unnamed' contacts, the filename should
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1401
// be synthesized as unnamed.vcf, unnamed1.vcf, unnamed2.vcf etc.
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1402
//---------------------------------------------------------------
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1403
QString MsgUnifiedEditorView::generateFileName(QString& suggestedName)
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1404
{
37
hgs
parents: 25
diff changeset
  1405
    QDir editorTempDir;
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1406
    editorTempDir.cd(editorTempPath());
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1407
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1408
    for(int i=0; i<MAX_VCARDS; i++)
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1409
    {
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1410
        QString searchFileName = suggestedName;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1411
        if(i>0)
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1412
        {
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1413
            searchFileName.append(QString::number(i));
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1414
        }
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1415
        searchFileName.append(FILE_EXTN);
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1416
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1417
        // check if filename is already used by an attachment in container
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1418
        bool alreadyExists = false;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1419
        if(mAttachmentContainer)
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1420
        {
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1421
            MsgUnifiedEditorAttachmentList attList =
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1422
                    mAttachmentContainer->attachmentList();
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1423
            int attCount = attList.count();
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1424
            for(int j=0; j<attCount; j++)
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1425
            {
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1426
                QFileInfo fileinfo(attList.at(j)->path());
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1427
                if(searchFileName == fileinfo.fileName())
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1428
                {
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1429
                    alreadyExists = true;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1430
                    break;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1431
                }
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1432
            }
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1433
        }
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1434
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1435
        if(!alreadyExists)
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1436
        {
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1437
            if(i>0)
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1438
            {
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1439
                suggestedName.append(QString::number(i));
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1440
            }
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1441
            break;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1442
        }
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1443
    }
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1444
    QString filepath(editorTempPath());
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1445
    filepath.append(suggestedName);
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1446
    filepath.append(FILE_EXTN);
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1447
    return filepath;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1448
}
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1449
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1450
void MsgUnifiedEditorView::handleViewExtnActivated(HbListWidgetItem* item)
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1451
    {
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1452
    QString itemText = item->text();
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1453
    
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1454
    if(itemText == LOC_PHOTO)
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1455
        {
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1456
        //launch photo picker.
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1457
        fetchImages();  
37
hgs
parents: 25
diff changeset
  1458
        }
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1459
    else if(itemText == LOC_SOUND)
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1460
        {
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1461
        //launch audio picker
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1462
        fetchAudio();
37
hgs
parents: 25
diff changeset
  1463
        }
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1464
    else if(itemText == LOC_BUSINESS_CARD)
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1465
        {
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1466
        //launch contact card picker.
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1467
        fetchContacts();
37
hgs
parents: 25
diff changeset
  1468
        }
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1469
   
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1470
}
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1471
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1472
//---------------------------------------------------------------
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1473
// MsgUnifiedEditorView::fetchContacts
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1474
// @see header file
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1475
//---------------------------------------------------------------
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1476
void MsgUnifiedEditorView::fetchContacts()
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1477
{
62
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1478
    QString service("phonebookservices");
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1479
    QString interface("com.nokia.symbian.IContactsFetch");
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1480
    QString operation("multiFetch(QString,QString)");
73
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
  1481
  
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
  1482
    XQApplicationManager appManager;   
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
  1483
    XQAiwRequest* request = appManager.create(service, interface, operation, true); //embedded
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
  1484
	
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1485
    if ( request == NULL )
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1486
    {
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1487
        QCRITICAL_WRITE("AIW-ERROR: NULL request");
62
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1488
        return;
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1489
    }
73
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
  1490
	
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
  1491
    request->setSynchronous(false); // synchronous
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
  1492
	
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1493
    // Result handlers
62
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1494
    connect (request, SIGNAL(requestOk(const QVariant&)),
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1495
        this, SLOT(contactsFetched(const QVariant&)));
62
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1496
    connect (request, SIGNAL(requestError(int,const QString&)),
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1497
        this, SLOT(serviceRequestError(int,const QString&)));
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1498
62
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
  1499
    QList<QVariant> args;
73
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
  1500
    args << LOC_TITLE;
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1501
    args << KCntActionAll;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1502
    args << KCntFilterDisplayAll;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1503
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1504
    request->setArguments(args);
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1505
    if(!request->send())
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1506
    {
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1507
        QDEBUG_WRITE_FORMAT("AIW-ERROR: Request Send failed:",request->lastError());
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1508
    }
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1509
}
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1510
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1511
//---------------------------------------------------------------
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1512
// MsgUnifiedEditorView::fetchImages
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1513
// @see header file
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1514
//---------------------------------------------------------------
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1515
void MsgUnifiedEditorView::fetchImages()
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1516
{
37
hgs
parents: 25
diff changeset
  1517
    QString service("photos");
hgs
parents: 25
diff changeset
  1518
    QString interface("com.nokia.symbian.IImageFetch");
hgs
parents: 25
diff changeset
  1519
    QString operation("fetch()");
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1520
    XQApplicationManager appManager;
73
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
  1521
    XQAiwRequest* request = appManager.create(service,interface, operation, true);//embedded
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1522
    if(!request)
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1523
    {     
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1524
        QCRITICAL_WRITE("AIW-ERROR: NULL request");
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1525
        return;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1526
    }
73
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
  1527
    request->setSynchronous(false); // synchronous
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1528
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1529
    connect(request, SIGNAL(requestOk(const QVariant&)),
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1530
        this, SLOT(imagesFetched(const QVariant&)));
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1531
    connect(request, SIGNAL(requestError(int,const QString&)),
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1532
        this, SLOT(serviceRequestError(int,const QString&)));
37
hgs
parents: 25
diff changeset
  1533
    
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1534
    // Make the request
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1535
    if (!request->send())
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1536
    {
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1537
        QDEBUG_WRITE_FORMAT("AIW-ERROR: Request Send failed:" , request->lastError());
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1538
    }  
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1539
}
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1540
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1541
//---------------------------------------------------------------
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1542
// MsgUnifiedEditorView::fetchAudio
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1543
// @see header file
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1544
//---------------------------------------------------------------
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1545
void MsgUnifiedEditorView::fetchAudio()
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1546
{
56
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1547
    // Launch Audio fetcher dialog
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1548
    if(!mDialog)
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1549
    {
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1550
       mDialog = new MsgAudioFetcherDialog();
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1551
       connect(mDialog,
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1552
            SIGNAL(audioSelected(QString&)),
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1553
            this,
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1554
            SLOT(onAudioSelected(QString&)));
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1555
    }
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1556
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1557
    //show the dialog
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1558
    mDialog->show();    
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1559
}
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1560
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1561
//---------------------------------------------------------------
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1562
// MsgUnifiedEditorView::contactsFetched
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1563
// @see header file
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1564
//---------------------------------------------------------------
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1565
void MsgUnifiedEditorView::contactsFetched(const QVariant& value)
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1566
{
73
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
  1567
    XQAiwRequest* request = qobject_cast<XQAiwRequest*>(this->sender());
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
  1568
    if(request)
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
  1569
    {
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
  1570
        delete request;
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
  1571
    }
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
  1572
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1573
    // create a vcard for each contact fetched and add as attachment
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1574
    QStringList attachmentList;
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1575
    if(createVCards(value, attachmentList) == KErrNone)
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1576
    {
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1577
        addAttachments(attachmentList);
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1578
    }
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1579
}
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1580
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1581
//---------------------------------------------------------------
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1582
// MsgUnifiedEditorView::imagesFetched
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1583
// @see header file
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1584
//---------------------------------------------------------------
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1585
void MsgUnifiedEditorView::imagesFetched(const QVariant& result )
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1586
{
73
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
  1587
    XQAiwRequest* request = qobject_cast<XQAiwRequest*>(this->sender());
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
  1588
    if(request)
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
  1589
    {
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
  1590
        delete request;        
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
  1591
    }
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
  1592
	
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1593
    if(result.canConvert<QStringList>())
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1594
    {
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1595
        QStringList fileList = result.value<QStringList>();
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1596
        if ( fileList.size()>0 )
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1597
        {
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1598
            QString filepath(QDir::toNativeSeparators(fileList.at(0)));
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1599
            mBody->setImage(filepath);
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1600
        }
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1601
    }
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1602
}
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1603
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1604
//---------------------------------------------------------------
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1605
// MsgUnifiedEditorView::serviceRequestError
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1606
// @see header file
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1607
//---------------------------------------------------------------
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1608
void MsgUnifiedEditorView::serviceRequestError(int errorCode, const QString& errorMessage)
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1609
{
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1610
    QDEBUG_WRITE_FORMAT(errorMessage,errorCode);
73
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
  1611
    Q_UNUSED(errorCode)
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
  1612
    Q_UNUSED(errorMessage)
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
  1613
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
  1614
    XQAiwRequest* request = qobject_cast<XQAiwRequest*>(this->sender());
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
  1615
    if(request)
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
  1616
    {
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
  1617
        delete request;	
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
  1618
    }
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1619
}
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1620
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1621
//---------------------------------------------------------------
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1622
// MsgUnifiedEditorView::activateInputBlocker
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1623
// @see header file
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1624
//--------------------------------------------------------------
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1625
void MsgUnifiedEditorView::activateInputBlocker()
37
hgs
parents: 25
diff changeset
  1626
{
hgs
parents: 25
diff changeset
  1627
    mainWindow()->setInteractive(false);
hgs
parents: 25
diff changeset
  1628
}
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1629
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1630
//---------------------------------------------------------------
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1631
// MsgUnifiedEditorView::deactivateInputBlocker
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1632
// @see header file
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1633
//--------------------------------------------------------------
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1634
void MsgUnifiedEditorView::deactivateInputBlocker()
37
hgs
parents: 25
diff changeset
  1635
{
hgs
parents: 25
diff changeset
  1636
    mainWindow()->setInteractive(true);
hgs
parents: 25
diff changeset
  1637
}
hgs
parents: 25
diff changeset
  1638
hgs
parents: 25
diff changeset
  1639
//---------------------------------------------------------------
hgs
parents: 25
diff changeset
  1640
// MsgUnifiedEditorView::setAttachOptionEnabled
hgs
parents: 25
diff changeset
  1641
// @see header file
hgs
parents: 25
diff changeset
  1642
//--------------------------------------------------------------
hgs
parents: 25
diff changeset
  1643
void MsgUnifiedEditorView::setAttachOptionEnabled(
hgs
parents: 25
diff changeset
  1644
        MsgUnifiedEditorView::TBE_AttachOption opt, bool enable)
hgs
parents: 25
diff changeset
  1645
{
hgs
parents: 25
diff changeset
  1646
    HbListWidgetItem* wgtItem = mTBExtnContentWidget->item(opt);
hgs
parents: 25
diff changeset
  1647
    wgtItem->setEnabled(enable);
hgs
parents: 25
diff changeset
  1648
}
hgs
parents: 25
diff changeset
  1649
hgs
parents: 25
diff changeset
  1650
//---------------------------------------------------------------
hgs
parents: 25
diff changeset
  1651
// MsgUnifiedEditorView::vkbOpened
hgs
parents: 25
diff changeset
  1652
// @see header file
hgs
parents: 25
diff changeset
  1653
//---------------------------------------------------------------
hgs
parents: 25
diff changeset
  1654
void MsgUnifiedEditorView::vkbOpened()
hgs
parents: 25
diff changeset
  1655
{
hgs
parents: 25
diff changeset
  1656
    hideChrome(true); 
hgs
parents: 25
diff changeset
  1657
    
hgs
parents: 25
diff changeset
  1658
    disconnect(mVkbHost,SIGNAL(keypadOpened()),this,SLOT(vkbOpened()));
hgs
parents: 25
diff changeset
  1659
}
hgs
parents: 25
diff changeset
  1660
      
hgs
parents: 25
diff changeset
  1661
//---------------------------------------------------------------
hgs
parents: 25
diff changeset
  1662
// MsgUnifiedEditorView::vkbClosed
hgs
parents: 25
diff changeset
  1663
// @see header file
hgs
parents: 25
diff changeset
  1664
//---------------------------------------------------------------
hgs
parents: 25
diff changeset
  1665
void MsgUnifiedEditorView::vkbClosed()
hgs
parents: 25
diff changeset
  1666
{
hgs
parents: 25
diff changeset
  1667
    hideChrome(false);
hgs
parents: 25
diff changeset
  1668
    
hgs
parents: 25
diff changeset
  1669
    connect(mVkbHost,SIGNAL(keypadOpened()),this,SLOT(vkbOpened()));
hgs
parents: 25
diff changeset
  1670
}
hgs
parents: 25
diff changeset
  1671
hgs
parents: 25
diff changeset
  1672
//---------------------------------------------------------------
51
3507212d340e 201031_02
hgs
parents: 48
diff changeset
  1673
// MsgUnifiedEditorView::vkbAboutToOpen
3507212d340e 201031_02
hgs
parents: 48
diff changeset
  1674
// @see header file
3507212d340e 201031_02
hgs
parents: 48
diff changeset
  1675
//---------------------------------------------------------------
3507212d340e 201031_02
hgs
parents: 48
diff changeset
  1676
void MsgUnifiedEditorView::vkbAboutToOpen()
3507212d340e 201031_02
hgs
parents: 48
diff changeset
  1677
{    
3507212d340e 201031_02
hgs
parents: 48
diff changeset
  1678
	  //This is done to avoid user action on attachment
3507212d340e 201031_02
hgs
parents: 48
diff changeset
  1679
	  //toolbar button when vkb is opening
3507212d340e 201031_02
hgs
parents: 48
diff changeset
  1680
    mAttachAction->setDisabled(true);
3507212d340e 201031_02
hgs
parents: 48
diff changeset
  1681
    disconnect(mVkbHost,SIGNAL(aboutToOpen()),
3507212d340e 201031_02
hgs
parents: 48
diff changeset
  1682
            this,SLOT(vkbAboutToOpen()));
3507212d340e 201031_02
hgs
parents: 48
diff changeset
  1683
}
3507212d340e 201031_02
hgs
parents: 48
diff changeset
  1684
      
3507212d340e 201031_02
hgs
parents: 48
diff changeset
  1685
//---------------------------------------------------------------
3507212d340e 201031_02
hgs
parents: 48
diff changeset
  1686
// MsgUnifiedEditorView::vkbAboutToClose
3507212d340e 201031_02
hgs
parents: 48
diff changeset
  1687
// @see header file
3507212d340e 201031_02
hgs
parents: 48
diff changeset
  1688
//---------------------------------------------------------------
3507212d340e 201031_02
hgs
parents: 48
diff changeset
  1689
void MsgUnifiedEditorView::vkbAboutToClose()
3507212d340e 201031_02
hgs
parents: 48
diff changeset
  1690
{      
3507212d340e 201031_02
hgs
parents: 48
diff changeset
  1691
    mAttachAction->setDisabled(false);
3507212d340e 201031_02
hgs
parents: 48
diff changeset
  1692
    connect(mVkbHost,SIGNAL(aboutToOpen()),
3507212d340e 201031_02
hgs
parents: 48
diff changeset
  1693
            this,SLOT(vkbAboutToOpen()));
3507212d340e 201031_02
hgs
parents: 48
diff changeset
  1694
}
56
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1695
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1696
//---------------------------------------------------------------
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1697
// MsgUnifiedEditorView::onAudioSelected
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1698
// @see header file
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1699
//---------------------------------------------------------------
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1700
void 
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1701
MsgUnifiedEditorView::onAudioSelected(QString& filePath)
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1702
{
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1703
    if (!filePath.isEmpty())
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1704
        {
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1705
            mBody->setAudio(filePath);
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1706
        }    
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1707
}
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1708
51
3507212d340e 201031_02
hgs
parents: 48
diff changeset
  1709
//---------------------------------------------------------------
37
hgs
parents: 25
diff changeset
  1710
// MsgUnifiedEditorView::hideChrome
hgs
parents: 25
diff changeset
  1711
//
hgs
parents: 25
diff changeset
  1712
//---------------------------------------------------------------
hgs
parents: 25
diff changeset
  1713
void MsgUnifiedEditorView::hideChrome(bool hide)
hgs
parents: 25
diff changeset
  1714
{
hgs
parents: 25
diff changeset
  1715
    if(hide)
hgs
parents: 25
diff changeset
  1716
    {        
hgs
parents: 25
diff changeset
  1717
        this->setContentFullScreen(true);
hgs
parents: 25
diff changeset
  1718
        this->hideItems(Hb::StatusBarItem | Hb::TitleBarItem);
hgs
parents: 25
diff changeset
  1719
    }
hgs
parents: 25
diff changeset
  1720
    else
hgs
parents: 25
diff changeset
  1721
    {
hgs
parents: 25
diff changeset
  1722
        this->setContentFullScreen(false);
hgs
parents: 25
diff changeset
  1723
        this->showItems(Hb::StatusBarItem | Hb::TitleBarItem);
hgs
parents: 25
diff changeset
  1724
    }
hgs
parents: 25
diff changeset
  1725
}
hgs
parents: 25
diff changeset
  1726
hgs
parents: 25
diff changeset
  1727
//---------------------------------------------------------------
hgs
parents: 25
diff changeset
  1728
// MsgUnifiedEditorView::doDelayedConstruction
hgs
parents: 25
diff changeset
  1729
//
hgs
parents: 25
diff changeset
  1730
//---------------------------------------------------------------
hgs
parents: 25
diff changeset
  1731
void MsgUnifiedEditorView::doDelayedConstruction()
hgs
parents: 25
diff changeset
  1732
{
hgs
parents: 25
diff changeset
  1733
    addMenu();
hgs
parents: 25
diff changeset
  1734
    createTempFolder();
hgs
parents: 25
diff changeset
  1735
    
hgs
parents: 25
diff changeset
  1736
    //Create VKB instance and listen to VKB open and close signals.
hgs
parents: 25
diff changeset
  1737
    mVkbHost = new HbAbstractVkbHost(this);
hgs
parents: 25
diff changeset
  1738
    connect(mVkbHost, SIGNAL(keypadOpened()), this, SLOT(vkbOpened()));
hgs
parents: 25
diff changeset
  1739
    connect(mVkbHost, SIGNAL(keypadClosed()), this, SLOT(vkbClosed()));
51
3507212d340e 201031_02
hgs
parents: 48
diff changeset
  1740
    connect(mVkbHost,SIGNAL(aboutToOpen()),this,SLOT(vkbAboutToOpen()));
3507212d340e 201031_02
hgs
parents: 48
diff changeset
  1741
    connect(mVkbHost,SIGNAL(aboutToClose()),this,SLOT(vkbAboutToClose()));
37
hgs
parents: 25
diff changeset
  1742
    
hgs
parents: 25
diff changeset
  1743
    disconnect(this->mainWindow(),SIGNAL(viewReady()),this,SLOT(doDelayedConstruction()));
hgs
parents: 25
diff changeset
  1744
    
hgs
parents: 25
diff changeset
  1745
}
hgs
parents: 25
diff changeset
  1746
hgs
parents: 25
diff changeset
  1747
//---------------------------------------------------------------
hgs
parents: 25
diff changeset
  1748
// MsgUnifiedEditorView::createTempFolder
hgs
parents: 25
diff changeset
  1749
//
hgs
parents: 25
diff changeset
  1750
//---------------------------------------------------------------
hgs
parents: 25
diff changeset
  1751
bool MsgUnifiedEditorView::createTempFolder()
hgs
parents: 25
diff changeset
  1752
{
hgs
parents: 25
diff changeset
  1753
    // create editor's temp folder
hgs
parents: 25
diff changeset
  1754
    QDir tempDir;
hgs
parents: 25
diff changeset
  1755
    QString tempPath(editorTempPath());
hgs
parents: 25
diff changeset
  1756
    bool result = tempDir.mkpath(tempPath);    
hgs
parents: 25
diff changeset
  1757
    return result;
hgs
parents: 25
diff changeset
  1758
}
hgs
parents: 25
diff changeset
  1759
hgs
parents: 25
diff changeset
  1760
//---------------------------------------------------------------
hgs
parents: 25
diff changeset
  1761
// MsgUnifiedEditorView::removeTempFolder
hgs
parents: 25
diff changeset
  1762
//
hgs
parents: 25
diff changeset
  1763
//---------------------------------------------------------------
hgs
parents: 25
diff changeset
  1764
void MsgUnifiedEditorView::removeTempFolder()
hgs
parents: 25
diff changeset
  1765
{
hgs
parents: 25
diff changeset
  1766
    QDir tempDir;
hgs
parents: 25
diff changeset
  1767
    QString tempPath(editorTempPath());
hgs
parents: 25
diff changeset
  1768
    tempDir.cd(tempPath);
hgs
parents: 25
diff changeset
  1769
    QStringList contentList(tempDir.entryList());
hgs
parents: 25
diff changeset
  1770
    
hgs
parents: 25
diff changeset
  1771
    int contentCount = contentList.count();
hgs
parents: 25
diff changeset
  1772
    for(int i=0; i<contentCount; i++)
hgs
parents: 25
diff changeset
  1773
    {
hgs
parents: 25
diff changeset
  1774
        tempDir.remove(contentList.at(i));
hgs
parents: 25
diff changeset
  1775
    }
hgs
parents: 25
diff changeset
  1776
    
hgs
parents: 25
diff changeset
  1777
    tempDir.cdUp();
hgs
parents: 25
diff changeset
  1778
    tempDir.rmdir(UNIFIED_EDITOR_TEMP_FOLDER); 
hgs
parents: 25
diff changeset
  1779
}
hgs
parents: 25
diff changeset
  1780
hgs
parents: 25
diff changeset
  1781
//---------------------------------------------------------------
hgs
parents: 25
diff changeset
  1782
// MsgUnifiedEditorView::setFocus
hgs
parents: 25
diff changeset
  1783
//
hgs
parents: 25
diff changeset
  1784
//---------------------------------------------------------------
hgs
parents: 25
diff changeset
  1785
void MsgUnifiedEditorView::setFocus(MsgUnifiedEditorBaseWidget* item)
hgs
parents: 25
diff changeset
  1786
{
hgs
parents: 25
diff changeset
  1787
    if(item)
hgs
parents: 25
diff changeset
  1788
    {
hgs
parents: 25
diff changeset
  1789
        item->setFocus();  
hgs
parents: 25
diff changeset
  1790
    }
hgs
parents: 25
diff changeset
  1791
}
hgs
parents: 25
diff changeset
  1792
hgs
parents: 25
diff changeset
  1793
//---------------------------------------------------------------
hgs
parents: 25
diff changeset
  1794
// MsgUnifiedEditorView::onContentChanged
hgs
parents: 25
diff changeset
  1795
//
hgs
parents: 25
diff changeset
  1796
//---------------------------------------------------------------
hgs
parents: 25
diff changeset
  1797
void MsgUnifiedEditorView::onContentChanged()
hgs
parents: 25
diff changeset
  1798
{
hgs
parents: 25
diff changeset
  1799
    mCanSaveToDrafts = true; 
hgs
parents: 25
diff changeset
  1800
}
hgs
parents: 25
diff changeset
  1801
hgs
parents: 25
diff changeset
  1802
//---------------------------------------------------------------
hgs
parents: 25
diff changeset
  1803
// MsgUnifiedEditorView::onDialogDeleteMsg
hgs
parents: 25
diff changeset
  1804
//---------------------------------------------------------------
hgs
parents: 25
diff changeset
  1805
void MsgUnifiedEditorView::onDialogDeleteMsg(HbAction* action)
hgs
parents: 25
diff changeset
  1806
{
hgs
parents: 25
diff changeset
  1807
    HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender());
hgs
parents: 25
diff changeset
  1808
    if (action == dlg->actions().at(0)) {
hgs
parents: 25
diff changeset
  1809
hgs
parents: 25
diff changeset
  1810
        mCanSaveToDrafts = false;
hgs
parents: 25
diff changeset
  1811
hgs
parents: 25
diff changeset
  1812
        //delete if draft entry opened
hgs
parents: 25
diff changeset
  1813
        if (mOpenedMessageId.getId() != -1) {
hgs
parents: 25
diff changeset
  1814
            if (!mPluginLoader) {
hgs
parents: 25
diff changeset
  1815
                mPluginLoader = new UniEditorPluginLoader(this);
hgs
parents: 25
diff changeset
  1816
            }
hgs
parents: 25
diff changeset
  1817
hgs
parents: 25
diff changeset
  1818
            UniEditorPluginInterface* pluginInterface = mPluginLoader->getUniEditorPlugin(
hgs
parents: 25
diff changeset
  1819
                MsgUnifiedEditorMonitor::messageType());
hgs
parents: 25
diff changeset
  1820
hgs
parents: 25
diff changeset
  1821
            pluginInterface->deleteDraftsEntry(mOpenedMessageId.getId());
hgs
parents: 25
diff changeset
  1822
        }
hgs
parents: 25
diff changeset
  1823
hgs
parents: 25
diff changeset
  1824
        //trigger back action.
hgs
parents: 25
diff changeset
  1825
        HbAction* backAction = this->navigationAction();
hgs
parents: 25
diff changeset
  1826
        if (backAction) {
hgs
parents: 25
diff changeset
  1827
            backAction->trigger();
hgs
parents: 25
diff changeset
  1828
        }
hgs
parents: 25
diff changeset
  1829
hgs
parents: 25
diff changeset
  1830
    }
hgs
parents: 25
diff changeset
  1831
}
hgs
parents: 25
diff changeset
  1832
hgs
parents: 25
diff changeset
  1833
//---------------------------------------------------------------
hgs
parents: 25
diff changeset
  1834
// MsgUnifiedEditorView::onDialogSmsSettings
hgs
parents: 25
diff changeset
  1835
//---------------------------------------------------------------
hgs
parents: 25
diff changeset
  1836
void MsgUnifiedEditorView::onDialogSmsSettings(HbAction* action)
hgs
parents: 25
diff changeset
  1837
{
hgs
parents: 25
diff changeset
  1838
    HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender());
hgs
parents: 25
diff changeset
  1839
    if (action == dlg->actions().at(0)) {
hgs
parents: 25
diff changeset
  1840
        
hgs
parents: 25
diff changeset
  1841
        QVariantList params;
hgs
parents: 25
diff changeset
  1842
        params << MsgBaseView::MSGSETTINGS;// target view
hgs
parents: 25
diff changeset
  1843
        params << MsgBaseView::UNIEDITOR; // source view
hgs
parents: 25
diff changeset
  1844
        params << MsgSettingsView::SMSView;
hgs
parents: 25
diff changeset
  1845
        emit switchView(params);
hgs
parents: 25
diff changeset
  1846
    
hgs
parents: 25
diff changeset
  1847
    }
hgs
parents: 25
diff changeset
  1848
}
hgs
parents: 25
diff changeset
  1849
hgs
parents: 25
diff changeset
  1850
//---------------------------------------------------------------
hgs
parents: 25
diff changeset
  1851
// MsgUnifiedEditorView::onDialogMmsSettings
hgs
parents: 25
diff changeset
  1852
//---------------------------------------------------------------
hgs
parents: 25
diff changeset
  1853
void MsgUnifiedEditorView::onDialogMmsSettings(HbAction* action)
hgs
parents: 25
diff changeset
  1854
{
hgs
parents: 25
diff changeset
  1855
    HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender());
hgs
parents: 25
diff changeset
  1856
    if (action == dlg->actions().at(0)) {
hgs
parents: 25
diff changeset
  1857
        
hgs
parents: 25
diff changeset
  1858
        QVariantList params;
hgs
parents: 25
diff changeset
  1859
        params << MsgBaseView::MSGSETTINGS;// target view
hgs
parents: 25
diff changeset
  1860
        params << MsgBaseView::UNIEDITOR; // source view
hgs
parents: 25
diff changeset
  1861
        params << MsgSettingsView::MMSView;
hgs
parents: 25
diff changeset
  1862
        emit switchView(params); 
hgs
parents: 25
diff changeset
  1863
    }
hgs
parents: 25
diff changeset
  1864
}
hgs
parents: 25
diff changeset
  1865
hgs
parents: 25
diff changeset
  1866
//---------------------------------------------------------------
hgs
parents: 25
diff changeset
  1867
// MsgUnifiedEditorView::enableSendButton
hgs
parents: 25
diff changeset
  1868
// @see header file
hgs
parents: 25
diff changeset
  1869
//--------------------------------------------------------------
hgs
parents: 25
diff changeset
  1870
void MsgUnifiedEditorView::enableSendButton(bool enable)
hgs
parents: 25
diff changeset
  1871
    {
hgs
parents: 25
diff changeset
  1872
    if(mSendAction)
hgs
parents: 25
diff changeset
  1873
        {
hgs
parents: 25
diff changeset
  1874
         // enable/disable based on only if its disabled/enabled.
hgs
parents: 25
diff changeset
  1875
         // this check is to avoid unnecessary calls to mSendAction->setEnabled(enable);
hgs
parents: 25
diff changeset
  1876
        if(mSendAction->isEnabled() != enable )
hgs
parents: 25
diff changeset
  1877
            mSendAction->setEnabled(enable);
hgs
parents: 25
diff changeset
  1878
        }
25
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1879
    }
84d9eb65b26f Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  1880
38
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
  1881
// ----------------------------------------------------------------------------
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
  1882
// MsgUnifiedEditorView::formatAddresses
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
  1883
// @see header
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
  1884
// ----------------------------------------------------------------------------
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
  1885
void MsgUnifiedEditorView::formatAddresses(
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
  1886
        ConvergedMessageAddressList& addresses)
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
  1887
{       
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
  1888
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
  1889
    for(int i=0; i < addresses.count() ;i++ )
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
  1890
    {
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
  1891
        QString addr = addresses[i]->address();
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
  1892
        
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
  1893
        HBufC *tempAddr = XQConversions::qStringToS60Desc(addr);     
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
  1894
            
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
  1895
        TPtr ptr = tempAddr->Des();
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
  1896
                    
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
  1897
         // Note: This is just to parse spaces etc away from phonenumbers.
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
  1898
         //       Ignore EFalse returned for email addresses.   
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
  1899
        CommonPhoneParser::ParsePhoneNumber(ptr , 
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
  1900
                                            CommonPhoneParser::ESMSNumber );        
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
  1901
       
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
  1902
        addr = XQConversions::s60DescToQString(tempAddr->Des()); 
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
  1903
        
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
  1904
        addresses[i]->setAddress(addr);
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
  1905
        
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
  1906
        delete tempAddr;                                                       
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
  1907
    }       
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
  1908
}
56
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1909
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1910
// ----------------------------------------------------------------------------
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1911
// MsgUnifiedEditorView::isReplyPathBroken
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1912
// @see header
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1913
// ----------------------------------------------------------------------------
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1914
bool MsgUnifiedEditorView::isReplyPathBroken()
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1915
{
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1916
    // 1. Never set for MMS
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1917
    // 2. if additional recipients exits
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1918
    if( (MsgUnifiedEditorMonitor::messageType() == ConvergedMessage::Mms) ||
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1919
        (mToField->addressCount() != 1) )
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1920
    {
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1921
        // broken
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1922
        return true;
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1923
    }
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1924
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1925
    // 3. if only recipient is not same as originating SME
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1926
    QString dispName;
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1927
    int phCount;
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1928
    int origCntLocalId = MsgContactHandler::resolveContactDisplayName(
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1929
            mOriginatingSME, dispName, phCount);
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1930
    int currCntLocalId = -1;
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1931
    QString currAddress(mToField->addresses().at(0)->address());
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1932
    if(origCntLocalId != -1)
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1933
    {
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1934
        currCntLocalId = MsgContactHandler::resolveContactDisplayName(
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1935
            currAddress, dispName, phCount);
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1936
    }
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1937
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1938
    if(currCntLocalId != -1)
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1939
    { // both are mapped contacts present in contacts db
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1940
        if(currCntLocalId != origCntLocalId)
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1941
        {
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1942
            return true;
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1943
        }
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1944
    }
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1945
    else
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1946
    { // atleast one contact is not present in contacts db
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1947
      // direct compare
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1948
        UniEditorGenUtils* genUtils = q_check_ptr(new UniEditorGenUtils);
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1949
        bool compareResult = false;
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1950
        TRAP_IGNORE(
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1951
        compareResult = genUtils->MatchPhoneNumberL(
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1952
                *XQConversions::qStringToS60Desc(mOriginatingSME),
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1953
                *XQConversions::qStringToS60Desc(currAddress))
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1954
        );
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1955
        delete genUtils;
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1956
        if(!compareResult)
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1957
        {
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1958
            return true;
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1959
        }
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1960
    }
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1961
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1962
    return false;
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1963
}
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
  1964
23
238255e8b033 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1965
//EOF