|
1 /* |
|
2 * Copyright (c) 2009 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: Offers file share services. |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef __SHARE_UI_PRIVATE_H__ |
|
19 #define __SHARE_UI_PRIVATE_H__ |
|
20 |
|
21 #include <QObject> |
|
22 #include <QMap> |
|
23 #include <QAction> |
|
24 #include <QModelIndex> |
|
25 #include <QStandardItemModel> |
|
26 #include <HbListViewItem> |
|
27 #include <xqappmgr.h> |
|
28 |
|
29 // FORWARD DECLARATIONS |
|
30 class XQAiwRequest; |
|
31 class XQAiwInterfaceDescriptor; |
|
32 class HbAction; |
|
33 class HbDialog; |
|
34 class HbListView; |
|
35 class HbListViewItem; |
|
36 class HbTextItem; |
|
37 class HbIconItem; |
|
38 |
|
39 #define SERVICE_INTERFACE "com.nokia.symbian.IFileShare" |
|
40 #define SHARE_OP "send(QVariant)" |
|
41 |
|
42 /** |
|
43 * Data roles for list |
|
44 */ |
|
45 enum ShareItemDataRole { |
|
46 ProviderNameRole = 10000, |
|
47 ProviderIconRole = 10001 |
|
48 }; |
|
49 |
|
50 /** |
|
51 * Share List item prototype |
|
52 */ |
|
53 class ShareListItem : public HbListViewItem |
|
54 { |
|
55 Q_OBJECT |
|
56 |
|
57 public: |
|
58 ShareListItem(QGraphicsItem* parent=0); |
|
59 HbAbstractViewItem* createItem(); |
|
60 void updateChildItems(); |
|
61 private: |
|
62 HbIconItem* mProviderIcon; |
|
63 HbTextItem *mProviderName; |
|
64 }; |
|
65 |
|
66 /** |
|
67 * Private implementaion of shareui. |
|
68 * implements showing sending services dialog and sending files |
|
69 */ |
|
70 class ShareUiPrivate : public QObject |
|
71 { |
|
72 Q_OBJECT |
|
73 |
|
74 public: |
|
75 |
|
76 /** |
|
77 * Constructor |
|
78 */ |
|
79 ShareUiPrivate(); |
|
80 |
|
81 /** |
|
82 * Destructor |
|
83 */ |
|
84 virtual ~ShareUiPrivate(); |
|
85 |
|
86 /** |
|
87 * Initiate share for the specified files. |
|
88 * @param fileList list of paths to files.eg: c:\images\sunset.jpg |
|
89 * @param embedded true if service launched is embedded in the |
|
90 * launched application. |
|
91 * |
|
92 * @return bool true if dialog initialization successfull. Otherwise false. |
|
93 */ |
|
94 bool init(QStringList& fileList, bool embedded); |
|
95 |
|
96 public slots: |
|
97 |
|
98 /** |
|
99 * Handles setting the arguments for triggered service. |
|
100 */ |
|
101 void onTriggered(void); |
|
102 |
|
103 /** |
|
104 * Slot for handling valid returns from the framework. |
|
105 * @param result const QVariant& |
|
106 */ |
|
107 void handleOk(const QVariant& result); |
|
108 |
|
109 /** |
|
110 * Slot for handling errors. Error ids are provided as |
|
111 * 32-bit integers. |
|
112 * @param errorCode qint32 |
|
113 */ |
|
114 void handleError(int errorCode, const QString& errorMessage); |
|
115 |
|
116 private slots: |
|
117 |
|
118 /** |
|
119 * When a list box item is pressed, this slot should be invoked. The action |
|
120 * corresponding to the clicked list item should be invoked with the stored lis |
|
121 * of files. |
|
122 * |
|
123 * @param index QModelIndex |
|
124 * |
|
125 */ |
|
126 void itemActivated(QModelIndex index); |
|
127 |
|
128 private: |
|
129 /** |
|
130 * Fetch the action associated with a specified interface descriptor. |
|
131 * @param interfaceDescriptor Descriptor got from application manager. |
|
132 * @return The action. |
|
133 */ |
|
134 HbAction* fetchServiceAction(XQAiwInterfaceDescriptor interfaceDescriptor); |
|
135 |
|
136 /** |
|
137 * Creates the view for the share ui dialog. |
|
138 */ |
|
139 void initializeUi(); |
|
140 |
|
141 /** |
|
142 * Update the shareui dialog (and associated list items) once the required |
|
143 * information has been fetched. |
|
144 * @param action HbAction* The action associated with list entry. |
|
145 * @param iconName The icon to be displayed |
|
146 */ |
|
147 void updateShareUiDialogList(HbAction* action, QString iconName); |
|
148 |
|
149 /** |
|
150 * Convert a QAction to HbAction. |
|
151 * @param action QAction* |
|
152 * @return HbAction* |
|
153 */ |
|
154 HbAction* convertAction(QAction *action); |
|
155 |
|
156 #ifdef __SHAREUI_MIME_HANDLING__ |
|
157 /** |
|
158 * Checks if the specified content type is allowed as per the |
|
159 * specified MIME pattern strings. |
|
160 * @param mimeType List of file MIME types |
|
161 * @param mimePattern List of file MIME patterns |
|
162 * @return true if the content is allowed. |
|
163 */ |
|
164 bool isContentAllowed ( QStringList mimeType, QString mimePattern ); |
|
165 |
|
166 /** Checks if the specified content type is blocked as per the |
|
167 * specified MIME pattern strings. |
|
168 * @param mimeType List of file MIME types |
|
169 * @param mimePattern List of file MIME patterns |
|
170 * @return true if the content is blocked. |
|
171 */ |
|
172 bool isContentBlocked ( QStringList mimeType, QString mimePattern ); |
|
173 |
|
174 /** |
|
175 * Get file attributes |
|
176 * @param fileList List of files. |
|
177 * @param mimeTypeList (out) List of MIME types corresponding to the files. |
|
178 * @param forwardStatusList (out) List of forward status corresponding to the files. |
|
179 */ |
|
180 void getFileAttributes ( QStringList& fileList, QStringList& mimeTypeList, |
|
181 QStringList& forwardStatusList ); |
|
182 #endif |
|
183 |
|
184 /** |
|
185 * Show notes |
|
186 */ |
|
187 void showNote(QString text); |
|
188 |
|
189 /** |
|
190 * Reset internal data structures |
|
191 */ |
|
192 void reset(); |
|
193 |
|
194 private: |
|
195 /** |
|
196 * List of files to be sent. |
|
197 */ |
|
198 QList<QVariant> mFileList; |
|
199 |
|
200 /** |
|
201 * Service List |
|
202 */ |
|
203 QList<XQAiwRequest*> mAiwRequestList; |
|
204 |
|
205 /** |
|
206 * ShareUi dialog |
|
207 */ |
|
208 HbDialog* mSharePopup; |
|
209 |
|
210 /** |
|
211 * item model for content list view. |
|
212 */ |
|
213 QStandardItemModel* mContentItemModel; |
|
214 |
|
215 /** |
|
216 * content view |
|
217 */ |
|
218 HbListView* mContentListView; |
|
219 |
|
220 /** |
|
221 * mapping qmodelindex to the action |
|
222 */ |
|
223 QMap<QModelIndex, HbAction*> mIndexActionMap; |
|
224 |
|
225 /** |
|
226 * Application Manager. |
|
227 */ |
|
228 XQApplicationManager mAppManager; |
|
229 |
|
230 /** |
|
231 * Whether to launch the sending application as embedded or not. |
|
232 */ |
|
233 bool mIsEmbedded; |
|
234 }; |
|
235 |
|
236 #endif /* __SHARE_UI_PRIVATE_H__ */ |