1 /* |
|
2 * Copyright (c) 2010 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: |
|
15 * |
|
16 */ |
|
17 #include "cntexamplebaseaction.h" |
|
18 |
|
19 #include <xqservicerequest.h> |
|
20 #include <qcontactphonenumber.h> |
|
21 #include <qcontactonlineaccount.h> |
|
22 #include <qcontactfilters.h> |
|
23 #include <QDebug> |
|
24 |
|
25 MobBaseAction::MobBaseAction(const QString &actionName, const QString& vendorName) : |
|
26 m_actionName(actionName), |
|
27 m_vendorName(vendorName), |
|
28 m_implementationVersion(1), |
|
29 m_result(), |
|
30 m_contact(), |
|
31 m_detail() |
|
32 { |
|
33 } |
|
34 |
|
35 MobBaseAction::~MobBaseAction() |
|
36 { |
|
37 } |
|
38 |
|
39 QContactActionDescriptor MobBaseAction::actionDescriptor() const |
|
40 { |
|
41 QContactActionDescriptor ret; |
|
42 ret.setActionName(m_actionName); |
|
43 ret.setVendorName(m_vendorName); |
|
44 ret.setImplementationVersion(m_implementationVersion); |
|
45 return ret; |
|
46 } |
|
47 |
|
48 bool MobBaseAction::invokeAction(const QContact& contact, const QContactDetail& detail, const QVariantMap& parameters) |
|
49 { |
|
50 m_contact = contact; |
|
51 m_detail = detail; |
|
52 } |
|
53 |
|
54 //Clears the action data, is called after the result has been emitted to contact (emitResult function) |
|
55 void MobBaseAction::resetAction() |
|
56 { |
|
57 m_contact = QContact(); |
|
58 m_detail = QContactDetail(); |
|
59 } |
|
60 |
|
61 //returns whether the actionDescription is supported by this action |
|
62 bool MobBaseAction::actionDescriptionSupported(const QContactActionDescriptor& descriptor) const |
|
63 { |
|
64 bool supported(false); |
|
65 |
|
66 if ((descriptor.actionName() == m_actionName) && (descriptor.vendorName() == m_vendorName) && (descriptor.implementationVersion() == m_implementationVersion)) |
|
67 supported = true; |
|
68 else |
|
69 supported = false; |
|
70 |
|
71 return supported; |
|
72 } |
|
73 |
|
74 //emit the result to the client |
|
75 void MobBaseAction::emitResult(int errorCode, const QVariant &retValue) |
|
76 { |
|
77 // m_result.clear(); |
|
78 // m_result.insert("Error", QVariant(errorCode)); |
|
79 // m_result.insert("ReturnValue", retValue); |
|
80 // |
|
81 // QContactAction::Status status; |
|
82 // |
|
83 // if (errorCode == 0){ |
|
84 // status = QContactAction::Finished; |
|
85 // } |
|
86 // |
|
87 // else{ |
|
88 // status = QContactAction::FinishedWithError; |
|
89 // } |
|
90 // |
|
91 // emit progress(status, m_result); |
|
92 |
|
93 resetAction(); //reset values in the action |
|
94 } |
|
95 |
|
96 QVariantMap MobBaseAction::results() const |
|
97 { |
|
98 return m_result; |
|
99 } |
|