16 * |
16 * |
17 */ |
17 */ |
18 |
18 |
19 // INCLUDES |
19 // INCLUDES |
20 #include "nmuiheaders.h" |
20 #include "nmuiheaders.h" |
21 |
|
22 /*! |
|
23 \class NmStartParamDataHelper |
|
24 \brief A helper class for processing the data given to the actual service. |
|
25 */ |
|
26 class NmStartParamDataHelper |
|
27 { |
|
28 public: |
|
29 |
|
30 /*! |
|
31 Class constructor. |
|
32 */ |
|
33 inline NmStartParamDataHelper() |
|
34 : mSubject(NULL), |
|
35 mToAddresses(NULL), |
|
36 mCcAddresses(NULL), |
|
37 mBccAddresses(NULL), |
|
38 mBodyText(NULL) |
|
39 { |
|
40 NM_FUNCTION; |
|
41 } |
|
42 |
|
43 /*! |
|
44 Class destructor. |
|
45 */ |
|
46 inline ~NmStartParamDataHelper() |
|
47 { |
|
48 NM_FUNCTION; |
|
49 } |
|
50 |
|
51 /*! |
|
52 Extracts the data from the given QString into the class members. |
|
53 \param data QString containing the data. |
|
54 \return True if success, false otherwise. |
|
55 */ |
|
56 inline bool extractData(const QString &data) |
|
57 { |
|
58 NM_FUNCTION; |
|
59 |
|
60 bool success(false); |
|
61 |
|
62 QUrl uri(data); |
|
63 |
|
64 if (uri.isValid()) { |
|
65 |
|
66 mSubject = new QString(uri.queryItemValue(emailSendSubjectKey)); |
|
67 QString to = uri.path(); |
|
68 QString cc = uri.queryItemValue(emailSendCcKey); |
|
69 QString bcc = uri.queryItemValue(emailSendBccKey); |
|
70 QString bodyText = uri.queryItemValue(emailSendBodyTextKey); |
|
71 if (bodyText.length()) { |
|
72 mBodyText = new QString(bodyText); |
|
73 } |
|
74 |
|
75 addAddressesToList(to, &mToAddresses); |
|
76 addAddressesToList(cc, &mCcAddresses); |
|
77 addAddressesToList(bcc, &mBccAddresses); |
|
78 |
|
79 success = true; |
|
80 } |
|
81 |
|
82 return success; |
|
83 } |
|
84 |
|
85 /*! |
|
86 Appends the given addresses into the given list. |
|
87 \param address The addresses to append. |
|
88 \param list The list where the addresses are appended to. |
|
89 */ |
|
90 inline void addAddressesToList(QString &addresses, |
|
91 QList<NmAddress*> **list) |
|
92 { |
|
93 NM_FUNCTION; |
|
94 |
|
95 if (!addresses.isEmpty()) { |
|
96 |
|
97 QList<NmAddress*> foundAddresses; |
|
98 |
|
99 // Process multiple addresses. |
|
100 if (addresses.contains(",")) { |
|
101 QString str; |
|
102 while (addresses.contains(",")) { |
|
103 str = addresses.section(",", 0, 0); // Get the occurance. |
|
104 addresses.remove(0, (addresses.indexOf(",")+1)); // Remove the occurance. |
|
105 if (!str.isEmpty()) { // In case str would be empty on some error data. |
|
106 NmAddress *address = new NmAddress(str); |
|
107 foundAddresses.append(address); |
|
108 } |
|
109 } |
|
110 } |
|
111 if (!addresses.isEmpty()) { // In case addresses would be empty on some error data. |
|
112 // Last one or single address. |
|
113 NmAddress *address = new NmAddress(addresses); |
|
114 foundAddresses.append(address); |
|
115 } |
|
116 // Append the found addresses into the given list. |
|
117 *list = new QList<NmAddress*>(); |
|
118 (*list)->append(foundAddresses); |
|
119 } |
|
120 } |
|
121 |
|
122 /*! |
|
123 Deletes the class members. Must be used if NmUiStartParam does not |
|
124 take ownership of the members. |
|
125 */ |
|
126 inline void deleteData() |
|
127 { |
|
128 NM_FUNCTION; |
|
129 |
|
130 delete mSubject; |
|
131 mSubject = NULL; |
|
132 |
|
133 if (mToAddresses) { |
|
134 qDeleteAll(*mToAddresses); |
|
135 delete mToAddresses; |
|
136 mToAddresses = NULL; |
|
137 } |
|
138 |
|
139 if (mCcAddresses) { |
|
140 qDeleteAll(*mCcAddresses); |
|
141 delete mCcAddresses; |
|
142 mCcAddresses = NULL; |
|
143 } |
|
144 |
|
145 if (mBccAddresses) { |
|
146 qDeleteAll(*mBccAddresses); |
|
147 delete mBccAddresses; |
|
148 mBccAddresses = NULL; |
|
149 } |
|
150 |
|
151 delete mBodyText; |
|
152 mBodyText = NULL; |
|
153 } |
|
154 |
|
155 public: // Data |
|
156 |
|
157 QString *mSubject; // Not owned. |
|
158 QList<NmAddress*> *mToAddresses; // Not owned. |
|
159 QList<NmAddress*> *mCcAddresses; // Not owned. |
|
160 QList<NmAddress*> *mBccAddresses; // Not owned. |
|
161 QString *mBodyText; |
|
162 }; |
|
163 |
21 |
164 /*! |
22 /*! |
165 \class NmUriServiceInterface |
23 \class NmUriServiceInterface |
166 \brief NMail application service interface which provides an email sending |
24 \brief NMail application service interface which provides an email sending |
167 interface for other application using the Qt Highway. |
25 interface for other application using the Qt Highway. |
262 note.show(); |
121 note.show(); |
263 cancelService(); |
122 cancelService(); |
264 } |
123 } |
265 else { // count > 0 |
124 else { // count > 0 |
266 if (mainWindow) { |
125 if (mainWindow) { |
267 mainWindow->show(); |
126 mainWindow->show(); |
268 } |
127 } |
269 |
128 |
|
129 // The ownership of these is passed to NmApplication in launchEditorView() |
|
130 QList<NmAddress*> *toAddresses = NmUtilities::qstringListToNmAddressList(uriParser.toAddresses()); |
|
131 QList<NmAddress*> *ccAddresses = NmUtilities::qstringListToNmAddressList(uriParser.ccAddresses()); |
|
132 QList<NmAddress*> *bccAddresses = NmUtilities::qstringListToNmAddressList(uriParser.bccAddresses()); |
|
133 |
|
134 QString* subject = new QString(uriParser.subject()); |
|
135 QString* bodyText = new QString(uriParser.bodyText()); |
|
136 |
270 mStartParam = new NmUiStartParam( |
137 mStartParam = new NmUiStartParam( |
271 NmUiViewMessageEditor, |
138 NmUiViewMessageEditor, |
272 0, // account id |
139 0, // account id |
273 0, // folder id |
140 0, // folder id |
274 0, // message id |
141 0, // message id |
275 NmUiEditorMailto, // editor start mode |
142 NmUiEditorMailto, // editor start mode |
276 dataHelper.mToAddresses, // address list |
143 toAddresses, |
277 NULL, // attachment list |
144 NULL, // attachment list |
278 true, // start as service |
145 true, // start as service |
279 dataHelper.mSubject, // message subject |
146 subject, // message subject |
280 dataHelper.mCcAddresses, // list containing cc recipient addresses |
147 ccAddresses, // list containing cc recipient addresses |
281 dataHelper.mBccAddresses, // list containing bcc recipient addresses |
148 bccAddresses, // list containing bcc recipient addresses |
282 dataHelper.mBodyText // body text |
149 bodyText // body text |
283 ); |
150 ); |
284 |
151 |
285 if (count == 1) { |
152 if (count == 1) { |
286 // A single mailbox exists. |
153 // A single mailbox exists. |
287 QModelIndex modelIndex = mailboxListModel.index(0, 0); |
154 QModelIndex modelIndex = mailboxListModel.index(0, 0); |
288 QVariant mailbox(mailboxListModel.data(modelIndex)); |
155 QVariant mailbox(mailboxListModel.data(modelIndex)); |
289 NmMailboxMetaData *mailboxMetaData = mailbox.value<NmMailboxMetaData*>(); |
156 NmMailboxMetaData *mailboxMetaData = mailbox.value<NmMailboxMetaData*>(); |