27 #include <msgitem.h> |
27 #include <msgitem.h> |
28 |
28 |
29 // CONSTANTS |
29 // CONSTANTS |
30 _LIT(KUnixEpoch, "19700000:000000.000000"); |
30 _LIT(KUnixEpoch, "19700000:000000.000000"); |
31 |
31 |
|
32 const TInt KMaxConversationIPCLimit = 250; |
|
33 |
32 |
34 |
33 //--------------------------------------------------------------- |
35 //--------------------------------------------------------------- |
34 // MsgHistoryPrivate::MsgHistoryPrivate |
36 // MsgHistoryPrivate::MsgHistoryPrivate |
35 // @see header |
37 // @see header |
36 //--------------------------------------------------------------- |
38 //--------------------------------------------------------------- |
37 MsgHistoryPrivate::MsgHistoryPrivate( MsgHistoryImpl* ptr ) |
39 MsgHistoryPrivate::MsgHistoryPrivate( MsgHistoryImpl* ptr ) |
38 :q_ptr(ptr) |
40 :CActive(EPriorityStandard), |
39 { |
41 currentState(EInit), |
|
42 q_ptr(ptr) |
|
43 |
|
44 { |
|
45 CActiveScheduler::Add(this); |
40 handler = CCSRequestHandler::NewL(); |
46 handler = CCSRequestHandler::NewL(); |
41 handler->RequestResultsEventL(this); |
47 handler->RequestResultsEventL(this); |
42 } |
48 } |
43 |
49 |
44 //--------------------------------------------------------------- |
50 //--------------------------------------------------------------- |
47 //--------------------------------------------------------------- |
53 //--------------------------------------------------------------- |
48 MsgHistoryPrivate::~MsgHistoryPrivate() |
54 MsgHistoryPrivate::~MsgHistoryPrivate() |
49 { |
55 { |
50 if ( handler ) |
56 if ( handler ) |
51 delete handler; |
57 delete handler; |
52 } |
58 if(msgs.count()) |
53 |
59 { |
|
60 msgs.clear(); |
|
61 } |
|
62 // Cancel the active Object |
|
63 Cancel(); |
|
64 } |
|
65 |
|
66 // --------------------------------------------------------------------------- |
|
67 // RunL |
|
68 // --------------------------------------------------------------------------- |
|
69 // |
|
70 void MsgHistoryPrivate::RunL() |
|
71 { |
|
72 if (iStatus != KErrNone) |
|
73 { |
|
74 return; |
|
75 } |
|
76 //process |
|
77 switch (currentState) |
|
78 { |
|
79 case EFetchMoreConversations: |
|
80 GetMessagingHistory(contactId, msgs.count()); |
|
81 break; |
|
82 } |
|
83 } |
|
84 |
|
85 // --------------------------------------------------------------------------- |
|
86 // DoCancel |
|
87 // --------------------------------------------------------------------------- |
|
88 // |
|
89 void MsgHistoryPrivate::DoCancel() |
|
90 { |
|
91 currentState = EInit; |
|
92 contactId = -1; |
|
93 |
|
94 } |
|
95 |
|
96 // --------------------------------------------------------------------------- |
|
97 // Make the active object alive. |
|
98 // --------------------------------------------------------------------------- |
|
99 // |
|
100 void MsgHistoryPrivate::IssueRequest() |
|
101 { |
|
102 if (!IsActive()) |
|
103 { |
|
104 iStatus = KRequestPending; |
|
105 TRequestStatus* status = &iStatus; |
|
106 SetActive(); |
|
107 User::RequestComplete(status, KErrNone); |
|
108 } |
|
109 } |
54 //--------------------------------------------------------------- |
110 //--------------------------------------------------------------- |
55 // MsgHistoryPrivate::GetMessagingHistory |
111 // MsgHistoryPrivate::GetMessagingHistory |
56 // @see header |
112 // @see header |
57 //--------------------------------------------------------------- |
113 //--------------------------------------------------------------- |
58 TBool MsgHistoryPrivate::GetMessagingHistory( const TInt aContactId ) |
114 TBool MsgHistoryPrivate::GetMessagingHistory( const TInt aContactId , |
59 { |
115 TInt aKnownIndex) |
60 TRAPD(err, handler->GetMessagingHistoryL(aContactId)); |
116 { |
|
117 contactId = aContactId; |
|
118 TRAPD(err, handler->GetMessagingHistoryL(contactId, |
|
119 aKnownIndex, |
|
120 KMaxConversationIPCLimit)); |
61 if ( err == KErrNone ) |
121 if ( err == KErrNone ) |
62 return ETrue; |
122 return ETrue; |
63 |
123 |
64 return EFalse; |
124 return EFalse; |
65 } |
125 } |
158 //--------------------------------------------------------------- |
218 //--------------------------------------------------------------- |
159 // MsgHistoryPrivate::Conversations |
219 // MsgHistoryPrivate::Conversations |
160 // @see header |
220 // @see header |
161 //--------------------------------------------------------------- |
221 //--------------------------------------------------------------- |
162 void MsgHistoryPrivate::Conversations |
222 void MsgHistoryPrivate::Conversations |
163 ( RPointerArray<CCsConversationEntry>& aConversationEntryList ) |
223 ( RPointerArray<CCsConversationEntry>& aConversationEntryList, |
164 { |
224 TInt& aTotalCount) |
165 QList<MsgItem> msgs; |
225 { |
166 |
226 |
167 for(TInt i=aConversationEntryList.Count()-1; i >= 0; --i ) |
227 for(TInt i = 0 ; i < aConversationEntryList.Count(); i++ ) |
168 { |
228 { |
169 MsgItem item; |
229 MsgItem item; |
170 PopulateMsgItem(item,*(aConversationEntryList[i])); |
230 PopulateMsgItem(item,*(aConversationEntryList[i])); |
171 msgs.append(item); |
231 msgs.append(item); |
172 } |
232 } |
173 //emit signal |
233 //emit signal, when all the messages in the conversation are fetched. |
174 q_ptr->messagesReadyEvent(msgs); |
234 if(msgs.count()== aTotalCount) |
|
235 { |
|
236 currentState = EInit; |
|
237 q_ptr->messagesReadyEvent(msgs); |
|
238 msgs.clear(); |
|
239 |
|
240 } |
|
241 else |
|
242 { |
|
243 currentState = EFetchMoreConversations; |
|
244 IssueRequest(); |
|
245 } |
175 } |
246 } |
176 |
247 |
177 //--------------------------------------------------------------- |
248 //--------------------------------------------------------------- |
178 // MsgHistoryPrivate::AddConversation |
249 // MsgHistoryPrivate::AddConversation |
179 // @see header |
250 // @see header |