main/glxaiwservicehandler.cpp
changeset 71 27f2d7aec52a
parent 65 ccee5c4b0de4
--- a/main/glxaiwservicehandler.cpp	Mon Sep 27 15:13:20 2010 +0530
+++ b/main/glxaiwservicehandler.cpp	Wed Oct 06 14:49:39 2010 +0530
@@ -42,6 +42,7 @@
 #define IMAGE_FETCHER_SERVICE_DEPINTERFACE_NAME QLatin1String("photos.Image")
 #define IMAGE_FETCHER_DEPSERVICE_DEPINTERFACE_NAME QLatin1String("com.nokia.services.media.Image")
 #define FILE_VIEWER_SERVICE_NAME QLatin1String("photos.com.nokia.symbian.IFileView")
+#define FILE_BROWSER_SERVICE_NAME QLatin1String("photos.com.nokia.symbian.IImageBrowse")
 #define XQINFO_KEY_FILTER_TYPE QLatin1String("GlxFetcherFilter")
 
 // ----------------------------------------------------------------------------
@@ -54,7 +55,8 @@
     mFetcherService(NULL),
     mNSDIService(NULL),
     mDSDIService(NULL),
-    mImageViewerService(NULL)
+    mImageViewerService(NULL),
+	mImageBrowserService(NULL)
     {
     QString currentInterfaceName = XQServiceUtil::interfaceName();
     if( 0 == currentInterfaceName.compare(QLatin1String("com.nokia.symbian.IImageFetch")))
@@ -72,6 +74,10 @@
 		viewport()->grabGesture(Qt::PinchGesture);
         mImageViewerService = new GlxImageViewerService(this);
         }
+    else if( 0 == currentInterfaceName.compare(QLatin1String("com.nokia.symbian.IImageBrowse")))
+        {
+        mImageBrowserService = new GlxBrowseImageService(this);
+        }
 
 #ifdef _DEBUG
 	QString t;
@@ -95,6 +101,7 @@
     delete mNSDIService;
     delete mDSDIService;
     delete mImageViewerService;
+	delete mImageBrowserService;
     }
 
 void GlxAiwServiceHandler::handleClientDisconnect()
@@ -182,6 +189,21 @@
         }
     return;
     }
+
+void GlxAiwServiceHandler::launchImageBrowser(QString viewTitle)
+    {
+    qApp->setApplicationName(viewTitle);
+    mStateMgr = new GlxStateManager();
+	mStateMgr->launchFetcher(0);
+    if (mImageBrowserService && mImageBrowserService->asyncRequest())
+        {
+        connect(mImageBrowserService, SIGNAL(returnValueDelivered()), this,
+                SLOT(handleAnswerDelivered()));
+        mImageBrowserService->complete(true);
+        }
+    return;
+    }
+	
 // ----------------------------------------------------------------------------
 // GlxGetImageService()
 // ----------------------------------------------------------------------------
@@ -562,5 +584,41 @@
     return true;
     }
 
+// ----------GlxBrowseImageService---------------
+
+GlxBrowseImageService::GlxBrowseImageService(GlxAiwServiceHandler* parent) :
+    XQServiceProvider(FILE_BROWSER_SERVICE_NAME, parent),
+            mServiceApp(parent), mAsyncReqId(-1), mAsyncRequest(false)
+
+    {
+    publishAll();
+    connect(this, SIGNAL(clientDisconnected()), mServiceApp,
+            SLOT(handleClientDisconnect()));
+    }
+
+GlxBrowseImageService::~GlxBrowseImageService()
+    {
+    }
+
+void GlxBrowseImageService::complete(bool ok)
+    {
+    if (mAsyncReqId == -1)
+        return;
+    completeRequest(mAsyncReqId, QVariant(ok));
+    }
+
+void GlxBrowseImageService::browse()
+    {
+	mServiceApp->launchImageBrowser(GLX_TITLE);
+    XQRequestInfo info = requestInfo();
+    mAsyncRequest = !info.isSynchronous();
+	
+    if (mAsyncRequest)
+        {
+        mAsyncReqId = setCurrentRequestAsync();
+        connect(this, SIGNAL(clientDisconnected()), this,
+                SLOT(handleClientDisconnect()));
+        }
+    }