author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 18 Aug 2010 09:45:25 +0300 | |
changeset 52 | 12db4185673b |
parent 43 | 35b64624a9e7 |
permissions | -rw-r--r-- |
31 | 1 |
/* |
2 |
* Copyright (c) 2009 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:Message Indicator private class. |
|
15 |
* Gets the indicaton information from conversation server. |
|
16 |
* |
|
17 |
*/ |
|
18 |
#include <ccsclientconversation.h> |
|
19 |
#include <ccsrequesthandler.h> |
|
20 |
#include <ccsconversationentry.h> |
|
21 |
||
22 |
#include "msgindicator_p.h" |
|
23 |
#include "msgindicator.h" |
|
24 |
#include "debugtraces.h" |
|
43
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
25 |
#include <xqconversions.h> |
31 | 26 |
|
27 |
#define LOC_RECEIVED_FILES hbTrId("Received Files") |
|
28 |
||
29 |
// ---------------------------------------------------------------------------- |
|
30 |
// MsgIndicatorPrivate::MsgIndicatorPrivate |
|
31 |
// @see MsgIndicatorPrivate.h |
|
32 |
// ---------------------------------------------------------------------------- |
|
33 |
MsgIndicatorPrivate::MsgIndicatorPrivate(MsgIndicator* inidcator) : |
|
34 |
q_ptr(inidcator), mCvServer(NULL) |
|
35 |
{ |
|
52
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
36 |
initL(); |
31 | 37 |
} |
38 |
||
39 |
// ---------------------------------------------------------------------------- |
|
40 |
// MsgIndicatorPrivate::~MsgIndicatorPrivate |
|
41 |
// @see MsgIndicatorPrivate.h |
|
42 |
// ---------------------------------------------------------------------------- |
|
43 |
MsgIndicatorPrivate::~MsgIndicatorPrivate() |
|
44 |
{ |
|
45 |
if (mCvServer) { |
|
46 |
delete mCvServer; |
|
47 |
mCvServer = NULL; |
|
48 |
} |
|
49 |
} |
|
50 |
||
51 |
// ---------------------------------------------------------------------------- |
|
52 |
// MsgIndicatorPrivate::initL() |
|
53 |
// @see MsgIndicatorPrivate.h |
|
54 |
// ---------------------------------------------------------------------------- |
|
55 |
void MsgIndicatorPrivate::initL() |
|
56 |
{ |
|
57 |
mCvServer = CCSRequestHandler::NewL(); |
|
58 |
} |
|
59 |
||
60 |
// ---------------------------------------------------------------------------- |
|
61 |
// MsgIndicatorPrivate::getIndicatorInfo |
|
62 |
// @see MsgIndicatorPrivate.h |
|
63 |
// ---------------------------------------------------------------------------- |
|
64 |
void MsgIndicatorPrivate::getIndicatorInfo(MsgInfo& indicatorData) |
|
65 |
{ |
|
66 |
TRAP_IGNORE(getIndicatorInfoL(indicatorData)); |
|
67 |
} |
|
68 |
||
69 |
// ---------------------------------------------------------------------------- |
|
70 |
// MsgIndicatorPrivate::getIndicatorInfoL |
|
71 |
// @see MsgIndicatorPrivate.h |
|
72 |
// ---------------------------------------------------------------------------- |
|
73 |
void MsgIndicatorPrivate::getIndicatorInfoL(MsgInfo& indicatorData) |
|
74 |
{ |
|
75 |
RPointerArray<CCsClientConversation> *clientConversationList = new RPointerArray< |
|
76 |
CCsClientConversation> (); |
|
77 |
CleanupStack::PushL(clientConversationList); |
|
78 |
mCvServer->GetConversationUnreadListL(clientConversationList); |
|
79 |
CleanupStack::Pop(); |
|
80 |
||
81 |
QStringList nameList; |
|
82 |
int count = clientConversationList->Count(); |
|
83 |
||
84 |
indicatorData.mMsgCount = 0; |
|
85 |
||
86 |
for (int loop = 0; loop < count; ++loop) { |
|
87 |
||
88 |
CCsClientConversation* conversation = |
|
89 |
static_cast<CCsClientConversation*> ((*clientConversationList)[loop]); |
|
90 |
||
91 |
CCsConversationEntry* convEntry = conversation->GetConversationEntry(); |
|
92 |
||
93 |
indicatorData.mMsgCount += conversation->GetUnreadMessageCount(); |
|
94 |
indicatorData.mConversationId = static_cast<int>(conversation->GetConversationEntryId()); |
|
95 |
||
96 |
HBufC* description = convEntry->Description(); |
|
97 |
if (description && (count == 1)) { |
|
98 |
// Only take the description from convEntry when there is one entry. |
|
99 |
// description will contain the name list when there are more entries. |
|
100 |
QString descText; |
|
43
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
101 |
descText = XQConversions::s60DescToQString(*description); |
31 | 102 |
descText.replace(QChar::ParagraphSeparator, QChar::LineSeparator); |
103 |
descText.replace('\r', QChar::LineSeparator); |
|
104 |
indicatorData.mDescription = descText; |
|
105 |
} |
|
106 |
||
107 |
if((indicatorData.mMessageType = static_cast<int>(convEntry->GetType()))==ECsBlueTooth){ |
|
108 |
// if we have bluetooth messages, nameList should contain the LOC_RECEVED_FILES |
|
109 |
// string. DisplayName/number are not needed. |
|
110 |
nameList.append(LOC_RECEIVED_FILES); |
|
111 |
indicatorData.mMessageType = ECsBlueTooth ; |
|
112 |
continue; |
|
113 |
} |
|
114 |
else { // non-bluetooth |
|
115 |
HBufC* displayName = conversation->GetDisplayName(); |
|
116 |
HBufC* number = convEntry->Contact(); |
|
117 |
||
118 |
if (displayName) { |
|
43
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
119 |
nameList.append(XQConversions::s60DescToQString(*displayName)); |
31 | 120 |
} |
121 |
else if (number) { |
|
43
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
122 |
nameList.append(XQConversions::s60DescToQString(*number)); |
31 | 123 |
} |
124 |
} |
|
125 |
} |
|
126 |
||
127 |
nameList.removeDuplicates(); |
|
128 |
nameList.sort(); |
|
129 |
||
130 |
if (nameList.count() > 1) { |
|
131 |
// more than 1 sender. Concatenate the names in the description |
|
132 |
||
133 |
indicatorData.mFromSingle = false; |
|
134 |
indicatorData.mDescription = nameList.join(QString(", ")); |
|
135 |
indicatorData.mMessageType = ECsSMS; |
|
136 |
} |
|
137 |
else if (nameList.count() == 1){ |
|
138 |
// only 1 sender. |
|
139 |
// displayname will have the name of the sender. |
|
140 |
// description will contain latest message if more than 1 message |
|
141 |
indicatorData.mFromSingle = true; |
|
142 |
indicatorData.mDisplayName.append(nameList.at(0)); |
|
143 |
} |
|
144 |
||
145 |
clientConversationList->ResetAndDestroy(); |
|
146 |
delete clientConversationList; |
|
147 |
} |
|
148 |