157 } |
158 } |
158 |
159 |
159 //common code to perform a call, videocall and message action |
160 //common code to perform a call, videocall and message action |
160 void CntAction::performNumberAction(const QString &interface, const QString &operation) |
161 void CntAction::performNumberAction(const QString &interface, const QString &operation) |
161 { |
162 { |
162 XQApplicationManager appMng; |
|
163 QVariantList args; |
163 QVariantList args; |
164 QVariant retValue; |
164 QVariant retValue; |
165 |
165 |
166 // TODO: Using XQApplicationManager is not working with calls |
166 // TODO: Using XQApplicationManager is not working with calls |
167 // The factory method cannot create a request. Find out why |
167 // The factory method cannot create a request. Find out why |
168 bool isCallAction = m_actionName == "call"; |
168 //bool isCallAction = (m_actionName == "call" || m_actionName == "videocall"); |
169 XQServiceRequest snd(interface, operation, false); |
169 XQServiceRequest snd(interface, operation, false); |
170 |
170 |
171 delete m_request; |
171 //QContactType == TypeGroup |
172 m_request = NULL; |
172 if (QContactType::TypeGroup == m_contact.type()) { |
173 m_request = appMng.create(interface, operation, false); // not embedded |
173 QContactPhoneNumber conferenceCall = m_contact.detail<QContactPhoneNumber>(); |
174 if (!isCallAction) { |
174 args << conferenceCall.number() << m_contact.localId() << m_contact.displayLabel(); |
175 if (!m_request) { |
175 |
176 emitResult(GeneralError, retValue); |
176 // TODO remove once call action works |
177 return; |
177 snd << conferenceCall.number() << m_contact.localId() << m_contact.displayLabel(); |
178 } |
178 snd.send(retValue); |
|
179 emitResult(snd.latestError(), retValue); |
179 } |
180 } |
180 |
181 //QContactType == TypeContact |
181 //detail exist use it |
182 //detail exist use it |
182 if (m_detail.definitionName() == QContactPhoneNumber::DefinitionName) |
183 else if (m_detail.definitionName() == QContactPhoneNumber::DefinitionName) { |
183 { |
|
184 const QContactPhoneNumber &phoneNumber = static_cast<const QContactPhoneNumber &>(m_detail); |
184 const QContactPhoneNumber &phoneNumber = static_cast<const QContactPhoneNumber &>(m_detail); |
185 |
185 |
186 args << phoneNumber.number() << m_contact.localId() << m_contact.displayLabel(); |
186 args << phoneNumber.number() << m_contact.localId() << m_contact.displayLabel(); |
187 |
187 |
188 // TODO remove once call action works |
188 snd << phoneNumber.number() << m_contact.localId() << m_contact.displayLabel(); |
189 if (isCallAction) { |
189 snd.send(retValue); |
190 snd << phoneNumber.number() << m_contact.localId() << m_contact.displayLabel(); |
190 emitResult(snd.latestError(), retValue); |
191 emitResult(snd.send(retValue), retValue); |
191 } |
192 } else { |
192 //QContactType == TypeContact |
193 m_request->setArguments(args); |
193 //if no detail, pick preferred |
194 m_request->setSynchronous(true); |
194 else if (m_detail.isEmpty()) |
195 emitResult(m_request->send(retValue), retValue); |
|
196 } |
|
197 } |
|
198 |
|
199 //if no detail, pick preferred |
|
200 else if(m_detail.isEmpty()) |
|
201 { |
195 { |
202 QContactDetail detail = m_contact.preferredDetail(m_actionName); |
196 QContactDetail detail = m_contact.preferredDetail(m_actionName); |
203 QContactPhoneNumber phoneNumber; |
197 QContactPhoneNumber phoneNumber; |
204 |
198 |
205 //if preferred is empty pick first phonenumber |
199 //if preferred is empty pick first phonenumber |
206 if(detail.isEmpty()) |
200 if (detail.isEmpty()) { |
207 { |
|
208 phoneNumber = m_contact.detail<QContactPhoneNumber>(); |
201 phoneNumber = m_contact.detail<QContactPhoneNumber>(); |
209 } |
202 } |
210 |
203 |
211 //if not empty, cast detail to phonenumber |
204 //if not empty, cast detail to phonenumber |
212 else |
205 else { |
213 { |
|
214 phoneNumber = static_cast<QContactPhoneNumber>(detail); |
206 phoneNumber = static_cast<QContactPhoneNumber>(detail); |
215 } |
207 } |
216 |
208 |
217 args << phoneNumber.number() << m_contact.localId() << m_contact.displayLabel(); |
209 args << phoneNumber.number() << m_contact.localId() << m_contact.displayLabel(); |
218 |
210 |
219 // TODO remove once call action works |
211 snd << phoneNumber.number() << m_contact.localId() << m_contact.displayLabel(); |
220 if (isCallAction) { |
212 snd.send(retValue); |
221 snd << phoneNumber.number() << m_contact.localId() << m_contact.displayLabel(); |
213 emitResult(snd.latestError(), retValue); |
222 emitResult(snd.send(retValue), retValue); |
214 } |
223 } else { |
|
224 m_request->setArguments(args); |
|
225 m_request->setSynchronous(true); |
|
226 emitResult(m_request->send(retValue), retValue); |
|
227 } |
|
228 } |
|
229 |
|
230 //else return an error |
215 //else return an error |
231 else |
216 else { |
232 { |
|
233 emitResult(GeneralError, retValue); |
217 emitResult(GeneralError, retValue); |
234 } |
218 } |
235 } |
219 } |
236 |
220 |
237 //emit the result to the client |
221 //emit the result to the client |