1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the Qt Mobility Components. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #ifndef ACTIONFACTORYPLUGINTARGET |
|
43 #define ACTIONFACTORYPLUGINTARGET contacts_sendemailactionfactory |
|
44 #endif |
|
45 #ifndef ACTIONFACTORYPLUGINNAME |
|
46 #define ACTIONFACTORYPLUGINNAME SendEmailActionFactory |
|
47 #endif |
|
48 |
|
49 #include "sendemailaction_p.h" |
|
50 |
|
51 #include "qcontactemailaddress.h" |
|
52 #include "qcontactfilters.h" |
|
53 |
|
54 #include <QMessageBox> |
|
55 #include <QTimer> |
|
56 |
|
57 #define makestr(x) (#x) |
|
58 #define makename(x) makestr(x) |
|
59 |
|
60 QContactSendEmailActionFactory::QContactSendEmailActionFactory() |
|
61 { |
|
62 } |
|
63 |
|
64 QContactSendEmailActionFactory::~QContactSendEmailActionFactory() |
|
65 { |
|
66 } |
|
67 |
|
68 QString QContactSendEmailActionFactory::name() const |
|
69 { |
|
70 return QString(makename(ACTIONFACTORYPLUGINNAME)); |
|
71 } |
|
72 Q_EXPORT_PLUGIN2(ACTIONFACTORYPLUGINTARGET, QContactSendEmailActionFactory); |
|
73 |
|
74 QList<QContactActionDescriptor> QContactSendEmailActionFactory::actionDescriptors() const |
|
75 { |
|
76 return QList<QContactActionDescriptor>() << QContactActionDescriptor("SendEmail", "Test", 1); |
|
77 } |
|
78 |
|
79 QContactAction* QContactSendEmailActionFactory::instance(const QContactActionDescriptor& descriptor) const |
|
80 { |
|
81 if (descriptor.actionName() != QString("SendEmail") || descriptor.vendorName() != QString("Test") || descriptor.implementationVersion() != 1) |
|
82 return 0; |
|
83 return new QContactSendEmailAction; |
|
84 } |
|
85 |
|
86 QVariantMap QContactSendEmailActionFactory::actionMetadata(const QContactActionDescriptor& descriptor) const |
|
87 { |
|
88 if (descriptor.actionName() != "SendEmail") |
|
89 return QVariantMap(); |
|
90 |
|
91 QVariantMap ret; |
|
92 ret.insert("Label", "Email Contact!"); |
|
93 return ret; |
|
94 } |
|
95 |
|
96 QContactSendEmailAction::QContactSendEmailAction() : QContactAction() |
|
97 { |
|
98 } |
|
99 |
|
100 QContactSendEmailAction::~QContactSendEmailAction() |
|
101 { |
|
102 } |
|
103 |
|
104 QContactActionDescriptor QContactSendEmailAction::actionDescriptor() const |
|
105 { |
|
106 QContactActionDescriptor ret; |
|
107 ret.setActionName("SendEmail"); |
|
108 ret.setVendorName("Test"); |
|
109 ret.setImplementationVersion(1); |
|
110 return ret; |
|
111 } |
|
112 |
|
113 QVariantMap QContactSendEmailAction::metaData() const |
|
114 { |
|
115 return QVariantMap(); |
|
116 } |
|
117 |
|
118 QContactFilter QContactSendEmailAction::contactFilter(const QVariant& value) const |
|
119 { |
|
120 QContactDetailFilter retn; |
|
121 retn.setDetailDefinitionName(QContactEmailAddress::DefinitionName, QContactEmailAddress::FieldEmailAddress); |
|
122 retn.setValue(value); |
|
123 return retn; |
|
124 } |
|
125 |
|
126 bool QContactSendEmailAction::isDetailSupported(const QContactDetail &detail, const QContact &) const |
|
127 { |
|
128 return (detail.definitionName() == QContactEmailAddress::DefinitionName); |
|
129 } |
|
130 |
|
131 QList<QContactDetail> QContactSendEmailAction::supportedDetails(const QContact& contact) const |
|
132 { |
|
133 return contact.details(QContactEmailAddress::DefinitionName); |
|
134 } |
|
135 |
|
136 bool QContactSendEmailAction::invokeAction(const QContact& contact, const QContactDetail& detail, const QVariantMap& ) |
|
137 { |
|
138 Q_UNUSED(contact); |
|
139 Q_UNUSED(detail); |
|
140 QTimer::singleShot(1, this, SLOT(performAction())); |
|
141 return true; |
|
142 } |
|
143 |
|
144 QVariantMap QContactSendEmailAction::results() const |
|
145 { |
|
146 return QVariantMap(); |
|
147 } |
|
148 |
|
149 void QContactSendEmailAction::performAction() |
|
150 { |
|
151 QMessageBox::information(0, "SendEmail Action", "This example action exists as an example of how the action interface may be implemented; it does not offer the advertised functionality."); |
|
152 emit stateChanged(QContactAction::FinishedState); |
|
153 } |
|