31
|
1 |
/*
|
|
2 |
* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: This shall hold all the contact data associated with a
|
|
15 |
* conversation like name, numbers and contact link .
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
|
|
20 |
// SYSTEM INCLUDE FILES
|
|
21 |
#include <miutpars.h>
|
|
22 |
|
|
23 |
// USER INCLUDE FILES
|
|
24 |
#include "ccsconversation.h"
|
|
25 |
#include "ccsconversationcontact.h"
|
|
26 |
#include "ccsdebug.h"
|
|
27 |
|
|
28 |
// ============================== MEMBER FUNCTIONS ============================
|
|
29 |
|
|
30 |
// ----------------------------------------------------------------------------
|
|
31 |
// CCsConversationContact::CCsConversationContact
|
|
32 |
// Default constructor
|
|
33 |
// ----------------------------------------------------------------------------
|
|
34 |
CCsConversationContact::CCsConversationContact()
|
|
35 |
{
|
|
36 |
}
|
|
37 |
|
|
38 |
// ----------------------------------------------------------------------------
|
|
39 |
// CCsConversationContact::ConstructL
|
|
40 |
// Two phase construction
|
|
41 |
// ----------------------------------------------------------------------------
|
|
42 |
void
|
|
43 |
CCsConversationContact::ConstructL()
|
|
44 |
{
|
|
45 |
iDisplayName = NULL;
|
|
46 |
iContactId = KErrNotFound;
|
|
47 |
iPhoneNumberList = new (ELeave) RPointerArray<HBufC> ();
|
|
48 |
}
|
|
49 |
|
|
50 |
// ----------------------------------------------------------------------------
|
|
51 |
// CCsConversationContact::NewL
|
|
52 |
// Two Phase constructor
|
|
53 |
// ----------------------------------------------------------------------------
|
|
54 |
CCsConversationContact*
|
|
55 |
CCsConversationContact::NewL()
|
|
56 |
{
|
|
57 |
CCsConversationContact* self = new (ELeave) CCsConversationContact();
|
|
58 |
CleanupStack::PushL(self);
|
|
59 |
self->ConstructL();
|
|
60 |
CleanupStack::Pop(self);
|
|
61 |
return self;
|
|
62 |
}
|
|
63 |
|
|
64 |
// ----------------------------------------------------------------------------
|
|
65 |
// CCsConversationContact::~CCsConversationContact
|
|
66 |
// Destructor
|
|
67 |
// ----------------------------------------------------------------------------
|
|
68 |
CCsConversationContact::~CCsConversationContact()
|
|
69 |
{
|
|
70 |
if(iDisplayName)
|
|
71 |
{
|
|
72 |
delete iDisplayName;
|
|
73 |
iDisplayName = NULL;
|
|
74 |
}
|
|
75 |
|
|
76 |
if (iPhoneNumberList)
|
|
77 |
{
|
|
78 |
iPhoneNumberList->ResetAndDestroy();
|
|
79 |
iPhoneNumberList->Close();
|
|
80 |
delete iPhoneNumberList;
|
|
81 |
iPhoneNumberList = NULL;
|
|
82 |
}
|
|
83 |
}
|
|
84 |
|
|
85 |
// ----------------------------------------------------------------------------
|
|
86 |
// CCsConversationContact::GetDisplayName
|
|
87 |
// get the display name of the conversation
|
|
88 |
// ----------------------------------------------------------------------------
|
|
89 |
HBufC*
|
|
90 |
CCsConversationContact::GetDisplayName() const
|
|
91 |
{
|
|
92 |
return iDisplayName;
|
|
93 |
}
|
|
94 |
|
|
95 |
// ----------------------------------------------------------------------------
|
|
96 |
// CCsConversationContact::SetDisplayNameL
|
|
97 |
// Sets the display name of the conversation
|
|
98 |
// ----------------------------------------------------------------------------
|
|
99 |
void
|
|
100 |
CCsConversationContact::SetDisplayNameL(
|
|
101 |
const TDesC& aDisplayName)
|
|
102 |
{
|
|
103 |
if( &aDisplayName )
|
|
104 |
{
|
|
105 |
TRAPD(error, iDisplayName = aDisplayName.AllocL());
|
|
106 |
if(error != KErrNone)
|
|
107 |
{
|
|
108 |
// handle error
|
|
109 |
// call panic
|
|
110 |
PRINT1 ( _L("CCsConversationContact::SetFirstNameL - Error:%d"),
|
|
111 |
error );
|
|
112 |
}
|
|
113 |
}
|
|
114 |
}
|
|
115 |
|
|
116 |
// ----------------------------------------------------------------------------
|
|
117 |
// CCsConversationContact::GetContactId
|
|
118 |
// get the phonebook Contact Id link for the conversation
|
|
119 |
// ----------------------------------------------------------------------------
|
|
120 |
TInt32
|
|
121 |
CCsConversationContact::GetContactId() const
|
|
122 |
{
|
|
123 |
return iContactId;
|
|
124 |
}
|
|
125 |
|
|
126 |
// ----------------------------------------------------------------------------
|
|
127 |
// CCsConversationContact::SetContactLink
|
|
128 |
// Sets the phonebook Contact Id for the conversation
|
|
129 |
// ----------------------------------------------------------------------------
|
|
130 |
void
|
|
131 |
CCsConversationContact::SetContactId(
|
|
132 |
TInt32 aContactId)
|
|
133 |
{
|
|
134 |
iContactId = aContactId;
|
|
135 |
}
|
|
136 |
|
|
137 |
// ----------------------------------------------------------------------------
|
|
138 |
// CCsConversationContact::AddPhoneNumber
|
|
139 |
// Sets the phone number inside contact list
|
|
140 |
// ----------------------------------------------------------------------------
|
|
141 |
void
|
|
142 |
CCsConversationContact::AddPhoneNumberL(
|
|
143 |
TDesC& aPhoneNumber)
|
|
144 |
{
|
|
145 |
HBufC* phoneNumber = aPhoneNumber.AllocL();
|
|
146 |
iPhoneNumberList->AppendL(phoneNumber);
|
|
147 |
}
|
|
148 |
|
|
149 |
// ----------------------------------------------------------------------------
|
|
150 |
// CCsConversationContact::GetPhoneNumberList
|
|
151 |
// Returns a list of associated phone numbers
|
|
152 |
// ----------------------------------------------------------------------------
|
|
153 |
void
|
|
154 |
CCsConversationContact::GetPhoneNumberList(
|
|
155 |
RPointerArray<TDesC>& aPhoneNumbers)
|
|
156 |
{
|
|
157 |
for ( int index = 0; index < iPhoneNumberList->Count(); index++ )
|
|
158 |
{
|
|
159 |
HBufC* value = (*iPhoneNumberList)[index];
|
|
160 |
aPhoneNumbers.Append(value);
|
|
161 |
}
|
|
162 |
}
|
|
163 |
|
|
164 |
// ----------------------------------------------------------------------------
|
|
165 |
// CCsConversationContact::MatchPhoneNumber
|
|
166 |
// Check if the input phone number (aPhoneNumber) is associated with this
|
|
167 |
// contact. Compares for aNumDigits.
|
|
168 |
// ----------------------------------------------------------------------------
|
|
169 |
TBool
|
|
170 |
CCsConversationContact::MatchPhoneNumber(
|
|
171 |
TDesC& aPhoneNumber, TInt aNumDigits) const
|
|
172 |
{
|
|
173 |
if (aPhoneNumber.Length() == 0)
|
|
174 |
{
|
|
175 |
return EFalse;
|
|
176 |
}
|
|
177 |
|
|
178 |
TInt useDigits = aNumDigits;
|
|
179 |
|
|
180 |
// Check if phone number is an email address
|
|
181 |
TImMessageField email;
|
|
182 |
if ( email.ValidInternetEmailAddress(aPhoneNumber) )
|
|
183 |
{
|
|
184 |
useDigits = aPhoneNumber.Length();
|
|
185 |
}
|
|
186 |
|
|
187 |
TInt count = iPhoneNumberList->Count();
|
|
188 |
for ( TInt i = 0 ; i < count; i++)
|
|
189 |
{
|
|
190 |
HBufC* pno = (*iPhoneNumberList)[i];
|
|
191 |
|
|
192 |
// Compare only last useDigits dgits of the number/ address
|
|
193 |
if (aPhoneNumber.Right(useDigits).CompareF(pno->Des().
|
|
194 |
Right(useDigits)) == 0)
|
|
195 |
{
|
|
196 |
return ETrue;
|
|
197 |
}
|
|
198 |
}
|
|
199 |
return EFalse;
|
|
200 |
}
|
|
201 |
|
|
202 |
|
|
203 |
// EOF
|