author | hgs |
Fri, 09 Jul 2010 14:46:10 +0530 | |
changeset 41 | 25fe1fe642e3 |
parent 38 | 4e4b6adb1024 |
child 48 | 4f501b74aeb1 |
permissions | -rw-r--r-- |
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 |
// INCLUDES |
37 | 19 |
#include <QTimer> |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
20 |
#include <HbTextItem> |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
21 |
#include <HbPushButton> |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
22 |
#include <HbAction> |
37 | 23 |
#include <hbmessagebox.h> |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
24 |
#include <cntservicescontact.h> |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
25 |
#include <xqaiwrequest.h> |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
26 |
#include <xqappmgr.h> |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
27 |
#include <telconfigcrkeys.h> // KCRUidTelephonyConfiguration |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
28 |
#include <centralrepository.h> |
37 | 29 |
#include <HbNotificationDialog> |
30 |
#include <commonphoneparser.h> // Common phone number validity checker |
|
31 |
#include <xqconversions.h> |
|
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
32 |
|
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
33 |
// USER INCLUDES |
37 | 34 |
#include "debugtraces.h" |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
35 |
#include "msgunieditoraddress.h" |
37 | 36 |
#include "msgunieditorlineedit.h" |
37 |
#include "msgunieditormonitor.h" |
|
38 |
#include "UniEditorGenUtils.h" |
|
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
39 |
|
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
40 |
const QString PBK_ICON("qtg_mono_contacts"); |
37 | 41 |
const QString REPLACEMENT_STR("; "); |
42 |
const QString COMMA_SEPERATOR(","); |
|
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
43 |
|
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
44 |
// Constants |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
45 |
const int KDefaultGsmNumberMatchLength = 7; //matching unique ph numbers |
37 | 46 |
#define LOC_SMS_RECIPIENT_LIMIT_REACHED hbTrId("txt_messaging_dialog_number_of_recipients_exceeded") |
47 |
#define LOC_MMS_RECIPIENT_LIMIT_REACHED hbTrId("txt_messaging_dpopinfo_unable_to_add_more_recipien") |
|
48 |
#define LOC_DIALOG_OK hbTrId("txt_common_button_ok") |
|
49 |
#define LOC_BUTTON_CANCEL hbTrId("txt_common_button_cancel") |
|
50 |
#define LOC_INVALID_RECIPIENT hbTrId("txt_messaging_dialog_invalid_recipient_found") |
|
51 |
#define LOC_INVALID_RECIPIENT_NOT_ADDED hbTrId("txt_messaging_dialog_invalid_recipient_not_added") |
|
52 |
#define LOC_INVALID_RECIPIENTS_NOT_ADDED hbTrId("txt_messaging_dialog_invalid_recipients_not_added") |
|
53 |
||
54 |
||
55 |
||
56 |
||
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
57 |
|
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
58 |
MsgUnifiedEditorAddress::MsgUnifiedEditorAddress( const QString& label, |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
59 |
QGraphicsItem *parent ) : |
37 | 60 |
MsgUnifiedEditorBaseWidget(parent), |
61 |
mSkipMaxRecipientQuery(false), |
|
62 |
mAboutToExceedMaxSmsRecipients(false), |
|
63 |
mAboutToExceedMaxMmsRecipients(false), |
|
64 |
mExceedsMaxMmsRecipientsBy(0) |
|
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
65 |
{ |
37 | 66 |
this->setContentsMargins(0,0,0,0); |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
67 |
|
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
68 |
mLaunchBtn = new HbPushButton(this); |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
69 |
HbStyle::setItemName(mLaunchBtn,"launchBtn"); |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
70 |
connect(mLaunchBtn,SIGNAL(clicked()),this,SLOT(fetchContacts())); |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
71 |
|
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
72 |
mLaunchBtn->setIcon(HbIcon(PBK_ICON)); |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
73 |
|
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
74 |
mAddressEdit = new MsgUnifiedEditorLineEdit(label,this); |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
75 |
HbStyle::setItemName(mAddressEdit,"addressField"); |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
76 |
|
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
77 |
mAddressEdit->setMaxRows(40); |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
78 |
connect(mAddressEdit, SIGNAL(contentsChanged(const QString&)), |
37 | 79 |
this, SLOT(onContentsChanged(const QString&))); |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
80 |
|
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
81 |
mAddressEdit->setInputMethodHints(Qt::ImhPreferNumbers); |
37 | 82 |
} |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
83 |
|
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
84 |
MsgUnifiedEditorAddress::~MsgUnifiedEditorAddress() |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
85 |
{ |
37 | 86 |
//TODO: Should remove this code depending on orbit's reply whether it is needed |
87 |
//to unregister the same plugin registered on two different widgets twice. |
|
88 |
//style()->unregisterPlugin(mPluginPath); |
|
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 |
|
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
91 |
void MsgUnifiedEditorAddress::fetchContacts() |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
92 |
{ |
37 | 93 |
mLaunchBtn->blockSignals(true); |
94 |
||
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
95 |
QList<QVariant> args; |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
96 |
QString serviceName("com.nokia.services.phonebookservices"); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
97 |
QString operation("fetch(QString,QString,QString)"); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
98 |
XQAiwRequest* request; |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
99 |
XQApplicationManager appManager; |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
100 |
request = appManager.create(serviceName, "Fetch", operation, true); // embedded |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
101 |
if ( request == NULL ) |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
102 |
{ |
37 | 103 |
return; |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
104 |
} |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
105 |
|
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
106 |
// Result handlers |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
107 |
connect (request, SIGNAL(requestOk(const QVariant&)), this, SLOT(handleOk(const QVariant&))); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
108 |
connect (request, SIGNAL(requestError(int,const QString&)), this, SLOT(handleError(int,const QString&))); |
37 | 109 |
|
110 |
args << QString(tr("Phonebook")); |
|
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
111 |
args << KCntActionAll; |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
112 |
args << KCntFilterDisplayAll; |
37 | 113 |
|
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
114 |
request->setArguments(args); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
115 |
request->send(); |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
116 |
delete request; |
37 | 117 |
|
118 |
//unblock click signal after some delay. |
|
119 |
QTimer::singleShot(250,this,SLOT(unblockSignals())); |
|
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
120 |
} |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
121 |
|
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
122 |
void MsgUnifiedEditorAddress::handleOk(const QVariant& value) |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
123 |
{ |
37 | 124 |
CntServicesContactList contactList = |
125 |
qVariantValue<CntServicesContactList>(value); |
|
126 |
int count = contactList.count(); |
|
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
127 |
|
37 | 128 |
ConvergedMessageAddressList addrlist; |
129 |
for(int i = 0; i < count; i++ ) |
|
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
130 |
{ |
37 | 131 |
ConvergedMessageAddress* address = |
132 |
new ConvergedMessageAddress(); |
|
133 |
if(!contactList[i].mPhoneNumber.isEmpty()) |
|
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
134 |
{ |
37 | 135 |
address->setAddress(contactList[i].mPhoneNumber); |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
136 |
} |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
137 |
else |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
138 |
{ |
37 | 139 |
address->setAddress(contactList[i].mEmailAddress); |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
140 |
} |
37 | 141 |
address->setAlias(contactList[i].mDisplayName); |
142 |
addrlist << address; |
|
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
143 |
} |
37 | 144 |
setAddresses(addrlist); |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
145 |
} |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
146 |
|
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
147 |
void MsgUnifiedEditorAddress::handleError(int errorCode, const QString& errorMessage) |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
148 |
{ |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
149 |
Q_UNUSED(errorMessage) |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
150 |
Q_UNUSED(errorCode) |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
151 |
} |
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
152 |
|
37 | 153 |
// ---------------------------------------------------------------------------- |
154 |
// MsgUnifiedEditorAddress::addresses |
|
155 |
// @see header |
|
156 |
// ---------------------------------------------------------------------------- |
|
157 |
ConvergedMessageAddressList MsgUnifiedEditorAddress::addresses( |
|
158 |
bool removeDuplicates) |
|
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
159 |
{ |
37 | 160 |
#ifdef _DEBUG_TRACES_ |
161 |
qCritical() << "MsgUnifiedEditorAddress::addresses start"; |
|
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
162 |
#endif |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
163 |
// sync-up map to account for user-actions on edit-field |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
164 |
syncDeletionsToMap(); |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
165 |
syncAdditionsToMap(); |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
166 |
|
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
167 |
ConvergedMessageAddressList addresses; |
37 | 168 |
if(removeDuplicates) |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
169 |
{ |
37 | 170 |
QStringList uniqueAddr; |
171 |
uniqueAddr = uniqueAddressList(); |
|
172 |
foreach(QString addr, uniqueAddr) |
|
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
173 |
{ |
37 | 174 |
ConvergedMessageAddress* address = new ConvergedMessageAddress; |
175 |
address->setAddress(addr); |
|
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
176 |
address->setAlias(mAddressMap.value(addr)); |
37 | 177 |
addresses.append(address); |
178 |
} |
|
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
179 |
} |
37 | 180 |
else |
181 |
{ |
|
182 |
QMap<QString, QString>::iterator i = mAddressMap.begin(); |
|
183 |
while (i != mAddressMap.end()) |
|
184 |
{ |
|
185 |
ConvergedMessageAddress* address = new ConvergedMessageAddress; |
|
186 |
address->setAddress(i.key()); |
|
187 |
address->setAlias(i.value()); |
|
188 |
addresses.append(address); |
|
189 |
i++; |
|
190 |
} |
|
191 |
} |
|
192 |
#ifdef _DEBUG_TRACES_ |
|
193 |
qCritical() << "MsgUnifiedEditorAddress::addresses end"; |
|
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
194 |
#endif |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
195 |
return addresses; |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
196 |
} |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
197 |
|
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
198 |
int MsgUnifiedEditorAddress::addressCount() |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
199 |
{ |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
200 |
return mAddressEdit->addresses().count(); |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
201 |
} |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
202 |
|
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
203 |
void MsgUnifiedEditorAddress::setAddresses(ConvergedMessageAddressList addrlist) |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
204 |
{ |
37 | 205 |
// avoid processing if no info available |
206 |
if(addrlist.count() == 0) |
|
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
207 |
{ |
37 | 208 |
return; |
209 |
} |
|
210 |
||
211 |
// ensure flags are reset before starting the addr addition |
|
212 |
mAboutToExceedMaxSmsRecipients = false; |
|
213 |
mAboutToExceedMaxMmsRecipients = false; |
|
214 |
mExceedsMaxMmsRecipientsBy = 0; |
|
215 |
||
216 |
// first, we check if MMS max-recipient count will exceed |
|
217 |
int count = addrlist.count(); |
|
218 |
int futureCount = count + MsgUnifiedEditorMonitor::msgAddressCount(); |
|
219 |
if(futureCount > MsgUnifiedEditorMonitor::maxMmsRecipients()) |
|
220 |
{ |
|
221 |
mAboutToExceedMaxMmsRecipients = true; |
|
222 |
mExceedsMaxMmsRecipientsBy = |
|
223 |
futureCount - MsgUnifiedEditorMonitor::maxMmsRecipients(); |
|
224 |
} |
|
225 |
// else, check if SMS max-recipient count will exceed |
|
226 |
else if(!mSkipMaxRecipientQuery) |
|
227 |
{ |
|
228 |
futureCount = count + addressCount(); |
|
229 |
if( (addressCount() <= MsgUnifiedEditorMonitor::maxSmsRecipients()) && |
|
230 |
(futureCount > MsgUnifiedEditorMonitor::maxSmsRecipients()) ) |
|
231 |
{ |
|
232 |
mAboutToExceedMaxSmsRecipients = true; |
|
233 |
} |
|
234 |
} |
|
235 |
||
236 |
int invalidCount= 0; |
|
237 |
QString invalidContacts; |
|
238 |
for(int i = 0; i < count; i++ ) |
|
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
239 |
{ |
37 | 240 |
bool isValid = false; |
241 |
isValid = checkValidAddress(addrlist.at(i)->address()); |
|
242 |
if(!isValid) |
|
243 |
{ |
|
244 |
invalidCount ++; |
|
245 |
// append the comma till last but one contact. |
|
246 |
// add the invalid ocntacts to the " , " seperated string. |
|
247 |
if(invalidCount > 1) |
|
248 |
{ |
|
249 |
invalidContacts.append(COMMA_SEPERATOR); |
|
250 |
} |
|
251 |
invalidContacts.append(addrlist.at(i)->alias()); |
|
252 |
} |
|
253 |
else |
|
254 |
{ |
|
255 |
mAddressMap.insertMulti(addrlist[i]->address(), addrlist[i]->alias()); |
|
256 |
if(!addrlist[i]->alias().isEmpty()) |
|
257 |
{ |
|
258 |
mAddressEdit->setText(addrlist[i]->alias()); |
|
259 |
} |
|
260 |
else |
|
261 |
{ |
|
262 |
mAddressEdit->setText(addrlist[i]->address(), false); |
|
263 |
} |
|
264 |
} |
|
265 |
} |
|
266 |
if(invalidCount) |
|
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
267 |
{ |
37 | 268 |
QString invalidStr; |
269 |
(invalidCount == 1)?(invalidStr = QString(LOC_INVALID_RECIPIENT_NOT_ADDED)) :(invalidStr = QString(LOC_INVALID_RECIPIENTS_NOT_ADDED)); |
|
270 |
// append line seperator |
|
271 |
invalidStr.append("<br>"); |
|
272 |
invalidStr.append(invalidContacts); |
|
41 | 273 |
HbMessageBox::information(invalidStr, 0, 0, HbMessageBox::Ok); |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
274 |
} |
37 | 275 |
|
276 |
// addition operation complete, reset flags |
|
277 |
mAboutToExceedMaxSmsRecipients = false; |
|
278 |
mAboutToExceedMaxMmsRecipients = false; |
|
279 |
mExceedsMaxMmsRecipientsBy = 0; |
|
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
280 |
} |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
281 |
|
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
282 |
int MsgUnifiedEditorAddress::contactMatchDigits() |
37 | 283 |
{ |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
284 |
// Read the amount of digits to be used in contact matching |
37 | 285 |
// The key is owned by PhoneApp |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
286 |
int matchDigitCount = 0; |
37 | 287 |
TRAP_IGNORE( |
288 |
CRepository* repository = CRepository::NewLC(KCRUidTelConfiguration); |
|
289 |
if ( repository->Get(KTelMatchDigits, matchDigitCount) == KErrNone ) |
|
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
290 |
{ |
37 | 291 |
// Min is 7 |
292 |
matchDigitCount = Max(matchDigitCount, KDefaultGsmNumberMatchLength); |
|
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
293 |
} |
37 | 294 |
CleanupStack::PopAndDestroy(); // repository |
295 |
); |
|
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
296 |
return matchDigitCount; |
37 | 297 |
} |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
298 |
|
37 | 299 |
void MsgUnifiedEditorAddress::onContentsChanged(const QString& text) |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
300 |
{ |
37 | 301 |
// Max MMS recipient count check |
302 |
if( mAboutToExceedMaxMmsRecipients || |
|
303 |
(MsgUnifiedEditorMonitor::msgAddressCount() >= MsgUnifiedEditorMonitor::maxMmsRecipients()) ) |
|
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
304 |
{ |
37 | 305 |
if(mAboutToExceedMaxMmsRecipients) |
306 |
{// show discreet note only once |
|
307 |
--mExceedsMaxMmsRecipientsBy; |
|
308 |
if(!mExceedsMaxMmsRecipientsBy) |
|
309 |
{ |
|
41 | 310 |
HbMessageBox::information(LOC_MMS_RECIPIENT_LIMIT_REACHED, 0, 0, HbMessageBox::Ok); |
37 | 311 |
} |
312 |
resetToPrevious(); |
|
313 |
} |
|
314 |
else |
|
315 |
{ |
|
316 |
// update monitor data |
|
317 |
emit contentChanged(); |
|
318 |
if(MsgUnifiedEditorMonitor::msgAddressCount() > MsgUnifiedEditorMonitor::maxMmsRecipients()) |
|
319 |
{ |
|
41 | 320 |
HbMessageBox::information(LOC_MMS_RECIPIENT_LIMIT_REACHED, 0, 0, HbMessageBox::Ok); |
37 | 321 |
resetToPrevious(); |
322 |
// reset monitor data |
|
323 |
emit contentChanged(); |
|
324 |
} |
|
325 |
else |
|
326 |
{ |
|
327 |
mPrevBuffer = text; |
|
328 |
} |
|
329 |
} |
|
330 |
return; |
|
331 |
} |
|
332 |
||
333 |
// Max SMS recipient count check |
|
334 |
if( !mSkipMaxRecipientQuery && |
|
335 |
(MsgUnifiedEditorMonitor::messageType() == ConvergedMessage::Sms) && |
|
336 |
(mAddressEdit->addresses().count() > MsgUnifiedEditorMonitor::maxSmsRecipients()) ) |
|
337 |
{ |
|
338 |
// when we show this dialog, we don't want the intermediate states |
|
339 |
// to be signalled to us |
|
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
340 |
disconnect(mAddressEdit, SIGNAL(contentsChanged(const QString&)), |
37 | 341 |
this, SLOT(onContentsChanged(const QString&))); |
342 |
QTimer::singleShot(50, this, SLOT(handleRecipientLimitReached())); |
|
343 |
} |
|
344 |
else |
|
345 |
{ |
|
346 |
if(!mAboutToExceedMaxSmsRecipients) |
|
347 |
{// remember addresses before the block insertion started |
|
348 |
mPrevBuffer = text; |
|
349 |
} |
|
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
350 |
emit contentChanged(); |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
351 |
} |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
352 |
} |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
353 |
|
37 | 354 |
void MsgUnifiedEditorAddress::handleRecipientLimitReached() |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
355 |
{ |
37 | 356 |
HbMessageBox* dlg = new HbMessageBox(HbMessageBox::MessageTypeQuestion); |
357 |
dlg->setAttribute(Qt::WA_DeleteOnClose); |
|
358 |
dlg->setFocusPolicy(Qt::NoFocus); |
|
359 |
dlg->setTimeout(HbPopup::NoTimeout); |
|
360 |
||
361 |
dlg->setText(LOC_SMS_RECIPIENT_LIMIT_REACHED); |
|
362 |
||
363 |
dlg->clearActions(); |
|
364 |
HbAction* okAction = new HbAction(LOC_DIALOG_OK,dlg); |
|
365 |
dlg->addAction(okAction); |
|
366 |
||
367 |
HbAction* cancelAction = new HbAction(LOC_BUTTON_CANCEL,dlg); |
|
368 |
dlg->addAction(cancelAction); |
|
369 |
||
370 |
dlg->open(this,SLOT(onMaxRecipientsReached(HbAction*))); |
|
371 |
// reconnect to get back updates |
|
372 |
connect(mAddressEdit, SIGNAL(contentsChanged(const QString&)), |
|
373 |
this, SLOT(onContentsChanged(const QString&))); |
|
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
374 |
} |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
375 |
|
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
376 |
void MsgUnifiedEditorAddress::syncDeletionsToMap() |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
377 |
{ |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
378 |
// get address list from edit-field |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
379 |
QStringList addrList = mAddressEdit->addresses(); |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
380 |
|
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
381 |
QMap<QString, QString>::iterator i = mAddressMap.begin(); |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
382 |
while (i != mAddressMap.end()) |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
383 |
{ |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
384 |
// check if either key or value is present in the list |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
385 |
if( !(addrList.contains(i.value(), Qt::CaseSensitive) || |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
386 |
addrList.contains(i.key(), Qt::CaseSensitive)) ) |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
387 |
{// if none are present, then delete entry from map |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
388 |
i = mAddressMap.erase(i); |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
389 |
} |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
390 |
else |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
391 |
{ |
37 | 392 |
// ensure that the matched contact is removed from the |
393 |
// address's list |
|
394 |
int matchedIndex = addrList.indexOf(i.value()); |
|
395 |
if(matchedIndex == -1) |
|
396 |
{ |
|
397 |
matchedIndex = addrList.indexOf(i.key()); |
|
398 |
} |
|
399 |
if(matchedIndex != -1) |
|
400 |
{ |
|
401 |
addrList.removeAt(matchedIndex); |
|
402 |
} |
|
403 |
// now go to next index in map |
|
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
404 |
++i; |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
405 |
} |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
406 |
} |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
407 |
} |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
408 |
|
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
409 |
void MsgUnifiedEditorAddress::syncAdditionsToMap() |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
410 |
{ |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
411 |
// remove already mapped addresses from edit-field |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
412 |
QStringList userInputAddrList(mAddressEdit->addresses()); |
37 | 413 |
QStringList mapAddrList = mAddressMap.values(); |
414 |
mapAddrList << mAddressMap.keys(); |
|
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
415 |
foreach(QString addr, mapAddrList) |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
416 |
{ |
37 | 417 |
userInputAddrList.removeOne(addr); |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
418 |
} |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
419 |
|
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
420 |
// add the unmapped addresses to address-map |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
421 |
foreach(QString addr, userInputAddrList) |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
422 |
{ |
37 | 423 |
mAddressMap.insertMulti(addr, QString()); |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
424 |
} |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
425 |
} |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
426 |
|
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
427 |
QStringList MsgUnifiedEditorAddress::uniqueAddressList() |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
428 |
{ |
25
84d9eb65b26f
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
429 |
int matchDigitCount = MsgUnifiedEditorAddress::contactMatchDigits(); |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
430 |
QStringList mapAddrList = mAddressMap.keys(); |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
431 |
for(int j = 0;j<mapAddrList.count()-1;j++) |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
432 |
{ |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
433 |
for(int i =j+1;i<mapAddrList.count();i++) |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
434 |
{ |
37 | 435 |
if(0 == mapAddrList[j].right(matchDigitCount).compare(mapAddrList[i].right(matchDigitCount))) |
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
436 |
{ |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
437 |
mapAddrList.removeAt(i); |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
438 |
i--; |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
439 |
} |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
440 |
} |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
441 |
} |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
442 |
return mapAddrList; |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
443 |
} |
37 | 444 |
|
445 |
// ---------------------------------------------------------------------------- |
|
446 |
// MsgUnifiedEditorAddress::skipMaxRecipientQuery |
|
447 |
// @see header |
|
448 |
// ---------------------------------------------------------------------------- |
|
449 |
void MsgUnifiedEditorAddress::skipMaxRecipientQuery(bool skip) |
|
450 |
{ |
|
451 |
mSkipMaxRecipientQuery = skip; |
|
452 |
} |
|
453 |
||
454 |
void MsgUnifiedEditorAddress::setFocus() |
|
455 |
{ |
|
456 |
mAddressEdit->setFocus(Qt::MouseFocusReason); |
|
457 |
} |
|
458 |
||
459 |
// ---------------------------------------------------------------------------- |
|
460 |
// MsgUnifiedEditorAddress::resetToPrevious |
|
461 |
// @see header |
|
462 |
// ---------------------------------------------------------------------------- |
|
463 |
void MsgUnifiedEditorAddress::resetToPrevious() |
|
464 |
{ |
|
465 |
// when we do this reset operation, we don't want the intermediate states |
|
466 |
// to be signalled to us |
|
467 |
disconnect(mAddressEdit, SIGNAL(contentsChanged(const QString&)), |
|
468 |
this, SLOT(onContentsChanged(const QString&))); |
|
469 |
||
470 |
mAddressEdit->clearContent(); |
|
471 |
QStringList list = mPrevBuffer.split(REPLACEMENT_STR, |
|
472 |
QString::SkipEmptyParts); |
|
473 |
int count = list.count(); |
|
474 |
QStringList valList = mAddressMap.values(); |
|
475 |
for(int i=0; i<count; i++) |
|
476 |
{ |
|
477 |
QString addr = list.at(i); |
|
478 |
if(valList.contains(addr)) |
|
479 |
{ |
|
480 |
mAddressEdit->setText(addr); |
|
481 |
} |
|
482 |
else |
|
483 |
{ |
|
484 |
mAddressEdit->setText(addr, false); |
|
485 |
} |
|
486 |
} |
|
487 |
syncDeletionsToMap(); |
|
488 |
connect(mAddressEdit, SIGNAL(contentsChanged(const QString&)), |
|
489 |
this, SLOT(onContentsChanged(const QString&))); |
|
490 |
} |
|
491 |
||
492 |
// ---------------------------------------------------------------------------- |
|
493 |
// MsgUnifiedEditorAddress::onMaxRecipientsReached |
|
494 |
// @see header |
|
495 |
// ---------------------------------------------------------------------------- |
|
496 |
void MsgUnifiedEditorAddress::onMaxRecipientsReached(HbAction* action) |
|
497 |
{ |
|
498 |
HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender()); |
|
499 |
if (action == dlg->actions().at(0)) { |
|
500 |
// accept new content, update prev-buffer |
|
501 |
emit contentChanged(); |
|
502 |
mPrevBuffer = mAddressEdit->content(); |
|
503 |
} |
|
504 |
else { |
|
505 |
// reject the new content, keep the old |
|
506 |
resetToPrevious(); |
|
507 |
} |
|
508 |
} |
|
509 |
||
510 |
// ---------------------------------------------------------------------------- |
|
511 |
// MsgUnifiedEditorAddress::validateContacts |
|
512 |
// @see header |
|
513 |
// ---------------------------------------------------------------------------- |
|
514 |
bool MsgUnifiedEditorAddress::validateContacts() |
|
515 |
{ |
|
516 |
UniEditorGenUtils* genUtils = new UniEditorGenUtils; |
|
517 |
||
518 |
// sync-up map to account for user-actions on address-field |
|
519 |
syncDeletionsToMap(); |
|
520 |
syncAdditionsToMap(); |
|
521 |
||
522 |
// get the list of contacts in address-field |
|
523 |
QStringList fieldAddresses(mAddressEdit->addresses()); |
|
524 |
||
525 |
bool isValid = true; |
|
526 |
foreach(QString addr, fieldAddresses) |
|
527 |
{ |
|
528 |
// run address validation only if address is unmapped |
|
529 |
// (i.e. user-inserted) |
|
530 |
if(mAddressMap.contains(addr)) |
|
531 |
{ |
|
532 |
isValid = checkValidAddress(addr); |
|
533 |
if(!isValid) |
|
534 |
{ |
|
535 |
mAddressEdit->highlightInvalidString(addr); |
|
536 |
QString invalidAddrStr = |
|
537 |
QString(LOC_INVALID_RECIPIENT).arg(addr); |
|
538 |
HbMessageBox* dlg = new HbMessageBox(invalidAddrStr, |
|
539 |
HbMessageBox::MessageTypeInformation); |
|
540 |
dlg->setDismissPolicy(HbPopup::TapInside); |
|
541 |
dlg->setTimeout(HbPopup::NoTimeout); |
|
542 |
dlg->setAttribute(Qt::WA_DeleteOnClose, true); |
|
543 |
dlg->open(this, SLOT(handleInvalidContactDialog(HbAction*))); |
|
544 |
break; |
|
545 |
} |
|
546 |
} |
|
547 |
} |
|
548 |
||
549 |
return isValid; |
|
550 |
} |
|
551 |
// ---------------------------------------------------------------------------- |
|
552 |
// MsgUnifiedEditorAddress::checkValidAddress |
|
553 |
// @see header |
|
554 |
// ---------------------------------------------------------------------------- |
|
555 |
bool MsgUnifiedEditorAddress::checkValidAddress(const QString& addr) |
|
556 |
{ |
|
557 |
bool isValid = false; |
|
38 | 558 |
|
559 |
HBufC *tempAddr = XQConversions::qStringToS60Desc(addr); |
|
560 |
||
37 | 561 |
// 1. perform number validation |
562 |
isValid = CommonPhoneParser::IsValidPhoneNumber( |
|
38 | 563 |
*tempAddr, |
37 | 564 |
CommonPhoneParser::ESMSNumber ); |
565 |
||
566 |
// 2. if number validity fails, then perform email addr validation |
|
567 |
UniEditorGenUtils* genUtils = new UniEditorGenUtils; |
|
568 |
if(!isValid) |
|
569 |
{ // additional check for MMS only |
|
570 |
isValid = genUtils->IsValidEmailAddress( |
|
38 | 571 |
*tempAddr ); |
572 |
} |
|
37 | 573 |
delete genUtils; |
38 | 574 |
delete tempAddr; |
37 | 575 |
return isValid; |
576 |
} |
|
577 |
||
578 |
void MsgUnifiedEditorAddress::handleInvalidContactDialog( |
|
579 |
HbAction* act) |
|
580 |
{ |
|
581 |
Q_UNUSED(act); |
|
582 |
QTimer::singleShot(250, this, SLOT(setFocus())); |
|
583 |
} |
|
584 |
||
585 |
void MsgUnifiedEditorAddress::unblockSignals() |
|
586 |
{ |
|
587 |
mLaunchBtn->blockSignals(false); |
|
588 |
} |
|
589 |
||
23
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
590 |
Q_IMPLEMENT_USER_METATYPE(CntServicesContact) |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
591 |
Q_IMPLEMENT_USER_METATYPE_NO_OPERATORS(CntServicesContactList) |
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
592 |
|
238255e8b033
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
593 |
//EOF |