63 } |
61 } |
64 |
62 |
65 void CntEmailAction::performAction() |
63 void CntEmailAction::performAction() |
66 { |
64 { |
67 QVariant retValue; |
65 QVariant retValue; |
68 |
66 delete m_request; |
69 if (mRequest) |
67 m_request = NULL; |
70 { |
68 m_request = m_AppManager.create(XQI_EMAIL_MESSAGE_SEND, "send(QVariant)", true); |
|
69 |
|
70 if (m_request) { |
71 QMap<QString, QVariant> map; |
71 QMap<QString, QVariant> map; |
72 QStringList recipients; |
72 QStringList recipients; |
73 QList<QVariant> data; |
73 QList<QVariant> data; |
74 |
74 |
|
75 //QContactType == TypeGroup |
|
76 if (QContactType::TypeGroup == m_contact.type()) { |
|
77 QStringList emails; |
|
78 QVariant value = m_data.value("email"); |
|
79 if (value.canConvert<QStringList>()) { |
|
80 emails = value.toStringList(); |
|
81 } |
|
82 |
|
83 if (!emails.isEmpty()) { |
|
84 for (int i=0;i<emails.count();i++) { |
|
85 recipients.append(emails.at(i)); |
|
86 } |
|
87 map.insert(EMAIL_SEND_TO_KEY, recipients); |
|
88 data.append(map); |
|
89 |
|
90 m_request->setArguments(data); |
|
91 m_request->send(retValue); |
|
92 emitResult(m_request->lastError(), retValue); |
|
93 } |
|
94 else { |
|
95 emitResult(GeneralError, retValue); |
|
96 } |
|
97 } |
|
98 //QContactType == TypeContact |
75 // If detail exists use it. |
99 // If detail exists use it. |
76 if (m_detail.definitionName() == QContactEmailAddress::DefinitionName) |
100 else if (m_detail.definitionName() == QContactEmailAddress::DefinitionName) { |
77 { |
|
78 const QContactEmailAddress &email = static_cast<const QContactEmailAddress &>(m_detail); |
101 const QContactEmailAddress &email = static_cast<const QContactEmailAddress &>(m_detail); |
79 |
102 |
80 recipients.append(email.emailAddress()); |
103 recipients.append(email.emailAddress()); |
81 map.insert(EMAIL_SEND_TO_KEY, recipients); |
104 map.insert(EMAIL_SEND_TO_KEY, recipients); |
82 data.append(map); |
105 data.append(map); |
83 |
106 |
84 mRequest->setArguments(data); |
107 m_request->setArguments(data); |
85 mRequest->send(retValue); |
108 m_request->send(retValue); |
86 emitResult(mRequest->lastError(), retValue); |
109 emitResult(m_request->lastError(), retValue); |
87 } |
110 } |
88 |
111 else { |
89 // If no detail, pick preferred. |
|
90 // Todo : Temporary fix. Remove setting preferred when selection popup feature available. |
|
91 else if (m_detail.isEmpty()) |
|
92 { |
|
93 QContactDetail detail = m_contact.preferredDetail(m_actionName); |
|
94 QContactEmailAddress email; |
|
95 |
|
96 // If preferred is empty pick first email. |
|
97 if(detail.isEmpty()) |
|
98 { |
|
99 email = m_contact.detail<QContactEmailAddress>(); |
|
100 } |
|
101 else |
|
102 { |
|
103 email = static_cast<QContactEmailAddress>(detail); |
|
104 } |
|
105 |
|
106 recipients.append(email.emailAddress()); |
|
107 map.insert(EMAIL_SEND_TO_KEY, recipients); |
|
108 data.append(map); |
|
109 |
|
110 mRequest->setArguments(data); |
|
111 mRequest->send(retValue); |
|
112 emitResult(mRequest->lastError(), retValue); |
|
113 } |
|
114 else |
|
115 { |
|
116 emitResult(GeneralError, retValue); |
112 emitResult(GeneralError, retValue); |
117 } |
113 } |
118 } |
114 } |
119 |
115 |
120 // Service not found. |
116 // Service not found. |
121 else |
117 else { |
122 { |
|
123 emitResult(GeneralError, retValue); |
118 emitResult(GeneralError, retValue); |
124 } |
119 } |
125 } |
120 } |
126 |
121 |
127 |
122 |