18
|
1 |
/**
|
|
2 |
* Copyright (c) 2010 Sasken Communication Technologies Ltd.
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of the "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 |
* Chandradeep Gandhi, Sasken Communication Technologies Ltd - Initial contribution
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
* Manasij Roy, Nalina Hariharan
|
|
14 |
*
|
|
15 |
* Description:
|
|
16 |
* Private Implementation of SmfActivityFetcher
|
|
17 |
*
|
|
18 |
*/
|
|
19 |
|
|
20 |
#include <QDebug>
|
|
21 |
|
|
22 |
#include "smfactivityfetcher.h"
|
|
23 |
#include "smfactivityfetcher_p.h"
|
|
24 |
#ifdef Q_OS_SYMBIAN
|
|
25 |
#include "smfclientsymbian.h"
|
|
26 |
#else
|
|
27 |
#include "smfclientqt.h"
|
|
28 |
#endif
|
|
29 |
|
|
30 |
|
|
31 |
SmfActivityFetcherPrivate::SmfActivityFetcherPrivate(SmfActivityFetcher *activityFetcher)
|
|
32 |
:m_activityFetcher(activityFetcher)
|
|
33 |
{
|
|
34 |
#ifdef Q_OS_SYMBIAN
|
|
35 |
//private impl for symbian
|
|
36 |
m_SmfClientPrivate = CSmfClientSymbian::NewL(this);
|
|
37 |
#else
|
|
38 |
//TODO:- Qt private impl
|
|
39 |
#endif
|
|
40 |
}
|
|
41 |
|
|
42 |
SmfActivityFetcherPrivate::~SmfActivityFetcherPrivate()
|
|
43 |
{
|
|
44 |
if(m_SmfClientPrivate)
|
|
45 |
{
|
|
46 |
delete m_SmfClientPrivate;
|
|
47 |
m_SmfClientPrivate = NULL;
|
|
48 |
}
|
|
49 |
}
|
|
50 |
|
|
51 |
void SmfActivityFetcherPrivate::selfActivities(int pageNum, int perPage)
|
|
52 |
{
|
|
53 |
SmfProvider* m_baseProvider = m_activityFetcher->getProvider();
|
|
54 |
//serialize start
|
|
55 |
m_serializedDataToServer.clear();
|
|
56 |
QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly);
|
|
57 |
//SmfProvider
|
|
58 |
write<<*m_baseProvider;
|
|
59 |
m_argFlag = 1;
|
|
60 |
write<<m_argFlag;
|
|
61 |
write<<pageNum;
|
|
62 |
write<<m_argFlag;
|
|
63 |
write<<perPage;
|
|
64 |
//serialize end
|
|
65 |
|
|
66 |
QString intfName(activityFetcherInterface);
|
|
67 |
int max = MaxSmfActivityEntrySize*perPage;
|
|
68 |
|
|
69 |
//call private impl's send method
|
|
70 |
m_SmfClientPrivate->sendRequest(m_serializedDataToServer, intfName,
|
|
71 |
SmfActivitySelfActivity, max);
|
|
72 |
}
|
|
73 |
|
|
74 |
void SmfActivityFetcherPrivate::friendsActivities(const SmfContact & aFriend, int pageNum, int perPage)
|
|
75 |
{
|
|
76 |
SmfProvider* m_baseProvider = m_activityFetcher->getProvider();
|
|
77 |
//serialize start
|
|
78 |
m_serializedDataToServer.clear();
|
|
79 |
QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly);
|
|
80 |
//SmfProvider
|
|
81 |
write<<*m_baseProvider;
|
|
82 |
m_argFlag = 1;
|
|
83 |
write<<m_argFlag;
|
|
84 |
write<<aFriend;
|
|
85 |
write<<m_argFlag;
|
|
86 |
write<<pageNum;
|
|
87 |
write<<m_argFlag;
|
|
88 |
write<<perPage;
|
|
89 |
|
|
90 |
QString intfName(activityFetcherInterface);
|
|
91 |
int max = MaxSmfActivityEntrySize*perPage;
|
|
92 |
|
|
93 |
//call private impl's send method
|
|
94 |
m_SmfClientPrivate->sendRequest(m_serializedDataToServer, intfName,
|
|
95 |
SmfActivityFriendsActivities, max);
|
|
96 |
}
|
|
97 |
|
|
98 |
void SmfActivityFetcherPrivate::filtered(QList<SmfActivityObjectType> filters, int pageNum, int perPage)
|
|
99 |
{
|
|
100 |
SmfProvider* m_baseProvider = m_activityFetcher->getProvider();
|
|
101 |
|
|
102 |
//serialize start
|
|
103 |
m_serializedDataToServer.clear();
|
|
104 |
QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly);
|
|
105 |
//SmfProvider
|
|
106 |
write<<*m_baseProvider;
|
|
107 |
m_argFlag = 1;
|
|
108 |
write<<m_argFlag;
|
|
109 |
write<<filters;
|
|
110 |
write<<m_argFlag;
|
|
111 |
write<<pageNum;
|
|
112 |
write<<m_argFlag;
|
|
113 |
write<<perPage;
|
|
114 |
|
|
115 |
QString intfName(activityFetcherInterface);
|
|
116 |
int max = MaxSmfActivityEntrySize*perPage;
|
|
117 |
|
|
118 |
//call private impl's send method
|
|
119 |
m_SmfClientPrivate->sendRequest(m_serializedDataToServer, intfName,
|
|
120 |
SmfActivityFiltered, max);
|
|
121 |
}
|
|
122 |
|
|
123 |
void SmfActivityFetcherPrivate::customRequest ( const int& operationId, QByteArray* customData )
|
|
124 |
{
|
|
125 |
SmfProvider* m_baseProvider = m_activityFetcher->getProvider();
|
|
126 |
|
|
127 |
//serialize start
|
|
128 |
m_serializedDataToServer.clear();
|
|
129 |
QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly);
|
|
130 |
write<<*m_baseProvider;
|
|
131 |
m_argFlag = 1;
|
|
132 |
write<<operationId;
|
|
133 |
if(customData)
|
|
134 |
{
|
|
135 |
write<<m_argFlag;
|
|
136 |
write<<*customData;
|
|
137 |
}
|
|
138 |
else
|
|
139 |
{
|
|
140 |
m_argFlag = 0;
|
|
141 |
write<<m_argFlag;
|
|
142 |
}
|
|
143 |
|
|
144 |
QString intfName(activityFetcherInterface);
|
|
145 |
//ToDo:- How much size to allocate for custom data? keeping MaxSmfActivityEntrySize for now
|
|
146 |
int maxAllocation = MaxSmfActivityEntrySize;
|
|
147 |
|
|
148 |
//call private impl's send method
|
|
149 |
m_SmfClientPrivate->sendRequest(m_serializedDataToServer, intfName,
|
|
150 |
SmfActivityCustomRequest, maxAllocation);
|
|
151 |
}
|
|
152 |
|
|
153 |
void SmfActivityFetcherPrivate::resultsAvailable(QByteArray result,SmfRequestTypeID opcode, SmfError error)
|
|
154 |
{
|
|
155 |
qDebug()<<"SmfActivityFetcherPrivate::resultsAvailable";
|
|
156 |
qDebug()<<"opcode = "<<opcode;
|
|
157 |
|
|
158 |
QDataStream reader(&result,QIODevice::ReadOnly);
|
|
159 |
|
|
160 |
//Now de-serialize it based on opcode
|
|
161 |
switch(opcode)
|
|
162 |
{
|
|
163 |
case SmfActivitySelfActivity:
|
|
164 |
case SmfActivityFriendsActivities:
|
|
165 |
case SmfActivityFiltered:
|
|
166 |
{
|
|
167 |
SmfActivityEntryList* m_entries = new SmfActivityEntryList;
|
|
168 |
reader>>*m_entries;
|
|
169 |
qDebug()<<"m_entries.count = "<<m_entries->count();
|
|
170 |
|
|
171 |
//ToDo:- not incorporating paging now
|
|
172 |
SmfResultPage page;
|
|
173 |
|
|
174 |
emit m_activityFetcher->resultsAvailable(m_entries,error,page);
|
|
175 |
}
|
|
176 |
break;
|
|
177 |
|
|
178 |
case SmfActivityCustomRequest:
|
|
179 |
{
|
|
180 |
int operationId;
|
|
181 |
QByteArray *data = new QByteArray;
|
|
182 |
reader>>operationId;
|
|
183 |
reader>>*data;
|
|
184 |
|
|
185 |
qDebug()<<"operationId = "<<operationId;
|
|
186 |
qDebug()<<"data size = "<<data->size();
|
|
187 |
emit m_activityFetcher->customDataAvailable(operationId, data);
|
|
188 |
}
|
|
189 |
break;
|
|
190 |
default:
|
|
191 |
Q_ASSERT_X(1,"Activity Private Unknown opcode","default case");
|
|
192 |
}
|
|
193 |
}
|