calendarui/calenlauncher/src/calenlauncher.cpp
branchRCL_3
changeset 65 12af337248b1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/calendarui/calenlauncher/src/calenlauncher.cpp	Tue Aug 31 15:13:43 2010 +0300
@@ -0,0 +1,80 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Calendar launcher
+*
+*/
+// System includes
+#include <xqservicerequest.h>
+
+// User includes
+#include <calenlauncher.h>
+
+/*!
+	\class CalenLauncher
+ */
+/*!
+	Constructor.
+
+	\param parent QObject pointer.
+ */
+CalenLauncher::CalenLauncher(QObject* parent)
+:QObject(parent)
+{
+}
+
+/*!
+  Destructor
+ */
+CalenLauncher::~CalenLauncher()
+{
+}
+
+/*!
+	API to launch the calendar application
+	\param view Claendar view to be launches
+	\param dateTime Date pertaining to which view has to be populated
+	\param synchronousLaunch bool value to tell whethe calendar has
+			to be launched synchronously or asynchronously
+ */
+void CalenLauncher::launchCalendarApp(CalenView view, 
+									QDateTime& dateTime, 
+									bool synchronousLaunch)
+{
+	// launch the calendar application
+	XQServiceRequest request("com.nokia.services.calendar.Launch", 
+	                         "launchCalendarApp(QDateTime,int)",synchronousLaunch);
+	// Pass the arguments needed
+	request << dateTime;
+	request << ((int)view);
+	
+	int retValue;
+	bool res = request.send(retValue);
+	if (!res && synchronousLaunch) {
+		int error = request.latestError();
+		// Emit the signal with the error id to the caller
+		emit calendarLaunchFailed(error);
+	}
+	
+	if (!synchronousLaunch) {
+		// Connect to the signal for async request
+		connect(&request, SIGNAL(requestError(int)), this, SLOT(handleError(int)));
+	}
+}																			
+
+void CalenLauncher::handleError(int error)
+{
+	// emit the signal to the client
+	emit calendarLaunchFailed(error);
+}
+// End of file	--Don't remove this.