40 #include <glxstatemanager.h> |
41 #include <glxstatemanager.h> |
41 #include <glximageviewermanager.h> |
42 #include <glximageviewermanager.h> |
42 #include <glxexternalutility.h> |
43 #include <glxexternalutility.h> |
43 #include "glxlocalisationstrings.h" |
44 #include "glxlocalisationstrings.h" |
44 #include <xqaiwdeclplat.h> |
45 #include <xqaiwdeclplat.h> |
|
46 #include <xqappmgr.h> |
45 |
47 |
46 #define IMAGE_FETCHER_SERVICE_NAME QLatin1String("photos.com.nokia.symbian.IImageFetch") |
48 #define IMAGE_FETCHER_SERVICE_NAME QLatin1String("photos.com.nokia.symbian.IImageFetch") |
47 #define IMAGE_FETCHER_SERVICE_DEPINTERFACE_NAME QLatin1String("photos.Image") |
49 #define IMAGE_FETCHER_SERVICE_DEPINTERFACE_NAME QLatin1String("photos.Image") |
48 #define IMAGE_FETCHER_DEPSERVICE_DEPINTERFACE_NAME QLatin1String("com.nokia.services.media.Image") |
50 #define IMAGE_FETCHER_DEPSERVICE_DEPINTERFACE_NAME QLatin1String("com.nokia.services.media.Image") |
49 #define FILE_VIEWER_SERVICE_NAME QLatin1String("photos.com.nokia.symbian.IFileView") |
51 #define FILE_VIEWER_SERVICE_NAME QLatin1String("photos.com.nokia.symbian.IFileView") |
63 mFetcherService(NULL), |
65 mFetcherService(NULL), |
64 mNSDIService(NULL), |
66 mNSDIService(NULL), |
65 mDSDIService(NULL), |
67 mDSDIService(NULL), |
66 mImageViewerService(NULL) |
68 mImageViewerService(NULL) |
67 { |
69 { |
68 mFetcherService = new GlxGetImageService(this); |
70 QString currentInterfaceName = XQServiceUtil::interfaceName(); |
69 mNSDIService = new GlxGetImageServiceNSDI(this); |
71 if( 0 == currentInterfaceName.compare(QLatin1String("com.nokia.symbian.IImageFetch"))) |
70 mDSDIService = new GlxGetImageServiceDSDI(this); |
72 { |
71 |
73 mFetcherService = new GlxGetImageService(this); |
72 mImageViewerService = new GlxImageViewerService(this); |
74 } |
|
75 else if( 0 == currentInterfaceName.compare(QLatin1String("Image"))) |
|
76 { |
|
77 mNSDIService = new GlxGetImageServiceNSDI(this); |
|
78 mDSDIService = new GlxGetImageServiceDSDI(this); |
|
79 } |
|
80 else if( 0 == currentInterfaceName.compare(QLatin1String("com.nokia.symbian.IFileView"))) |
|
81 { |
|
82 viewport()->setAttribute(Qt::WA_AcceptTouchEvents); |
|
83 viewport()->grabGesture(Qt::PinchGesture); |
|
84 mImageViewerService = new GlxImageViewerService(this); |
|
85 } |
73 |
86 |
74 #ifdef _DEBUG |
87 #ifdef _DEBUG |
75 QString t; |
88 QString t; |
76 QStringList args = QApplication::arguments(); |
89 QStringList args = QApplication::arguments(); |
77 foreach (QString arg, args) |
90 foreach (QString arg, args) |
115 // |
128 // |
116 void GlxAiwServiceHandler::itemSelected(const QModelIndex & index) |
129 void GlxAiwServiceHandler::itemSelected(const QModelIndex & index) |
117 { |
130 { |
118 qDebug() << "GlxFetcher::itemSelected"; |
131 qDebug() << "GlxFetcher::itemSelected"; |
119 |
132 |
120 if (mFetcherService->isActive()) |
133 if (mFetcherService && mFetcherService->isActive()) |
121 { |
134 { |
122 qDebug() << "GlxFetcher::itemSelected mFetcherService->isActive()"; |
135 qDebug() << "GlxFetcher::itemSelected mFetcherService->isActive()"; |
123 QVariant variant = mModel->data(index, GlxUriRole); |
136 QVariant variant = mModel->data(index, GlxUriRole); |
124 if (variant.isValid()) |
137 if (variant.isValid()) |
125 { |
138 { |
127 QStringList list = (QStringList() << itemPath); |
140 QStringList list = (QStringList() << itemPath); |
128 mFetcherService->complete(list); |
141 mFetcherService->complete(list); |
129 } |
142 } |
130 } |
143 } |
131 |
144 |
132 if (mNSDIService->isActive()) |
145 else if (mNSDIService && mNSDIService->isActive()) |
133 { |
146 { |
134 qDebug() << "GlxFetcher::itemSelected mNSDIService->isActive()"; |
147 qDebug() << "GlxFetcher::itemSelected mNSDIService->isActive()"; |
135 QVariant variant = mModel->data(index, GlxUriRole); |
148 QVariant variant = mModel->data(index, GlxUriRole); |
136 if (variant.isValid()) |
149 if (variant.isValid()) |
137 { |
150 { |
139 QStringList list = (QStringList() << itemPath); |
152 QStringList list = (QStringList() << itemPath); |
140 mNSDIService->complete(list); |
153 mNSDIService->complete(list); |
141 } |
154 } |
142 } |
155 } |
143 |
156 |
144 if (mDSDIService->isActive()) |
157 else if (mDSDIService && mDSDIService->isActive()) |
145 { |
158 { |
146 qDebug() << "GlxFetcher::itemSelected mDSDIService->isActive()"; |
159 qDebug() << "GlxFetcher::itemSelected mDSDIService->isActive()"; |
147 QVariant variant = mModel->data(index, GlxUriRole); |
160 QVariant variant = mModel->data(index, GlxUriRole); |
148 if (variant.isValid()) |
161 if (variant.isValid()) |
149 { |
162 { |
154 } |
167 } |
155 } |
168 } |
156 |
169 |
157 |
170 |
158 |
171 |
159 void GlxAiwServiceHandler::launchFetcher() |
172 void GlxAiwServiceHandler::launchFetcher(QString viewTitle) |
160 { |
173 { |
161 qDebug() << "GlxAiwServiceHandler::launchFetcher START"; |
174 qDebug() << "GlxAiwServiceHandler::launchFetcher START"; |
|
175 qApp->setApplicationName(viewTitle); |
162 HbStyleLoader::registerFilePath(":/data/photos.css"); |
176 HbStyleLoader::registerFilePath(":/data/photos.css"); |
163 GlxModelParm modelParm(KGlxCollectionPluginAllImplementationUid, 0); |
177 GlxModelParm modelParm(KGlxCollectionPluginAllImplementationUid, 0); |
164 mModel = new GlxMediaModel(modelParm); |
178 mModel = new GlxMediaModel(modelParm); |
165 |
179 |
166 if ( this->orientation() == Qt::Horizontal ) { |
180 if ( this->orientation() == Qt::Horizontal ) { |
167 mModel->setData(QModelIndex(), (int)GlxContextLsFs, GlxContextRole ); |
181 mModel->setData(QModelIndex(), (int)GlxContextLsGrid, GlxContextRole ); |
168 } |
182 } |
169 else { |
183 else { |
170 mModel->setData(QModelIndex(), (int)GlxContextPtFs, GlxContextRole ); |
184 mModel->setData(QModelIndex(), (int)GlxContextPtGrid, GlxContextRole ); |
171 } |
185 } |
172 |
186 |
173 mView = GlxViewsFactory::createView(GLX_GRIDVIEW_ID, this); |
187 mView = GlxViewsFactory::createView(GLX_GRIDVIEW_ID, this); |
174 mView->activate(); |
188 mView->activate(); |
175 mView->setModel(mModel); |
189 mView->setModel(mModel); |
182 Qt::QueuedConnection ); |
196 Qt::QueuedConnection ); |
183 qDebug() << "GlxAiwServiceHandler::launchFetcher END"; |
197 qDebug() << "GlxAiwServiceHandler::launchFetcher END"; |
184 } |
198 } |
185 |
199 |
186 void GlxAiwServiceHandler::itemSpecificMenuTriggered(qint32 viewId,QPointF pos) |
200 void GlxAiwServiceHandler::itemSpecificMenuTriggered(qint32 viewId,QPointF pos) |
187 { |
201 { |
188 mFetcherContextMenu = new HbMenu(); |
202 mFetcherContextMenu = new HbMenu(); |
189 HbAction *action = mFetcherContextMenu->addAction(GLX_MENU_OPEN); |
203 HbAction *action = mFetcherContextMenu->addAction(GLX_MENU_OPEN); |
|
204 action->setObjectName( "Menu Open" ); |
190 connect(action, SIGNAL(triggered()), this, SLOT(openFSView())); |
205 connect(action, SIGNAL(triggered()), this, SLOT(openFSView())); |
191 connect(this, SIGNAL(aboutToChangeOrientation ()), mFetcherContextMenu, SLOT(close())); |
206 connect(this, SIGNAL(aboutToChangeOrientation ()), mFetcherContextMenu, SLOT(close())); |
192 connect( mFetcherContextMenu, SIGNAL( aboutToClose () ), this, SLOT( closeContextMenu() ) ); |
207 connect( mFetcherContextMenu, SIGNAL( aboutToClose () ), this, SLOT( closeContextMenu() ) ); |
193 mFetcherContextMenu->setPreferredPos( pos ); |
208 mFetcherContextMenu->setPreferredPos( pos ); |
194 mFetcherContextMenu->show(); |
209 mFetcherContextMenu->show(); |
195 } |
210 } |
196 |
211 |
197 void GlxAiwServiceHandler::closeContextMenu() |
212 void GlxAiwServiceHandler::closeContextMenu() |
198 { |
213 { |
199 disconnect( this, SIGNAL( aboutToChangeOrientation () ), mFetcherContextMenu, SLOT( close() ) ); |
214 disconnect( this, SIGNAL( aboutToChangeOrientation () ), mFetcherContextMenu, SLOT( close() ) ); |
200 disconnect( mFetcherContextMenu, SIGNAL( aboutToClose () ), this, SLOT( closeContextMenu() ) ); |
215 disconnect( mFetcherContextMenu, SIGNAL( aboutToClose () ), this, SLOT( closeContextMenu() ) ); |
202 mFetcherContextMenu = NULL; |
217 mFetcherContextMenu = NULL; |
203 } |
218 } |
204 |
219 |
205 void GlxAiwServiceHandler::openFSView() |
220 void GlxAiwServiceHandler::openFSView() |
206 { |
221 { |
|
222 if ( this->orientation() == Qt::Horizontal ) { |
|
223 mModel->setData(QModelIndex(), (int)GlxContextLsFs, GlxContextRole ); |
|
224 } |
|
225 else { |
|
226 mModel->setData(QModelIndex(), (int)GlxContextPtFs, GlxContextRole ); |
|
227 } |
207 HbAction* selectAction = new HbAction(GLX_BUTTON_SELECT); |
228 HbAction* selectAction = new HbAction(GLX_BUTTON_SELECT); |
|
229 selectAction->setObjectName( "FS Select" ); |
|
230 |
208 connect(selectAction, SIGNAL(triggered()), this, SLOT(handleFSSelect())); |
231 connect(selectAction, SIGNAL(triggered()), this, SLOT(handleFSSelect())); |
209 HbToolBar* toolBar = new HbToolBar(); |
232 HbToolBar* toolBar = new HbToolBar(); |
210 toolBar->setOrientation( Qt::Horizontal ); |
233 toolBar->setOrientation( Qt::Horizontal ); |
211 toolBar->setVisible(true); |
234 toolBar->setVisible(true); |
212 toolBar->addAction(selectAction); |
235 toolBar->addAction(selectAction); |
315 // ---------------------------------------------------------------------------- |
338 // ---------------------------------------------------------------------------- |
316 // |
339 // |
317 void GlxGetImageService::fetch() |
340 void GlxGetImageService::fetch() |
318 { |
341 { |
319 mImageRequestIndex = setCurrentRequestAsync(); |
342 mImageRequestIndex = setCurrentRequestAsync(); |
320 mServiceApp->launchFetcher(); |
343 QString title = requestInfo().info("WindowTitle").toString(); |
|
344 if(title.isNull()){ |
|
345 title = QString("Image Fetcher"); |
|
346 } |
|
347 mServiceApp->launchFetcher(title); |
321 } |
348 } |
322 |
349 |
323 // ---------------------------------------------------------------------------- |
350 // ---------------------------------------------------------------------------- |
324 // GlxGetImageService() |
351 // GlxGetImageService() |
325 // ---------------------------------------------------------------------------- |
352 // ---------------------------------------------------------------------------- |
404 // |
431 // |
405 void GlxGetImageServiceNSDI::fetch() |
432 void GlxGetImageServiceNSDI::fetch() |
406 { |
433 { |
407 qDebug() << "GlxGetImageServiceNSDI::fetch START"; |
434 qDebug() << "GlxGetImageServiceNSDI::fetch START"; |
408 mImageRequestIndex = setCurrentRequestAsync(); |
435 mImageRequestIndex = setCurrentRequestAsync(); |
409 mServiceApp->launchFetcher(); |
436 QString title = requestInfo().info("WindowTitle").toString(); |
|
437 if(title.isNull()){ |
|
438 title = QString("Image Fetcher"); |
|
439 } |
|
440 mServiceApp->launchFetcher(title); |
410 qDebug() << "GlxGetImageServiceNSDI::fetch END"; |
441 qDebug() << "GlxGetImageServiceNSDI::fetch END"; |
411 } |
442 } |
412 |
443 |
413 //==============================================================================// |
444 //==============================================================================// |
414 // ---------------------------------------------------------------------------- |
445 // ---------------------------------------------------------------------------- |
483 void GlxGetImageServiceDSDI::fetch(QVariantMap filter, QVariant flag) |
514 void GlxGetImageServiceDSDI::fetch(QVariantMap filter, QVariant flag) |
484 { |
515 { |
485 Q_UNUSED(filter) |
516 Q_UNUSED(filter) |
486 Q_UNUSED(flag) |
517 Q_UNUSED(flag) |
487 mImageRequestIndex = setCurrentRequestAsync(); |
518 mImageRequestIndex = setCurrentRequestAsync(); |
488 mServiceApp->launchFetcher(); |
519 QString title = requestInfo().info("WindowTitle").toString(); |
|
520 if(title.isNull()){ |
|
521 title = QString("Image Fetcher"); |
|
522 } |
|
523 mServiceApp->launchFetcher(title); |
489 } |
524 } |
490 |
525 |
491 // ----------GlxImageViewerService--------------- |
526 // ----------GlxImageViewerService--------------- |
492 |
527 |
493 GlxImageViewerService::GlxImageViewerService(GlxAiwServiceHandler* parent) : |
528 GlxImageViewerService::GlxImageViewerService(GlxAiwServiceHandler* parent) : |
516 completeRequest(mAsyncReqId, QVariant(ok)); |
551 completeRequest(mAsyncReqId, QVariant(ok)); |
517 } |
552 } |
518 |
553 |
519 bool GlxImageViewerService::view(QString file) |
554 bool GlxImageViewerService::view(QString file) |
520 { |
555 { |
|
556 XQApplicationManager appmgr; |
|
557 QFile tempfile(file); |
|
558 QVariantList attrValues; |
|
559 QList<int> attrNames; |
|
560 attrNames.append(XQApplicationManager::IsProtected); |
|
561 bool ok = appmgr.getDrmAttributes(tempfile, attrNames, attrValues); |
|
562 if(attrValues.at(0).toBool()){ |
|
563 HbNotificationDialog::launchDialog("NOT SUPPORTED"); |
|
564 connect(this, SIGNAL(returnValueDelivered()), mServiceApp, |
|
565 SLOT(handleAnswerDelivered())); |
|
566 complete(true); |
|
567 return false; |
|
568 } |
|
569 |
521 XQRequestInfo info = requestInfo(); |
570 XQRequestInfo info = requestInfo(); |
522 mAsyncRequest = !info.isSynchronous(); |
571 mAsyncRequest = !info.isSynchronous(); |
523 if (!mImageViewerInstance) |
572 if (!mImageViewerInstance) |
524 { |
573 { |
525 mImageViewerInstance = CGlxImageViewerManager::InstanceL(); |
574 mImageViewerInstance = CGlxImageViewerManager::InstanceL(); |
526 } |
575 } |
527 QString filepath(QDir::toNativeSeparators(file.at(0))); |
576 QString filepath(QDir::toNativeSeparators(file)); |
528 TPtrC16 str(reinterpret_cast<const TUint16*> (filepath.utf16())); |
577 TPtrC16 str(reinterpret_cast<const TUint16*> (filepath.utf16())); |
529 HBufC* uri = str.Alloc(); |
578 HBufC* uri = str.Alloc(); |
530 |
579 |
531 mImageViewerInstance->SetImageUriL(*uri); |
580 mImageViewerInstance->SetImageUriL(*uri); |
532 if (mAsyncRequest) |
581 if (mAsyncRequest) |