Binary file doc/html.rar has changed
Binary file doc/smfhelp.chm has changed
--- a/example/AuthApp/ui_AuthApp.h Thu Sep 16 11:15:30 2010 +0530
+++ b/example/AuthApp/ui_AuthApp.h Thu Sep 23 17:15:03 2010 +0530
@@ -1,7 +1,7 @@
/********************************************************************************
** Form generated from reading UI file 'AuthApp.ui'
**
-** Created: Fri Jul 30 14:06:33 2010
+** Created: Wed Sep 22 18:28:00 2010
** by: Qt User Interface Compiler version 4.6.2
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
--- a/example/AuthApp/ui_progressbar.h Thu Sep 16 11:15:30 2010 +0530
+++ b/example/AuthApp/ui_progressbar.h Thu Sep 23 17:15:03 2010 +0530
@@ -1,7 +1,7 @@
/********************************************************************************
** Form generated from reading UI file 'progressbar.ui'
**
-** Created: Fri Jul 30 14:06:30 2010
+** Created: Wed Sep 22 18:27:56 2010
** by: Qt User Interface Compiler version 4.6.2
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
--- a/example/DemoGUI/.cproject Thu Sep 16 11:15:30 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,133 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<?fileVersion 4.0.0?>
-
-<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
-<storageModule buildFromInf="true" buildingTestComps="true" cleanLevel="0" concurrentBuildJobs="4" defaultMMPChangedAction="0" extraSBSv2Args="" infBuildComponents="" infFileLocation="bld.inf" macrosFile="" makeEngineToUse="make" manageDependencies="true" moduleId="com.nokia.carbide.cdt.builder.carbideCPPBuilder" overrideMakeEngine="false" overrideWorkspaceSettings="false" promptForMMPChangedAction="true" useConcurrentBuilding="true" useDebugMode="false" useIncrementalBuilder="false" useKeepGoing="false" useMMPMacros="true"/>
-<storageModule moduleId="org.eclipse.cdt.core.settings">
-<cconfiguration id="Emulator Debug (WINSCW) [Nokia_Symbian3_SDK_v0.8]">
-<storageModule buildSystemId="com.nokia.carbide.cdt.builder.CarbideConfigurationDataProvider" id="Emulator Debug (WINSCW) [Nokia_Symbian3_SDK_v0.8]" moduleId="org.eclipse.cdt.core.settings" name="Emulator Debug (WINSCW) [Nokia_Symbian3_SDK_v0.8]">
-<externalSettings/>
-<extensions>
-<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
-<extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>
-<extension id="com.nokia.cdt.debug.cw.symbian.SymbianE32" point="org.eclipse.cdt.core.BinaryParser"/>
-<extension id="com.nokia.carbide.cdt.builder.MakmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-<extension id="com.nokia.carbide.cdt.builder.CarbideMakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-<extension id="com.nokia.carbide.cdt.builder.SBSv2ErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-<extension id="com.nokia.carbide.cdt.builder.MWLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-<extension id="com.nokia.carbide.cdt.builder.RCOMPErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-<extension id="com.nokia.carbide.cdt.builder.MWCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-<extension id="com.nokia.carbide.cdt.builder.MakeDefErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-</extensions>
-</storageModule>
-<storageModule moduleId="CarbideConfigurationDataProvider">
-<ENV_VAR_DATA_ID/>
-<ARGUMENTS_DATA_ID ABLDFREEZEARGSSTORAGE="-r"/>
-<ROM_BUILDER_DATA_ID ROMBUILDWORKINGDIRECTORYSTORAGE="D:\S60\devices\Nokia_Symbian3_SDK_v0.8\epoc32\rom\"/>
-</storageModule>
-<storageModule filesCache="D:\smf\MissingCode\DemoGUI\DemoGUI_0xE9d1bae8.mmp;D:\smf\MissingCode\DemoGUI\bld.inf;" includesCache="D:/Qt/4.6.2/include/QtCore;D:/Qt/4.6.2/include/QtCore/tmp;D:/Qt/4.6.2/include/QtNetwork;D:/Qt/4.6.2/include/QtNetwork/tmp;D:/Qt/4.6.2/include/QtGui;D:/Qt/4.6.2/include/QtGui/tmp;D:/Qt/4.6.2/include;D:/Qt/4.6.2/include/tmp;D:/smf/MissingCode/DemoGUI;D:/smf/MissingCode/DemoGUI/tmp;D:/Qt/4.6.2/mkspecs/common/symbian;D:/Qt/4.6.2/mkspecs/common/symbian/tmp;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/stdapis;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/stdapis/sys;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/mw;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/platform/mw;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/platform;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/app;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/platform/app;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/platform/mw/loc;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/platform/app/loc;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/platform/mw/loc/sc;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/stdapis/stlportv5;" macrosCache="QT_CORE_LIB;_UNICODE;__SUPPORT_CPP_EXCEPTIONS__;__WINSCW__;__SYMBIAN32__;QT_KEYPAD_NAVIGATION;__EXE__;QT_USE_MATH_H_FLOATS;__CW32__;__WINS__;QT_GUI_LIB;UNICODE;QT_NETWORK_LIB;QT_SOFTKEYS_ENABLED;_DEBUG;" moduleId="configDataCache" sourcesCache="" timestampCache="1280473572226" useMmpMacrosCache="true"/>
-<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
-</cconfiguration>
-<cconfiguration id="Phone Debug (ARMV5) [Nokia_Symbian3_SDK_v0.8]">
-<storageModule buildSystemId="com.nokia.carbide.cdt.builder.CarbideConfigurationDataProvider" id="Phone Debug (ARMV5) [Nokia_Symbian3_SDK_v0.8]" moduleId="org.eclipse.cdt.core.settings" name="Phone Debug (ARMV5) [Nokia_Symbian3_SDK_v0.8]">
-<externalSettings/>
-<extensions>
-<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
-<extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>
-<extension id="com.nokia.cdt.debug.cw.symbian.SymbianE32" point="org.eclipse.cdt.core.BinaryParser"/>
-<extension id="com.nokia.carbide.cdt.builder.MakmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-<extension id="com.nokia.carbide.cdt.builder.RVCTLinkerErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-<extension id="com.nokia.carbide.cdt.builder.CarbideMakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-<extension id="com.nokia.carbide.cdt.builder.SBSv2ErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-<extension id="com.nokia.carbide.cdt.builder.Elf2E32ErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-<extension id="com.nokia.carbide.cdt.builder.RCOMPErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-<extension id="com.nokia.carbide.cdt.builder.MakeDefErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-<extension id="com.nokia.carbide.cdt.builder.RVCTCompilerErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-</extensions>
-</storageModule>
-<storageModule moduleId="CarbideConfigurationDataProvider">
-<ENV_VAR_DATA_ID/>
-<ARGUMENTS_DATA_ID ABLDFREEZEARGSSTORAGE="-r"/>
-<ROM_BUILDER_DATA_ID ROMBUILDWORKINGDIRECTORYSTORAGE="D:\S60\devices\Nokia_Symbian3_SDK_v0.8\epoc32\rom\"/>
-</storageModule>
-<storageModule filesCache="D:\smf\MissingCode\DemoGUI\DemoGUI_0xE9d1bae8.mmp;D:\smf\MissingCode\DemoGUI\bld.inf;" includesCache="D:/Qt/4.6.2/include/QtCore;D:/Qt/4.6.2/include/QtCore/tmp;D:/Qt/4.6.2/include/QtNetwork;D:/Qt/4.6.2/include/QtNetwork/tmp;D:/Qt/4.6.2/include/QtGui;D:/Qt/4.6.2/include/QtGui/tmp;D:/Qt/4.6.2/include;D:/Qt/4.6.2/include/tmp;D:/smf/MissingCode/DemoGUI;D:/smf/MissingCode/DemoGUI/tmp;D:/Qt/4.6.2/mkspecs/common/symbian;D:/Qt/4.6.2/mkspecs/common/symbian/tmp;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/stdapis;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/stdapis/sys;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/mw;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/platform/mw;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/platform;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/app;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/platform/app;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/platform/mw/loc;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/platform/app/loc;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/platform/mw/loc/sc;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/stdapis/stlportv5;" macrosCache="QT_CORE_LIB;_UNICODE;__SUPPORT_CPP_EXCEPTIONS__;__MARM_ARMV5__;__ARMCC__;__ARMCC_2_2__;__SYMBIAN32__;QT_KEYPAD_NAVIGATION;__MARM__;QT_USE_MATH_H_FLOATS;__EXE__;__ARMCC_2__;__EPOC32__;__GENERIC_MARM__;QT_GUI_LIB;UNICODE;QT_NETWORK_LIB;QT_SOFTKEYS_ENABLED;__EABI__;_DEBUG;" moduleId="configDataCache" sourcesCache="" timestampCache="1280473572257" useMmpMacrosCache="true"/>
-</cconfiguration>
-<cconfiguration id="Phone Release (ARMV5) [Nokia_Symbian3_SDK_v0.8]">
-<storageModule buildSystemId="com.nokia.carbide.cdt.builder.CarbideConfigurationDataProvider" id="Phone Release (ARMV5) [Nokia_Symbian3_SDK_v0.8]" moduleId="org.eclipse.cdt.core.settings" name="Phone Release (ARMV5) [Nokia_Symbian3_SDK_v0.8]">
-<externalSettings/>
-<extensions>
-<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
-<extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>
-<extension id="com.nokia.cdt.debug.cw.symbian.SymbianE32" point="org.eclipse.cdt.core.BinaryParser"/>
-<extension id="com.nokia.carbide.cdt.builder.MakmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-<extension id="com.nokia.carbide.cdt.builder.RVCTLinkerErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-<extension id="com.nokia.carbide.cdt.builder.CarbideMakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-<extension id="com.nokia.carbide.cdt.builder.SBSv2ErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-<extension id="com.nokia.carbide.cdt.builder.Elf2E32ErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-<extension id="com.nokia.carbide.cdt.builder.RCOMPErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-<extension id="com.nokia.carbide.cdt.builder.MakeDefErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-<extension id="com.nokia.carbide.cdt.builder.RVCTCompilerErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-</extensions>
-</storageModule>
-<storageModule moduleId="CarbideConfigurationDataProvider">
-<ENV_VAR_DATA_ID/>
-<ARGUMENTS_DATA_ID ABLDFREEZEARGSSTORAGE="-r"/>
-<ROM_BUILDER_DATA_ID ROMBUILDWORKINGDIRECTORYSTORAGE="D:\S60\devices\Nokia_Symbian3_SDK_v0.8\epoc32\rom\"/>
-</storageModule>
-<storageModule filesCache="D:\smf\MissingCode\DemoGUI\DemoGUI_0xE9d1bae8.mmp;D:\smf\MissingCode\DemoGUI\bld.inf;" includesCache="D:/Qt/4.6.2/include/QtCore;D:/Qt/4.6.2/include/QtCore/tmp;D:/Qt/4.6.2/include/QtNetwork;D:/Qt/4.6.2/include/QtNetwork/tmp;D:/Qt/4.6.2/include/QtGui;D:/Qt/4.6.2/include/QtGui/tmp;D:/Qt/4.6.2/include;D:/Qt/4.6.2/include/tmp;D:/smf/MissingCode/DemoGUI;D:/smf/MissingCode/DemoGUI/tmp;D:/Qt/4.6.2/mkspecs/common/symbian;D:/Qt/4.6.2/mkspecs/common/symbian/tmp;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/stdapis;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/stdapis/sys;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/mw;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/platform/mw;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/platform;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/app;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/platform/app;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/platform/mw/loc;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/platform/app/loc;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/platform/mw/loc/sc;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/stdapis/stlportv5;" macrosCache="QT_CORE_LIB;_UNICODE;__SUPPORT_CPP_EXCEPTIONS__;__MARM_ARMV5__;NDEBUG;__ARMCC__;__ARMCC_2_2__;__SYMBIAN32__;QT_KEYPAD_NAVIGATION;__MARM__;QT_USE_MATH_H_FLOATS;__EXE__;__ARMCC_2__;__EPOC32__;__GENERIC_MARM__;QT_GUI_LIB;UNICODE;QT_NETWORK_LIB;QT_SOFTKEYS_ENABLED;__EABI__;" moduleId="configDataCache" sourcesCache="" timestampCache="1280473572273" useMmpMacrosCache="true"/>
-</cconfiguration>
-<cconfiguration id="Phone Debug (GCCE) [Nokia_Symbian3_SDK_v0.8]">
-<storageModule buildSystemId="com.nokia.carbide.cdt.builder.CarbideConfigurationDataProvider" id="Phone Debug (GCCE) [Nokia_Symbian3_SDK_v0.8]" moduleId="org.eclipse.cdt.core.settings" name="Phone Debug (GCCE) [Nokia_Symbian3_SDK_v0.8]">
-<externalSettings/>
-<extensions>
-<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
-<extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>
-<extension id="com.nokia.cdt.debug.cw.symbian.SymbianE32" point="org.eclipse.cdt.core.BinaryParser"/>
-<extension id="com.nokia.carbide.cdt.builder.MakmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-<extension id="com.nokia.carbide.cdt.builder.CarbideMakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-<extension id="com.nokia.carbide.cdt.builder.SBSv2ErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-<extension id="com.nokia.carbide.cdt.builder.Elf2E32ErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-<extension id="com.nokia.carbide.cdt.builder.RCOMPErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-<extension id="com.nokia.carbide.cdt.builder.GCCECompilerErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-<extension id="com.nokia.carbide.cdt.builder.MakeDefErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-<extension id="com.nokia.carbide.cdt.builder.GCCEAssemblerErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-<extension id="com.nokia.carbide.cdt.builder.GCCELinkerErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-</extensions>
-</storageModule>
-<storageModule moduleId="CarbideConfigurationDataProvider">
-<ENV_VAR_DATA_ID/>
-<ARGUMENTS_DATA_ID ABLDFREEZEARGSSTORAGE="-r"/>
-<ROM_BUILDER_DATA_ID ROMBUILDWORKINGDIRECTORYSTORAGE="D:\S60\devices\Nokia_Symbian3_SDK_v0.8\epoc32\rom\"/>
-</storageModule>
-<storageModule filesCache="D:\smf\MissingCode\DemoGUI\DemoGUI_0xE9d1bae8.mmp;D:\smf\MissingCode\DemoGUI\bld.inf;" includesCache="D:/Qt/4.6.2/include/QtCore;D:/Qt/4.6.2/include/QtCore/tmp;D:/Qt/4.6.2/include/QtNetwork;D:/Qt/4.6.2/include/QtNetwork/tmp;D:/Qt/4.6.2/include/QtGui;D:/Qt/4.6.2/include/QtGui/tmp;D:/Qt/4.6.2/include;D:/Qt/4.6.2/include/tmp;D:/smf/MissingCode/DemoGUI;D:/smf/MissingCode/DemoGUI/tmp;D:/Qt/4.6.2/mkspecs/common/symbian;D:/Qt/4.6.2/mkspecs/common/symbian/tmp;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/stdapis;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/stdapis/sys;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/mw;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/platform/mw;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/platform;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/app;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/platform/app;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/platform/mw/loc;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/platform/app/loc;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/platform/mw/loc/sc;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/stdapis/stlportv5;" macrosCache="QT_CORE_LIB;_UNICODE;__SUPPORT_CPP_EXCEPTIONS__;__MARM_ARMV5__;__SYMBIAN32__;QT_KEYPAD_NAVIGATION;__GCCE__;__MARM__;QT_USE_MATH_H_FLOATS;__EXE__;__EPOC32__;__GENERIC_MARM__;QT_GUI_LIB;UNICODE;QT_NETWORK_LIB;QT_SOFTKEYS_ENABLED;__EABI__;_DEBUG;" moduleId="configDataCache" sourcesCache="" timestampCache="1280473572304" useMmpMacrosCache="true"/>
-</cconfiguration>
-<cconfiguration id="Phone Release (GCCE) [Nokia_Symbian3_SDK_v0.8]">
-<storageModule buildSystemId="com.nokia.carbide.cdt.builder.CarbideConfigurationDataProvider" id="Phone Release (GCCE) [Nokia_Symbian3_SDK_v0.8]" moduleId="org.eclipse.cdt.core.settings" name="Phone Release (GCCE) [Nokia_Symbian3_SDK_v0.8]">
-<externalSettings/>
-<extensions>
-<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
-<extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>
-<extension id="com.nokia.cdt.debug.cw.symbian.SymbianE32" point="org.eclipse.cdt.core.BinaryParser"/>
-<extension id="com.nokia.carbide.cdt.builder.MakmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-<extension id="com.nokia.carbide.cdt.builder.CarbideMakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-<extension id="com.nokia.carbide.cdt.builder.SBSv2ErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-<extension id="com.nokia.carbide.cdt.builder.Elf2E32ErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-<extension id="com.nokia.carbide.cdt.builder.RCOMPErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-<extension id="com.nokia.carbide.cdt.builder.GCCECompilerErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-<extension id="com.nokia.carbide.cdt.builder.MakeDefErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-<extension id="com.nokia.carbide.cdt.builder.GCCEAssemblerErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-<extension id="com.nokia.carbide.cdt.builder.GCCELinkerErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
-</extensions>
-</storageModule>
-<storageModule moduleId="CarbideConfigurationDataProvider">
-<ENV_VAR_DATA_ID/>
-<ARGUMENTS_DATA_ID ABLDFREEZEARGSSTORAGE="-r"/>
-<ROM_BUILDER_DATA_ID ROMBUILDWORKINGDIRECTORYSTORAGE="D:\S60\devices\Nokia_Symbian3_SDK_v0.8\epoc32\rom\"/>
-</storageModule>
-<storageModule filesCache="D:\smf\MissingCode\DemoGUI\DemoGUI_0xE9d1bae8.mmp;D:\smf\MissingCode\DemoGUI\bld.inf;" includesCache="D:/Qt/4.6.2/include/QtCore;D:/Qt/4.6.2/include/QtCore/tmp;D:/Qt/4.6.2/include/QtNetwork;D:/Qt/4.6.2/include/QtNetwork/tmp;D:/Qt/4.6.2/include/QtGui;D:/Qt/4.6.2/include/QtGui/tmp;D:/Qt/4.6.2/include;D:/Qt/4.6.2/include/tmp;D:/smf/MissingCode/DemoGUI;D:/smf/MissingCode/DemoGUI/tmp;D:/Qt/4.6.2/mkspecs/common/symbian;D:/Qt/4.6.2/mkspecs/common/symbian/tmp;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/stdapis;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/stdapis/sys;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/mw;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/platform/mw;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/platform;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/app;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/platform/app;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/platform/mw/loc;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/platform/app/loc;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/platform/mw/loc/sc;D:/S60/devices/Nokia_Symbian3_SDK_v0.8/epoc32/include/stdapis/stlportv5;" macrosCache="QT_CORE_LIB;_UNICODE;__SUPPORT_CPP_EXCEPTIONS__;__MARM_ARMV5__;NDEBUG;__SYMBIAN32__;QT_KEYPAD_NAVIGATION;__GCCE__;__MARM__;QT_USE_MATH_H_FLOATS;__EXE__;__EPOC32__;__GENERIC_MARM__;QT_GUI_LIB;UNICODE;QT_NETWORK_LIB;QT_SOFTKEYS_ENABLED;__EABI__;" moduleId="configDataCache" sourcesCache="" timestampCache="1280473572320" useMmpMacrosCache="true"/>
-</cconfiguration>
-</storageModule>
-</cproject>
--- a/example/DemoGUI/ImageDownload.cpp Thu Sep 16 11:15:30 2010 +0530
+++ b/example/DemoGUI/ImageDownload.cpp Thu Sep 23 17:15:03 2010 +0530
@@ -65,9 +65,6 @@
// For proxy settings on emulator only - REMOVE for device
QString httpProxy = "10.1.0.214";
QString httpPort = "3128";
-
- qDebug()<<httpUser;
- qDebug()<<httpPass;
//==Classes used from Network Module==
QNetworkProxy proxy;
--- a/example/DemoGUI/tmp/.svn/all-wcprops Thu Sep 16 11:15:30 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-K 25
-svn:wc:ra_dav:version-url
-V 120
-/svn/symbian/!svn/ver/414/products/s-series/engg/symbian/s60-app-dev/SocialMobileFrameWork/MissingCodeForSmf/DemoGUI/tmp
-END
--- a/example/DemoGUI/tmp/.svn/entries Thu Sep 16 11:15:30 2010 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-10
-
-dir
-415
-http://svnz02/svn/symbian/products/s-series/engg/symbian/s60-app-dev/SocialMobileFrameWork/MissingCodeForSmf/DemoGUI/tmp
-http://svnz02/svn/symbian
-
-
-
-2010-07-30T12:20:29.303136Z
-414
-nalinah
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-ddc49ed9-7720-479e-b42b-43a572c34f33
-
--- a/example/DemoGUI/ui_mainwindow.h Thu Sep 16 11:15:30 2010 +0530
+++ b/example/DemoGUI/ui_mainwindow.h Thu Sep 23 17:15:03 2010 +0530
@@ -1,7 +1,7 @@
/********************************************************************************
** Form generated from reading UI file 'mainwindow.ui'
**
-** Created: Fri Jul 30 12:42:18 2010
+** Created: Wed Sep 22 18:28:37 2010
** by: Qt User Interface Compiler version 4.6.2
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
--- a/example/FlickrAuthApp/ui_AuthApp.h Thu Sep 16 11:15:30 2010 +0530
+++ b/example/FlickrAuthApp/ui_AuthApp.h Thu Sep 23 17:15:03 2010 +0530
@@ -1,7 +1,7 @@
/********************************************************************************
** Form generated from reading UI file 'AuthApp.ui'
**
-** Created: Fri Jul 30 14:06:39 2010
+** Created: Wed Sep 22 18:28:06 2010
** by: Qt User Interface Compiler version 4.6.2
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
--- a/example/FlickrAuthApp/ui_progressbar.h Thu Sep 16 11:15:30 2010 +0530
+++ b/example/FlickrAuthApp/ui_progressbar.h Thu Sep 23 17:15:03 2010 +0530
@@ -1,7 +1,7 @@
/********************************************************************************
** Form generated from reading UI file 'progressbar.ui'
**
-** Created: Fri Jul 30 14:06:35 2010
+** Created: Wed Sep 22 18:28:02 2010
** by: Qt User Interface Compiler version 4.6.2
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/example/MusicLyricsPlugin/MusicLyricsPlugin.cpp Thu Sep 23 17:15:03 2010 +0530
@@ -0,0 +1,589 @@
+/*
+ * MusicLyricsPlugin.cpp
+ *
+ * Created on: Aug 18, 2010
+ * Author: sanpra
+ */
+
+//Include files
+#include <QtPlugin>
+#include <QCryptographicHash>
+#include <QDataStream>
+#include <QTextStream>
+#include <QFile>
+#include <QNetworkReply>
+#include <QMap>
+#include <QListIterator>
+#include <QXmlStreamReader>
+#include <SmfPicture.h>
+#include <QDebug>
+#include "musiclyricsplugin.h"
+
+
+
+//Added for testing - start
+//static const QString apiKey = "8823ece35e487bada68fa893d7ecf91e";
+static const QString apiKey = "1b76e55254f5f22ae";
+//static const QString apiSecret = "20ccb1cc62aa50caf7d8aae31808d429";
+//static const QString miniToken = "773193698 ";
+
+//QString fullToken = "72157624000326005-e6cba1c7665a778e";
+
+//Payload data array
+QByteArray payload;
+QString uids;
+/**
+ * Method called by plugins for logging
+ * @param log string to be logged
+ */
+void MusicLyricsPlugin::writeLog(QString log) const
+ {
+ QFile file("c:\\data\\LyricsPluginLogs.txt");
+ if (!file.open(QIODevice::Append | QIODevice::Text))
+ ;
+ QTextStream out(&file);
+ out << log << "\n";
+ file.close();
+ }
+
+/**
+ * Destructor
+ */
+MusicLyricsPlugin::~MusicLyricsPlugin()
+ {
+ if(m_provider)
+ delete m_provider;
+ }
+
+
+/**
+ * Method called by plugins to generate a signature string from a base string
+ * @param aBaseString The base string
+ * @return The md5 hash of the base string
+ */
+QString MusicLyricsPlugin::generateSignature(const QString aBaseString)
+ {
+ writeLog("MusicLyricsPlugin::generateSignature");
+
+ // Create md5 hash of the signature string
+ QByteArray byteArray;
+ byteArray.insert(0, aBaseString.toAscii());
+
+ QByteArray md5Hash = QCryptographicHash::hash(byteArray,QCryptographicHash::Md5 ).toHex();
+ QString returnString (md5Hash);
+ return returnString;
+ }
+
+
+SmfPluginError MusicLyricsPlugin::lyrics( SmfPluginRequestData &aRequest,
+ const SmfTrackInfo &aTrack,
+ const int aPageNum ,
+ const int aItemsPerPage )
+ {
+ SmfPluginError error = SmfPluginErrUserNotLoggedIn;
+
+ writeLog("MusicLyricsPlugin::lyrics()");
+
+ QString baseString;
+ //spanda
+ QString Url1 = "http://api.lyricsfly.com/api/txt-api.php?";
+ Url1 += "i=7a48a610d6c65171a-temporary.API.access";//[USER ID]
+ Url1 += "&";
+ Url1 += "l=one_love";//[LYRICS TEXT STRING]
+ //till here
+
+ //baseString.append(apiSecret);
+/* baseString.append("api_key"+apiKey);
+ //baseString.append("auth_token");
+ //baseString.append("method=geo.getEvents");
+ writeLog("Url string is :"+baseString);
+ // Create the url
+ QUrl url("http://api.lyricsfly.com/api/");
+ //url.addQueryItem("method", "geo.getevents");
+ //url.addQueryItem("location","madrid");
+ url.addQueryItem("api_key", apiKey);
+ url.addQueryItem("api_sig", generateSignature(baseString));
+ writeLog("/n/n"+generateSignature(baseString));
+ writeLog("/n/n Response is :"+url.toString());*/
+ // Create the request, set the url
+ aRequest.iNetworkRequest.setUrl(Url1);
+ aRequest.iRequestType = SmfMusicGetLyrics;
+
+ //aRequest.iPostData = NULL;
+ aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation;
+ writeLog("/n/n responseAvailble() is getting called");
+ error = SmfPluginErrNone;
+ return error;
+ }
+
+SmfPluginError MusicLyricsPlugin::subtitles( SmfPluginRequestData &aRequest,
+ const SmfTrackInfo &aTrack,
+ const SmfSubtitleSearchFilter &aFilter ,
+ const int aPageNum ,
+ const int aItemsPerPage )
+ {
+ //spanda_13
+ SmfPluginError error = SmfPluginErrUserNotLoggedIn;
+
+ writeLog("MusicLyricsPlugin::subtitle()");
+
+ QString baseString;
+ //spanda
+ QString Url2 = "http://api.allsubs.org/index.php?";
+ Url2 += "search=anaconda";
+ Url2 += "&";
+ Url2 += "language=en";
+ Url2 += "&";
+ Url2 += "limit=3";
+
+
+ aRequest.iNetworkRequest.setUrl(Url2);
+ aRequest.iRequestType = SmfMusicGetSubtitle;
+
+ //aRequest.iPostData = NULL;
+ aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation;
+ //writeLog("/n/n responseAvailble() is getting called");
+ error = SmfPluginErrNone;
+ return error;
+ //till here
+ }
+/**
+ * Customised method for SmfMusicEventsPlugin interface
+ * @param aRequest [out] The request data to be sent to network
+ * @param aOperation The operation type (should be known between
+ * the client interface and the plugin)
+ * @param aData The data required to form the request (The type
+ * of data should be known between client and the plugin)
+ * @return SmfPluginError Plugin error if any, else SmfPluginErrNone
+ */
+SmfPluginError MusicLyricsPlugin::customRequest( SmfPluginRequestData &aRequest,
+ const int &aOperation, QByteArray *aData )
+ {
+ Q_UNUSED(aRequest)
+ Q_UNUSED(aOperation)
+ Q_UNUSED(aData)
+ return SmfPluginErrServiceNotSupported;
+ }
+
+/**
+ * The first method to be called in the plugin that implements this interface.
+ * If this method is not called, plugin may not behave as expected.
+ * Plugins are expected to save the aUtil handle and use and when required.
+ * @param aUtil The instance of SmfPluginUtil
+ */
+void MusicLyricsPlugin::initialize( /*SmfPluginUtil *aUtil*/)
+ {
+ // Save the SmfPluginUtil handle
+ //m_util = aUtil;
+
+ // Create an instance of MusicProviderBase
+ m_provider = new MusicProviderBase;
+ m_provider->initialize();
+ }
+
+/**
+ * Method to get the provider information
+ * @return Instance of SmfProviderBase
+ */
+SmfProviderBase* MusicLyricsPlugin::getProviderInfo( )
+ {
+ return m_provider;
+ }
+
+/**
+ * Method to get the result for a network request.
+ * @param aOperation The type of operation to be requested
+ * @param aTransportResult The result of transport operation
+ * @param aResponse The QByteArray instance containing the network response.
+ * The plugins should delete this instance once they have read the
+ * data from it.
+ * @param aResult [out] An output parameter to the plugin manager.If the
+ * return value is SmfSendRequestAgain, QVariant will be of type
+ * SmfPluginRequestData.
+ * For SmfLyricsServicePlugin: If last operation was lyrics(), aResult will
+ * be of type QList<SmfLyrics>. If last operation was subtitles(), aResult will
+* be of type QList<SmfSubtitle>.
+ */
+SmfPluginError MusicLyricsPlugin::responseAvailable(
+ const SmfRequestTypeID aOperation,
+ const SmfTransportResult &aTransportResult,
+ QByteArray *aResponse,
+ QVariant* aResult,
+ SmfPluginRetType &aRetType,
+ SmfResultPage &aPageResult )
+ {
+ writeLog("MusicLyricsPlugin::responseAvailable");
+ Q_UNUSED(aPageResult)
+ SmfPluginError error = SmfPluginErrNetworkError;
+
+ if( !aResponse || (0 == aResponse->size()) )
+ {
+ writeLog("Response is NULL or empty");
+ aRetType = SmfRequestError;
+ return error;
+ }
+
+ QByteArray response(*aResponse);
+ delete aResponse;
+
+ //Write the response to a file
+ QFile file("c:\\data\\musiclyricsresponse.txt");
+ writeLog("response data written to c:\\data\\musiclyricsresponse.txt");
+
+ if (!file.open(QIODevice::Append | QIODevice::Text));
+ file.write(response);
+ file.close();
+
+ writeLog("MusicEvent response = "+QString(response));
+ writeLog("MusicEvent response size = "+QString::number(response.size(), 10));
+
+ if(SmfTransportOpNoError == aTransportResult)
+ {
+ qDebug()<<"No transport error";
+
+ if(SmfMusicGetLyrics == aOperation )
+ {
+ QList<SmfLyrics> SmfLyricsList;
+ //spanda_14
+ qDebug()<<"Xml parsing";
+
+ //For getting contacts from xml response
+ QXmlStreamReader xml(response);
+ //int count = 0;
+ while (!xml.atEnd())
+ {
+ xml.readNext();
+ if (xml.tokenType() == QXmlStreamReader::StartElement)
+ {
+ SmfLyrics lyrics;
+ //SmfLyrics
+ if (xml.name() == "id")
+ {
+
+
+ qDebug()<<"id tag found";
+ QString id ;
+ QString message(xml.readElementText());
+ id.append(message);
+ qDebug()<<" IDS : "<< id;
+ lyrics.setId(id);
+ //count++;
+
+ }
+ if (xml.name() == "tx")
+ {
+
+ qDebug()<<"tx tag found";
+ QString tx;
+ QString message(xml.readElementText());
+ tx.append(message);
+ qDebug()<<" text : "<< tx;
+ QByteArray data;
+ QDataStream stream(&data, QIODevice::ReadWrite);
+ stream<<tx;
+ lyrics.setId(data);
+ //count++;
+
+ }
+ else if("error_msg" == xml.name())
+ {
+ qDebug()<<"error_msg tag found";
+ //errStr.append(xml.readElementText());
+ break;
+ }
+ }
+ }
+
+
+ //aRetType = SmfRequestComplete;
+ error = SmfPluginErrNone;
+ }
+
+ else if (SmfMusicGetSubtitle == aOperation)
+ {
+ writeLog("SmfMusicGetEventsOnVenue = ");
+
+ writeLog("Inside SmfMusicGetSubtitle ");
+ QList<SmfSubtitle> SmfSubtitleList;
+
+ writeLog("Xml parsing");
+
+ SmfSubtitle Lyricssubtiltle1;
+ Lyricssubtiltle1.setSubtitleUrl(QUrl("http://www.allsubs.org/subs-download/anaconda/1276543/"));
+ Lyricssubtiltle1.setLanguage("english");
+ QDateTime dt = QDateTime::currentDateTime();
+ Lyricssubtiltle1.setReleaseYear(dt);
+ SmfSubtitleList.append(Lyricssubtiltle1);
+
+ SmfSubtitle Lyricssubtiltle2;
+ Lyricssubtiltle2.setSubtitleUrl(QUrl("http://www.allsubs.org/subs-download/"));
+ Lyricssubtiltle2.setLanguage("hindi");
+ QDateTime dt1 = QDateTime::currentDateTime();
+ Lyricssubtiltle2.setReleaseYear(dt1);
+ SmfSubtitleList.append(Lyricssubtiltle2);
+
+ SmfSubtitle Lyricssubtiltle3;
+ Lyricssubtiltle3.setSubtitleUrl(QUrl("http://www.allsubs.org"));
+ Lyricssubtiltle3.setLanguage("hindi");
+ QDateTime dt2 = QDateTime::currentDateTime();
+ Lyricssubtiltle3.setReleaseYear(dt2);
+ SmfSubtitleList.append(Lyricssubtiltle3);
+
+ //For getting contacts from xml response
+ QXmlStreamReader xml(response);
+ //int count = 0;
+ /*while (!xml.atEnd())
+ {
+ SmfSubtitle Lyricssubtiltle;
+ xml.readNext();
+
+ if(xml.tokenType() == QXmlStreamReader::StartDocument)
+ {
+ continue;
+ }
+
+ if (xml.tokenType() == QXmlStreamReader::StartElement)
+ {
+ if (xml.name() == "AllSubsAPI")
+ {
+ continue;
+ }
+ //writeLog("START ELEMNT"+xml.name().toString());
+ if (xml.name() == "items")
+ continue;
+
+ if (xml.name() == "item")
+ {
+ // xml.readNext();
+ while(!(xml.tokenType() == QXmlStreamReader::EndElement &&
+ xml.name() == "item"))
+ {
+ writeLog("loop");
+ if(xml.tokenType() == QXmlStreamReader::StartElement)
+ {
+
+ //}
+ // We've found link.
+ if(xml.name() == "link")
+ {
+
+ Lyricssubtiltle.setSubtitleUrl(xml.readElementText());
+ writeLog("link "+ Lyricssubtiltle.subtitleUrl());
+ writeLog("LINK"+xml.readElementText());
+
+ }
+ // We've found email.
+ if(xml.name() == "languages")
+ {
+ Lyricssubtiltle.setLanguage(xml.readElementText());
+ writeLog("languages "+Lyricssubtiltle.language());
+ writeLog("languages"+xml.readElementText());
+
+
+ }
+ // We've found website.
+ if(xml.name() == "added_on")
+ {
+ QDateTime dt = QDateTime::fromString(xml.readElementText());//stringToTime()
+ Lyricssubtiltle.setReleaseYear(dt);
+ writeLog("added_on "+Lyricssubtiltle.releaseYear().toString());
+ writeLog("added_on"+xml.readElementText());
+ }
+
+ }
+ SmfSubtitleList.append(Lyricssubtiltle);
+ // ...and next...
+ xml.readNext();
+ }//while
+
+ //}
+
+ }//end OF IF iem
+ // }//end of If
+ }//end of start elementIF
+
+
+
+ }//end of while*/
+
+ //}
+ writeLog("End Of Log");
+ writeLog("Count of subtitlles List:"+QString::number(SmfSubtitleList.count(),10));
+ aResult->setValue(SmfSubtitleList);
+ aRetType = SmfRequestComplete;
+
+ aRetType = SmfRequestComplete;
+ error = SmfPluginErrNone;
+ }
+ else
+ {
+ writeLog("Service unsupported!!!");
+ aRetType = SmfRequestError;
+ error = SmfPluginErrServiceNotSupported;
+ }
+ }//end if of if(SmfTransportOpNoError == aTransportResult)
+
+ else if(SmfTransportOpOperationCanceledError == aTransportResult)
+ {
+ writeLog("Operation Cancelled !!!");
+ error = SmfPluginErrCancelComplete;
+ aRetType = SmfRequestComplete;
+ }
+
+ else
+ {
+ writeLog("Transport Error !!!");
+ error = SmfPluginErrNetworkError;
+ aRetType = SmfRequestError;
+ }
+
+ return error;
+ }
+
+
+/**
+ * Destructor
+ */
+MusicProviderBase::~MusicProviderBase( )
+ {
+ }
+
+/**
+ * Method to get the Localisable name of the service.
+ * @return The Localisable name of the service.
+ */
+QString MusicProviderBase::serviceName( ) const
+ {
+ return m_serviceName;
+ }
+
+/**
+ * Method to get the Logo of the service
+ * @return The Logo of the service
+ */
+QImage MusicProviderBase::serviceIcon( ) const
+ {
+ return m_serviceIcon;
+ }
+
+/**
+ * Method to get the Readable service description
+ * @return The Readable service description
+ */
+QString MusicProviderBase::description( ) const
+ {
+ return m_description;
+ }
+
+/**
+ * Method to get the Website of the service
+ * @return The Website of the service
+ */
+QUrl MusicProviderBase::serviceUrl( ) const
+ {
+ return m_serviceUrl;
+ }
+
+/**
+ * Method to get the URL of the Application providing this service
+ * @return The URL of the Application providing this service
+ */
+QUrl MusicProviderBase::applicationUrl( ) const
+ {
+ return m_applicationUrl;
+ }
+
+/**
+ * Method to get the Icon of the application
+ * @return The Icon of the application
+ */
+QImage MusicProviderBase::applicationIcon( ) const
+ {
+ return m_applicationIcon;
+ }
+/**
+* Method to get the list of interfaces that this provider support
+* @return List of supported Interafces
+*/
+QList<QString> MusicProviderBase::supportedInterfaces( ) const
+ {
+ return m_serviceType;
+ }
+
+/**
+* Method to get the list of languages supported by this service provider
+* @return a QStringList of languages supported by this service
+* provider in 2 letter ISO 639-1 format.
+*/
+QStringList MusicProviderBase::supportedLanguages( ) const
+ {
+ return m_supportedLanguages;
+ }
+
+/**
+ * Method to get the Plugin specific ID
+ * @return The Plugin specific ID
+ */
+QString MusicProviderBase::pluginId( ) const
+ {
+ return m_pluginId;
+ }
+
+/**
+ * Method to get the ID of the authentication application
+ * for this service
+ * @param aProgram The authentication application name
+ * @param aArguments List of arguments required for authentication app
+ * @param aMode Strting mode for authentication application
+ * @return The ID of the authentication application
+ */
+QString MusicProviderBase::authenticationApp( QString &aProgram,
+ QStringList & aArguments,
+ QIODevice::OpenModeFlag aMode ) const
+ {
+ return m_authAppId;
+ }
+
+/**
+ * Method to get the unique registration ID provided by the
+ * Smf for authorised plugins
+ * @return The unique registration ID/token provided by the Smf for
+ * authorised plugins
+ */
+QString MusicProviderBase::smfRegistrationId( ) const
+ {
+ return m_smfRegToken;
+ }
+
+void MusicProviderBase::initialize()
+ {
+ m_serviceName = "LyricsFly";
+ m_description = "Description";
+ m_serviceUrl = QUrl(QString("http://api.lyricsfly.com"));
+ m_serviceType << m_serviceName << m_description;// << (QString)(m_serviceUrl);
+ m_supportedLanguages << "English" ;
+ m_pluginId = "musiclyricsplugin.qtplugin";
+ m_authAppId = "0xEFE2FD23";
+ m_smfRegToken = "hsdfusdghf";
+
+ //sandeep_Added_13-08-2010
+ /* m_serviceName = "allsubs";
+ m_description = "Description";
+ //m_serviceUrl = QUrl(QString//("http://api.allsubs.org"));
+
+ // m_serviceType << m_serviceName << m_description;// << (QString)(m_serviceUrl);
+ m_supportedLanguages << "English" ;
+ m_pluginId = "musiclyricsplugin.qtplugin";
+ m_authAppId = "0xEFE2FD23";
+ m_smfRegToken = "hsdfusdghf";
+ //m_smfRegToken = "hsdfusdghf"; //yet to be recvd*/
+
+ }
+
+
+/*
+ * Export Macro
+ * plugin name : MusicLyricsPlugin
+ * plugin class : MusicLyricsPlugin
+ */
+Q_EXPORT_PLUGIN2( musiclyricsplugin, MusicLyricsPlugin )
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/example/MusicLyricsPlugin/MusicLyricsPlugin.h Thu Sep 23 17:15:03 2010 +0530
@@ -0,0 +1,253 @@
+/*
+ * MusicLyricsPlugin.h
+ *
+ * Created on: Aug 18, 2010
+ * Author: sanpra
+ */
+
+
+
+#ifndef MUSICLYRICSPLUGIN_H_
+#define MUSICLYRICSPLUGIN_H_
+
+// Include files
+#include "smflyricsserviceplugin.h"
+#include "smfpluginutil.h"
+
+#include <parser.h>
+
+// Forward declarations
+class MusicProviderBase;
+class QVariant;
+class QNetworkReply;
+
+// Class declaration
+class MusicLyricsPlugin : public QObject, public SmfLyricsServicePlugin
+{
+ Q_OBJECT
+ Q_INTERFACES( SmfLyricsServicePlugin SmfPluginBase )
+
+public:
+ virtual ~MusicLyricsPlugin();
+
+public: // From SmfMusicEventsPlugin
+
+ /**
+ * Method to get the lyrics
+ * @param aRequest [out] The request data to be sent to network
+ * @param aTrack The track whose lyrics need to be fetched
+ * @param aPageNum The page to be extracted
+ * @param aItemsPerPage Number of items per page
+ * @return SmfPluginError Plugin error if any, else SmfPluginErrNone
+ */
+ SmfPluginError lyrics( SmfPluginRequestData &aRequest,
+ const SmfTrackInfo &aTrack,
+ const int aPageNum = SMF_FIRST_PAGE,
+ const int aItemsPerPage = SMF_ITEMS_PER_PAGE ) ;
+
+ /**
+ * Method to get the subtitle
+ * @param aRequest [out] The request data to be sent to network
+ * @param aTrack The track whose subtitle need to be fetched
+ * @param aFilter The subtitle search filter if any
+ * @param aPageNum The page to be extracted
+ * @param aItemsPerPage Number of items per page
+ * @return SmfPluginError Plugin error if any, else SmfPluginErrNone
+ */
+ SmfPluginError subtitles( SmfPluginRequestData &aRequest,
+ const SmfTrackInfo &aTrack,
+ const SmfSubtitleSearchFilter &aFilter = SubtitleAll,
+ const int aPageNum = SMF_FIRST_PAGE,
+ const int aItemsPerPage = SMF_ITEMS_PER_PAGE ) ;
+ /**
+ * Customised method for SmfMusicEventsPlugin interface
+ * @param aRequest [out] The request data to be sent to network
+ * @param aOperation The operation type (should be known between
+ * the client interface and the plugin)
+ * @param aData The data required to form the request (The type
+ * of data should be known between client and the plugin)
+ * @return SmfPluginError Plugin error if any, else SmfPluginErrNone
+ */
+ SmfPluginError customRequest( SmfPluginRequestData &aRequest,
+ const int &aOperation, QByteArray *aData );
+
+public: // From SmfPluginBase
+ /**
+ * The first method to be called in the plugin that implements this interface.
+ * If this method is not called, plugin may not behave as expected.
+ * Plugins are expected to save the aUtil handle and use and when required.
+ * @param aUtil The instance of SmfPluginUtil
+ */
+ void initialize(/*SmfPluginUtil *aUtil*/);
+
+ /**
+ * Method to get the provider information
+ * @return Instance of SmfProviderBase
+ */
+ SmfProviderBase* getProviderInfo( );
+
+ /**
+ * Method to get the result for a network request.
+ * @param aTransportResult The result of transport operation
+ * @param aReply The QNetworkReply instance for the request
+ * @param aResult [out] An output parameter to the plugin manager.If the
+ * return value is SmfSendRequestAgain, QVariant will be of type
+ * SmfPluginRequestData.
+ * For SmfGalleryPlugin: If last operation was pictures(), aResult will
+ * be of type QList<SmfPicture>. If last operation was description(),
+ * aResult will be of type QString. If last operation was upload() or
+ * postComment(), aResult will be of type bool.
+ * @param aRetType [out] SmfPluginRetType
+ * @param aPageResult [out] The SmfResultPage structure variable
+ */
+ /* SmfPluginError responseAvailable(
+ const SmfTransportResult &aTransportResult,
+ QNetworkReply *aReply,
+ QVariant* aResult,
+ SmfPluginRetType &aRetType,
+ SmfResultPage &aPageResult );*/
+ SmfPluginError responseAvailable(
+ const SmfRequestTypeID aOperation,
+ const SmfTransportResult &aTransportResult,
+ QByteArray *aResponse,
+ QVariant* aResult,
+ SmfPluginRetType &aRetType,
+ SmfResultPage &aPageResult );
+
+ void writeLog(QString log) const;
+
+
+private:
+
+ QString generateSignature(const QString aBaseString);
+
+
+private slots:
+
+
+
+private:
+ /**
+ * Method called by plugins to generate a request data
+ * @param aRequest [out] The request data to be sent to network
+ * @param aOperation The type of http operation
+ * @param aSignatureMethod The signature method to be used
+ * @param aParams A map of parameters to its values
+ * @param aMode The mode of creation of the request
+ * @param aPostData The data to be posted (for HTTP POST
+ * only, else it will be NULL)
+ * @return SmfPluginError Plugin error if any, else SmfPluginErrNone
+ */
+ SmfPluginError createRequest( SmfPluginRequestData &aRequest,const QNetworkAccessManager::Operation aOperation,
+ const SmfSignatureMethod aSignatureMethod,
+ QMultiMap<QByteArray, QByteArray> &aParams,
+ const SmfParsingMode aMode,
+ QBuffer *aPostData );
+
+private:
+ MusicProviderBase *m_provider;
+ SmfPluginUtil *m_util;
+};
+
+// Class declaration
+class MusicProviderBase : public QObject, public SmfProviderBase
+ {
+ Q_OBJECT
+ Q_INTERFACES( SmfProviderBase )
+
+public:
+ virtual ~MusicProviderBase( );
+
+ /**
+ * Method to get the Localisable name of the service.
+ * @return The Localisable name of the service.
+ */
+ QString serviceName( ) const;
+
+ /**
+ * Method to get the Logo of the service
+ * @return The Logo of the service
+ */
+ QImage serviceIcon( ) const;
+
+ /**
+ * Method to get the Readable service description
+ * @return The Readable service description
+ */
+ QString description( ) const;
+
+ /**
+ * Method to get the Website of the service
+ * @return The Website of the service
+ */
+ QUrl serviceUrl( ) const;
+
+ /**
+ * Method to get the URL of the Application providing this service
+ * @return The URL of the Application providing this service
+ */
+ QUrl applicationUrl( ) const;
+
+ /**
+ * Method to get the Icon of the application
+ * @return The Icon of the application
+ */
+ QImage applicationIcon( ) const;
+
+ /**
+ * Method to get the list of interfaces that this provider support
+ * @return List of supported Interafces
+ */
+ QList<QString> supportedInterfaces( ) const;
+
+ /**
+ * Method to get the list of languages supported by this service provider
+ * @return a QStringList of languages supported by this service
+ * provider in 2 letter ISO 639-1 format.
+ */
+ QStringList supportedLanguages( ) const;
+
+ /**
+ * Method to get the Plugin specific ID
+ * @return The Plugin specific ID
+ */
+ QString pluginId( ) const;
+
+ /**
+ * Method to get the ID of the authentication application
+ * for this service
+ * @param aProgram The authentication application name
+ * @param aArguments List of arguments required for authentication app
+ * @param aMode Strting mode for authentication application
+ * @return The ID of the authentication application
+ */
+ QString authenticationApp( QString &aProgram, QStringList & aArguments,
+ QIODevice::OpenModeFlag aMode = QIODevice::ReadWrite ) const;
+
+ /**
+ * Method to get the unique registration ID provided by the
+ * Smf for authorised plugins
+ * @return The unique registration ID/token provided by the Smf for
+ * authorised plugins
+ */
+ QString smfRegistrationId( ) const;
+
+private:
+ friend class MusicLyricsPlugin;
+ void initialize();
+ QString m_serviceName;
+ QImage m_serviceIcon;
+ QString m_description;
+ QUrl m_serviceUrl;
+ QUrl m_applicationUrl;
+ QImage m_applicationIcon;
+ QStringList m_serviceType;
+ QStringList m_supportedLanguages;
+ QString m_pluginId;
+ QString m_authAppId;
+ QString m_smfRegToken;
+ };
+
+
+
+#endif /* MUSICLYRICSPLUGIN_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/example/MusicLyricsPlugin/MusicLyricsPlugin.pro Thu Sep 23 17:15:03 2010 +0530
@@ -0,0 +1,37 @@
+TEMPLATE = lib
+CONFIG += plugin \
+ mobility
+MOBILITY += location
+QT += core \
+ xml \
+ network
+HEADERS = musiclyricsplugin.h
+SOURCES = musiclyricsplugin.cpp
+TARGET = $$qtLibraryTarget(musiclyricsplugin)
+symbian: {
+ # Load predefined include paths (e.g. QT_PLUGINS_BASE_DIR) to be used in the pro-files
+ load(data_caging_paths)
+
+ # EPOCALLOWDLLDATA have to set true because Qt macros has initialised global data
+ TARGET.EPOCALLOWDLLDATA = 1
+
+ # Defines plugin files into Symbian .pkg package
+ pluginDep.sources = musiclyricsplugin.dll
+ pluginDep.path = $$QT_PLUGINS_BASE_DIR/smf/plugin/music.lyrics
+ DEPLOYMENT += pluginDep
+ TARGET.CAPABILITY = ReadUserData \
+ WriteUserData \
+ LocalServices \
+ NetworkServices \
+ UserEnvironment \
+ ReadDeviceData \
+ WriteDeviceData
+ LIBS += -lsmfclient.dll
+ LIBS += -lsmfcommon
+ LIBS += -lqjson.dll
+}
+target.path += $$[QT_INSTALL_PLUGINS]/smf/plugin/music.lyrics
+INSTALLS += target
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/example/MusicLyricsPlugin/plugin_commonU.def Thu Sep 23 17:15:03 2010 +0530
@@ -0,0 +1,16 @@
+; ==============================================================================
+; Generated by qmake (2.01a) (Qt 4.6.2) on: 2010-09-23T11:35:50
+; This file is generated by qmake and should not be modified by the
+; user.
+; Name : plugin_commonU.def
+; Part of : musiclyricsplugin
+; Description : Fixes common plugin symbols to known ordinals
+; Version :
+;
+; ==============================================================================
+
+
+EXPORTS
+ qt_plugin_query_verification_data @ 1 NONAME
+ qt_plugin_instance @ 2 NONAME
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/example/MusicLyricsPlugin/qmakepluginstubs/musiclyricsplugin.qtplugin Thu Sep 23 17:15:03 2010 +0530
@@ -0,0 +1,1 @@
+This file is a Qt plugin stub file. The real Qt plugin is located in \sys\bin. Created:2010-09-23T11:35:50
--- a/example/example.pro Thu Sep 16 11:15:30 2010 +0530
+++ b/example/example.pro Thu Sep 23 17:15:03 2010 +0530
@@ -6,6 +6,11 @@
fbpostproviderplugin \
flickrcontactfetcherplugin \
flickrgalleryplugin \
+ lastfmmusicsearchplugin \
+ lastfmmusicserviceplugin \
+ lastfmplaylistserviceplugin \
+ lastfmmusiceventplugin \
+ MusicLyricsPlugin \
smfclientapp \
DemoGUI
CONFIG += ordered
\ No newline at end of file
--- a/example/fbactivityfetcherplugin/plugin_commonU.def Thu Sep 16 11:15:30 2010 +0530
+++ b/example/fbactivityfetcherplugin/plugin_commonU.def Thu Sep 23 17:15:03 2010 +0530
@@ -1,5 +1,5 @@
; ==============================================================================
-; Generated by qmake (2.01a) (Qt 4.6.2) on: 2010-07-30T14:11:44
+; Generated by qmake (2.01a) (Qt 4.6.2) on: 2010-09-23T11:35:50
; This file is generated by qmake and should not be modified by the
; user.
; Name : plugin_commonU.def
--- a/example/fbactivityfetcherplugin/qmakepluginstubs/fbactivityfetcherplugin.qtplugin Thu Sep 16 11:15:30 2010 +0530
+++ b/example/fbactivityfetcherplugin/qmakepluginstubs/fbactivityfetcherplugin.qtplugin Thu Sep 23 17:15:03 2010 +0530
@@ -1,1 +1,1 @@
-This file is a Qt plugin stub file. The real Qt plugin is located in \sys\bin. Created:2010-07-30T14:11:44
+This file is a Qt plugin stub file. The real Qt plugin is located in \sys\bin. Created:2010-09-23T11:35:50
--- a/example/fbcontactfetcherplugin/fbcontactfetcherplugin.cpp Thu Sep 16 11:15:30 2010 +0530
+++ b/example/fbcontactfetcherplugin/fbcontactfetcherplugin.cpp Thu Sep 23 17:15:03 2010 +0530
@@ -405,12 +405,14 @@
* Method to search for a contact in a group
* @param aRequest [out] The request data to be sent to network
* @param aGroup the group in which to search
+ * @param aContact The contact to be searched, default (NULL) is the self contact.
* @param aPageNum The page to be extracted
* @param aItemsPerPage Number of items per page
* @return SmfPluginError Plugin error if any, else SmfPluginErrNone
*/
SmfPluginError FBContactFetcherPlugin::searchInGroup( SmfPluginRequestData &aRequest,
const SmfGroup &aGroup,
+ SmfContact *aContact,
const int aPageNum ,
const int aItemsPerPage )
{
--- a/example/fbcontactfetcherplugin/fbcontactfetcherplugin.h Thu Sep 16 11:15:30 2010 +0530
+++ b/example/fbcontactfetcherplugin/fbcontactfetcherplugin.h Thu Sep 23 17:15:03 2010 +0530
@@ -112,12 +112,14 @@
* Method to search for a contact in a group
* @param aRequest [out] The request data to be sent to network
* @param aGroup the group in which to search
+ * @param aContact The contact to be searched, default (NULL) is the self contact.
* @param aPageNum The page to be extracted
* @param aItemsPerPage Number of items per page
* @return SmfPluginError Plugin error if any, else SmfPluginErrNone
*/
SmfPluginError searchInGroup( SmfPluginRequestData &aRequest,
const SmfGroup &aGroup,
+ SmfContact *aContact = NULL,
const int aPageNum = SMF_FIRST_PAGE,
const int aItemsPerPage = SMF_ITEMS_PER_PAGE );
--- a/example/fbcontactfetcherplugin/plugin_commonU.def Thu Sep 16 11:15:30 2010 +0530
+++ b/example/fbcontactfetcherplugin/plugin_commonU.def Thu Sep 23 17:15:03 2010 +0530
@@ -1,5 +1,5 @@
; ==============================================================================
-; Generated by qmake (2.01a) (Qt 4.6.2) on: 2010-07-30T14:11:44
+; Generated by qmake (2.01a) (Qt 4.6.2) on: 2010-09-23T11:35:50
; This file is generated by qmake and should not be modified by the
; user.
; Name : plugin_commonU.def
--- a/example/fbcontactfetcherplugin/qmakepluginstubs/fbcontactfetcherplugin.qtplugin Thu Sep 16 11:15:30 2010 +0530
+++ b/example/fbcontactfetcherplugin/qmakepluginstubs/fbcontactfetcherplugin.qtplugin Thu Sep 23 17:15:03 2010 +0530
@@ -1,1 +1,1 @@
-This file is a Qt plugin stub file. The real Qt plugin is located in \sys\bin. Created:2010-07-30T14:11:44
+This file is a Qt plugin stub file. The real Qt plugin is located in \sys\bin. Created:2010-09-23T11:35:50
--- a/example/fbpostproviderplugin/plugin_commonU.def Thu Sep 16 11:15:30 2010 +0530
+++ b/example/fbpostproviderplugin/plugin_commonU.def Thu Sep 23 17:15:03 2010 +0530
@@ -1,5 +1,5 @@
; ==============================================================================
-; Generated by qmake (2.01a) (Qt 4.6.2) on: 2010-07-30T14:11:44
+; Generated by qmake (2.01a) (Qt 4.6.2) on: 2010-09-23T11:35:50
; This file is generated by qmake and should not be modified by the
; user.
; Name : plugin_commonU.def
--- a/example/fbpostproviderplugin/qmakepluginstubs/fbpostproviderplugin.qtplugin Thu Sep 16 11:15:30 2010 +0530
+++ b/example/fbpostproviderplugin/qmakepluginstubs/fbpostproviderplugin.qtplugin Thu Sep 23 17:15:03 2010 +0530
@@ -1,1 +1,1 @@
-This file is a Qt plugin stub file. The real Qt plugin is located in \sys\bin. Created:2010-07-30T14:11:44
+This file is a Qt plugin stub file. The real Qt plugin is located in \sys\bin. Created:2010-09-23T11:35:50
--- a/example/flickrcontactfetcherplugin/flickrcontactfetcherplugin.cpp Thu Sep 16 11:15:30 2010 +0530
+++ b/example/flickrcontactfetcherplugin/flickrcontactfetcherplugin.cpp Thu Sep 23 17:15:03 2010 +0530
@@ -183,11 +183,70 @@
const int aPageNum ,
const int aItemsPerPage )
{
+#ifndef TESTINGTHISFUNCTION
Q_UNUSED(aRequest)
Q_UNUSED(aPageNum)
Q_UNUSED(aItemsPerPage)
qDebug()<<"Inside FlickrContactFetcherPlugin::followers()";
return SmfPluginErrServiceNotSupported;
+#else
+ SmfPluginError error = SmfPluginErrInvalidArguments;
+
+ // invalid arguments
+ if( aPageNum < 0 || aItemsPerPage < 0 )
+ {
+ qDebug()<<"Invalid arguments";
+ return error;
+ }
+
+ qDebug()<<"Valid arguments";
+
+ // Get the key sets from SMF Plugin Utility class.
+ QString apiKey;
+ QString apiSecret;
+ QString authToken;
+ fetchKeys(apiKey, apiSecret, authToken );
+
+ // Create the API signature string
+ QString baseString;
+ baseString.append(apiSecret);
+ baseString.append("api_key"+apiKey);
+ baseString.append("auth_token"+authToken);
+ baseString.append("filterfriends");
+#ifdef SMF_XMLPARSING
+ baseString.append("formatxml");
+#else
+ baseString.append("formatjson");
+#endif
+ baseString.append("methodflickr.contacts.getList");
+ baseString.append("page"+QString::number(aPageNum));
+ baseString.append("per_page"+QString::number(aItemsPerPage));
+
+ // Create the url
+ QUrl url("http://api.flickr.com/services/rest/?");
+ url.addQueryItem("api_key", apiKey);
+ url.addQueryItem("auth_token", authToken);
+ url.addQueryItem("filter", "friends");
+#ifdef SMF_XMLPARSING
+ url.addQueryItem("format", "x");
+#else
+ url.addQueryItem("format", "json");
+#endif
+ url.addQueryItem("method", "flickr.contacts.getList");
+ url.addQueryItem("page", QString::number(aPageNum));
+ url.addQueryItem("per_page", QString::number(aItemsPerPage));
+ url.addQueryItem("api_sig", generateSignature(baseString));
+
+ // Create the request, set the url
+ aRequest.iNetworkRequest.setUrl(url);
+ aRequest.iRequestType = SmfContactGetFollowers;
+ aRequest.iPostData = NULL;
+ aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation;
+ error = SmfPluginErrNone;
+
+ qDebug()<<"Url string is : "<<aRequest.iNetworkRequest.url().toString();
+ return error;
+#endif
}
/**
@@ -203,12 +262,56 @@
const int aPageNum ,
const int aItemsPerPage )
{
+#ifndef TESTINGTHISFUNCTION
Q_UNUSED(aRequest)
Q_UNUSED(aContact)
Q_UNUSED(aPageNum)
Q_UNUSED(aItemsPerPage)
qDebug()<<"Inside FlickrContactFetcherPlugin::search()";
return SmfPluginErrServiceNotSupported;
+#else
+ SmfPluginError error = SmfPluginErrInvalidArguments;
+
+ // Get the key sets from SMF Plugin Utility class.
+ QString apiKey;
+ QString apiSecret;
+ QString authToken;
+ fetchKeys(apiKey, apiSecret, authToken );
+
+ // Create the API signature string
+ QString baseString;
+ baseString.append(apiSecret);
+ baseString.append("api_key"+apiKey);
+ baseString.append("auth_token"+authToken);
+ baseString.append("formatjson");
+ baseString.append("methodflickr.people.findByUsername");
+ //baseString.append("page"+QString::number(aPageNum));
+ //baseString.append("per_page"+QString::number(aItemsPerPage));
+ baseString.append("username"+(aContact.value("Name").value<QContactName>().firstName()));
+
+
+ // Create the url
+ QUrl url("http://api.flickr.com/services/rest/?");
+ url.addQueryItem("api_key", apiKey);
+ url.addQueryItem("auth_token", authToken);
+ url.addQueryItem("format", "json");
+ url.addQueryItem("method", "flickr.people.findByUsername");
+ url.addQueryItem("username",aContact.value("Name").value<QContactName>().firstName());
+ //url.addQueryItem("page", QString::number(10));
+ //url.addQueryItem("per_page", QString::number(10));
+
+ url.addQueryItem("api_sig", generateSignature(baseString));
+
+ // Create the request, set the url
+ aRequest.iNetworkRequest.setUrl(url);
+ aRequest.iRequestType = SmfContactSearch;
+ aRequest.iPostData = NULL;
+ aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation;
+ error = SmfPluginErrNone;
+// writeLog("Url string is :"+aRequest.iNetworkRequest.url().toString());
+ return error;
+
+#endif
}
/**
@@ -227,6 +330,7 @@
const int aPageNum ,
const int aItemsPerPage )
{
+#ifndef TESTINGTHISFUNCTION
Q_UNUSED(aRequest)
Q_UNUSED(aLocation)
Q_UNUSED(aProximity)
@@ -234,6 +338,64 @@
Q_UNUSED(aItemsPerPage)
qDebug()<<"Inside FlickrContactFetcherPlugin::searchNear()";
return SmfPluginErrServiceNotSupported;
+#else
+ SmfPluginError error = SmfPluginErrInvalidArguments;
+
+ // invalid arguments
+ if( aPageNum < 0 || aItemsPerPage < 0 )
+ {
+ qDebug()<<"Invalid arguments";
+ return error;
+ }
+
+ qDebug()<<"Valid arguments";
+
+ // Get the key sets from SMF Plugin Utility class.
+ QString apiKey;
+ QString apiSecret;
+ QString authToken;
+ fetchKeys(apiKey, apiSecret, authToken );
+
+ // Create the API signature string
+ QString baseString;
+ baseString.append(apiSecret);
+ baseString.append("api_key"+apiKey);
+ baseString.append("auth_token"+authToken);
+ baseString.append("filterfriends");
+#ifdef SMF_XMLPARSING
+ baseString.append("formatxml");
+#else
+ baseString.append("formatjson");
+#endif
+ baseString.append("methodflickr.contacts.getList");
+ baseString.append("page"+QString::number(aPageNum));
+ baseString.append("per_page"+QString::number(aItemsPerPage));
+
+ // Create the url
+ QUrl url("http://api.flickr.com/services/rest/?");
+ url.addQueryItem("api_key", apiKey);
+ url.addQueryItem("auth_token", authToken);
+ url.addQueryItem("filter", "friends");
+#ifdef SMF_XMLPARSING
+ url.addQueryItem("format", "x");
+#else
+ url.addQueryItem("format", "json");
+#endif
+ url.addQueryItem("method", "flickr.contacts.getList");
+ url.addQueryItem("page", QString::number(aPageNum));
+ url.addQueryItem("per_page", QString::number(aItemsPerPage));
+ url.addQueryItem("api_sig", generateSignature(baseString));
+
+ // Create the request, set the url
+ aRequest.iNetworkRequest.setUrl(url);
+ aRequest.iRequestType = SmfContactSearchNear;
+ aRequest.iPostData = NULL;
+ aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation;
+ error = SmfPluginErrNone;
+
+ qDebug()<<"Url string is : "<<aRequest.iNetworkRequest.url().toString();
+ return error;
+#endif
}
/**
@@ -247,32 +409,128 @@
const int aPageNum ,
const int aItemsPerPage )
{
- Q_UNUSED(aRequest)
- Q_UNUSED(aPageNum)
- Q_UNUSED(aItemsPerPage)
qDebug()<<"Inside FlickrContactFetcherPlugin::groups()";
- return SmfPluginErrServiceNotSupported;
+
+ SmfPluginError error = SmfPluginErrInvalidArguments;
+
+ // invalid arguments
+ /*if( aPageNum < 0 || aItemsPerPage < 0 )
+ {
+ qDebug()<<"Invalid arguments";
+ return error;
+ }*/
+ // Get the key sets from SMF Plugin Utility class.
+ QString apiKey;
+ QString apiSecret;
+ QString authToken;
+ fetchKeys(apiKey, apiSecret, authToken );
+
+ // Create the API signature string
+ QString baseString;
+ baseString.append(apiSecret);
+ baseString.append("api_key"+apiKey);
+ baseString.append("auth_token"+authToken);
+ baseString.append("formatjson");
+ baseString.append("methodflickr.groups.pools.getGroups");
+
+ // Create the url
+ QUrl url("http://api.flickr.com/services/rest/?");
+ url.addQueryItem("api_key", apiKey);
+ url.addQueryItem("auth_token", authToken);
+ url.addQueryItem("format", "json");
+ url.addQueryItem("method","flickr.groups.pools.getGroups");
+ url.addQueryItem("api_sig", generateSignature(baseString));
+
+ // Create the request, set the url
+ aRequest.iNetworkRequest.setUrl(url);
+ aRequest.iRequestType = SmfContactGetGroups;
+ aRequest.iPostData = NULL;
+ aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation;
+ error = SmfPluginErrNone;
+// writeLog("Url string is : "+aRequest.iNetworkRequest.url().toString());
+ return error;
}
/**
* Method to search for a contact in a group
* @param aRequest [out] The request data to be sent to network
* @param aGroup the group in which to search
+ * @param aContact The contact to be searched, default (NULL) is the self contact.
* @param aPageNum The page to be extracted
* @param aItemsPerPage Number of items per page
* @return SmfPluginError Plugin error if any, else SmfPluginErrNone
*/
SmfPluginError FlickrContactFetcherPlugin::searchInGroup( SmfPluginRequestData &aRequest,
const SmfGroup &aGroup,
+ SmfContact *aContact,
const int aPageNum ,
const int aItemsPerPage )
{
+#ifndef TESTINGTHISFUNCTION
Q_UNUSED(aRequest)
Q_UNUSED(aGroup)
Q_UNUSED(aPageNum)
Q_UNUSED(aItemsPerPage)
qDebug()<<"Inside FlickrContactFetcherPlugin::searchInGroup()";
return SmfPluginErrServiceNotSupported;
+#else
+ SmfPluginError error = SmfPluginErrInvalidArguments;
+
+ // invalid arguments
+ if( aPageNum < 0 || aItemsPerPage < 0 )
+ {
+ qDebug()<<"Invalid arguments";
+ return error;
+ }
+
+ qDebug()<<"Valid arguments";
+
+ // Get the key sets from SMF Plugin Utility class.
+ QString apiKey;
+ QString apiSecret;
+ QString authToken;
+ fetchKeys(apiKey, apiSecret, authToken );
+
+ // Create the API signature string
+ QString baseString;
+ baseString.append(apiSecret);
+ baseString.append("api_key"+apiKey);
+ baseString.append("auth_token"+authToken);
+ baseString.append("filterfriends");
+#ifdef SMF_XMLPARSING
+ baseString.append("formatxml");
+#else
+ baseString.append("formatjson");
+#endif
+ baseString.append("methodflickr.contacts.getList");
+ baseString.append("page"+QString::number(aPageNum));
+ baseString.append("per_page"+QString::number(aItemsPerPage));
+
+ // Create the url
+ QUrl url("http://api.flickr.com/services/rest/?");
+ url.addQueryItem("api_key", apiKey);
+ url.addQueryItem("auth_token", authToken);
+ url.addQueryItem("filter", "friends");
+#ifdef SMF_XMLPARSING
+ url.addQueryItem("format", "x");
+#else
+ url.addQueryItem("format", "json");
+#endif
+ url.addQueryItem("method", "flickr.contacts.getList");
+ url.addQueryItem("page", QString::number(aPageNum));
+ url.addQueryItem("per_page", QString::number(aItemsPerPage));
+ url.addQueryItem("api_sig", generateSignature(baseString));
+
+ // Create the request, set the url
+ aRequest.iNetworkRequest.setUrl(url);
+ aRequest.iRequestType = SmfContactSearchInGroup;
+ aRequest.iPostData = NULL;
+ aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation;
+ error = SmfPluginErrNone;
+
+ qDebug()<<"Url string is : "<<aRequest.iNetworkRequest.url().toString();
+ return error;
+#endif
}
/**
@@ -372,7 +630,11 @@
{
qDebug()<<"No transport error";
+#ifndef TESTINGTHISFUNCTION
if(SmfContactGetFriends == aOperation)
+#else
+ if(SmfContactGetFriends == aOperation ||aOperation == SmfContactGetFollowers||aOperation== SmfContactSearch ||aOperation ==SmfContactSearchNear||aOperation ==SmfContactSearchInGroup)
+#endif
{
qDebug()<<"For getting friends response";
@@ -491,6 +753,50 @@
aRetType = SmfRequestComplete;
error = SmfPluginErrNone;
}
+ else if(aOperation==SmfContactGetGroups)
+ {
+ response.remove(0, 14);
+ response.chop(1);
+
+ bool ok;
+ qDebug()<<"Before Parser--";
+
+ SmfPluginUtil util;
+ QVariant result = util.parse(response, &ok);
+ if (!ok)
+ {
+ qDebug()<<"An error occurred during json parsing";
+ aRetType = SmfRequestError;
+ return SmfPluginErrParsingFailed;
+ //return 0;
+ }
+
+ QVariantMap map1 = result.toMap();
+ QList<SmfGroup> list;
+ QVariantMap map2 = map1["groups"].toMap();
+ int page = map2["page"].toInt(&ok);
+ qDebug()<<"PAGE = "<<map2["page"].toString();
+ QList<QVariant> list1 = map2["group"].toList();
+ QListIterator<QVariant> iter(list1);
+
+ //Getting the group list from QJson Parser
+ while(iter.hasNext())
+ {
+ QVariantMap map2 = iter.next().toMap();
+ qDebug()<<"name = "<<map2["name"].toString();
+ qDebug()<<"id = "<<map2["id"].toString();
+ SmfGroup group;
+ QString id(map2["id"].toString());
+ group.setId(id);
+ QString grpname(map2["name"].toString());
+ group.setName(grpname);
+
+ list.append(group);
+
+ }//end While
+ qDebug()<<"list count = "<<QString::number(list.count(),10);
+ aResult->setValue(list);
+ }
else
{
qDebug()<<"Service unsupported, currently only SmfContactGetFriends !!!";
--- a/example/flickrcontactfetcherplugin/flickrcontactfetcherplugin.h Thu Sep 16 11:15:30 2010 +0530
+++ b/example/flickrcontactfetcherplugin/flickrcontactfetcherplugin.h Thu Sep 23 17:15:03 2010 +0530
@@ -111,12 +111,14 @@
* Method to search for a contact in a group
* @param aRequest [out] The request data to be sent to network
* @param aGroup the group in which to search
+ * @param aContact The contact to be searched, default (NULL) is the self contact.
* @param aPageNum The page to be extracted
* @param aItemsPerPage Number of items per page
* @return SmfPluginError Plugin error if any, else SmfPluginErrNone
*/
SmfPluginError searchInGroup( SmfPluginRequestData &aRequest,
const SmfGroup &aGroup,
+ SmfContact *aContact = NULL,
const int aPageNum = SMF_FIRST_PAGE,
const int aItemsPerPage = SMF_ITEMS_PER_PAGE );
--- a/example/flickrcontactfetcherplugin/plugin_commonU.def Thu Sep 16 11:15:30 2010 +0530
+++ b/example/flickrcontactfetcherplugin/plugin_commonU.def Thu Sep 23 17:15:03 2010 +0530
@@ -1,5 +1,5 @@
; ==============================================================================
-; Generated by qmake (2.01a) (Qt 4.6.2) on: 2010-07-30T14:11:44
+; Generated by qmake (2.01a) (Qt 4.6.2) on: 2010-09-23T11:35:50
; This file is generated by qmake and should not be modified by the
; user.
; Name : plugin_commonU.def
--- a/example/flickrcontactfetcherplugin/qmakepluginstubs/flickrcontactfetcherplugin.qtplugin Thu Sep 16 11:15:30 2010 +0530
+++ b/example/flickrcontactfetcherplugin/qmakepluginstubs/flickrcontactfetcherplugin.qtplugin Thu Sep 23 17:15:03 2010 +0530
@@ -1,1 +1,1 @@
-This file is a Qt plugin stub file. The real Qt plugin is located in \sys\bin. Created:2010-07-30T14:11:44
+This file is a Qt plugin stub file. The real Qt plugin is located in \sys\bin. Created:2010-09-23T11:35:50
--- a/example/flickrgalleryplugin/flickrgalleryplugin.cpp Thu Sep 16 11:15:30 2010 +0530
+++ b/example/flickrgalleryplugin/flickrgalleryplugin.cpp Thu Sep 23 17:15:03 2010 +0530
@@ -31,7 +31,7 @@
#include "flickrgalleryplugin.h"
-static int count = 1;
+static int count = 0;
static int chance = 0; // 0 = for pics from album, 1 = pics not in any album
static int listIndex = 0;// For Mutliple Load
QByteArray payload;
@@ -1008,6 +1008,45 @@
}
#endif
}
+ else if (SmfPictureMultiUpload == aOperation)
+ {
+ bool result;
+ qDebug()<<("SmfMultiPictureUpload");
+ QXmlStreamReader xml(response);
+ while (!xml.atEnd())
+ {
+ xml.readNext();
+ if (xml.tokenType() == QXmlStreamReader::StartElement)
+ {
+ qDebug()<<("inside tag");
+ //If the tag is contact
+ if (xml.name() == "photoid")
+ {
+ qDebug()<<("photoid tag found");
+ result=TRUE;
+ }
+ else
+ result=FALSE;
+ }//end If
+ }//endWhile;
+
+ aResult->setValue(result);
+ if (listIndex < count)
+ {
+ listIndex=listIndex+1;
+ error = SmfPluginErrNone;
+ aRetType = SmfSendRequestAgain;
+
+ }
+ else
+ {
+ //Final result sent
+ count=1; //clear counter
+ aRetType = SmfRequestComplete;
+ error = SmfPluginErrNone;
+ }
+
+ }
else if (SmfPicturePostComment == aOperation)
{
qDebug()<<"Response for adding comment on a photo";
--- a/example/flickrgalleryplugin/plugin_commonU.def Thu Sep 16 11:15:30 2010 +0530
+++ b/example/flickrgalleryplugin/plugin_commonU.def Thu Sep 23 17:15:03 2010 +0530
@@ -1,5 +1,5 @@
; ==============================================================================
-; Generated by qmake (2.01a) (Qt 4.6.2) on: 2010-07-30T14:11:44
+; Generated by qmake (2.01a) (Qt 4.6.2) on: 2010-09-23T11:35:50
; This file is generated by qmake and should not be modified by the
; user.
; Name : plugin_commonU.def
--- a/example/flickrgalleryplugin/qmakepluginstubs/flickrgalleryplugin.qtplugin Thu Sep 16 11:15:30 2010 +0530
+++ b/example/flickrgalleryplugin/qmakepluginstubs/flickrgalleryplugin.qtplugin Thu Sep 23 17:15:03 2010 +0530
@@ -1,1 +1,1 @@
-This file is a Qt plugin stub file. The real Qt plugin is located in \sys\bin. Created:2010-07-30T14:11:44
+This file is a Qt plugin stub file. The real Qt plugin is located in \sys\bin. Created:2010-09-23T11:35:50
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/example/lastfmmusiceventplugin/lastfmmusiceventplugin.cpp Thu Sep 23 17:15:03 2010 +0530
@@ -0,0 +1,955 @@
+/*
+ * lastfmmusiceventplugin.cpp
+ *
+ * Created on: Jun 21, 2010
+ * Author: ankitg
+ */
+
+//Include files
+#include <QtPlugin>
+#include <QCryptographicHash>
+#include <QDataStream>
+#include <QTextStream>
+#include <QFile>
+#include <QNetworkReply>
+#include <QMap>
+#include <QListIterator>
+#include <QXmlStreamReader>
+#include <SmfPicture.h>
+#include <QSettings>
+#include "lastfmmusiceventplugin.h"
+
+
+
+//Added for testing - start
+//static const QString apiKey = "8823ece35e487bada68fa893d7ecf91e";
+//static const QString apiKey = "50ac6d6581c3784efe40748fe87d8413";
+//static const QString apiSecret = "20ccb1cc62aa50caf7d8aae31808d429";
+//static const QString apiSecret = "623f4274bcea772fd6f411cf298b6bfa";
+//static const QString miniToken = "773193698 ";
+
+//static const QString apiKey = "eb3a2d8361718782ebf3887f2bb8775b";
+//static const QString apiSecret = "7a390c4c1ec4fef41cef4d77354b30f8"; // created on 12th Aug
+
+static const QString apiKey = "50ac6d6581c3784efe40748fe87d8413";
+static const QString apiSecret = "623f4274bcea772fd6f411cf298b6bfa"; // created on 23th Aug
+
+//QString fullToken = "72157624000326005-e6cba1c7665a778e";
+
+//Payload data array
+QByteArray payload;
+QString uids;
+/**
+ * Method called by plugins for logging
+ * @param log string to be logged
+ */
+void MusicEventPlugin::writeLog(QString log) const
+ {
+ QFile file("c:\\data\\PluginLogs.txt");
+ if (!file.open(QIODevice::Append | QIODevice::Text))
+ ;
+ QTextStream out(&file);
+ out << log << "\n";
+ file.close();
+ }
+/**
+ * Method to interpret the key sets obtained from credential manager
+ * @param aApiKey [out] The api key
+ * @param aApiSecret [out] The api secret
+ * @param aSessionKey [out] The session key
+ * @param aSessionSecret [out] The session secret
+ * @param aAppId [out] The application ID
+ */
+void MusicEventPlugin::fetchKeys( QString &aApiKey,
+ QString &aApiSecret,
+ QString &aSessionKey,
+ QString &aSessionSecret )
+ {
+ writeLog("Inside MusicEventPlugin::fetchKeys()");
+
+ writeLog("Reg Token = "+m_provider->m_smfRegToken);
+ writeLog("Expiry Date as int = "+m_provider->m_validity.toTime_t());
+
+ SmfAuthParams keys;
+ SmfPluginUtil util;
+ util.getAuthKeys(keys, m_provider->m_smfRegToken,
+ m_provider->m_validity, m_provider->m_pluginId);
+
+ writeLog("Number of key-value pairs = "+keys.count());
+
+ QByteArray keyName;
+ keyName.append("ApiKey");
+ aApiKey.append(keys.value(keyName));
+
+ keyName.clear();
+ keyName.append("ApiSecret");
+ aApiSecret.append(keys.value(keyName));
+
+ keyName.clear();
+ keyName.append("SessionKey");
+ aSessionKey.append(keys.value(keyName));
+
+ keyName.clear();
+ keyName.append("SessionSecret");
+ aSessionSecret.append(keys.value(keyName));
+
+ writeLog("Api Key = "+aApiKey);
+ writeLog("Api Secret = "+aApiSecret);
+ writeLog("session Key = "+aSessionKey);
+ writeLog("session Secret = "+aSessionSecret);
+ }
+/**
+ * Destructor
+ */
+MusicEventPlugin::~MusicEventPlugin()
+ {
+ if(m_provider)
+ delete m_provider;
+ }
+
+
+/**
+ * Method called by plugins to generate a signature string from a base string
+ * @param aBaseString The base string
+ * @return The md5 hash of the base string
+ */
+QString MusicEventPlugin::generateSignature(const QString aBaseString)
+ {
+ writeLog("MusicEventPlugin::generateSignature");
+
+ // Create md5 hash of the signature string
+ QByteArray byteArray;
+ byteArray.insert(0, aBaseString.toAscii());
+
+ QByteArray md5Hash = QCryptographicHash::hash(byteArray,QCryptographicHash::Md5 ).toHex();
+ QString returnString (md5Hash);
+ return returnString;
+ }
+
+/**
+ * Method to get the events based on location
+ * @param aRequest [out] The request data to be sent to network
+ * @param aLocation Location of the event
+ * @param aPageNum The page to be extracted
+ * @param aItemsPerPage Number of items per page
+ * @return SmfPluginError Plugin error if any, else SmfPluginErrNone
+ */
+/*SmfPluginError MusicEventPlugin::events( SmfPluginRequestData &aRequest,
+ const QGeoPositionInfo &aLocation,const int aPageNum,
+ const int aItemsPerPage)
+ {
+ Q_UNUSED(aItemsPerPage);
+ SmfPluginError error = SmfPluginErrUserNotLoggedIn;
+
+ writeLog("MusicEventPlugin::events()");
+
+ QString baseString;
+ baseString.append(apiSecret);
+ baseString.append("api_key"+apiKey);
+ baseString.append("auth_token");
+ baseString.append("formatjson");
+ baseString.append("location=Delhi");
+ baseString.append("method=geo.getEvents");
+ writeLog("Url string is :"+baseString);
+
+ // Create the url
+ QUrl url("http://ws.audioscrobbler.com/2.0/?");
+ url.addQueryItem("method", "geo.getevents");
+ url.addQueryItem("location","madrid");
+ url.addQueryItem("api_key", apiKey);
+ url.addQueryItem("format","json");
+ url.addQueryItem("auth_token","");
+ url.addQueryItem("api_sig", generateSignature(baseString));
+ writeLog("/n/n"+generateSignature(baseString));
+ writeLog("/n/n Response is :"+url.toString());
+ // Create the request, set the url
+ aRequest.iNetworkRequest.setUrl(url);
+ aRequest.iRequestType = SmfMusicGetEventsOnLoc;
+ aRequest.iPostData = NULL;
+ aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation;
+ error = SmfPluginErrNone;
+ return error;
+ }
+ */
+/**
+ * Method to get the venues based on location
+ * @param aRequest [out] The request data to be sent to network
+ * @param aLocation Location of the venue
+ * @param aPageNum The page to be extracted
+ * @param aItemsPerPage Number of items per page
+ * @return SmfPluginError Plugin error if any, else SmfPluginErrNone
+ */
+SmfPluginError MusicEventPlugin::venues( SmfPluginRequestData &aRequest,
+ const SmfLocation &aLocation,const int aPageNum,
+ const int aItemsPerPage)
+ {
+ Q_UNUSED(aItemsPerPage);
+ Q_UNUSED(aPageNum);
+
+ SmfPluginError error = SmfPluginErrUserNotLoggedIn;
+
+ // Get the key sets from SMF Plugin Utility class.
+ QString apiKey;
+ QString apiSecret;
+ QString sessionKey;
+ QString sessionSecret;
+ fetchKeys(apiKey, apiSecret, sessionKey, sessionSecret);
+ writeLog("API KEY"+apiKey);
+ writeLog("API SECRET"+apiSecret);
+ writeLog("SessionKey"+sessionKey);
+ writeLog("sessionSecret"+sessionSecret);
+ writeLog("MusicEventPlugin::Venues()");
+ //QString qName("New York");
+ //aLocation.setCity(qName);
+ //QString qLocation = aLocation.city();
+ //640418
+ //QString qLocation("New York");
+/* QString baseString;
+ baseString.append(apiSecret);
+ baseString.append("api_key"+apiKey);
+ baseString.append("auth_token");
+ baseString.append("formatjson");
+ baseString.append("location ="+aLocation.city());
+ baseString.append("method=geo.getEvents");
+ writeLog("Url string is :"+baseString);
+
+ //Create the url
+ QUrl url("http://ws.audioscrobbler.com/2.0/?");
+ url.addQueryItem("method", "geo.getevents");
+ url.addQueryItem("location",aLocation.city());
+ url.addQueryItem("api_key", apiKey);
+ url.addQueryItem("api_key", apiKey);
+ url.addQueryItem("format","json");
+ url.addQueryItem("auth_token","");
+ url.addQueryItem("api_sig", generateSignature(baseString));
+
+ writeLog("/n/n"+generateSignature(baseString));
+ writeLog("/n/n Response is :"+url.toString());
+ //Create the request, set the url
+ aRequest.iNetworkRequest.setUrl(url);
+ aRequest.iRequestType = SmfEventsGetVenues;
+ aRequest.iPostData = NULL;
+ aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation;
+ error = SmfPluginErrNone;
+ return error; */
+
+
+ QString baseString;
+ baseString.append(apiSecret);
+ baseString.append("api_key"+apiKey);
+ baseString.append("auth_token");
+ baseString.append("formatjson");
+ baseString.append("location=Newyork");
+ baseString.append("method=geo.getEvents");
+ writeLog("Url string is :"+baseString);
+
+ // Create the url
+ QUrl url("http://ws.audioscrobbler.com/2.0/?");
+ url.addQueryItem("method", "geo.getevents");
+ url.addQueryItem("location","Newyork");
+ url.addQueryItem("api_key", apiKey);
+ url.addQueryItem("format","json");
+ url.addQueryItem("auth_token","");
+ url.addQueryItem("api_sig", generateSignature(baseString));
+ writeLog("/n/n"+generateSignature(baseString));
+ writeLog("/n/n Response is :"+url.toString());
+ // Create the request, set the url
+ aRequest.iNetworkRequest.setUrl(url);
+ aRequest.iRequestType = SmfEventsGetEvents;
+ aRequest.iPostData = NULL;
+ aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation;
+ error = SmfPluginErrNone;
+ return error;
+
+
+ }
+
+/**
+ * Method to get the events based on venues
+ * @param aRequest [out] The request data to be sent to network
+ * @param aVenue Venue of the event
+ * @param aPageNum The page to be extracted
+ * @param aItemsPerPage Number of items per page
+ * @return SmfPluginError Plugin error if any, else SmfPluginErrNone
+ */
+SmfPluginError MusicEventPlugin::events( SmfPluginRequestData &aRequest,
+ const SmfLocation &aVenue,const int aPageNum,
+ const int aItemsPerPage)
+ {
+ Q_UNUSED(aItemsPerPage);
+ Q_UNUSED(aPageNum);
+
+ SmfPluginError error = SmfPluginErrUserNotLoggedIn;
+
+
+ // Get the key sets from SMF Plugin Utility class.
+ QString apiKey;
+ QString apiSecret;
+ QString sessionKey;
+ QString sessionSecret;
+ fetchKeys(apiKey, apiSecret, sessionKey, sessionSecret);
+ writeLog("API KEY"+apiKey);
+ writeLog("API SECRET"+apiSecret);
+ writeLog("SessionKey"+sessionKey);
+ writeLog("sessionSecret"+sessionSecret);
+
+ QString baseString;
+ baseString.append(apiSecret);
+ baseString.append("api_key"+apiKey);
+ baseString.append("auth_token");
+ baseString.append("formatjson");
+ baseString.append("location="+aVenue.city());
+ baseString.append("method=geo.getEvents");
+ writeLog("Url string is :"+baseString);
+
+ // Create the url
+ QUrl url("http://ws.audioscrobbler.com/2.0/?");
+ url.addQueryItem("method", "geo.getevents");
+ url.addQueryItem("location",aVenue.city());
+ url.addQueryItem("api_key", apiKey);
+ url.addQueryItem("format","json");
+ url.addQueryItem("auth_token","");
+ url.addQueryItem("api_sig", generateSignature(baseString));
+ writeLog("/n/n"+generateSignature(baseString));
+ writeLog("/n/n Response is :"+url.toString());
+ //Create the request, set the url
+ aRequest.iNetworkRequest.setUrl(url);
+ aRequest.iRequestType = SmfEventsGetEvents;
+ aRequest.iPostData = NULL;
+ aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation;
+ error = SmfPluginErrNone;
+ return error;
+
+ }
+
+/**
+ * Method to post events
+ * @param aRequest [out] The request data to be sent to network
+ * @param aEventList The list of events to be posted
+ * @return SmfPluginError Plugin error if any, else SmfPluginErrNone
+ */
+SmfPluginError MusicEventPlugin::postEvents( SmfPluginRequestData &aRequest,
+ const QList<SmfEvent> &aEventList )
+ {
+ Q_UNUSED(aEventList)
+ SmfPluginError error = SmfPluginErrUserNotLoggedIn;
+ writeLog("MusicEventPlugin::events()");
+ int count =aEventList.count();
+ for(int i=0;i<count;i++)
+ {
+ SmfEvent ievent=aEventList[i];
+ writeLog("Event List"+ievent.id());
+ }
+ // Get the key sets from SMF Plugin Utility class.
+ QString apiKey;
+ QString apiSecret;
+ QString sessionKey;
+ QString sessionSecret;
+ fetchKeys(apiKey, apiSecret, sessionKey, sessionSecret);
+ writeLog("API KEY"+apiKey);
+ writeLog("API SECRET"+apiSecret);
+ writeLog("SessionKey"+sessionKey);
+ writeLog("sessionSecret"+sessionSecret);
+ /* QString baseString;
+
+ baseString.append(apiSecret);
+ baseString.append("api_key"+apiKey);
+ baseString.append("auth_token");
+ baseString.append("formatjson");
+ // baseString.append("method=event.shout"); // needs authentication
+ // baseString.append("Event"+"aEventList.at(0)");
+ writeLog("Url string is :"+baseString);
+
+ //Create the url
+ QUrl url("http://ws.audioscrobbler.com/2.0/?");
+ url.addQueryItem("method", "event.shout"); // needs authentication
+ url.addQueryItem("api_key", apiKey);
+ url.addQueryItem("format","json");
+ // url.addQueryItem("Event","aEventList.at(0)");
+ url.addQueryItem("auth_token","");
+ url.addQueryItem("api_sig", generateSignature(baseString));
+ writeLog("/n/n Response is :"+url.toString());
+ // Create the request, set the url
+ aRequest.iNetworkRequest.setUrl(url);
+ aRequest.iRequestType = SmfEventsPostEvents;
+ aRequest.iPostData = NULL;
+
+ aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation;
+ error = SmfPluginErrNone;
+ return error; */
+
+ //For Testing Only
+ QString baseString;
+
+ //QString strId("328799");
+
+ QString eventId("328799");//= aEvent.id();
+ //QString eventId;
+ //eventId = aEvent.id();
+ baseString.append(apiSecret);
+ baseString.append("api_key"+apiKey);
+ //baseString.append("auth_token");
+ baseString.append("formatjson");
+ baseString.append("method=event.getattendees");
+ baseString.append("event"+eventId);
+ writeLog("Url string is :"+baseString);
+
+ //Create the url
+ QUrl url("http://ws.audioscrobbler.com/2.0/?");
+ url.addQueryItem("method", "event.getattendees");
+ url.addQueryItem("event",eventId);
+ url.addQueryItem("api_key", apiKey);
+ url.addQueryItem("format","json");
+ //url.addQueryItem("auth_token","");
+ //url.addQueryItem("api_sig", generateSignature(baseString));
+ writeLog("/n/n Response is :"+url.toString());
+ //Create the request, set the url
+ aRequest.iNetworkRequest.setUrl(url);
+ aRequest.iRequestType = SmfEventsPostEvents;
+ aRequest.iPostData = NULL;
+
+ aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation;
+ error = SmfPluginErrNone;
+ return error;
+ }
+
+/**
+ * Customised method for SmfMusicEventsPlugin interface
+ * @param aRequest [out] The request data to be sent to network
+ * @param aOperation The operation type (should be known between
+ * the client interface and the plugin)
+ * @param aData The data required to form the request (The type
+ * of data should be known between client and the plugin)
+ * @return SmfPluginError Plugin error if any, else SmfPluginErrNone
+ */
+SmfPluginError MusicEventPlugin::attendees( SmfPluginRequestData &aRequest,
+ const SmfEvent &aEvent,
+ const int aPageNum ,
+ const int aItemsPerPage )
+ {
+ Q_UNUSED(aItemsPerPage);
+ SmfPluginError error = SmfPluginErrUserNotLoggedIn;
+ writeLog("MusicEventPlugin::events()");
+
+ // Get the key sets from SMF Plugin Utility class.
+ QString apiKey;
+ QString apiSecret;
+ QString sessionKey;
+ QString sessionSecret;
+ fetchKeys(apiKey, apiSecret, sessionKey, sessionSecret);
+ writeLog("API KEY"+apiKey);
+ writeLog("API SECRET"+apiSecret);
+ writeLog("SessionKey"+sessionKey);
+ writeLog("sessionSecret"+sessionSecret);
+ QString baseString;
+
+ //QString strId("328799");
+ //aEvent.setId(strId);
+ //QString eventId = aEvent.id();
+ QString eventId;
+ eventId = aEvent.id();
+ baseString.append(apiSecret);
+ baseString.append("api_key"+apiKey);
+ //baseString.append("auth_token");
+ baseString.append("formatjson");
+ baseString.append("method=event.getattendees");
+ baseString.append("event"+eventId);
+ writeLog("Url string is :"+baseString);
+
+ //Create the url
+ QUrl url("http://ws.audioscrobbler.com/2.0/?");
+ url.addQueryItem("method", "event.getattendees");
+ url.addQueryItem("event",eventId);
+ url.addQueryItem("api_key", apiKey);
+ url.addQueryItem("format","json");
+ // url.addQueryItem("auth_token","");
+ // url.addQueryItem("api_sig", generateSignature(baseString));
+ writeLog("/n/n Response is :"+url.toString());
+ //Create the request, set the url
+ aRequest.iNetworkRequest.setUrl(url);
+ aRequest.iRequestType = SmfEventsGetEventAttendees;
+ aRequest.iPostData = NULL;
+
+
+
+ aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation;
+ error = SmfPluginErrNone;
+ return error;
+ }
+SmfPluginError MusicEventPlugin::customRequest( SmfPluginRequestData &aRequest,
+ const int &aOperation, QByteArray *aData )
+ {
+ Q_UNUSED(aRequest)
+ Q_UNUSED(aOperation)
+ Q_UNUSED(aData)
+ //SmfEventsCustomRequest
+ return SmfPluginErrServiceNotSupported;
+ }
+
+/**
+ * The first method to be called in the plugin that implements this interface.
+ * If this method is not called, plugin may not behave as expected.
+ * Plugins are expected to save the aUtil handle and use and when required.
+ * @param aUtil The instance of SmfPluginUtil
+ */
+void MusicEventPlugin::initialize(/* SmfPluginUtil *aUtil */)
+ {
+ // Save the SmfPluginUtil handle
+ //m_util = aUtil;
+
+ // Create an instance of MusicProviderBase
+ m_provider = new MusicProviderBase;
+ m_provider->initialize();
+ }
+
+/**
+ * Method to get the provider information
+ * @return Instance of SmfProviderBase
+ */
+SmfProviderBase* MusicEventPlugin::getProviderInfo( )
+ {
+ return m_provider;
+ }
+
+/**
+ * Method to get the result for a network request.
+ * @param aOperation The type of operation to be requested
+ * @param aTransportResult The result of transport operation
+ * @param aResponse The QByteArray instance containing the network response.
+ * The plugins should delete this instance once they have read the
+ * data from it.
+ * @param aResult [out] An output parameter to the plugin manager.If the
+ * return value is SmfSendRequestAgain, QVariant will be of type
+ * SmfPluginRequestData.
+ * For SmfGalleryPlugin: If last operation was pictures(), aResult will
+ * be of type QList<SmfPicture>. If last operation was description(),
+ * aResult will be of type QString. If last operation was upload() or
+ * postComment(), aResult will be of type bool.
+ * @param aRetType [out] SmfPluginRetType
+ * @param aPageResult [out] The SmfResultPage structure variable
+ */
+SmfPluginError MusicEventPlugin::responseAvailable(
+ const SmfRequestTypeID aOperation,
+ const SmfTransportResult &aTransportResult,
+ QByteArray *aResponse,
+ QVariant* aResult,
+ SmfPluginRetType &aRetType,
+ SmfResultPage &aPageResult )
+ {
+ writeLog("MusicEventPlugin::responseAvailable");
+ Q_UNUSED(aPageResult)
+ SmfPluginError error = SmfPluginErrNetworkError;
+
+ if( !aResponse || (0 == aResponse->size()) )
+ {
+ writeLog("Response is NULL or empty");
+ aRetType = SmfRequestError;
+ return error;
+ }
+
+ QByteArray response(*aResponse);
+ delete aResponse;
+
+ //Write the response to a file
+ QFile file("c:\\data\\musiceventresponse.txt");
+ writeLog("response data written to c:\\data\\musiceventresponse.txt");
+
+ if (!file.open(QIODevice::Append | QIODevice::Text));
+ file.write(response);
+ file.close();
+
+ writeLog("MusicEvent response = "+QString(response));
+ writeLog("MusicEvent response size = "+QString::number(response.size(), 10));
+
+ if(SmfTransportOpNoError == aTransportResult)
+ {
+ writeLog("No transport error");
+ // QVariantMap map1;
+ // bool resType=response.startsWith("<?xml");
+ /* if(resType) //XML REsponse
+ {
+ writeLog("Before XML Parser--");
+
+ }
+ else //JSON RESPONSE
+ {
+ bool ok;
+ writeLog("Before JSON Parser--");
+
+ SmfPluginUtil util;
+ QVariant result = util.parse(response, &ok);
+ if (!ok)
+ {
+ writeLog("An error occurred during json parsing");
+ aRetType = SmfRequestError;
+ return SmfPluginErrParsingFailed;
+ }
+
+ //map1 = result.toMap();*/
+ //}
+ if(SmfEventsGetEvents == aOperation /*|| SmfMusicGetEventsOnVenue == aOperation*/)
+ {
+
+ QDateTime dt = QDateTime::currentDateTime();
+ QList<SmfEvent> eventlist;
+
+
+
+ //Tested By Hardcoding
+
+ SmfEvent event;
+ event.setId("111111");
+ event.setTitle("bangalore");
+ event.setEventDateTime(dt);
+ QStringList stringList; //for artist
+ stringList.append("sssss");
+ stringList.append("aaaa");
+ SmfArtists artists;
+ artists.setNames(stringList);
+ event.setArtists(artists);
+
+ SmfLocation Location;
+ Location.setCity("Bangalore");
+ Location.setCountry("india");
+
+ event.setVenue(Location);
+ eventlist.append(event);
+
+ //2nd Event
+ SmfEvent event1;
+ event1.setId("2222");
+ event1.setTitle("delhi");
+ event1.setEventDateTime(dt);
+ QStringList stringList1; //for artist
+ stringList1.append("ddddd");
+ stringList1.append("rrrrrr");
+ SmfArtists artists1;
+ artists1.setNames(stringList1);
+ event1.setArtists(artists1);
+
+ SmfLocation Location1;
+ Location1.setCity("Delhi");
+ Location1.setCountry("india");
+
+ event1.setVenue(Location1);
+ eventlist.append(event1);
+
+ writeLog("SmfEventsGetEvents = ");
+ /*QVariantMap eventmap = map1["events"].toMap();
+ QList<QVariant> list1 = eventmap["event"].toList();
+
+ QListIterator<QVariant> iter(list1);
+ writeLog("SmfEventsGetEvents123 = ");
+ while(iter.hasNext()) //not runing for one event
+ {
+ SmfEvent event;
+ QVariantMap map2 = iter.next().toMap();
+ writeLog("id = "+map2["id"].toString());
+ event.setId(map2["id"].toString());
+ writeLog("title = "+map2["title"].toString());
+ event.setTitle(map2["title"].toString());
+ writeLog("EventDateTime= "+map2["startDate"].toString());
+ event.setEventDateTime(map2["startDate"].toDateTime());
+ // writeLog("SetdUration= "+map2["startDate"].toDateTime()); //didn't find that
+ //for Getting the Artist List
+ QVariantMap map4 = map2["artists"].toMap();
+ QList<QVariant> artistList =map4["artist"].toList();
+
+ writeLog("artist"+map4["artist"].toString());
+
+ // writeLog("artists"+artistList["artist"].toString());
+ // QList<QVariant> artistList =map2["artists"].toList();
+
+
+ QListIterator<QVariant> iterartists(artistList);
+ SmfArtists artists;
+ QStringList stringList;
+ while(iterartists.hasNext())
+ {
+
+ //QString artistName;
+ QString artistName = iterartists.next().toString();
+ writeLog("artist Name = "+ artistName);
+ //artistName.append(map2["artist"].toString());
+ stringList.append(artistName);
+
+ }//end while
+ //writeLog("artists= "+stringList[0]);
+
+ artists.setNames(stringList);
+ event.setArtists(artists);
+
+ //all Artist list we got
+ //For Venue
+ SmfLocation Location;
+ QVariantMap map3 = map2["venue"].toMap();
+ writeLog("LocationId : "+map3["id"].toString());
+ Location.setId(map3["id"].toString());
+ //for city
+ QVariantMap map6 = map3["location"].toMap();
+ writeLog("Location city : "+map6["city"].toString());
+ Location.setCity(map6["city"].toString());
+ writeLog("Location city : "+map6["country"].toString());
+ Location.setCountry(map6["country"].toString());
+ // Location.geoPositionInfo() dont know how to set
+ event.setVenue(Location);
+ eventlist.append(event);
+ }//end While*/
+ aResult->setValue(eventlist);
+ aRetType = SmfRequestComplete;
+ error = SmfPluginErrNone;
+ }
+ else if(SmfEventsGetVenues == aOperation)
+ {
+ writeLog("SmfEventsGetVenues = ");
+ QList<SmfLocation> LocationList;
+ SmfLocation Location;
+ Location.setId("111111");
+ //for city
+ Location.setCity("delhi");
+ Location.setCountry("India");
+ Location.setUrl(QUrl("http://wwwqqqqq/ee"));
+ LocationList.append(Location);
+
+ SmfLocation Location1;
+ Location1.setId("22222");
+ //for city
+ Location1.setCity("bangalore");
+ Location1.setCountry("India");
+ LocationList.append(Location1);
+
+ aResult->setValue(LocationList);
+ aRetType = SmfRequestComplete;
+ error = SmfPluginErrNone;
+
+
+ }
+
+ else if (SmfEventsPostEvents == aOperation)
+ {
+ writeLog("SmfEventsPostEvents = ");
+ bool postEvent=true;
+ aResult->setValue(postEvent);
+ aRetType = SmfRequestComplete;
+ error = SmfPluginErrNone;
+
+ }
+ else if (SmfEventsGetEventAttendees == aOperation)
+ {
+
+ QList<SmfContact> contactList;
+
+ writeLog("SmfMusicGetEventsAttendees = ");
+ bool ok;
+ writeLog("Before Parser--");
+
+ SmfPluginUtil util;
+ QVariantMap result = util.parse(response, &ok).toMap();
+ if (!ok)
+ {
+ writeLog("An error occurred during json parsing");
+ aRetType = SmfRequestError;
+ return SmfPluginErrParsingFailed;
+
+ }
+
+ //QVariantMap map1 = result.toMap();
+ writeLog("MAP1");
+
+
+ QVariantMap map1 = result["attendees"].toMap();
+ //QVariantMap map2 = map1["attendees"].toMap();
+ writeLog("MAP2");
+ //int page = map2["page"].toInt(&ok);
+ QList<QVariant> list1 = map1["user"].toList();
+ writeLog("list count"+QString::number(list1.count(),10));
+
+ QListIterator<QVariant> i(list1);
+ writeLog("iterate list"); //While loop not work if there is only one attendee
+ while(i.hasNext())
+ {
+ writeLog("inside loop");
+ SmfContact contact;
+ QVariantMap map2 = i.next().toMap();
+ writeLog("name= "+map2["name"].toString());
+ writeLog("realname = "+map2["realname"].toString());
+
+ //Contact Name
+ QContactName contactname;
+ QString username = map2["name"].toString();
+ writeLog("name = "+username);
+ contactname.setFirstName(username);
+ contactname.setLastName(username);
+ QVariant nameVar = QVariant::fromValue(contactname);
+ contact.setValue("Name",nameVar);
+ contactList.append(contact);
+ }
+ aResult->setValue(contactList);
+ aRetType = SmfRequestComplete;
+ error = SmfPluginErrNone;
+
+ }
+ else
+ {
+ writeLog("Service unsupported!!!");
+ aRetType = SmfRequestError;
+ error = SmfPluginErrServiceNotSupported;
+ }
+ }//end if of if(SmfTransportOpNoError == aTransportResult)
+
+ else if(SmfTransportOpOperationCanceledError == aTransportResult)
+ {
+ writeLog("Operation Cancelled !!!");
+ error = SmfPluginErrCancelComplete;
+ aRetType = SmfRequestComplete;
+ }
+
+ else
+ {
+ writeLog("Transport Error !!!");
+ error = SmfPluginErrNetworkError;
+ aRetType = SmfRequestError;
+ }
+
+ return error;
+ }
+
+
+/**
+ * Destructor
+ */
+MusicProviderBase::~MusicProviderBase( )
+ {
+ }
+
+/**
+ * Method to get the Localisable name of the service.
+ * @return The Localisable name of the service.
+ */
+QString MusicProviderBase::serviceName( ) const
+ {
+ return m_serviceName;
+ }
+
+/**
+ * Method to get the Logo of the service
+ * @return The Logo of the service
+ */
+QImage MusicProviderBase::serviceIcon( ) const
+ {
+ return m_serviceIcon;
+ }
+
+/**
+ * Method to get the Readable service description
+ * @return The Readable service description
+ */
+QString MusicProviderBase::description( ) const
+ {
+ return m_description;
+ }
+
+/**
+ * Method to get the Website of the service
+ * @return The Website of the service
+ */
+QUrl MusicProviderBase::serviceUrl( ) const
+ {
+ return m_serviceUrl;
+ }
+
+/**
+ * Method to get the URL of the Application providing this service
+ * @return The URL of the Application providing this service
+ */
+QUrl MusicProviderBase::applicationUrl( ) const
+ {
+ return m_applicationUrl;
+ }
+
+/**
+ * Method to get the Icon of the application
+ * @return The Icon of the application
+ */
+QImage MusicProviderBase::applicationIcon( ) const
+ {
+ return m_applicationIcon;
+ }
+/**
+* Method to get the list of interfaces that this provider support
+* @return List of supported Interafces
+*/
+QList<QString> MusicProviderBase::supportedInterfaces( ) const
+ {
+ return m_serviceType;
+ }
+
+/**
+* Method to get the list of languages supported by this service provider
+* @return a QStringList of languages supported by this service
+* provider in 2 letter ISO 639-1 format.
+*/
+QStringList MusicProviderBase::supportedLanguages( ) const
+ {
+ return m_supportedLanguages;
+ }
+
+/**
+ * Method to get the Plugin specific ID
+ * @return The Plugin specific ID
+ */
+QString MusicProviderBase::pluginId( ) const
+ {
+ return m_pluginId;
+ }
+
+/**
+ * Method to get the ID of the authentication application
+ * for this service
+ * @param aProgram The authentication application name
+ * @param aArguments List of arguments required for authentication app
+ * @param aMode Strting mode for authentication application
+ * @return The ID of the authentication application
+ */
+QString MusicProviderBase::authenticationApp( QString &aProgram,
+ QStringList & aArguments,
+ QIODevice::OpenModeFlag aMode ) const
+ {
+ return m_authAppId;
+ }
+
+/**
+ * Method to get the unique registration ID provided by the
+ * Smf for authorised plugins
+ * @return The unique registration ID/token provided by the Smf for
+ * authorised plugins
+ */
+QString MusicProviderBase::smfRegistrationId( ) const
+ {
+ return m_smfRegToken;
+ }
+
+void MusicProviderBase::initialize()
+ {
+
+ m_serviceName = "Last.fm";
+ m_description = "Description";
+ m_serviceUrl = QUrl(QString("http://ws.audioscrobbler.com"));
+ // m_serviceType << m_serviceName << m_description;// << (QString)(m_serviceUrl);
+ m_supportedLanguages << "English" ;
+ m_pluginId = "lastfmmusiceventplugin.qtplugin";
+ m_authAppId = "0xE1D8C7D8";
+ QSettings iSettings;
+ m_smfRegToken = iSettings.value("CMLastFmRegToken").toString();
+ m_validity = iSettings.value("LastFmExpiryTime").toDateTime();
+ //m_smfRegToken = "hsdfusdghf"; //yet to be recvd
+
+ }
+
+
+/*
+ * Export Macro
+ * plugin name : musiceventplugin
+ * plugin class : MusicEventPlugin
+ */
+Q_EXPORT_PLUGIN2( musiceventplugin, MusicEventPlugin )
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/example/lastfmmusiceventplugin/lastfmmusiceventplugin.h Thu Sep 23 17:15:03 2010 +0530
@@ -0,0 +1,292 @@
+/*
+ * lastfmmusiceventplugin.h
+ *
+ * Created on: Jun 21, 2010
+ * Author: ankitg
+ */
+
+#ifndef LASTFMMUSICEVENTPLUGIN_H_
+#define LASTFMMUSICEVENTPLUGIN_H_
+
+// Include files
+#include "smfeventsfetcherplugin.h"
+#include "smfpluginutil.h"
+
+#include <parser.h>
+
+// Forward declarations
+class MusicProviderBase;
+class QVariant;
+class QNetworkReply;
+
+// Class declaration
+class MusicEventPlugin : public QObject, public SmfEventsFetcherPlugin
+{
+ Q_OBJECT
+ Q_INTERFACES( SmfEventsFetcherPlugin SmfPluginBase )
+
+public:
+ virtual ~MusicEventPlugin();
+
+public: // From SmfMusicEventsPlugin
+
+ /**
+ * Method to get the events based on location
+ * @param aRequest [out] The request data to be sent to network
+ * @param aLocation Location of the event
+ * @param aPageNum The page to be extracted
+ * @param aItemsPerPage Number of items per page
+ * @return SmfPluginError Plugin error if any, else SmfPluginErrNone
+ */
+ /*SmfPluginError events( SmfPluginRequestData &aRequest,
+ const QGeoPositionInfo &aLocation,
+ const int aPageNum = SMF_FIRST_PAGE,
+ const int aItemsPerPage = SMF_ITEMS_PER_PAGE );
+ */
+
+ /**
+ * Method to get the venues based on location
+ * @param aRequest [out] The request data to be sent to network
+ * @param aLocation Location of the venue
+ * @param aPageNum The page to be extracted
+ * @param aItemsPerPage Number of items per page
+ * @return SmfPluginError Plugin error if any, else SmfPluginErrNone
+ */
+ void fetchKeys( QString &aApiKey,
+ QString &aApiSecret,
+ QString &aSessionKey,
+ QString &aSessionSecret );
+ SmfPluginError venues( SmfPluginRequestData &aRequest,
+ const SmfLocation &aLocation,
+ const int aPageNum = SMF_FIRST_PAGE,
+ const int aItemsPerPage = SMF_ITEMS_PER_PAGE );
+
+ /**
+ * Method to get the events based on venues
+ * @param aRequest [out] The request data to be sent to network
+ * @param aVenue Venue of the event
+ * @param aPageNum The page to be extracted
+ * @param aItemsPerPage Number of items per page
+ * @return SmfPluginError Plugin error if any, else SmfPluginErrNone
+ */
+ SmfPluginError events( SmfPluginRequestData &aRequest,
+ const SmfLocation &aVenue,
+ const int aPageNum = SMF_FIRST_PAGE,
+ const int aItemsPerPage = SMF_ITEMS_PER_PAGE );
+
+ /**
+ * Method to post events
+ * @param aRequest [out] The request data to be sent to network
+ * @param aEventList The list of events to be posted
+ * @return SmfPluginError Plugin error if any, else SmfPluginErrNone
+ */
+ SmfPluginError postEvents( SmfPluginRequestData &aRequest,
+ const QList<SmfEvent> &aEventList );
+
+
+ /*** Method to get the list of attendees for a musical event
+ * @param aRequest [out] The request data to be sent to network
+ * @param aEvent The event for which attendees should be fetched
+ * @param aPageNum The page to be extracted
+ * @param aItemsPerPage Number of items per page
+ * @return SmfPluginError Plugin error if any, else SmfPluginErrNone
+ */
+ SmfPluginError attendees( SmfPluginRequestData &aRequest,
+ const SmfEvent &aEvent,
+ const int aPageNum = SMF_FIRST_PAGE,
+ const int aItemsPerPage = SMF_ITEMS_PER_PAGE );
+
+ /**
+ * Customised method for SmfMusicEventsPlugin interface
+ * @param aRequest [out] The request data to be sent to network
+ * @param aOperation The operation type (should be known between
+ * the client interface and the plugin)
+ * @param aData The data required to form the request (The type
+ * of data should be known between client and the plugin)
+ * @return SmfPluginError Plugin error if any, else SmfPluginErrNone
+ */
+ SmfPluginError customRequest( SmfPluginRequestData &aRequest,
+ const int &aOperation, QByteArray *aData );
+
+
+
+
+public: // From SmfPluginBase
+ /**
+ * The first method to be called in the plugin that implements this interface.
+ * If this method is not called, plugin may not behave as expected.
+ * Plugins are expected to save the aUtil handle and use and when required.
+ * @param aUtil The instance of SmfPluginUtil
+ */
+ void initialize(/*SmfPluginUtil *aUtil*/);
+
+ /**
+ * Method to get the provider information
+ * @return Instance of SmfProviderBase
+ */
+ SmfProviderBase* getProviderInfo( );
+
+ /**
+ * Method to get the result for a network request.
+ * @param aTransportResult The result of transport operation
+ * @param aReply The QNetworkReply instance for the request
+ * @param aResult [out] An output parameter to the plugin manager.If the
+ * return value is SmfSendRequestAgain, QVariant will be of type
+ * SmfPluginRequestData.
+ * For SmfGalleryPlugin: If last operation was pictures(), aResult will
+ * be of type QList<SmfPicture>. If last operation was description(),
+ * aResult will be of type QString. If last operation was upload() or
+ * postComment(), aResult will be of type bool.
+ * @param aRetType [out] SmfPluginRetType
+ * @param aPageResult [out] The SmfResultPage structure variable
+ */
+ /* SmfPluginError responseAvailable(
+ const SmfTransportResult &aTransportResult,
+ QNetworkReply *aReply,
+ QVariant* aResult,
+ SmfPluginRetType &aRetType,
+ SmfResultPage &aPageResult );*/
+ SmfPluginError responseAvailable(
+ const SmfRequestTypeID aOperation,
+ const SmfTransportResult &aTransportResult,
+ QByteArray *aResponse,
+ QVariant* aResult,
+ SmfPluginRetType &aRetType,
+ SmfResultPage &aPageResult );
+
+ void writeLog(QString log) const;
+
+
+private:
+
+ QString generateSignature(const QString aBaseString);
+
+
+private slots:
+
+
+
+private:
+ /**
+ * Method called by plugins to generate a request data
+ * @param aRequest [out] The request data to be sent to network
+ * @param aOperation The type of http operation
+ * @param aSignatureMethod The signature method to be used
+ * @param aParams A map of parameters to its values
+ * @param aMode The mode of creation of the request
+ * @param aPostData The data to be posted (for HTTP POST
+ * only, else it will be NULL)
+ * @return SmfPluginError Plugin error if any, else SmfPluginErrNone
+ */
+ SmfPluginError createRequest( SmfPluginRequestData &aRequest,
+ const QNetworkAccessManager::Operation aOperation,
+ const SmfSignatureMethod aSignatureMethod,
+ QMultiMap<QByteArray, QByteArray> &aParams,
+ const SmfParsingMode aMode,
+ QBuffer *aPostData );
+
+private:
+ MusicProviderBase *m_provider;
+ SmfPluginUtil *m_util;
+};
+
+// Class declaration
+class MusicProviderBase : public QObject, public SmfProviderBase
+ {
+ Q_OBJECT
+ Q_INTERFACES( SmfProviderBase )
+
+public:
+ virtual ~MusicProviderBase( );
+
+ /**
+ * Method to get the Localisable name of the service.
+ * @return The Localisable name of the service.
+ */
+ QString serviceName( ) const;
+
+ /**
+ * Method to get the Logo of the service
+ * @return The Logo of the service
+ */
+ QImage serviceIcon( ) const;
+
+ /**
+ * Method to get the Readable service description
+ * @return The Readable service description
+ */
+ QString description( ) const;
+
+ /**
+ * Method to get the Website of the service
+ * @return The Website of the service
+ */
+ QUrl serviceUrl( ) const;
+
+ /**
+ * Method to get the URL of the Application providing this service
+ * @return The URL of the Application providing this service
+ */
+ QUrl applicationUrl( ) const;
+
+ /**
+ * Method to get the Icon of the application
+ * @return The Icon of the application
+ */
+ QImage applicationIcon( ) const;
+
+ /**
+ * Method to get the list of interfaces that this provider support
+ * @return List of supported Interafces
+ */
+ QList<QString> supportedInterfaces( ) const;
+
+ /**
+ * Method to get the list of languages supported by this service provider
+ * @return a QStringList of languages supported by this service
+ * provider in 2 letter ISO 639-1 format.
+ */
+ QStringList supportedLanguages( ) const;
+
+ /**
+ * Method to get the Plugin specific ID
+ * @return The Plugin specific ID
+ */
+ QString pluginId( ) const;
+
+ /**
+ * Method to get the ID of the authentication application
+ * for this service
+ * @param aProgram The authentication application name
+ * @param aArguments List of arguments required for authentication app
+ * @param aMode Strting mode for authentication application
+ * @return The ID of the authentication application
+ */
+ QString authenticationApp( QString &aProgram, QStringList & aArguments,
+ QIODevice::OpenModeFlag aMode = QIODevice::ReadWrite ) const;
+
+ /**
+ * Method to get the unique registration ID provided by the
+ * Smf for authorised plugins
+ * @return The unique registration ID/token provided by the Smf for
+ * authorised plugins
+ */
+ QString smfRegistrationId( ) const;
+
+private:
+ friend class MusicEventPlugin;
+ void initialize();
+ QString m_serviceName;
+ QImage m_serviceIcon;
+ QString m_description;
+ QUrl m_serviceUrl;
+ QUrl m_applicationUrl;
+ QImage m_applicationIcon;
+ QStringList m_serviceType;
+ QStringList m_supportedLanguages;
+ QString m_pluginId;
+ QString m_authAppId;
+ QString m_smfRegToken;
+ QDateTime m_validity;
+ };
+#endif /* LASTFMMUSICEVENTPLUGIN_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/example/lastfmmusiceventplugin/lastfmmusiceventplugin.pro Thu Sep 23 17:15:03 2010 +0530
@@ -0,0 +1,37 @@
+TEMPLATE = lib
+CONFIG += plugin \
+ mobility
+MOBILITY += location \
+ contacts
+QT += core \
+ network
+HEADERS = lastfmmusiceventplugin.h
+SOURCES = lastfmmusiceventplugin.cpp
+TARGET = $$qtLibraryTarget(lastfmmusiceventplugin)
+symbian: {
+ # Load predefined include paths (e.g. QT_PLUGINS_BASE_DIR) to be used in the pro-files
+ load(data_caging_paths)
+
+ # EPOCALLOWDLLDATA have to set true because Qt macros has initialised global data
+ TARGET.EPOCALLOWDLLDATA = 1
+
+ # Defines plugin files into Symbian .pkg package
+ pluginDep.sources = lastfmmusiceventplugin.dll
+ pluginDep.path = $$QT_PLUGINS_BASE_DIR/smf/plugin/events.fetcher
+ DEPLOYMENT += pluginDep
+ TARGET.CAPABILITY = ReadUserData \
+ WriteUserData \
+ LocalServices \
+ NetworkServices \
+ UserEnvironment \
+ ReadDeviceData \
+ WriteDeviceData
+ LIBS += -lsmfcommon.dll
+ LIBS += -lqjson.dll
+
+}
+target.path += $$[QT_INSTALL_PLUGINS]/smf/plugin/events.fetcher
+INSTALLS += target
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/example/lastfmmusiceventplugin/plugin_commonU.def Thu Sep 23 17:15:03 2010 +0530
@@ -0,0 +1,16 @@
+; ==============================================================================
+; Generated by qmake (2.01a) (Qt 4.6.2) on: 2010-09-23T11:35:50
+; This file is generated by qmake and should not be modified by the
+; user.
+; Name : plugin_commonU.def
+; Part of : lastfmmusiceventplugin
+; Description : Fixes common plugin symbols to known ordinals
+; Version :
+;
+; ==============================================================================
+
+
+EXPORTS
+ qt_plugin_query_verification_data @ 1 NONAME
+ qt_plugin_instance @ 2 NONAME
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/example/lastfmmusiceventplugin/qmakepluginstubs/lastfmmusiceventplugin.qtplugin Thu Sep 23 17:15:03 2010 +0530
@@ -0,0 +1,1 @@
+This file is a Qt plugin stub file. The real Qt plugin is located in \sys\bin. Created:2010-09-23T11:35:50
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/example/lastfmmusicsearchplugin/lastfmmusicsearchplugin.cpp Thu Sep 23 17:15:03 2010 +0530
@@ -0,0 +1,1428 @@
+/**
+ * Copyright (c) 2010 Sasken Communication Technologies Ltd.
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the "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:
+ * Chandradeep Gandhi, Sasken Communication Technologies Ltd - Initial contribution
+ *
+ * Contributors:
+ * Nalina Hariharan
+ *
+ * Description:
+ * The Plugin that does music search related functionalities from last.fm site
+ *
+ */
+
+// Include files
+#include <QtPlugin>
+#include <QDebug>
+#include <QCryptographicHash>
+#include <QTextStream>
+#include <QFile>
+#include <QMap>
+#include <QListIterator>
+#include <QSettings>
+#include <smfpluginutil.h>
+#include <qlocale.h>
+#include <smfprovider.h>
+
+#include "lastfmmusicsearchplugin.h"
+
+static int gPageNum = 0;
+static int gItemsPerPage = 0;
+static quint8 forTracksOfAlbum = 0;
+QString albumId;
+
+int gOperationId;
+
+
+/**
+ * Destructor
+ */
+LastFmMusicSearchPlugin::~LastFmMusicSearchPlugin( )
+ {
+ if(m_provider)
+ delete m_provider;
+ }
+
+/**
+ * Method to interpret the key sets obtained from credential manager
+ * @param aApiKey [out] The api key
+ * @param aApiSecret [out] The api secret
+ * @param aSessionKey [out] The session key
+ * @param aToken [out] The session token
+ */
+void LastFmMusicSearchPlugin::fetchKeys( QString &aApiKey,
+ QString &aApiSecret,
+ QString &aToken )
+ {
+ qDebug()<<"Reg Token = "<<m_provider->m_smfRegToken;
+ qDebug()<<"Expiry Date as int = "<<m_provider->m_validity.toTime_t();
+
+ SmfAuthParams keys;
+ SmfPluginUtil util;
+ util.getAuthKeys(keys, m_provider->m_smfRegToken,
+ m_provider->m_validity, m_provider->m_pluginId);
+
+ QByteArray keyName;
+ keyName.append("ApiKey");
+ aApiKey.append(keys.value(keyName));
+
+ keyName.clear();
+ keyName.append("ApiSecret");
+ aApiSecret.append(keys.value(keyName));
+
+ keyName.clear();
+ keyName.append("Token");
+ aToken.append(keys.value(keyName));
+
+ qDebug()<<"Api Key = "<<aApiKey;
+ qDebug()<<"Api Secret = "<<aApiSecret;
+ qDebug()<<"Token = "<<aToken;
+ }
+
+/**
+ * Method called by plugins to generate a signature string from a base string
+ * @param aBaseString The base string
+ * @return The md5 hash of the base string
+ */
+QString LastFmMusicSearchPlugin::generateSignature(const QString aBaseString)
+ {
+ // Create md5 hash of the signature string
+ QByteArray byteArray;
+ byteArray.insert(0, aBaseString.toAscii());
+
+ QByteArray md5Hash = QCryptographicHash::hash(byteArray,QCryptographicHash::Md5 ).toHex();
+ QString returnString (md5Hash);
+ return returnString;
+ }
+
+/**
+ * Method to get the current country name as per ISO 3166-1 standard.
+ * @return Current country name
+ */
+QString LastFmMusicSearchPlugin::currentCountryName() const
+ {
+// ToDo :- complete remaining country code and names
+ QLocale locale;
+ QLocale::Country country = locale.country();
+
+ switch(country)
+ {
+ case 0:
+ return QString();
+ case 1:
+ return QString("AFGHANISTAN");
+ // ToDo :- fill for other countries
+ case 100:
+ return QString("INDIA");
+ case 224: // UK
+ return QString("UNITED KINGDOM");
+ default:
+ return QString();
+ }
+ }
+
+/**
+ * Method to get recommended tracks
+ * @param aRequest [out] The request data to be sent to network
+ * @param aTrack The track for which similar recommendations
+ * need to be fetched.
+ * @param aPageNum The page to be extracted
+ * @param aItemsPerPage Number of items per page
+ * @return SmfPluginError Plugin error if any, else SmfPluginErrNone
+ */
+SmfPluginError LastFmMusicSearchPlugin::recommendations( SmfPluginRequestData &aRequest,
+ const SmfTrackInfo &aTrack,
+ const int aPageNum,
+ const int aItemsPerPage )
+ {
+ Q_UNUSED(aRequest)
+ Q_UNUSED(aTrack)
+ Q_UNUSED(aPageNum)
+ Q_UNUSED(aItemsPerPage)
+ qDebug()<<"Inside LastFmMusicSearchPlugin::recommendations()";
+ SmfPluginError error = SmfPluginErrInvalidRequest;
+ return error;
+
+#if 0 // recommended artist not present in music.search interface
+ qDebug()<<"Inside LastFmMusicSearchPlugin::recommendations()";
+
+ SmfPluginError error = SmfPluginErrInvalidArguments;
+
+ // invalid arguments
+ if( aPageNum < 0 || aItemsPerPage < 0 )
+ {
+ qDebug()<<"Invalid arguments";
+ return error;
+ }
+
+ qDebug()<<"Valid arguments";
+
+ // Get the key sets from SMF Plugin Utility class.
+ QString apiKey;
+ QString apiSecret;
+ QString token;
+ fetchKeys(apiKey, apiSecret, token);
+
+ // Create the API signature string
+ QString baseString;
+ baseString.append("api_key"+apiKey);
+ baseString.append("methoduser.getRecommendedArtists");
+ baseString.append("sk"+token);
+ baseString.append(apiSecret);
+
+ // Create the url
+ QUrl url("http://ws.audioscrobbler.com/2.0/?");
+ url.addQueryItem("api_key", apiKey);
+ url.addQueryItem("format", "json");
+ url.addQueryItem("method", "user.getRecommendedArtists");
+ url.addQueryItem("sk", token);
+ url.addQueryItem("api_sig", generateSignature(baseString));
+
+ // Create the request, set the url
+ aRequest.iNetworkRequest.setUrl(url);
+ aRequest.iRequestType = SmfMusicGetRecommendations;
+ aRequest.iPostData = NULL;
+ aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation;
+ error = SmfPluginErrNone;
+
+ qDebug()<<"Url string is : "<<aRequest.iNetworkRequest.url().toString();
+ return error;
+#endif
+ }
+
+/**
+ * Method to search for tracks similar to a given track
+ * @param aRequest [out] The request data to be sent to network
+ * @param aTrack The track for which similar tracks
+ * need to be fetched.
+ * @param aPageNum The page to be extracted
+ * @param aItemsPerPage Number of items per page
+ * @return SmfPluginError Plugin error if any, else SmfPluginErrNone
+ */
+SmfPluginError LastFmMusicSearchPlugin::tracksSimilar( SmfPluginRequestData &aRequest,
+ const SmfTrackInfo &aTrack,
+ const int aPageNum,
+ const int aItemsPerPage )
+ {
+ // Note :
+ // only mbid won't work
+ // only artist won't work
+ // only track wont work
+ // a combination of artist mbid and track name won't work
+ // Give a combination of artist name and track name for a valid response
+ qDebug()<<"Inside LastFmMusicSearchPlugin::tracksSimilar()";
+ qDebug()<<"Page num = "<<aPageNum;
+ qDebug()<<"item per Page = "<<aItemsPerPage;
+
+ SmfPluginError error = SmfPluginErrInvalidArguments;
+
+ // invalid arguments
+ if( aPageNum < 0 || aItemsPerPage < 0 || (0 == aTrack.artists().names().count()) ||
+ aTrack.title().isEmpty() )
+ {
+ qDebug()<<"Invalid arguments";
+ return error;
+ }
+
+ qDebug()<<"Valid arguments";
+
+ gPageNum = aPageNum;
+ gItemsPerPage = aItemsPerPage;
+
+ // Get the key sets from SMF Plugin Utility class.
+ QString apiKey;
+ QString apiSecret;
+ QString token;
+ fetchKeys(apiKey, apiSecret, token);
+
+ // Create the API signature string
+ QString baseString;
+ baseString.append("api_key"+apiKey);
+ baseString.append("artist"+aTrack.artists().names().at(0)); // artist name
+ baseString.append("methodtrack.getSimilar");
+ baseString.append("track"+aTrack.title()); // track name
+ baseString.append(apiSecret);
+
+ // Create the url
+ QUrl url("http://ws.audioscrobbler.com/2.0/?");
+ url.addQueryItem("api_key", apiKey);
+ url.addQueryItem("artist", aTrack.artists().names().at(0));
+ url.addQueryItem("format", "json");
+ url.addQueryItem("method", "track.getSimilar");
+ url.addQueryItem("track", aTrack.title());
+ url.addQueryItem("api_sig", generateSignature(baseString));
+
+ // Create the request, set the url
+ aRequest.iNetworkRequest.setUrl(url);
+ aRequest.iRequestType = SmfMusicGetTracksSimilar;
+ aRequest.iPostData = NULL;
+ aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation;
+ error = SmfPluginErrNone;
+
+ qDebug()<<"Url string is : "<<aRequest.iNetworkRequest.url().toString();
+ return error;
+ }
+
+/**
+ * Method to search for tracks of a given album
+ * @param aRequest [out] The request data to be sent to network
+ * @param aAlbum The album whose tracks need to be fetched.
+ * @param aPageNum The page to be extracted
+ * @param aItemsPerPage Number of items per page
+ * @return SmfPluginError Plugin error if any, else SmfPluginErrNone
+ */
+SmfPluginError LastFmMusicSearchPlugin::tracksOfAlbum( SmfPluginRequestData &aRequest,
+ const SmfAlbum &aAlbum,
+ const int aPageNum,
+ const int aItemsPerPage )
+ {
+ qDebug()<<"Inside LastFmMusicSearchPlugin::tracksOfAlbum()";
+ qDebug()<<"Page num = "<<aPageNum;
+ qDebug()<<"item per Page = "<<aItemsPerPage;
+
+ SmfPluginError error = SmfPluginErrInvalidArguments;
+
+ // invalid arguments
+ if( aPageNum < 0 || aItemsPerPage < 0 || aAlbum.name().isEmpty()
+ || aAlbum.artists().names().at(0).isEmpty() )
+ {
+ qDebug()<<"Invalid arguments";
+ return error;
+ }
+
+ qDebug()<<"Valid arguments";
+
+ gPageNum = aPageNum;
+ gItemsPerPage = aItemsPerPage;
+
+ if(0 == forTracksOfAlbum)
+ return getAlbumId(aRequest, aAlbum);
+ else //if(1 == forTracksOfAlbum)
+ return getTracksOfAlbum(aRequest, aAlbum);
+ }
+
+/**
+ * Method to get the last.fm specific ID of the given album
+ * @param aRequest [out] The request data to be sent to network
+ * @param aAlbum The album whose tracks need to be fetched.
+ * @return SmfPluginError Plugin error if any, else SmfPluginErrNone
+ */
+SmfPluginError LastFmMusicSearchPlugin::getAlbumId( SmfPluginRequestData &aRequest,
+ const SmfAlbum &aAlbum )
+ {
+ qDebug()<<"Inside LastFmMusicSearchPlugin::getAlbumId()";
+
+ SmfPluginError error = SmfPluginErrNone;
+
+ // Get the key sets from SMF Plugin Utility class.
+ QString apiKey;
+ QString apiSecret;
+ QString token;
+ fetchKeys(apiKey, apiSecret, token);
+
+ // Create the API signature string
+ QString baseString;
+ baseString.append("album"+aAlbum.name()); // album name
+ baseString.append("api_key"+apiKey);
+ baseString.append("artist"+aAlbum.artists().names().at(0)); // artist name
+ baseString.append("methodalbum.getInfo");
+ baseString.append(apiSecret);
+
+ // Create the url
+ QUrl url("http://ws.audioscrobbler.com/2.0/?");
+ url.addQueryItem("album", aAlbum.name());
+ url.addQueryItem("api_key", apiKey);
+ url.addQueryItem("artist", aAlbum.artists().names().at(0));
+ url.addQueryItem("format", "json");
+ url.addQueryItem("method", "album.getInfo");
+ url.addQueryItem("api_sig", generateSignature(baseString));
+
+ // Create the request, set the url
+ aRequest.iNetworkRequest.setUrl(url);
+ aRequest.iRequestType = SmfMusicGetTracksOfAlbum;
+ aRequest.iPostData = NULL;
+ aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation;
+ error = SmfPluginErrNone;
+
+ qDebug()<<"Url string is : "<<aRequest.iNetworkRequest.url().toString();
+ return error;
+ }
+
+/**
+ * Method to search for tracks of a given album using its ID in last.fm
+ * @param aRequest [out] The request data to be sent to network
+ * @param aAlbum The album whose tracks need to be fetched.
+ * @return SmfPluginError Plugin error if any, else SmfPluginErrNone
+ */
+SmfPluginError LastFmMusicSearchPlugin::getTracksOfAlbum( SmfPluginRequestData &aRequest,
+ const SmfAlbum &aAlbum)
+ {
+ qDebug()<<"Inside LastFmMusicSearchPlugin::getTracksOfAlbum()";
+ Q_UNUSED(aAlbum)
+ SmfPluginError error = SmfPluginErrInvalidArguments;
+
+ // Get the key sets from SMF Plugin Utility class.
+ QString apiKey;
+ QString apiSecret;
+ QString token;
+ fetchKeys(apiKey, apiSecret, token);
+
+ QString playlistUrl("lastfm://playlist/album/");
+ playlistUrl.append(albumId);
+
+ // Create the API signature string
+ QString baseString;
+ baseString.append("api_key"+apiKey);
+ baseString.append("methodplaylist.fetch");
+ baseString.append("playlistURL"+playlistUrl);
+ baseString.append(apiSecret);
+
+ // Create the url
+ QUrl url("http://ws.audioscrobbler.com/2.0/?");
+ url.addQueryItem("api_key", apiKey);
+ url.addQueryItem("format", "json");
+ url.addQueryItem("method", "playlist.fetch");
+ url.addQueryItem("playlistURL", playlistUrl);
+ url.addQueryItem("api_sig", generateSignature(baseString));
+
+ // Create the request, set the url
+ aRequest.iNetworkRequest.setUrl(url);
+ aRequest.iRequestType = SmfMusicGetTracksOfAlbum;
+ aRequest.iPostData = NULL;
+ aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation;
+ error = SmfPluginErrNone;
+
+ qDebug()<<"Url string is : "<<aRequest.iNetworkRequest.url().toString();
+ return error;
+ }
+
+/**
+ * Method to search for tracks of the given artist(s)
+ * @param aRequest [out] The request data to be sent to network
+ * @param aArtist The artist(s) whose tracks need to be fetched.
+ * @param aPageNum The page to be extracted
+ * @param aItemsPerPage Number of items per page
+ * @return SmfPluginError Plugin error if any, else SmfPluginErrNone
+ */
+SmfPluginError LastFmMusicSearchPlugin::tracksOfArtist( SmfPluginRequestData &aRequest,
+ const SmfArtists &aArtist,
+ const int aPageNum,
+ const int aItemsPerPage )
+ {
+ qDebug()<<"Inside LastFmMusicSearchPlugin::tracksOfArtist()";
+ qDebug()<<"Page num = "<<aPageNum;
+ qDebug()<<"item per Page = "<<aItemsPerPage;
+
+ SmfPluginError error = SmfPluginErrInvalidArguments;
+
+ // invalid arguments
+ if( aPageNum < 0 || aItemsPerPage < 0 || aArtist.names().at(0).isEmpty() )
+ {
+ qDebug()<<"Invalid arguments";
+ return error;
+ }
+
+ qDebug()<<"Valid arguments";
+
+ gPageNum = aPageNum;
+ gItemsPerPage = aItemsPerPage;
+
+ // Get the key sets from SMF Plugin Utility class.
+ QString apiKey;
+ QString apiSecret;
+ QString token;
+ fetchKeys(apiKey, apiSecret, token);
+
+ // Create the API signature string
+ QString baseString;
+ baseString.append("api_key"+apiKey);
+ baseString.append("artist"+aArtist.names().at(0)); // artist name
+ baseString.append("methodartist.getTopTracks");
+ baseString.append(apiSecret);
+
+ // Create the url
+ QUrl url("http://ws.audioscrobbler.com/2.0/?");
+ url.addQueryItem("api_key", apiKey);
+ url.addQueryItem("artist", aArtist.names().at(0));
+ url.addQueryItem("format", "json");
+ url.addQueryItem("method", "artist.getTopTracks");
+ url.addQueryItem("api_sig", generateSignature(baseString));
+
+ // Create the request, set the url
+ aRequest.iNetworkRequest.setUrl(url);
+ aRequest.iRequestType = SmfMusicGetTracksOfArtist;
+ aRequest.iPostData = NULL;
+ aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation;
+ error = SmfPluginErrNone;
+
+ qDebug()<<"Url string is : "<<aRequest.iNetworkRequest.url().toString();
+ return error;
+ }
+
+/**
+ * Method to get tracks having a similar finger print
+ * @param aRequest [out] The request data to be sent to network
+ * @param aSignature The finger print to be searched for need to be
+ * fetched.
+ * @param aPageNum The page to be extracted
+ * @param aItemsPerPage Number of items per page
+ * @return SmfPluginError Plugin error if any, else SmfPluginErrNone
+ */
+SmfPluginError LastFmMusicSearchPlugin::trackInfo( SmfPluginRequestData &aRequest,
+ const SmfMusicFingerPrint &aSignature,
+ const int aPageNum,
+ const int aItemsPerPage )
+ {
+ qDebug()<<"Inside LastFmMusicSearchPlugin::trackInfo()";
+
+ SmfPluginError error = SmfPluginErrInvalidArguments;
+
+ // invalid arguments
+ if( aPageNum < 0 || aItemsPerPage < 0 || aSignature.id().isEmpty() )
+ {
+ qDebug()<<"Invalid arguments";
+ return error;
+ }
+
+ qDebug()<<"Valid arguments";
+
+ gPageNum = aPageNum;
+ gItemsPerPage = aItemsPerPage;
+
+ // Get the key sets from SMF Plugin Utility class.
+ QString apiKey;
+ QString apiSecret;
+ QString token;
+ fetchKeys(apiKey, apiSecret, token);
+
+ // Create the API signature string
+ QString baseString;
+ baseString.append("api_key"+apiKey);
+ baseString.append("fingerprintid"+aSignature.id());
+ baseString.append("methodtrack.getFingerprintMetadata");
+ baseString.append(apiSecret);
+
+ // Create the url
+ QUrl url("http://ws.audioscrobbler.com/2.0/?");
+ url.addQueryItem("api_key", apiKey);
+ url.addQueryItem("fingerprintid", aSignature.id());
+ url.addQueryItem("format", "json");
+ url.addQueryItem("method", "track.getFingerprintMetadata");
+ url.addQueryItem("api_sig", generateSignature(baseString));
+
+ // Create the request, set the url
+ aRequest.iNetworkRequest.setUrl(url);
+ aRequest.iRequestType = SmfMusicGetTrackInfo;
+ aRequest.iPostData = NULL;
+ aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation;
+ error = SmfPluginErrNone;
+
+ qDebug()<<"Url string is : "<<aRequest.iNetworkRequest.url().toString();
+ return error;
+ }
+
+/**
+ * Method to search information about where to buy this song from
+ * @param aRequest [out] The request data to be sent to network
+ * @param aTrack The track for which stores need to be searched
+ * @param aPageNum The page to be extracted
+ * @param aItemsPerPage Number of items per page
+ * @return SmfPluginError Plugin error if any, else SmfPluginErrNone
+ */
+SmfPluginError LastFmMusicSearchPlugin::stores( SmfPluginRequestData &aRequest,
+ const SmfTrackInfo &aTrack,
+ const int aPageNum,
+ const int aItemsPerPage )
+ {
+ qDebug()<<"Inside LastFmMusicSearchPlugin::stores()";
+
+ SmfPluginError error = SmfPluginErrInvalidArguments;
+
+ // invalid arguments
+ if( aPageNum < 0 || aItemsPerPage < 0 || (0 == aTrack.artists().names().count()) ||
+ aTrack.album().name().isEmpty() )
+ {
+ qDebug()<<"Invalid arguments";
+ return error;
+ }
+
+ qDebug()<<"Valid arguments";
+
+ gPageNum = aPageNum;
+ gItemsPerPage = aItemsPerPage;
+
+ // Get the key sets from SMF Plugin Utility class.
+ QString apiKey;
+ QString apiSecret;
+ QString token;
+ fetchKeys(apiKey, apiSecret, token);
+
+ QString countryName = currentCountryName();
+
+ // Create the API signature string
+ QString baseString;
+ baseString.append("album"+aTrack.album().name());
+ baseString.append("api_key"+apiKey);
+ baseString.append("artist"+aTrack.artists().names().at(0));
+ baseString.append("country"+countryName);
+ baseString.append("methodalbum.getBuylinks");
+ baseString.append(apiSecret);
+
+ // Create the url
+ QUrl url("http://ws.audioscrobbler.com/2.0/?");
+ url.addQueryItem("album", aTrack.album().name());
+ url.addQueryItem("api_key", apiKey);
+ url.addQueryItem("artist", aTrack.artists().names().at(0));
+ url.addQueryItem("country", countryName);
+ url.addQueryItem("format", "json");
+ url.addQueryItem("method", "album.getBuylinks");
+ url.addQueryItem("api_sig", generateSignature(baseString));
+
+ // Create the request, set the url
+ aRequest.iNetworkRequest.setUrl(url);
+ aRequest.iRequestType = SmfMusicGetStores;
+ aRequest.iPostData = NULL;
+ aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation;
+ error = SmfPluginErrNone;
+
+ qDebug()<<"Url string is : "<<aRequest.iNetworkRequest.url().toString();
+ return error;
+ }
+
+/**
+ * Customised method for SmfMusicSearchPlugin interface
+ * @param aRequest [out] The request data to be sent to network
+ * @param aOperation The operation type (should be known between
+ * the client interface and the plugin)
+ * @param aData The data required to form the request (The type
+ * of data should be known between client and the plugin)
+ * @return SmfPluginError Plugin error if any, else SmfPluginErrNone
+ */
+SmfPluginError LastFmMusicSearchPlugin::customRequest( SmfPluginRequestData &aRequest,
+ const int &aOperation, QByteArray *aData )
+ {
+ qDebug()<<"Inside LastFmMusicSearchPlugin::customRequest()";
+
+ SmfPluginError error = SmfPluginErrInvalidArguments;
+
+ // invalid arguments
+ if( NULL == aData )
+ {
+ qDebug()<<"Invalid arguments";
+ return error;
+ }
+
+ qDebug()<<"Valid arguments";
+
+ // Get the key sets from SMF Plugin Utility class.
+ QString apiKey;
+ QString apiSecret;
+ QString token;
+ fetchKeys(apiKey, apiSecret, token);
+
+
+ if(107 == aOperation)
+ {
+ gOperationId = aOperation;
+ int limit;
+ int pageNum;
+ SmfAlbum album;
+
+ QDataStream read(aData, QIODevice::ReadOnly);
+ read>>limit;
+ read>>pageNum;
+ read>>album;
+
+ gItemsPerPage = limit;
+ gPageNum = pageNum;
+
+ // Create the API signature string
+ QString baseString;
+ baseString.append("album"+album.name());
+ baseString.append("api_key"+apiKey);
+ baseString.append("limit"+QString::number(limit));
+ baseString.append("methodalbum.search");
+ baseString.append("page"+QString::number(pageNum));
+ baseString.append(apiSecret);
+
+ // Create the url
+ QUrl url("http://ws.audioscrobbler.com/2.0/?");
+ url.addQueryItem("album", album.name());
+ url.addQueryItem("api_key", apiKey);
+ url.addQueryItem("limit", QString::number(limit));
+ url.addQueryItem("page", QString::number(pageNum));
+ url.addQueryItem("format", "json");
+ url.addQueryItem("method", "album.search");
+ url.addQueryItem("api_sig", generateSignature(baseString));
+
+ // Create the request, set the url
+ aRequest.iNetworkRequest.setUrl(url);
+ aRequest.iRequestType = SmfMusicSearchCustomRequest;
+ aRequest.iPostData = NULL;
+ aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation;
+ error = SmfPluginErrNone;
+
+ qDebug()<<"Url string is : "<<aRequest.iNetworkRequest.url().toString();
+ }
+ return error;
+ }
+
+/**
+ * The first method to be called in the plugin that implements this interface.
+ * If this method is not called, plugin may not behave as expected.
+ */
+void LastFmMusicSearchPlugin::initialize( )
+ {
+ // Create an instance of LastFmMusicSearchProviderBase
+ m_provider = new LastFmMusicSearchProviderBase;
+ m_provider->initialize();
+ }
+
+/**
+ * Method to get the provider information
+ * @return Instance of SmfProviderBase
+ */
+SmfProviderBase* LastFmMusicSearchPlugin::getProviderInfo( )
+ {
+ return m_provider;
+ }
+
+/**
+ * Method to get the result for a network request.
+ * @param aOperation The type of operation to be requested
+ * @param aTransportResult The result of transport operation
+ * @param aResponse The QByteArray instance containing the network response.
+ * The plugins should delete this instance once they have read the
+ * data from it.
+ * @param aResult [out] An output parameter to the plugin manager.If the
+ * return value is SmfSendRequestAgain, QVariant will be of type
+ * SmfPluginRequestData.
+ * For SmfMusicSearchPlugin: If last operation was recommendations(),
+ * tracksSimilar() or tracksOfAlbum() or tracksOfArtist() or trackInfo(),
+ * aResult will be of type QList<SmfTrackInfo>.
+ * If last operation was stores(), aResult will be of type QList<SmfProvider>.
+ * @param aRetType [out] SmfPluginRetType
+ * @param aPageResult [out] The SmfResultPage structure variable
+ */
+SmfPluginError LastFmMusicSearchPlugin::responseAvailable(
+ const SmfRequestTypeID aOperation,
+ const SmfTransportResult &aTransportResult,
+ QByteArray *aResponse,
+ QVariant* aResult,
+ SmfPluginRetType &aRetType,
+ SmfResultPage &aPageResult )
+ {
+ Q_UNUSED(aPageResult)
+ qDebug()<<"Inside LastFmMusicSearchPlugin::responseAvailable()";
+
+ SmfPluginError error = SmfPluginErrNetworkError;
+
+ if( !aResponse || (0 == aResponse->size()) )
+ {
+ qDebug()<<"Response is NULL or empty";
+ aRetType = SmfRequestError;
+ return error;
+ }
+
+ QByteArray response(*aResponse);
+ delete aResponse;
+
+ QFile respFile("c://data//SmfMusicSearchPluginResponse.txt");
+ if(!respFile.open(QIODevice::WriteOnly))
+ qDebug()<<"File to write the response could not be opened";
+ else
+ {
+ respFile.write(response);
+ respFile.close();
+ qDebug()<<"Writing FB response to a file named 'SmfMusicSearchPluginResponse.txt'";
+ }
+ qDebug()<<"FB response size = "<<response.size();
+
+ if(SmfTransportOpNoError == aTransportResult)
+ {
+ qDebug()<<"No transport error";
+
+ if((SmfMusicGetTracksSimilar == aOperation) || (SmfMusicGetTracksOfArtist == aOperation))
+ {
+ qDebug()<<"Response for music search get similar tracks/artist's tracks";
+
+ QList<SmfTrackInfo> list;
+ QString errStr;
+ errStr.clear();
+
+ bool ok;
+ SmfPluginUtil util;
+ QVariantMap result = util.parse(response, &ok).toMap();
+ if (!ok)
+ {
+ qDebug()<<"An error occurred during json parsing";
+ aRetType = SmfRequestError;
+ return SmfPluginErrParsingFailed;
+ }
+
+ if(response.contains(QByteArray("error")))
+ {
+ errStr.append(result["message"].toString());
+ }
+ else
+ {
+ QVariantMap map1;
+ if(SmfMusicGetTracksSimilar == aOperation)
+ map1 = result["similartracks"].toMap();
+ else //if(SmfMusicGetTracksOfArtist == aOperation) // tracks of artists
+ map1 = result["toptracks"].toMap();
+ QList<QVariant> list1 = map1["track"].toList();
+ QListIterator<QVariant> iter(list1);
+ while(iter.hasNext())
+ {
+ SmfTrackInfo track;
+
+ QVariantMap map2 = iter.next().toMap();
+ qDebug()<<"track title = "<<map2["name"].toString();
+ if(SmfMusicGetTracksSimilar == aOperation)
+ qDebug()<<"duration in milli sec = "<<map2["duration"].toString();
+
+ // Set the track title
+ track.setTitle(map2["name"].toString());
+
+ // Set the tracks duration in seconds
+ if(SmfMusicGetTracksSimilar == aOperation)
+ {
+ int timeValInSec = map2["duration"].toInt();
+ timeValInSec /= 1000;
+ QString str = QString::number(timeValInSec);
+ str.prepend("0.");
+ QTime time = QTime::fromString(str, "m.z");
+ qDebug()<<" Time value = "<<time;
+ track.setDuration(time);
+ }
+
+ // Set the track's Id - last.fm's mbid
+ track.setId(map2["mbid"].toString());
+
+ // Set the tracks artist details
+ QVariantMap map3 = map2["artist"].toMap();
+ SmfArtists artists;
+
+ // Set the artist's name
+ QStringList namesList;
+ namesList.append(map3["name"].toString());
+ artists.setNames(namesList);
+
+ // Set the artist's url
+ QUrl url(map3["url"].toString());
+ artists.setUrl(url);
+
+ // Set the artist's id
+ artists.setId(map3["mbid"].toString());
+
+ // Set the artist's image url
+ QList<QVariant> list2 = map3["image"].toList();
+ QListIterator<QVariant> iter2(list2);
+ while(iter2.hasNext())
+ {
+ QVariantMap map4 = iter.next().toMap();
+
+ // Set the artist's image url
+ QUrl url(map4["#text"].toString());
+ //artists.setImageUrlurl);
+ break;
+ }
+
+ track.setArtists(artists);
+
+ list.append(track);
+ if(gItemsPerPage == list.count())
+ break;
+ }
+ }
+
+ if(errStr.size())
+ {
+ qDebug()<<"Response error found = "<<errStr;
+ error = SmfPluginErrInvalidRequest;
+ aRetType = SmfRequestError;
+ aResult->setValue(errStr);
+ }
+ else
+ {
+ qDebug()<<"list count = "<<list.count();
+ aResult->setValue(list);
+ aRetType = SmfRequestComplete;
+ error = SmfPluginErrNone;
+ }
+ }
+ else if (SmfMusicGetTracksOfAlbum == aOperation)
+ {
+ qDebug()<<"Response for music search tracks of album";
+
+ if(0 == forTracksOfAlbum) // for fetching album ID
+ {
+ qDebug()<<"FOR GETTING ALBUMID";
+ QString errStr;
+ errStr.clear();
+
+ bool ok;
+ SmfPluginUtil util;
+ QVariantMap result = util.parse(response, &ok).toMap();
+ if (!ok)
+ {
+ qDebug()<<"An error occurred during json parsing";
+ aRetType = SmfRequestError;
+ return SmfPluginErrParsingFailed;
+ }
+
+ qDebug()<<"Json parsing complete";
+
+ if(response.contains(QByteArray("error")))
+ {
+ errStr.append(result["message"].toString());
+ }
+ else
+ {
+ QVariantMap map1 = result["album"].toMap();
+ albumId.clear();
+ albumId.append(map1["id"].toString());
+ forTracksOfAlbum = 1;
+ }
+
+ if(errStr.size())
+ {
+ qDebug()<<"Response error found = "<<errStr;
+ error = SmfPluginErrInvalidRequest;
+ aRetType = SmfRequestError;
+ aResult->setValue(errStr);
+ }
+ else
+ {
+ qDebug()<<"album id = "<<albumId;
+ aRetType = SmfSendRequestAgain;
+ error = SmfPluginErrNone;
+ }
+ }
+ else // for fetching tracks of the album
+ {
+ qDebug()<<"FOR GETTING TRACKS OF ALBUM";
+ QList<SmfTrackInfo> list;
+ QString errStr;
+ errStr.clear();
+
+ bool ok;
+ SmfPluginUtil util;
+ QVariantMap result = util.parse(response, &ok).toMap();
+ if (!ok)
+ {
+ qDebug()<<"An error occurred during json parsing";
+ aRetType = SmfRequestError;
+ return SmfPluginErrParsingFailed;
+ }
+
+ if(response.contains(QByteArray("error")))
+ {
+ errStr.append(result["message"].toString());
+ }
+ else
+ {
+ QVariantMap map1 = result["playlist"].toMap();
+ QVariantMap map2 = map1["trackList"].toMap();
+ QList<QVariant> list1 = map2["track"].toList();
+ QListIterator<QVariant> iter(list1);
+ while(iter.hasNext())
+ {
+ SmfTrackInfo track;
+
+ QVariantMap map3 = iter.next().toMap();
+ qDebug()<<"track title = "<<map3["title"].toString();
+
+ // Set the track's Id - last.fm's identifier
+ track.setId(map3["identifier"].toString());
+
+ // Set the track title
+ track.setTitle(map3["title"].toString());
+
+ // Set the tracks album
+ SmfAlbum album;
+ album.setName(map3["album"].toString());
+ track.setAlbum(album);
+
+ // Set the tracks artist details
+ SmfArtists artists;
+ QStringList namesList;
+ namesList.append(map3["creator"].toString());
+ artists.setNames(namesList);
+
+ QUrl url(map3["info"].toString());
+ artists.setUrl(url);
+
+ //QUrl imageUrl(map3["image"].toString());
+ //artists.setImageUrl(imageUrl);
+
+ track.setArtists(artists);
+
+ // Set the tracks duration in seconds
+ int timeValInSec = map3["duration"].toInt();
+ timeValInSec /= 1000;
+ QTime time = QTime::fromString(QString::number(timeValInSec), "z");
+ track.setDuration(time);
+
+ list.append(track);
+
+ if(gItemsPerPage == list.count())
+ break;
+ }
+ }
+
+ if(errStr.size())
+ {
+ qDebug()<<"Response error found = "<<errStr;
+ error = SmfPluginErrInvalidRequest;
+ aRetType = SmfRequestError;
+ aResult->setValue(errStr);
+ }
+ else
+ {
+ qDebug()<<"list count = "<<list.count();
+ aResult->setValue(list);
+ aRetType = SmfRequestComplete;
+ error = SmfPluginErrNone;
+ }
+ }
+ }
+ else if(SmfMusicGetStores == aOperation)
+ {
+ qDebug()<<"Response for music search get stores";
+
+ QList<SmfProvider> list;
+ QString errStr;
+ errStr.clear();
+
+ bool ok;
+ SmfPluginUtil util;
+ QVariantMap result = util.parse(response, &ok).toMap();
+ if (!ok)
+ {
+ qDebug()<<"An error occurred during json parsing";
+ aRetType = SmfRequestError;
+ return SmfPluginErrParsingFailed;
+ }
+
+ qDebug()<<"Json parsing complete";
+
+ if(response.contains(QByteArray("error")))
+ {
+ errStr.append(result["message"].toString());
+ }
+ else
+ {
+ QVariantMap map1 = result["affiliations"].toMap();
+ QVariantMap map2 = map1["physicals"].toMap();
+ QList<QVariant> list1 = map2["affiliation"].toList();
+ QListIterator<QVariant> iter(list1);
+ while(iter.hasNext())
+ {
+ SmfProvider provider;
+
+ QVariantMap map3 = iter.next().toMap();
+ qDebug()<<"provider name = "<<map3["supplierName"].toString();
+ qDebug()<<"provider URL = "<<map3["buyLink"].toString();
+
+ // Set the provider name
+ QString str(map3["supplierName"].toString());
+ provider.setServiceName(str);
+
+ // Set the provider url
+ QUrl url(map3["buyLink"].toString());
+ provider.setServiceUrl(url);
+
+ // Set the provider icon
+ //QUrl url(map3["supplierIcon"].toString());
+ //provider.setServiceIcon(url);
+
+ list.append(provider);
+ if(gItemsPerPage == list.count())
+ break;
+ }
+ }
+
+ if(errStr.size())
+ {
+ qDebug()<<"Response error found = "<<errStr;
+ error = SmfPluginErrInvalidRequest;
+ aRetType = SmfRequestError;
+ aResult->setValue(errStr);
+ }
+ else
+ {
+ qDebug()<<"list count = "<<list.count();
+ aResult->setValue(list);
+ aRetType = SmfRequestComplete;
+ error = SmfPluginErrNone;
+ }
+ }
+
+ else if (SmfMusicGetTrackInfo == aOperation)
+ {
+ qDebug()<<"Response for music search get fingerprint tracks";
+
+ QList<SmfTrackInfo> list;
+ QString errStr;
+ errStr.clear();
+
+ bool ok;
+ SmfPluginUtil util;
+ QVariantMap result = util.parse(response, &ok).toMap();
+ if (!ok)
+ {
+ qDebug()<<"An error occurred during json parsing";
+ aRetType = SmfRequestError;
+ return SmfPluginErrParsingFailed;
+ }
+
+ qDebug()<<"Json parsing complete";
+
+ if(response.contains(QByteArray("error")))
+ {
+ errStr.append(result["message"].toString());
+ }
+ else
+ {
+ QVariantMap map1 = result["tracks"].toMap();
+ QList<QVariant> list1 = map1["track"].toList();
+ QListIterator<QVariant> iter(list1);
+ while(iter.hasNext())
+ {
+ SmfTrackInfo track;
+
+ QVariantMap map3 = iter.next().toMap();
+
+ // Set the track's Id - last.fm's identifier
+ track.setId(map3["mbid"].toString());
+
+ // Set the track title
+ track.setTitle(map3["name"].toString());
+
+ // Set the tracks artist details
+ QVariantMap map4 = map3["artist"].toMap();
+ SmfArtists artists;
+ QStringList namesList;
+ namesList.append(map4["name"].toString());
+ artists.setNames(namesList);
+
+ QUrl url(map4["url"].toString());
+ artists.setUrl(url);
+
+ artists.setId(map4["mbid"].toString());
+
+ QList<QVariant> list2 = map4["image"].toList();
+ QListIterator<QVariant> iter2(list2);
+ while(iter2.hasNext())
+ {
+ QVariantMap map5 = iter2.next().toMap();
+ QUrl imageUrl(map5["#text"].toString());
+ //artists.setImageUrl(imageUrl);
+ break;
+ }
+
+ track.setArtists(artists);
+
+ list.append(track);
+
+ if(gItemsPerPage == list.count())
+ break;
+ }
+ }
+
+ if(errStr.size())
+ {
+ qDebug()<<"Response error found = "<<errStr;
+ error = SmfPluginErrInvalidRequest;
+ aRetType = SmfRequestError;
+ aResult->setValue(errStr);
+ }
+ else
+ {
+ qDebug()<<"list count = "<<list.count();
+ aResult->setValue(list);
+ aRetType = SmfRequestComplete;
+ error = SmfPluginErrNone;
+ }
+ }
+
+ else if (SmfMusicSearchCustomRequest == aOperation)
+ {
+ qDebug()<<"Response for music search custom request = album.search";
+
+ QList<SmfAlbum> list;
+ QString errStr;
+ errStr.clear();
+
+ bool ok;
+ SmfPluginUtil util;
+ QVariantMap result = util.parse(response, &ok).toMap();
+ if (!ok)
+ {
+ qDebug()<<"An error occurred during json parsing";
+ aRetType = SmfRequestError;
+ return SmfPluginErrParsingFailed;
+ }
+
+ qDebug()<<"Json parsing complete";
+
+ if(response.contains(QByteArray("error")))
+ {
+ errStr.append(result["message"].toString());
+ }
+ else
+ {
+ QVariantMap map1 = result["results"].toMap();
+ QVariantMap map2 = map1["albummatches"].toMap();
+ QList<QVariant> list1 = map2["album"].toList();
+ QListIterator<QVariant> iter(list1);
+ while(iter.hasNext())
+ {
+ SmfAlbum album;
+
+ QVariantMap map3 = iter.next().toMap();
+
+ album.setName(map3["name"].toString());
+
+ SmfArtists artists;
+ QStringList names;
+ names.append(map3["artist"].toString());
+ artists.setNames(names);
+
+ QList<QVariant> list2 = map3["image"].toList();
+ QListIterator<QVariant> iter2(list2);
+ while(iter2.hasNext())
+ {
+ QVariantMap map5 = iter2.next().toMap();
+ QUrl imageUrl(map5["#text"].toString());
+ //artists.setImageUrl(imageUrl);
+ break;
+ }
+
+ album.setArtists(artists);
+
+ album.setId(map3["id"].toString());
+
+ //QUrl url(map3["url"].toString())
+ //album.setUrl(url);
+
+ list.append(album);
+
+ if(gItemsPerPage == list.count())
+ break;
+ }
+ }
+
+ if(errStr.size())
+ {
+ qDebug()<<"Response error found = "<<errStr;
+ error = SmfPluginErrInvalidRequest;
+ aRetType = SmfRequestError;
+ aResult->setValue(errStr);
+ }
+ else
+ {
+ QByteArray customResponseData;
+ QByteArray entireData;
+ QDataStream writeResponse(&customResponseData, QIODevice::WriteOnly);
+ qDebug()<<"list count = "<<list.count();
+ writeResponse<<list;
+
+ QDataStream writeFull(&entireData, QIODevice::WriteOnly);
+ qDebug()<<"operation id = "<<gOperationId;
+ writeFull<<gOperationId;
+ qDebug()<<"custom Data size = "<<customResponseData.size();
+ writeFull<<customResponseData;
+
+ aResult->setValue(entireData);
+ aRetType = SmfRequestComplete;
+ error = SmfPluginErrNone;
+ }
+ }
+
+ else
+ {
+ qDebug()<<"Service unsupported!!! ="<<aOperation;
+ aRetType = SmfRequestError;
+ error = SmfPluginErrServiceNotSupported;
+ }
+ }
+
+ else if(SmfTransportOpOperationCanceledError == aTransportResult)
+ {
+ qDebug()<<"Operation Cancelled !!!";
+ error = SmfPluginErrCancelComplete;
+ aRetType = SmfRequestComplete;
+ }
+
+ else
+ {
+ qDebug()<<"Transport Error !!!";
+ error = SmfPluginErrNetworkError;
+ aRetType = SmfRequestError;
+ }
+
+ return error;
+ }
+
+
+
+/**
+ * Destructor
+ */
+LastFmMusicSearchProviderBase::~LastFmMusicSearchProviderBase( )
+ {
+ }
+
+
+/**
+ * Method to get the Localisable name of the service.
+ * @return The Localisable name of the service.
+ */
+QString LastFmMusicSearchProviderBase::serviceName( ) const
+ {
+ return m_serviceName;
+ }
+
+
+/**
+ * Method to get the Logo of the service
+ * @return The Logo of the service
+ */
+QImage LastFmMusicSearchProviderBase::serviceIcon( ) const
+ {
+ return m_serviceIcon;
+ }
+
+
+/**
+ * Method to get the Readable service description
+ * @return The Readable service description
+ */
+QString LastFmMusicSearchProviderBase::description( ) const
+ {
+ return m_description;
+ }
+
+
+/**
+ * Method to get the Website of the service
+ * @return The Website of the service
+ */
+QUrl LastFmMusicSearchProviderBase::serviceUrl( ) const
+ {
+ return m_serviceUrl;
+ }
+
+
+/**
+ * Method to get the URL of the Application providing this service
+ * @return The URL of the Application providing this service
+ */
+QUrl LastFmMusicSearchProviderBase::applicationUrl( ) const
+ {
+ return m_applicationUrl;
+ }
+
+
+/**
+ * Method to get the Icon of the application
+ * @return The Icon of the application
+ */
+QImage LastFmMusicSearchProviderBase::applicationIcon( ) const
+ {
+ return m_applicationIcon;
+ }
+
+/**
+* Method to get the list of interfaces that this provider support
+* @return List of supported Interafces
+*/
+QList<QString> LastFmMusicSearchProviderBase::supportedInterfaces( ) const
+ {
+ return m_supportedInterfaces;
+ }
+
+/**
+* Method to get the list of languages supported by this service provider
+* @return a QStringList of languages supported by this service
+* provider in 2 letter ISO 639-1 format.
+*/
+QStringList LastFmMusicSearchProviderBase::supportedLanguages( ) const
+ {
+ return m_supportedLangs;
+ }
+
+/**
+ * Method to get the Plugin specific ID
+ * @return The Plugin specific ID
+ */
+QString LastFmMusicSearchProviderBase::pluginId( ) const
+ {
+ return m_pluginId;
+ }
+
+
+/**
+ * Method to get the ID of the authentication application
+ * for this service
+ * @param aProgram The authentication application name
+ * @param aArguments List of arguments required for authentication app
+ * @param aMode Strting mode for authentication application
+ * @return The ID of the authentication application
+ */
+QString LastFmMusicSearchProviderBase::authenticationApp( QString &aProgram,
+ QStringList & aArguments,
+ QIODevice::OpenModeFlag aMode ) const
+ {
+ Q_UNUSED(aProgram)
+ Q_UNUSED(aArguments)
+ Q_UNUSED(aMode)
+ return m_authAppId;
+ }
+
+
+/**
+ * Method to get the unique registration ID provided by the
+ * Smf for authorised plugins
+ * @return The unique registration ID/token provided by the Smf for
+ * authorised plugins
+ */
+QString LastFmMusicSearchProviderBase::smfRegistrationId( ) const
+ {
+ return m_smfRegToken;
+ }
+
+
+/**
+ * Method that initializes this class. This method should be called
+ * from the initialize() method of the FBContactFetcherPlugin class
+ */
+void LastFmMusicSearchProviderBase::initialize()
+ {
+ m_serviceName = "last.fm";
+ m_description = "Last.fm music search plugin description";
+ m_serviceUrl = QUrl(QString("http://www.last.fm"));
+ m_pluginId = "lastfmmusicsearchplugin.qtplugin";
+ m_authAppId = "0x12345678";
+ m_supportedInterfaces.append("org.symbian.smf.plugin.music.search/v0.2");
+ QSettings iSettings;
+ m_smfRegToken = iSettings.value("LastFmRegToken").toString();
+ m_validity = iSettings.value("LastFmExpiryTime").toDateTime();
+ }
+
+
+/*
+ * Export Macro
+ * plugin name : lastfmmusicsearchplugin
+ * plugin class : LastFmMusicSearchPlugin
+ */
+Q_EXPORT_PLUGIN2( lastfmmusicsearchplugin, LastFmMusicSearchPlugin )
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/example/lastfmmusicsearchplugin/lastfmmusicsearchplugin.h Thu Sep 23 17:15:03 2010 +0530
@@ -0,0 +1,335 @@
+/**
+ * Copyright (c) 2010 Sasken Communication Technologies Ltd.
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the "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:
+ * Chandradeep Gandhi, Sasken Communication Technologies Ltd - Initial contribution
+ *
+ * Contributors:
+ * Nalina Hariharan
+ *
+ * Description:
+ * The Plugin that does music search related functionalities from last.fm site
+ *
+ */
+
+#ifndef _LASTFMMUSICSEARCHPLUGIN_H
+#define _LASTFMMUSICSEARCHPLUGIN_H
+
+// Include files
+#include <smfmusicsearchplugin.h>
+
+// Class declaration
+class LastFmMusicSearchProviderBase;
+class QVariant;
+
+/**
+ * The Plugin does music serach related functionalities from last.fm site
+ */
+class LastFmMusicSearchPlugin : public QObject, public SmfMusicSearchPlugin
+ {
+ Q_OBJECT
+ Q_INTERFACES( SmfMusicSearchPlugin SmfPluginBase )
+
+public:
+ /**
+ * Destructor
+ */
+ virtual ~LastFmMusicSearchPlugin ( );
+
+public: // From SmfMusicSearchPlugin interface
+ /**
+ * Method to get recommended tracks
+ * @param aRequest [out] The request data to be sent to network
+ * @param aTrack The track for which similar recommendations
+ * need to be fetched.
+ * @param aPageNum The page to be extracted
+ * @param aItemsPerPage Number of items per page
+ * @return SmfPluginError Plugin error if any, else SmfPluginErrNone
+ */
+ SmfPluginError recommendations( SmfPluginRequestData &aRequest,
+ const SmfTrackInfo &aTrack,
+ const int aPageNum = SMF_FIRST_PAGE,
+ const int aItemsPerPage = SMF_ITEMS_PER_PAGE );
+
+ /**
+ * Method to search for tracks similar to a given track
+ * @param aRequest [out] The request data to be sent to network
+ * @param aTrack The track for which similar tracks
+ * need to be fetched.
+ * @param aPageNum The page to be extracted
+ * @param aItemsPerPage Number of items per page
+ * @return SmfPluginError Plugin error if any, else SmfPluginErrNone
+ */
+ SmfPluginError tracksSimilar( SmfPluginRequestData &aRequest,
+ const SmfTrackInfo &aTrack,
+ const int aPageNum = SMF_FIRST_PAGE,
+ const int aItemsPerPage = SMF_ITEMS_PER_PAGE );
+
+ /**
+ * Method to search for tracks of a given album
+ * @param aRequest [out] The request data to be sent to network
+ * @param aAlbum The album whose tracks need to be fetched.
+ * @param aPageNum The page to be extracted
+ * @param aItemsPerPage Number of items per page
+ * @return SmfPluginError Plugin error if any, else SmfPluginErrNone
+ */
+ SmfPluginError tracksOfAlbum( SmfPluginRequestData &aRequest,
+ const SmfAlbum &aAlbum,
+ const int aPageNum = SMF_FIRST_PAGE,
+ const int aItemsPerPage = SMF_ITEMS_PER_PAGE );
+
+ /**
+ * Method to search for tracks of the given artist(s)
+ * @param aRequest [out] The request data to be sent to network
+ * @param aArtist The artist(s) whose tracks need to be fetched.
+ * @param aPageNum The page to be extracted
+ * @param aItemsPerPage Number of items per page
+ * @return SmfPluginError Plugin error if any, else SmfPluginErrNone
+ */
+ SmfPluginError tracksOfArtist( SmfPluginRequestData &aRequest,
+ const SmfArtists &aArtist,
+ const int aPageNum = SMF_FIRST_PAGE,
+ const int aItemsPerPage = SMF_ITEMS_PER_PAGE );
+
+ /**
+ * Method to get tracks having a similar finger print
+ * @param aRequest [out] The request data to be sent to network
+ * @param aSignature The finger print to be searched for need to be
+ * fetched.
+ * @param aPageNum The page to be extracted
+ * @param aItemsPerPage Number of items per page
+ * @return SmfPluginError Plugin error if any, else SmfPluginErrNone
+ */
+ SmfPluginError trackInfo( SmfPluginRequestData &aRequest,
+ const SmfMusicFingerPrint &aSignature,
+ const int aPageNum = SMF_FIRST_PAGE,
+ const int aItemsPerPage = SMF_ITEMS_PER_PAGE );
+
+ /**
+ * Method to search information about where to buy this song from
+ * @param aRequest [out] The request data to be sent to network
+ * @param aTrack The track for which stores need to be searched
+ * @param aPageNum The page to be extracted
+ * @param aItemsPerPage Number of items per page
+ * @return SmfPluginError Plugin error if any, else SmfPluginErrNone
+ */
+ SmfPluginError stores( SmfPluginRequestData &aRequest,
+ const SmfTrackInfo &aTrack,
+ const int aPageNum = SMF_FIRST_PAGE,
+ const int aItemsPerPage = SMF_ITEMS_PER_PAGE );
+
+ /**
+ * Customised method for SmfMusicSearchPlugin interface
+ * @param aRequest [out] The request data to be sent to network
+ * @param aOperation The operation type (should be known between
+ * the client interface and the plugin)
+ * @param aData The data required to form the request (The type
+ * of data should be known between client and the plugin)
+ * @return SmfPluginError Plugin error if any, else SmfPluginErrNone
+ */
+ SmfPluginError customRequest( SmfPluginRequestData &aRequest,
+ const int &aOperation, QByteArray *aData );
+
+public: // From SmfPluginBase interface
+ /**
+ * The first method to be called in the plugin that implements this interface.
+ * If this method is not called, plugin may not behave as expected.
+ */
+ void initialize( );
+
+ /**
+ * Method to get the provider information
+ * @return Instance of SmfProviderBase
+ */
+ SmfProviderBase* getProviderInfo( );
+
+ /**
+ * Method to get the result for a network request.
+ * @param aOperation The type of operation to be requested
+ * @param aTransportResult The result of transport operation
+ * @param aResponse The QByteArray instance containing the network response.
+ * The plugins should delete this instance once they have read the
+ * data from it.
+ * @param aResult [out] An output parameter to the plugin manager.If the
+ * return value is SmfSendRequestAgain, QVariant will be of type
+ * SmfPluginRequestData.
+ * For SmfMusicSearchPlugin: If last operation was recommendations(),
+ * tracksSimilar() or tracksOfAlbum() or tracksOfArtist() or trackInfo(),
+ * aResult will be of type QList<SmfTrackInfo>.
+ * If last operation was stores(), aResult will be of type QList<SmfProvider>.
+ * @param aRetType [out] SmfPluginRetType
+ * @param aPageResult [out] The SmfResultPage structure variable
+ */
+ SmfPluginError responseAvailable(
+ const SmfRequestTypeID aOperation,
+ const SmfTransportResult &aTransportResult,
+ QByteArray *aResponse,
+ QVariant* aResult,
+ SmfPluginRetType &aRetType,
+ SmfResultPage &aPageResult );
+
+private:
+ /**
+ * Method called by plugins to generate a signature string from a base string
+ * @param aBaseString The base string
+ * @return The md5 hash of the base string
+ */
+ QString generateSignature(const QString aBaseString);
+
+ /**
+ * Method to interpret the key sets obtained from credential manager
+ * @param aApiKey [out] The api key
+ * @param aApiSecret [out] The api secret
+ * @param aSessionKey [out] The session key
+ * @param aToken [out] The session token
+ */
+ void fetchKeys( QString &aApiKey,
+ QString &aApiSecret,
+ QString &aToken );
+
+ /**
+ * Method to get the last.fm specific ID of the given album
+ * @param aRequest [out] The request data to be sent to network
+ * @param aAlbum The album whose tracks need to be fetched.
+ * @return SmfPluginError Plugin error if any, else SmfPluginErrNone
+ */
+ SmfPluginError getAlbumId( SmfPluginRequestData &aRequest,
+ const SmfAlbum &aAlbum );
+ /**
+ * Method to search for tracks of a given album using its ID in last.fm
+ * @param aRequest [out] The request data to be sent to network
+ * @param aAlbum The album whose tracks need to be fetched.
+ * @return SmfPluginError Plugin error if any, else SmfPluginErrNone
+ */
+ SmfPluginError getTracksOfAlbum( SmfPluginRequestData &aRequest,
+ const SmfAlbum &aAlbum );
+
+ /**
+ * Method to get the current country name as per ISO 3166-1 standard.
+ * @return Current country name
+ */
+ QString currentCountryName() const;
+
+private: // Data
+ LastFmMusicSearchProviderBase *m_provider;
+ };
+
+
+
+/**
+ * The Plugin class that implements SmfProviderBase for this last.fm plugin
+ */
+class LastFmMusicSearchProviderBase : public QObject, public SmfProviderBase
+ {
+ Q_OBJECT
+ Q_INTERFACES( SmfProviderBase )
+
+public:
+ /**
+ * Destructor
+ */
+ virtual ~LastFmMusicSearchProviderBase( );
+
+ /**
+ * Method to get the Localisable name of the service.
+ * @return The Localisable name of the service.
+ */
+ QString serviceName( ) const;
+
+ /**
+ * Method to get the Logo of the service
+ * @return The Logo of the service
+ */
+ QImage serviceIcon( ) const;
+
+ /**
+ * Method to get the Readable service description
+ * @return The Readable service description
+ */
+ QString description( ) const;
+
+ /**
+ * Method to get the Website of the service
+ * @return The Website of the service
+ */
+ QUrl serviceUrl( ) const;
+
+ /**
+ * Method to get the URL of the Application providing this service
+ * @return The URL of the Application providing this service
+ */
+ QUrl applicationUrl( ) const;
+
+ /**
+ * Method to get the Icon of the application
+ * @return The Icon of the application
+ */
+ QImage applicationIcon( ) const;
+
+ /**
+ * Method to get the list of interfaces that this provider support
+ * @return List of supported Interafces
+ */
+ QList<QString> supportedInterfaces( ) const;
+
+ /**
+ * Method to get the list of languages supported by this service provider
+ * @return a QStringList of languages supported by this service
+ * provider in 2 letter ISO 639-1 format.
+ */
+ QStringList supportedLanguages( ) const;
+
+ /**
+ * Method to get the Plugin specific ID
+ * @return The Plugin specific ID
+ */
+ QString pluginId( ) const;
+
+ /**
+ * Method to get the ID of the authentication application
+ * for this service
+ * @param aProgram The authentication application name
+ * @param aArguments List of arguments required for authentication app
+ * @param aMode Strting mode for authentication application
+ * @return The ID of the authentication application
+ */
+ QString authenticationApp( QString &aProgram, QStringList & aArguments,
+ QIODevice::OpenModeFlag aMode = QIODevice::ReadWrite ) const;
+
+ /**
+ * Method to get the unique registration ID provided by the
+ * Smf for authorised plugins
+ * @return The unique registration ID/token provided by the Smf for
+ * authorised plugins
+ */
+ QString smfRegistrationId( ) const;
+
+private:
+ /**
+ * Method that initializes this class. This method should be called
+ * from the initialize() method of the FBContactFetcherPlugin class
+ */
+ void initialize();
+
+private:
+ friend class LastFmMusicSearchPlugin;
+ QString m_serviceName;
+ QImage m_serviceIcon;
+ QString m_description;
+ QUrl m_serviceUrl;
+ QUrl m_applicationUrl;
+ QImage m_applicationIcon;
+ QString m_pluginId;
+ QString m_authAppId;
+ QString m_smfRegToken;
+ QList<QString> m_supportedInterfaces;
+ QStringList m_supportedLangs;
+ QDateTime m_validity;
+ };
+
+#endif //_LASTFMMUSICSEARCHPLUGIN_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/example/lastfmmusicsearchplugin/lastfmmusicsearchplugin.pro Thu Sep 23 17:15:03 2010 +0530
@@ -0,0 +1,43 @@
+TEMPLATE = lib
+
+CONFIG += plugin \
+ mobility
+
+MOBILITY += contacts \
+ location
+
+QT += core \
+ network
+
+HEADERS = lastfmmusicsearchplugin.h
+
+SOURCES = lastfmmusicsearchplugin.cpp
+
+TARGET = $$qtLibraryTarget(lastfmmusicsearchplugin)
+
+symbian: {
+ # Load predefined include paths (e.g. QT_PLUGINS_BASE_DIR) to be used in the pro-files
+ load(data_caging_paths)
+
+ # EPOCALLOWDLLDATA have to set true because Qt macros has initialised global data
+ TARGET.EPOCALLOWDLLDATA = 1
+
+ # Defines plugin files into Symbian .pkg package
+ pluginDep.sources = lastfmmusicsearchplugin.dll
+ pluginDep.path = $$QT_PLUGINS_BASE_DIR/smf/plugin/music.search
+ DEPLOYMENT += pluginDep
+
+ TARGET.CAPABILITY = NetworkServices \
+ ReadUserData \
+ WriteUserData \
+ LocalServices \
+ UserEnvironment \
+ ReadDeviceData \
+ WriteDeviceData
+
+ LIBS += -lsmfcommon
+}
+
+target.path += $$[QT_INSTALL_PLUGINS]/smf/plugin/music.search
+
+INSTALLS += target
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/example/lastfmmusicsearchplugin/plugin_commonU.def Thu Sep 23 17:15:03 2010 +0530
@@ -0,0 +1,16 @@
+; ==============================================================================
+; Generated by qmake (2.01a) (Qt 4.6.2) on: 2010-09-23T11:35:50
+; This file is generated by qmake and should not be modified by the
+; user.
+; Name : plugin_commonU.def
+; Part of : lastfmmusicsearchplugin
+; Description : Fixes common plugin symbols to known ordinals
+; Version :
+;
+; ==============================================================================
+
+
+EXPORTS
+ qt_plugin_query_verification_data @ 1 NONAME
+ qt_plugin_instance @ 2 NONAME
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/example/lastfmmusicsearchplugin/qmakepluginstubs/lastfmmusicsearchplugin.qtplugin Thu Sep 23 17:15:03 2010 +0530
@@ -0,0 +1,1 @@
+This file is a Qt plugin stub file. The real Qt plugin is located in \sys\bin. Created:2010-09-23T11:35:50
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/example/lastfmmusicserviceplugin/lastfmmusicserviceplugin.cpp Thu Sep 23 17:15:03 2010 +0530
@@ -0,0 +1,1604 @@
+/**
+ * Copyright (c) 2010 Sasken Communication Technologies Ltd.
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the "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:
+ * Chandradeep Gandhi, Sasken Communication Technologies Ltd - Initial contribution
+ *
+ * Contributors:
+ * Nalina Hariharan
+ *
+ * Description:
+ * The Plugin that does music services related functionalities from last.fm site
+ *
+ */
+
+// Include files
+#include <QtPlugin>
+#include <QDebug>
+#include <QCryptographicHash>
+#include <QTextStream>
+#include <QFile>
+#include <QMap>
+#include <QListIterator>
+#include <QSettings>
+#include <smfpluginutil.h>
+#include <smfcontact.h>
+
+#include "lastfmmusicserviceplugin.h"
+
+
+static int gPageNum = 0;
+static int gItemsPerPage = 0;
+
+QString gUserId;
+static int userMusicInfoChance = 0;
+QList<SmfTrackInfo> gRecentTracks;
+QList<SmfTrackInfo> gFavorites;
+QList<SmfEvent> gUserEvents;
+
+/**
+ * Destructor
+ */
+LastFmMusicServicePlugin::~LastFmMusicServicePlugin( )
+ {
+ if(m_provider)
+ delete m_provider;
+ }
+
+/**
+ * Method to interpret the key sets obtained from credential manager
+ * @param aApiKey [out] The api key
+ * @param aApiSecret [out] The api secret
+ * @param aSessionKey [out] The session key
+ * @param aToken [out] The session token
+ */
+void LastFmMusicServicePlugin::fetchKeys( QString &aApiKey,
+ QString &aApiSecret,
+ QString &aToken,
+ QString &aName )
+ {
+ qDebug()<<"Reg Token = "<<m_provider->m_smfRegToken;
+ qDebug()<<"Expiry Date as int = "<<m_provider->m_validity.toTime_t();
+
+ SmfAuthParams keys;
+ SmfPluginUtil util;
+ util.getAuthKeys(keys, m_provider->m_smfRegToken,
+ m_provider->m_validity, m_provider->m_pluginId);
+
+ QByteArray keyName;
+ keyName.append("ApiKey");
+ aApiKey.append(keys.value(keyName));
+
+ keyName.clear();
+ keyName.append("ApiSecret");
+ aApiSecret.append(keys.value(keyName));
+
+ keyName.clear();
+ keyName.append("Token");
+ aToken.append(keys.value(keyName));
+
+ keyName.clear();
+ keyName.append("Name");
+ aName.append(keys.value(keyName));
+
+ qDebug()<<"Api Key = "<<aApiKey;
+ qDebug()<<"Api Secret = "<<aApiSecret;
+ qDebug()<<"Token = "<<aToken;
+ qDebug()<<"Name = "<<aName;
+ }
+
+/**
+ * Method called by plugins to generate a signature string from a base string
+ * @param aBaseString The base string
+ * @return The md5 hash of the base string
+ */
+QString LastFmMusicServicePlugin::generateSignature(const QString aBaseString)
+ {
+ // Create md5 hash of the signature string
+ QByteArray byteArray;
+ byteArray.insert(0, aBaseString.toAscii());
+
+ QByteArray md5Hash = QCryptographicHash::hash(byteArray,QCryptographicHash::Md5 ).toHex();
+ QString returnString (md5Hash);
+ return returnString;
+ }
+
+/**
+ * Method to get self profile information
+ * @param aRequest [out] The request data to be sent to network
+ * @return Appropriate value of the enum SmfPluginError.
+ * Plugin error if any, else SmfPluginErrNone for success
+ */
+SmfPluginError LastFmMusicServicePlugin::userMusicInfo(
+ SmfPluginRequestData &aRequest )
+ {
+ qDebug()<<"Inside LastFmMusicServicePlugin::userMusicInfo()";
+
+ SmfPluginError error = SmfPluginErrInvalidArguments;
+
+ // Get the key sets from SMF Plugin Utility class.
+ QString apiKey;
+ QString apiSecret;
+ QString token;
+ QString userName;
+ fetchKeys(apiKey, apiSecret, token, userName);
+
+ // Get the current logged in user id
+ if(0 == userMusicInfoChance)
+ {
+ // Clear the global variables
+ gUserId.clear();
+ gRecentTracks.clear();
+ gFavorites.clear();
+ gUserEvents.clear();
+ gPageNum = 1;
+ gItemsPerPage = 5;
+
+ // Create the API signature string
+ QString baseString;
+ baseString.append("api_key"+apiKey);
+ baseString.append("methoduser.getInfo");
+ baseString.append("user"+userName);
+ baseString.append(apiSecret);
+
+ // Create the url
+ QUrl url("http://ws.audioscrobbler.com/2.0/?");
+ url.addQueryItem("api_key", apiKey);
+ url.addQueryItem("format", "json");
+ url.addQueryItem("method", "user.getInfo");
+ url.addQueryItem("user", userName);
+ url.addQueryItem("api_sig", generateSignature(baseString));
+
+ // Create the request, set the url
+ aRequest.iNetworkRequest.setUrl(url);
+ aRequest.iRequestType = SmfMusicGetUserInfo;
+ aRequest.iPostData = NULL;
+ aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation;
+ error = SmfPluginErrNone;
+ }
+
+ // Getting the user's recent tracks
+ else if(1 == userMusicInfoChance)
+ {
+ // Create the API signature string
+ QString baseString;
+ baseString.append("api_key"+apiKey);
+ baseString.append("limit"+QString::number(gItemsPerPage));
+ baseString.append("methoduser.getRecentTracks");
+ baseString.append("page"+QString::number(gPageNum));
+ baseString.append("user"+userName);
+ baseString.append(apiSecret);
+
+ // Create the url
+ QUrl url("http://ws.audioscrobbler.com/2.0/?");
+ url.addQueryItem("api_key", apiKey);
+ url.addQueryItem("format", "json");
+ url.addQueryItem("limit", QString::number(gItemsPerPage));
+ url.addQueryItem("method", "user.getRecentTracks");
+ url.addQueryItem("page", QString::number(gPageNum));
+ url.addQueryItem("user", userName);
+ url.addQueryItem("api_sig", generateSignature(baseString));
+
+ // Create the request, set the url
+ aRequest.iNetworkRequest.setUrl(url);
+ aRequest.iRequestType = SmfMusicGetUserInfo;
+ aRequest.iPostData = NULL;
+ aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation;
+ error = SmfPluginErrNone;
+ }
+
+ // Getting the user's favorites
+ else if(2 == userMusicInfoChance)
+ {
+ // Create the API signature string
+ QString baseString;
+ baseString.append("api_key"+apiKey);
+ baseString.append("limit"+QString::number(gItemsPerPage));
+ baseString.append("methoduser.getLovedTracks");
+ baseString.append("page"+QString::number(gPageNum));
+ baseString.append("user"+userName);
+ baseString.append(apiSecret);
+
+ // Create the url
+ QUrl url("http://ws.audioscrobbler.com/2.0/?");
+ url.addQueryItem("api_key", apiKey);
+ url.addQueryItem("format", "json");
+ url.addQueryItem("limit", QString::number(gItemsPerPage));
+ url.addQueryItem("method", "user.getLovedTracks");
+ url.addQueryItem("page", QString::number(gPageNum));
+ url.addQueryItem("user", userName);
+ url.addQueryItem("api_sig", generateSignature(baseString));
+
+ // Create the request, set the url
+ aRequest.iNetworkRequest.setUrl(url);
+ aRequest.iRequestType = SmfMusicGetUserInfo;
+ aRequest.iPostData = NULL;
+ aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation;
+ error = SmfPluginErrNone;
+ }
+
+ // Get the user's events
+ else //if(3 == userMusicInfoChance)
+ {
+ // Create the API signature string
+ QString baseString;
+ baseString.append("api_key"+apiKey);
+ baseString.append("methoduser.getEvents");
+ baseString.append("user"+userName);
+ baseString.append(apiSecret);
+
+ // Create the url
+ QUrl url("http://ws.audioscrobbler.com/2.0/?");
+ url.addQueryItem("api_key", apiKey);
+ url.addQueryItem("format", "json");
+ url.addQueryItem("method", "user.getEvents");
+ url.addQueryItem("user", userName);
+ url.addQueryItem("api_sig", generateSignature(baseString));
+
+ // Create the request, set the url
+ aRequest.iNetworkRequest.setUrl(url);
+ aRequest.iRequestType = SmfMusicGetUserInfo;
+ aRequest.iPostData = NULL;
+ aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation;
+ error = SmfPluginErrNone;
+ }
+
+ qDebug()<<"Url string is : "<<aRequest.iNetworkRequest.url().toString();
+ return error;
+ }
+
+/**
+ * Method to search information about artists. All information
+ * in SmfArtists is not required, however more available the better
+ * @param aRequest [out] The request data to be sent to network
+ * @param aArtist The artist which is the search criteria
+ * @param aPageNum The page to be extracted
+ * @param aItemsPerPage Number of items per page
+ * @return Appropriate value of the enum SmfPluginError.
+ * Plugin error if any, else SmfPluginErrNone for success
+ */
+SmfPluginError LastFmMusicServicePlugin::searchArtist(
+ SmfPluginRequestData &aRequest,
+ const SmfArtists &aArtist,
+ const int aPageNum ,
+ const int aItemsPerPage )
+ {
+ qDebug()<<"Inside LastFmMusicServicePlugin::searchArtist()";
+
+ SmfPluginError error = SmfPluginErrInvalidArguments;
+
+ // invalid arguments
+ if( aPageNum < 0 || aItemsPerPage < 0 || aArtist.names().at(0).isEmpty() )
+ {
+ qDebug()<<"Invalid arguments";
+ return error;
+ }
+
+ qDebug()<<"Valid arguments";
+
+ gPageNum = aPageNum;
+ gItemsPerPage = aItemsPerPage;
+
+ // Get the key sets from SMF Plugin Utility class.
+ QString apiKey;
+ QString apiSecret;
+ QString token;
+ QString userName;
+ fetchKeys(apiKey, apiSecret, token, userName);
+
+ // Create the API signature string
+ QString baseString;
+ baseString.append("api_key"+apiKey);
+ baseString.append("artist"+aArtist.names().at(0));
+ baseString.append("limit"+QString::number(aItemsPerPage));
+ baseString.append("methodartist.search");
+ baseString.append("page"+QString::number(aPageNum));
+ baseString.append(apiSecret);
+
+ // Create the url
+ QUrl url("http://ws.audioscrobbler.com/2.0/?");
+ url.addQueryItem("api_key", apiKey);
+ url.addQueryItem("artist", aArtist.names().at(0));
+ url.addQueryItem("format", "json");
+ url.addQueryItem("limit", QString::number(aItemsPerPage));
+ url.addQueryItem("page", QString::number(aPageNum));
+ url.addQueryItem("method", "artist.search");
+ url.addQueryItem("api_sig", generateSignature(baseString));
+
+ // Create the request, set the url
+ aRequest.iNetworkRequest.setUrl(url);
+ aRequest.iRequestType = SmfMusicSearchArtist;
+ aRequest.iPostData = NULL;
+ aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation;
+ error = SmfPluginErrNone;
+
+ qDebug()<<"Url string is : "<<aRequest.iNetworkRequest.url().toString();
+ return error;
+ }
+
+/**
+ * Method to search information about album. All information
+ * in SmfAlbum is not required, however more available the better
+ * @param aRequest [out] The request data to be sent to network
+ * @param aAlbum [in] The album which is the search criteria
+ * @param aPageNum [in] The page to be extracted
+ * @param aItemsPerPage [in] Number of items per page
+ * @return Appropriate value of the enum SmfPluginError.
+ * Plugin error if any, else SmfPluginErrNone for success
+ */
+SmfPluginError LastFmMusicServicePlugin::searchAlbum(
+ SmfPluginRequestData &aRequest,
+ const SmfAlbum &aAlbum,
+ const int aPageNum,
+ const int aItemsPerPage )
+ {
+ qDebug()<<"Inside LastFmMusicServicePlugin::searchAlbum()";
+
+ SmfPluginError error = SmfPluginErrInvalidArguments;
+
+ // invalid arguments
+ if( aPageNum < 0 || aItemsPerPage < 0 || aAlbum.name().isEmpty() )
+ {
+ qDebug()<<"Invalid arguments";
+ return error;
+ }
+
+ qDebug()<<"Valid arguments";
+
+ gPageNum = aPageNum;
+ gItemsPerPage = aItemsPerPage;
+
+ // Get the key sets from SMF Plugin Utility class.
+ QString apiKey;
+ QString apiSecret;
+ QString token;
+ QString userName;
+ fetchKeys(apiKey, apiSecret, token, userName);
+
+ // Create the API signature string
+ QString baseString;
+ baseString.append("album"+aAlbum.name());
+ baseString.append("api_key"+apiKey);
+ baseString.append("limit"+QString::number(aItemsPerPage));
+ baseString.append("methodalbum.search");
+ baseString.append("page"+QString::number(aPageNum));
+ baseString.append(apiSecret);
+
+ // Create the url
+ QUrl url("http://ws.audioscrobbler.com/2.0/?");
+ url.addQueryItem("album", aAlbum.name());
+ url.addQueryItem("api_key", apiKey);
+ url.addQueryItem("limit", QString::number(aItemsPerPage));
+ url.addQueryItem("page", QString::number(aPageNum));
+ url.addQueryItem("format", "json");
+ url.addQueryItem("method", "album.search");
+ url.addQueryItem("api_sig", generateSignature(baseString));
+
+ // Create the request, set the url
+ aRequest.iNetworkRequest.setUrl(url);
+ aRequest.iRequestType = SmfMusicSearchAlbum;
+ aRequest.iPostData = NULL;
+ aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation;
+ error = SmfPluginErrNone;
+
+ qDebug()<<"Url string is : "<<aRequest.iNetworkRequest.url().toString();
+ return error;
+ }
+
+/**
+ * Method to search information about events. All information
+ * in SmfEvent is not required, however more available the better
+ * @param aRequest [out] The request data to be sent to network
+ * @param aEvent [in] The event which is the search criteria
+ * @param aPageNum [in] The page to be extracted
+ * @param aItemsPerPage [in] Number of items per page
+ * @return Appropriate value of the enum SmfPluginError.
+ * Plugin error if any, else SmfPluginErrNone for success
+ */
+SmfPluginError LastFmMusicServicePlugin::searchEvents(
+ SmfPluginRequestData &aRequest,
+ const SmfEvent &aEvent,
+ const int aPageNum,
+ const int aItemsPerPage )
+ {
+ qDebug()<<"Inside LastFmMusicServicePlugin::searchEvents()";
+
+ SmfPluginError error = SmfPluginErrInvalidArguments;
+
+ // invalid arguments
+ if( aPageNum < 0 || aItemsPerPage < 0 || aEvent.id().isEmpty() )
+ {
+ qDebug()<<"Invalid arguments";
+ return error;
+ }
+
+ qDebug()<<"Valid arguments";
+
+ gPageNum = aPageNum;
+ gItemsPerPage = aItemsPerPage;
+
+ // Get the key sets from SMF Plugin Utility class.
+ QString apiKey;
+ QString apiSecret;
+ QString token;
+ QString userName;
+ fetchKeys(apiKey, apiSecret, token, userName);
+
+ // Create the API signature string
+ QString baseString;
+ baseString.append("api_key"+apiKey);
+ baseString.append("event"+aEvent.id());
+ baseString.append("methodevent.getInfo");
+ baseString.append(apiSecret);
+
+ // Create the url
+ QUrl url("http://ws.audioscrobbler.com/2.0/?");
+ url.addQueryItem("event", aEvent.id());
+ url.addQueryItem("api_key", apiKey);
+ url.addQueryItem("format", "json");
+ url.addQueryItem("method", "event.getInfo");
+ url.addQueryItem("api_sig", generateSignature(baseString));
+
+ // Create the request, set the url
+ aRequest.iNetworkRequest.setUrl(url);
+ aRequest.iRequestType = SmfMusicSearchEvent;
+ aRequest.iPostData = NULL;
+ aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation;
+ error = SmfPluginErrNone;
+
+ qDebug()<<"Url string is : "<<aRequest.iNetworkRequest.url().toString();
+ return error;
+ }
+
+/**
+ * Method to search information about venue. All information
+ * in SmfLocation is not required, however more available the better
+ * @param aRequest [out] The request data to be sent to network
+ * @param aVenue [in] The venue which is the search criteria
+ * @param aPageNum [in] The page to be extracted
+ * @param aItemsPerPage [in] Number of items per page
+ * @return Appropriate value of the enum SmfPluginError.
+ * Plugin error if any, else SmfPluginErrNone for success
+ */
+SmfPluginError LastFmMusicServicePlugin::searchVenue(
+ SmfPluginRequestData &aRequest,
+ const SmfLocation &aVenue,
+ const int aPageNum,
+ const int aItemsPerPage )
+ {
+ qDebug()<<"Inside LastFmMusicServicePlugin::searchVenue()";
+
+ SmfPluginError error = SmfPluginErrInvalidArguments;
+
+ // invalid arguments
+ if( aPageNum < 0 || aItemsPerPage < 0 || aVenue.name().isEmpty() )
+ {
+ qDebug()<<"Invalid arguments";
+ return error;
+ }
+
+ qDebug()<<"Valid arguments";
+
+ gPageNum = aPageNum;
+ gItemsPerPage = aItemsPerPage;
+
+ // Get the key sets from SMF Plugin Utility class.
+ QString apiKey;
+ QString apiSecret;
+ QString token;
+ QString userName;
+ fetchKeys(apiKey, apiSecret, token, userName);
+
+ // Create the API signature string
+ QString baseString;
+ baseString.append("api_key"+apiKey);
+ baseString.append("limit"+QString::number(aItemsPerPage));
+ baseString.append("methodvenue.search");
+ baseString.append("page"+QString::number(aPageNum));
+ baseString.append("venue"+aVenue.name());
+ baseString.append(apiSecret);
+
+ // Create the url
+ QUrl url("http://ws.audioscrobbler.com/2.0/?");
+ url.addQueryItem("venue", aVenue.name());
+ url.addQueryItem("api_key", apiKey);
+ url.addQueryItem("format", "json");
+ url.addQueryItem("limit", QString::number(aItemsPerPage));
+ url.addQueryItem("page", QString::number(aPageNum));
+ url.addQueryItem("method", "venue.search");
+ url.addQueryItem("api_sig", generateSignature(baseString));
+
+ // Create the request, set the url
+ aRequest.iNetworkRequest.setUrl(url);
+ aRequest.iRequestType = SmfMusicSearchVenue;
+ aRequest.iPostData = NULL;
+ aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation;
+ error = SmfPluginErrNone;
+
+ qDebug()<<"Url string is : "<<aRequest.iNetworkRequest.url().toString();
+ return error;
+ }
+
+/**
+ * Method to search information about other service users for a
+ * particular place
+ * @param aRequest [out] The request data to be sent to network
+ * @param aPlace [in] The place which is the search criteria
+ * @param aPageNum [in] The page to be extracted
+ * @param aItemsPerPage [in] Number of items per page
+ * @return Appropriate value of the enum SmfPluginError.
+ * Plugin error if any, else SmfPluginErrNone for success
+ */
+SmfPluginError LastFmMusicServicePlugin::searchUser(
+ SmfPluginRequestData &aRequest,
+ const SmfLocation &aPlace,
+ const int aPageNum,
+ const int aItemsPerPage )
+ {
+ Q_UNUSED(aRequest)
+ Q_UNUSED(aPlace)
+ Q_UNUSED(aPageNum)
+ Q_UNUSED(aItemsPerPage)
+ qDebug()<<"Inside LastFmMusicServicePlugin::searchUser()";
+ SmfPluginError error = SmfPluginErrInvalidRequest;
+ return error;
+
+#if 0
+ Q_UNUSED(aPlace)
+ qDebug()<<"Inside LastFmMusicServicePlugin::searchUser()";
+
+ SmfPluginError error = SmfPluginErrInvalidArguments;
+
+ // invalid arguments
+ if( aPageNum < 0 || aItemsPerPage < 0 )
+ {
+ qDebug()<<"Invalid arguments";
+ return error;
+ }
+
+ qDebug()<<"Valid arguments";
+
+ // Get the key sets from SMF Plugin Utility class.
+ QString apiKey;
+ QString apiSecret;
+ QString token;
+ QString userName;
+ fetchKeys(apiKey, apiSecret, token, userName);
+
+ // Create the API signature string
+ QString baseString;
+ baseString.append("api_key"+apiKey);
+ baseString.append("methoduser.getNeighbours");
+ baseString.append("user"+userName);
+ baseString.append(apiSecret);
+
+ // Create the url
+ QUrl url("http://ws.audioscrobbler.com/2.0/?");
+ url.addQueryItem("api_key", apiKey);
+ url.addQueryItem("format", "json");
+ url.addQueryItem("method", "user.getNeighbours");
+ url.addQueryItem("user", userName);
+ url.addQueryItem("api_sig", generateSignature(baseString));
+
+ // Create the request, set the url
+ aRequest.iNetworkRequest.setUrl(url);
+ aRequest.iRequestType = SmfMusicSearchUser;
+ aRequest.iPostData = NULL;
+ aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation;
+ error = SmfPluginErrNone;
+
+ qDebug()<<"Url string is : "<<aRequest.iNetworkRequest.url().toString();
+ return error;
+#endif
+ }
+
+/**
+ * Method to post the currently playing track
+ * @param aRequest [out] The request data to be sent to network
+ * @param aTrack [in] The current playing track, that should be posted
+ * @return Appropriate value of the enum SmfPluginError.
+ * Plugin error if any, else SmfPluginErrNone for success
+ */
+SmfPluginError LastFmMusicServicePlugin::postCurrentPlaying(
+ SmfPluginRequestData &aRequest,
+ const SmfTrackInfo &aTrack )
+ {
+ Q_UNUSED(aRequest)
+ Q_UNUSED(aTrack)
+ qDebug()<<"Inside LastFmMusicServicePlugin::postCurrentPlaying()";
+ SmfPluginError error = SmfPluginErrInvalidRequest;
+ return error;
+ }
+
+/**
+ * Method to post the rating on a track
+ * @param aRequest [out] The request data to be sent to network
+ * @param aTrack [in] The track on which rating should be posted
+ * @param aRating [in] The rating values
+ * @return Appropriate value of the enum SmfPluginError.
+ * Plugin error if any, else SmfPluginErrNone for success
+ */
+SmfPluginError LastFmMusicServicePlugin::postRating(
+ SmfPluginRequestData &aRequest,
+ const SmfTrackInfo &aTrack,
+ const SmfMusicRating &aRating )
+ {
+ Q_UNUSED(aRequest)
+ Q_UNUSED(aTrack)
+ Q_UNUSED(aRating)
+ qDebug()<<"Inside LastFmMusicServicePlugin::postRating()";
+ SmfPluginError error = SmfPluginErrInvalidRequest;
+ return error;
+ }
+
+/**
+ * Method to post comment on a track
+ * @param aRequest [out] The request data to be sent to network
+ * @param aTrack [in] The track on which comment should be posted
+ * @param aComment [in] The comment content
+ * @return Appropriate value of the enum SmfPluginError.
+ * Plugin error if any, else SmfPluginErrNone for success
+ */
+SmfPluginError LastFmMusicServicePlugin::postComments(
+ SmfPluginRequestData &aRequest,
+ const SmfTrackInfo &aTrack,
+ const SmfComment &aComment )
+ {
+ Q_UNUSED(aRequest)
+ Q_UNUSED(aTrack)
+ Q_UNUSED(aComment)
+ qDebug()<<"Inside LastFmMusicServicePlugin::postComments()";
+ SmfPluginError error = SmfPluginErrInvalidRequest;
+ return error;
+ }
+
+/**
+ * Customised method for SmfMusicServicePlugin interface
+ * @param aRequest [out] The request data to be sent to network
+ * @param aOperation [in] The operation type (should be known between
+ * the client interface and the plugin)
+ * @param aData [in] The data required to form the request (The type
+ * of data should be known between client and the plugin)
+ * @return Appropriate value of the enum SmfPluginError.
+ * Plugin error if any, else SmfPluginErrNone for success
+ */
+SmfPluginError LastFmMusicServicePlugin::customRequest(
+ SmfPluginRequestData &aRequest,
+ const int &aOperation, QByteArray *aData )
+ {
+ Q_UNUSED(aRequest)
+ Q_UNUSED(aOperation)
+ Q_UNUSED(aData)
+ qDebug()<<"Inside LastFmMusicServicePlugin::customRequest()";
+ SmfPluginError error = SmfPluginErrInvalidRequest;
+ return error;
+ }
+
+/**
+ * The first method to be called in the plugin that implements this interface.
+ * If this method is not called, plugin may not behave as expected.
+ */
+void LastFmMusicServicePlugin::initialize( )
+ {
+ // Create an instance of LastFmMusicServiceProviderBase
+ m_provider = new LastFmMusicServiceProviderBase;
+ m_provider->initialize();
+ }
+
+/**
+ * Method to get the provider information
+ * @return Instance of SmfProviderBase
+ */
+SmfProviderBase* LastFmMusicServicePlugin::getProviderInfo( )
+ {
+ return m_provider;
+ }
+
+/**
+ * Method to get the result for a network request.
+ * @param aOperation The type of operation to be requested
+ * @param aTransportResult The result of transport operation
+ * @param aResponse The QByteArray instance containing the network response.
+ * The plugins should delete this instance once they have read the
+ * data from it.
+ * @param aResult [out] An output parameter to the plugin manager.If the
+ * return value is SmfSendRequestAgain, QVariant will be of type
+ * SmfPluginRequestData.
+ * For SmfMusicServicePlugin: If last operation was userMusicInfo(), aResult
+ * will be of type SmfMusicProfile. If last operation was searchArtist(),
+ * aResult will be of type QList<SmfArtists>. If last operation was searchAlbum(),
+ * aResult will be of type QList<SmfAlbum>. If last operation was searchEvents(),
+ * aResult will be of type QList<SmfEvent>. If last operation was searchVenue(),
+ * aResult will be of type QList<Smfocation>. If last operation was searchUser(),
+ * aResult will be of type QList<SmfMusicProfile>. If last operation was
+ * postCurrentPlaying() or postRating() or postComments(), aResult will be of
+ * type bool.
+ * @param aRetType [out] SmfPluginRetType
+ * @param aPageResult [out] The SmfResultPage structure variable
+ */
+SmfPluginError LastFmMusicServicePlugin::responseAvailable(
+ const SmfRequestTypeID aOperation,
+ const SmfTransportResult &aTransportResult,
+ QByteArray *aResponse,
+ QVariant* aResult,
+ SmfPluginRetType &aRetType,
+ SmfResultPage &aPageResult )
+ {
+ Q_UNUSED(aPageResult)
+ qDebug()<<"Inside LastFmMusicServicePlugin::responseAvailable()";
+
+ SmfPluginError error = SmfPluginErrNetworkError;
+
+ if( !aResponse || (0 == aResponse->size()) )
+ {
+ qDebug()<<"Response is NULL or empty";
+ aRetType = SmfRequestError;
+ return error;
+ }
+
+ QByteArray response(*aResponse);
+ delete aResponse;
+
+ QFile respFile("c://data//SmfMusicServicePluginResponse.txt");
+ if(!respFile.open(QIODevice::WriteOnly))
+ qDebug()<<"File to write the response could not be opened";
+ else
+ {
+ respFile.write(response);
+ respFile.close();
+ qDebug()<<"Writing FB response to a file named 'SmfMusicServicePluginResponse.txt'";
+ }
+ qDebug()<<"FB response size = "<<response.size();
+
+ if(SmfTransportOpNoError == aTransportResult)
+ {
+ qDebug()<<"No transport error";
+
+ // Get music user info
+ if(SmfMusicGetUserInfo == aOperation)
+ {
+ qDebug()<<"Response for getting user profile";
+
+ QString errStr;
+ errStr.clear();
+
+ bool ok;
+ SmfPluginUtil util;
+ QVariantMap result = util.parse(response, &ok).toMap();
+ if (!ok)
+ {
+ qDebug()<<"An error occurred during json parsing";
+ aRetType = SmfRequestError;
+ return SmfPluginErrParsingFailed;
+ }
+
+ qDebug()<<"Json parsing complete";
+
+ if(response.contains(QByteArray("error")))
+ {
+ errStr.append(result["message"].toString());
+ }
+ else
+ {
+ if(0 == userMusicInfoChance)
+ {
+ qDebug()<<"For getting logged in user's name";
+
+ QVariantMap map1 = result["user"].toMap();
+ gUserId.clear();
+ gUserId.append(map1["id"].toString());
+ }
+ else if(1 == userMusicInfoChance)
+ {
+ qDebug()<<"For getting recent tracks";
+
+ QVariantMap map1 = result["recenttracks"].toMap();
+ QList<QVariant> list1 = map1["track"].toList();
+ QListIterator<QVariant> iter1(list1);
+ while(iter1.hasNext())
+ {
+ QVariantMap map2 = iter1.next().toMap();
+ SmfTrackInfo track;
+
+ SmfArtists artist;
+ QStringList names;
+ QVariantMap map3 = map2["artist"].toMap();
+ names.append(map3["#text"].toString());
+ artist.setNames(names);
+
+ artist.setId(map3["mbid"].toString());
+
+ track.setArtists(artist);
+
+ track.setTitle(map2["name"].toString());
+ track.setId(map2["mbid"].toString());
+
+ SmfAlbum album;
+ QVariantMap map4 = map2["album"].toMap();
+ album.setName(map4["#text"].toString());
+ album.setId(map4["mbid"].toString());
+
+ track.setAlbum(album);
+
+ gRecentTracks.append(track);
+
+ if(gItemsPerPage == gRecentTracks.count())
+ break;
+ }
+ }
+ else if(2 == userMusicInfoChance)
+ {
+ qDebug()<<"For getting favorites";
+
+ QVariantMap map1 = result["lovedtracks"].toMap();
+ QList<QVariant> list1 = map1["track"].toList();
+ QListIterator<QVariant> iter1(list1);
+ while(iter1.hasNext())
+ {
+ QVariantMap map2 = iter1.next().toMap();
+ SmfTrackInfo track;
+
+ track.setTitle(map2["name"].toString());
+ qDebug()<<"Track name : "<<track.title();
+ track.setId(map2["mbid"].toString());
+
+ SmfArtists artist;
+ QStringList names;
+ QVariantMap map3 = map2["artist"].toMap();
+ names.append(map3["name"].toString());
+ artist.setNames(names);
+ artist.setId(map3["mbid"].toString());
+ QUrl url(map3["url"].toString());
+ artist.setUrl(url);
+ QList<QVariant> list2 = map3["image"].toList();
+ QListIterator<QVariant> iter2(list2);
+ while(iter2.hasNext())
+ {
+ QVariantMap map4 = iter2.next().toMap();
+
+ // Set the artist's image url
+ QUrl url(map4["#text"].toString());
+ //artist.setImageUrlurl);
+ qDebug()<<"Track artists image url : "<<url.toString();
+ }
+
+ track.setArtists(artist);
+ qDebug()<<"Favorite tracks count = "<<gFavorites.count();
+ gFavorites.append(track);
+
+ if(gItemsPerPage == gFavorites.count())
+ break;
+ }
+ }
+ else //if(3 == userMusicInfoChance)
+ {
+ qDebug()<<"For getting user's registered events";
+ QVariantMap map1 = result["events"].toMap();
+ QList<QVariant> list1 = map1["event"].toList();
+ QListIterator<QVariant> iter1(list1);
+ while(iter1.hasNext())
+ {
+ QVariantMap map2 = iter1.next().toMap();
+
+ SmfEvent event;
+ event.setId(map2["id"].toString());
+ event.setTitle(map2["title"].toString());
+
+ // Set the events date and time
+ QDateTime dateTime;// = QDateTime::fromString("M1d1y9800:01:02","'M'M'd'd'y'yyhh:mm:ss");
+ event.setEventDateTime(dateTime);
+
+ // Set the events artists
+ SmfArtists artists;
+ QStringList names;
+ names.clear();
+ QVariantMap map3 = map2["artists"].toMap();
+ QList<QVariant> list1 = map3["artist"].toList();
+ names.clear();
+ QListIterator<QVariant> iter1(list1);
+ while(iter1.hasNext())
+ names.append(iter1.next().toString());
+ artists.setNames(names);
+ event.setArtists(artists);
+
+ // Set the events venue information
+ QVariantMap map4 = map2["venue"].toMap();
+ SmfLocation location;
+ location.setId(map4["id"].toString());
+ location.setName(map4["name"].toString());
+ QUrl url(map4["url"].toString());
+ location.setUrl(url);
+
+
+ QVariantMap map5 = map4["location"].toMap();
+ location.setCity(map5["city"].toString());
+ location.setCountry(map5["country"].toString());
+ location.setStreet(map5["street"].toString());
+ location.setZipCode(map5["postalcode"].toString());
+
+ QVariantMap map6 = map5["geo:point"].toMap();
+ double latitude = map6["geo:lat"].toDouble();
+ double longitude = map6["geo:long"].toDouble();
+ QGeoCoordinate coordinate(latitude, longitude);
+ QGeoPositionInfo geoInfo;
+ geoInfo.setCoordinate(coordinate);
+ location.setGeoPositionInfo(geoInfo);
+
+ event.setVenue(location);
+
+ // Set the events ticketUrl
+ QUrl ticketUrl(map2["tickets"].toString());
+ event.setTicketUrl(ticketUrl);
+
+
+ gUserEvents.append(event);
+
+ if(gItemsPerPage == gUserEvents.count())
+ break;
+ }
+ }
+ }
+
+ if(errStr.size())
+ {
+ qDebug()<<"Response error found = "<<errStr;
+ error = SmfPluginErrInvalidRequest;
+ aRetType = SmfRequestError;
+ aResult->setValue(errStr);
+ }
+ else
+ {
+ if(0 == userMusicInfoChance)
+ {
+ qDebug()<<"current logged in userId = "<<gUserId;
+ aRetType = SmfSendRequestAgain;
+ error = SmfPluginErrNone;
+ userMusicInfoChance = 1;
+ }
+ else if(1 == userMusicInfoChance)
+ {
+ qDebug()<<"Count of user's recent tracks = "<<gRecentTracks.count();
+ aRetType = SmfSendRequestAgain;
+ error = SmfPluginErrNone;
+ userMusicInfoChance = 2;
+ }
+ else if(2 == userMusicInfoChance)
+ {
+ qDebug()<<"Count of user's favorite tracks = "<<gFavorites.count();
+ aRetType = SmfSendRequestAgain;
+ error = SmfPluginErrNone;
+ userMusicInfoChance = 3;
+ }
+ else //if(3 == userMusicInfoChance)
+ {
+ SmfMusicProfile profile;
+ profile.setFavorites(gFavorites);
+ profile.setRecentTracks(gRecentTracks);
+ profile.setUserEvents(gUserEvents);
+ profile.setId(gUserId);
+
+ qDebug()<<"profile id in last.fm = "<<profile.id();
+ aResult->setValue(profile);
+ aRetType = SmfRequestComplete;
+ error = SmfPluginErrNone;
+ }
+ }
+
+ }
+ // Artists search
+ else if ( SmfMusicSearchArtist == aOperation )
+ {
+ qDebug()<<"Response for searching artists";
+
+ QList<SmfArtists> list;
+ QString errStr;
+ errStr.clear();
+
+ bool ok;
+ SmfPluginUtil util;
+ QVariantMap result = util.parse(response, &ok).toMap();
+ if (!ok)
+ {
+ qDebug()<<"An error occurred during json parsing";
+ aRetType = SmfRequestError;
+ return SmfPluginErrParsingFailed;
+ }
+
+ qDebug()<<"Json parsing complete";
+
+ if(response.contains(QByteArray("error")))
+ {
+ errStr.append(result["message"].toString());
+ }
+ else
+ {
+ QVariantMap map1 = result["results"].toMap();
+ QVariantMap map2 = map1["artistmatches"].toMap();
+ QList<QVariant> list1 = map2["artist"].toList();
+ QListIterator<QVariant> iter(list1);
+ while(iter.hasNext())
+ {
+ SmfArtists artist;
+ QVariantMap map3 = iter.next().toMap();
+
+ // Name of the artist
+ QStringList names;
+ names.append(map3["name"].toString());
+ artist.setNames(names);
+
+ // last.fm ID of the artist
+ artist.setId(map3["mbid"].toString());
+
+ // last.fm url of the artist
+ QUrl url(map3["url"].toString());
+ artist.setUrl(url);
+
+ // last.fm image of the artist
+ QList<QVariant> list2 = map3["image"].toList();
+ QListIterator<QVariant> iter2(list2);
+ while(iter2.hasNext())
+ {
+ QVariantMap map5 = iter2.next().toMap();
+ QUrl imageUrl(map5["#text"].toString());
+ //artists.setImageUrl(imageUrl);
+ break;
+ }
+
+ list.append(artist);
+
+ if(gItemsPerPage == list.count())
+ break;
+ }
+ }
+
+ if(errStr.size())
+ {
+ qDebug()<<"Response error found = "<<errStr;
+ error = SmfPluginErrInvalidRequest;
+ aRetType = SmfRequestError;
+ aResult->setValue(errStr);
+ }
+ else
+ {
+ qDebug()<<"list count = "<<list.count();
+ aResult->setValue(list);
+ aRetType = SmfRequestComplete;
+ error = SmfPluginErrNone;
+ }
+ }
+
+ // Albums search
+ else if ( SmfMusicSearchAlbum == aOperation )
+ {
+ qDebug()<<"Response for searching albums";
+
+ QList<SmfAlbum> list;
+ QString errStr;
+ errStr.clear();
+
+ bool ok;
+ SmfPluginUtil util;
+ QVariantMap result = util.parse(response, &ok).toMap();
+ if (!ok)
+ {
+ qDebug()<<"An error occurred during json parsing";
+ aRetType = SmfRequestError;
+ return SmfPluginErrParsingFailed;
+ }
+
+ qDebug()<<"Json parsing complete";
+
+ if(response.contains(QByteArray("error")))
+ {
+ errStr.append(result["message"].toString());
+ }
+ else
+ {
+ QVariantMap map1 = result["results"].toMap();
+ QVariantMap map2 = map1["albummatches"].toMap();
+ QList<QVariant> list1 = map2["album"].toList();
+ QListIterator<QVariant> iter(list1);
+ while(iter.hasNext())
+ {
+ SmfAlbum album;
+
+ QVariantMap map3 = iter.next().toMap();
+
+ album.setName(map3["name"].toString());
+
+ SmfArtists artists;
+ QStringList names;
+ names.append(map3["artist"].toString());
+ artists.setNames(names);
+
+ QList<QVariant> list2 = map3["image"].toList();
+ QListIterator<QVariant> iter2(list2);
+ while(iter2.hasNext())
+ {
+ QVariantMap map5 = iter2.next().toMap();
+ QUrl imageUrl(map5["#text"].toString());
+ //artists.setImageUrl(imageUrl);
+ break;
+ }
+
+ album.setArtists(artists);
+
+ album.setId(map3["id"].toString());
+
+ //QUrl url(map3["url"].toString())
+ //album.setUrl(url);
+
+ list.append(album);
+
+ if(gItemsPerPage == list.count())
+ break;
+ }
+ }
+
+ if(errStr.size())
+ {
+ qDebug()<<"Response error found = "<<errStr;
+ error = SmfPluginErrInvalidRequest;
+ aRetType = SmfRequestError;
+ aResult->setValue(errStr);
+ }
+ else
+ {
+ qDebug()<<"list count = "<<list.count();
+ aResult->setValue(list);
+ aRetType = SmfRequestComplete;
+ error = SmfPluginErrNone;
+ }
+
+ }
+
+ // Events search
+ else if (SmfMusicSearchEvent == aOperation)
+ {
+ qDebug()<<"Response for searching events";
+
+ QList<SmfEvent> list;
+ QString errStr;
+ errStr.clear();
+
+ bool ok;
+ SmfPluginUtil util;
+ QVariantMap result = util.parse(response, &ok).toMap();
+ if (!ok)
+ {
+ qDebug()<<"An error occurred during json parsing";
+ aRetType = SmfRequestError;
+ return SmfPluginErrParsingFailed;
+ }
+
+ qDebug()<<"Json parsing complete";
+
+ if(response.contains(QByteArray("error")))
+ {
+ errStr.append(result["message"].toString());
+ }
+ else
+ {
+ QVariantMap map1 = result["event"].toMap();
+ SmfEvent event;
+
+ // Set the events title
+ event.setTitle(map1["title"].toString());
+
+ // Set the events id
+ event.setId(map1["id"].toString());
+
+ // Set the events date and time
+ QDateTime dateTime;// = QDateTime::fromString("M1d1y9800:01:02","'M'M'd'd'y'yyhh:mm:ss");
+ event.setEventDateTime(dateTime);
+
+ // Set the events artists
+ SmfArtists artists;
+ QStringList names;
+ names.clear();
+ QVariantMap map2 = map1["artists"].toMap();
+ QList<QVariant> list1 = map2["artist"].toList();
+ QListIterator<QVariant> iter(list1);
+ while(iter.hasNext())
+ names.append(iter.next().toString());
+ artists.setNames(names);
+ event.setArtists(artists);
+
+ // Set the events venue information
+ QVariantMap map3 = map1["venue"].toMap();
+ SmfLocation location;
+ location.setName(map3["name"].toString());
+ QUrl url(map3["url"].toString());
+ location.setUrl(url);
+ location.setId(map3["id"].toString());
+
+ QVariantMap map4 = map3["location"].toMap();
+ location.setCity(map4["city"].toString());
+ location.setCountry(map4["country"].toString());
+ location.setStreet(map4["street"].toString());
+ location.setZipCode(map4["postalcode"].toString());
+
+ QVariantMap map5 = map4["geo:point"].toMap();
+ double latitude = map5["geo:lat"].toDouble();
+ double longitude = map5["geo:long"].toDouble();
+ QGeoCoordinate coordinate(latitude, longitude);
+ QGeoPositionInfo geoInfo;
+ geoInfo.setCoordinate(coordinate);
+ location.setGeoPositionInfo(geoInfo);
+
+ event.setVenue(location);
+
+ // Set the events ticketUrl
+ QUrl ticketUrl(map1["tickets"].toString());
+ event.setTicketUrl(ticketUrl);
+
+ // Set the events id
+ event.setId(map1["id"].toString());
+
+ list.append(event);
+ }
+
+ if(errStr.size())
+ {
+ qDebug()<<"Response error found = "<<errStr;
+ error = SmfPluginErrInvalidRequest;
+ aRetType = SmfRequestError;
+ aResult->setValue(errStr);
+ }
+ else
+ {
+ qDebug()<<"list count = "<<list.count();
+ aResult->setValue(list);
+ aRetType = SmfRequestComplete;
+ error = SmfPluginErrNone;
+ }
+ }
+
+ // Venues Search
+ else if(SmfMusicSearchVenue == aOperation)
+ {
+ qDebug()<<"Response for searching venues";
+
+ QList<SmfLocation> list;
+ QString errStr;
+ errStr.clear();
+
+ bool ok;
+ SmfPluginUtil util;
+ QVariantMap result = util.parse(response, &ok).toMap();
+ if (!ok)
+ {
+ qDebug()<<"An error occurred during json parsing";
+ aRetType = SmfRequestError;
+ return SmfPluginErrParsingFailed;
+ }
+
+ qDebug()<<"Json parsing complete";
+
+ if(response.contains(QByteArray("error")))
+ {
+ errStr.append(result["message"].toString());
+ }
+ else
+ {
+ QVariantMap map1 = result["results"].toMap();
+ QVariantMap map2 = map1["venuematches"].toMap();
+ QList<QVariant> list1 = map2["venue"].toList();
+ QListIterator<QVariant> iter(list1);
+ while(iter.hasNext())
+ {
+ SmfLocation location;
+ QVariantMap map3 = iter.next().toMap();
+
+ location.setName(map3["name"].toString());
+ QUrl url(map3["url"].toString());
+ location.setUrl(url);
+ location.setId(map3["id"].toString());
+
+ QVariantMap map4 = map3["location"].toMap();
+ location.setCity(map4["city"].toString());
+ location.setCountry(map4["country"].toString());
+ location.setStreet(map4["street"].toString());
+ location.setZipCode(map4["postalcode"].toString());
+
+ QVariantMap map5 = map4["geo:point"].toMap();
+ double latitude = map5["geo:lat"].toDouble();
+ double longitude = map5["geo:long"].toDouble();
+ QGeoCoordinate coordinate(latitude, longitude);
+ QGeoPositionInfo geoInfo;
+ geoInfo.setCoordinate(coordinate);
+ location.setGeoPositionInfo(geoInfo);
+
+ list.append(location);
+
+ if(gItemsPerPage == list.count())
+ break;
+ }
+ }
+
+ if(errStr.size())
+ {
+ qDebug()<<"Response error found = "<<errStr;
+ error = SmfPluginErrInvalidRequest;
+ aRetType = SmfRequestError;
+ aResult->setValue(errStr);
+ }
+ else
+ {
+ qDebug()<<"list count = "<<list.count();
+ aResult->setValue(list);
+ aRetType = SmfRequestComplete;
+ error = SmfPluginErrNone;
+ }
+ }
+
+#if 0
+ // User search
+ else if(SmfMusicSearchUser == aOperation)
+ {
+ qDebug()<<"Response for searching users";
+
+ QList<SmfMusicProfile> list;
+ QString errStr;
+ errStr.clear();
+
+ bool ok;
+ SmfPluginUtil util;
+ QVariantMap result = util.parse(response, &ok).toMap();
+ if (!ok)
+ {
+ qDebug()<<"An error occurred during json parsing";
+ aRetType = SmfRequestError;
+ return SmfPluginErrParsingFailed;
+ }
+
+ if(response.contains(QByteArray("error")))
+ {
+ errStr.append(result["message"].toString());
+ }
+ else
+ {
+ qDebug()<<"For getting user's neighbours";
+
+ QVariantMap map1 = result["neighbours"].toMap();
+ QList<QVariant> list1 = map1["user"].toList();
+ QListIterator<QVariant> iter(list1);
+ while(iter.hasNext())
+ {
+ SmfMusicProfile profile;
+ QVariantMap map2 = iter.next().toMap();
+
+/* QContactName name;
+ name.setFirstName(map2["name"].toString());
+ QVariant nameVar = QVariant::fromValue<QContactName>(name);
+ contact.setValue("Name", nameVar);
+
+ QContactUrl url;
+ url.setUrl(map2["url"].toString());
+ QVariant urlVar = QVariant::fromValue<QContactUrl>(url);
+ contact.setValue("Url", urlVar);
+
+ QContactAvatar avatar;
+ QList<QVariant> list2 = map2["image"].toList();
+ QListIterator<QVariant> iter2(list2);
+ while(iter2.hasNext())
+ {
+ QVariantMap map3 = iter2.next().toMap();
+ QUrl imageUrl(map3["#text"].toString());
+ avatar.setImageUrl(imageUrl);
+ break;
+ }
+
+ QVariant avatarVar = QVariant::fromValue<QContactAvatar>(avatar);
+ contact.setValue("Avatar", avatarVar);*/
+
+ profile.setId(map2["name"].toString());
+
+ list.append(profile);
+
+ if(gItemsPerPage == list.count())
+ break;
+
+ }
+ }
+
+ if(errStr.size())
+ {
+ qDebug()<<"Response error found = "<<errStr;
+ error = SmfPluginErrInvalidRequest;
+ aRetType = SmfRequestError;
+ aResult->setValue(errStr);
+ }
+ else
+ {
+ qDebug()<<"list count = "<<list.count();
+ aResult->setValue(list);
+ aRetType = SmfRequestComplete;
+ error = SmfPluginErrNone;
+ }
+ }
+#endif
+
+ else
+ {
+ qDebug()<<"Service unsupported!!!";
+ aRetType = SmfRequestError;
+ error = SmfPluginErrServiceNotSupported;
+ }
+ }
+
+ else if(SmfTransportOpOperationCanceledError == aTransportResult)
+ {
+ qDebug()<<"Operation Cancelled !!!";
+ error = SmfPluginErrCancelComplete;
+ aRetType = SmfRequestComplete;
+ }
+
+ else
+ {
+ qDebug()<<"Transport Error !!!";
+ error = SmfPluginErrNetworkError;
+ aRetType = SmfRequestError;
+ }
+
+ return error;
+ }
+
+
+
+/**
+ * Destructor
+ */
+LastFmMusicServiceProviderBase::~LastFmMusicServiceProviderBase( )
+ {
+ }
+
+
+/**
+ * Method to get the Localisable name of the service.
+ * @return The Localisable name of the service.
+ */
+QString LastFmMusicServiceProviderBase::serviceName( ) const
+ {
+ return m_serviceName;
+ }
+
+
+/**
+ * Method to get the Logo of the service
+ * @return The Logo of the service
+ */
+QImage LastFmMusicServiceProviderBase::serviceIcon( ) const
+ {
+ return m_serviceIcon;
+ }
+
+
+/**
+ * Method to get the Readable service description
+ * @return The Readable service description
+ */
+QString LastFmMusicServiceProviderBase::description( ) const
+ {
+ return m_description;
+ }
+
+
+/**
+ * Method to get the Website of the service
+ * @return The Website of the service
+ */
+QUrl LastFmMusicServiceProviderBase::serviceUrl( ) const
+ {
+ return m_serviceUrl;
+ }
+
+
+/**
+ * Method to get the URL of the Application providing this service
+ * @return The URL of the Application providing this service
+ */
+QUrl LastFmMusicServiceProviderBase::applicationUrl( ) const
+ {
+ return m_applicationUrl;
+ }
+
+
+/**
+ * Method to get the Icon of the application
+ * @return The Icon of the application
+ */
+QImage LastFmMusicServiceProviderBase::applicationIcon( ) const
+ {
+ return m_applicationIcon;
+ }
+
+/**
+* Method to get the list of interfaces that this provider support
+* @return List of supported Interafces
+*/
+QList<QString> LastFmMusicServiceProviderBase::supportedInterfaces( ) const
+ {
+ return m_supportedInterfaces;
+ }
+
+/**
+* Method to get the list of languages supported by this service provider
+* @return a QStringList of languages supported by this service
+* provider in 2 letter ISO 639-1 format.
+*/
+QStringList LastFmMusicServiceProviderBase::supportedLanguages( ) const
+ {
+ return m_supportedLangs;
+ }
+
+/**
+ * Method to get the Plugin specific ID
+ * @return The Plugin specific ID
+ */
+QString LastFmMusicServiceProviderBase::pluginId( ) const
+ {
+ return m_pluginId;
+ }
+
+
+/**
+ * Method to get the ID of the authentication application
+ * for this service
+ * @param aProgram The authentication application name
+ * @param aArguments List of arguments required for authentication app
+ * @param aMode Strting mode for authentication application
+ * @return The ID of the authentication application
+ */
+QString LastFmMusicServiceProviderBase::authenticationApp( QString &aProgram,
+ QStringList & aArguments,
+ QIODevice::OpenModeFlag aMode ) const
+ {
+ Q_UNUSED(aProgram)
+ Q_UNUSED(aArguments)
+ Q_UNUSED(aMode)
+ return m_authAppId;
+ }
+
+
+/**
+ * Method to get the unique registration ID provided by the
+ * Smf for authorised plugins
+ * @return The unique registration ID/token provided by the Smf for
+ * authorised plugins
+ */
+QString LastFmMusicServiceProviderBase::smfRegistrationId( ) const
+ {
+ return m_smfRegToken;
+ }
+
+
+/**
+ * Method that initializes this class. This method should be called
+ * from the initialize() method of the FBContactFetcherPlugin class
+ */
+void LastFmMusicServiceProviderBase::initialize()
+ {
+ m_serviceName = "last.fm";
+ m_description = "Last.fm music service plugin description";
+ m_serviceUrl = QUrl(QString("http://www.last.fm"));
+ m_pluginId = "lastfmmusicserviceplugin.qtplugin";
+ m_authAppId = "0x12345678";
+ m_supportedInterfaces.append("org.symbian.smf.plugin.music.service/v0.2");
+ QSettings iSettings;
+ m_smfRegToken = iSettings.value("LastFmRegToken").toString();
+ m_validity = iSettings.value("LastFmExpiryTime").toDateTime();
+ }
+
+
+/*
+ * Export Macro
+ * plugin name : LastFmMusicServicePlugin
+ * plugin class : LastFmMusicServicePlugin
+ */
+Q_EXPORT_PLUGIN2( lastfmmusicserviceplugin, LastFmMusicServicePlugin )
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/example/lastfmmusicserviceplugin/lastfmmusicserviceplugin.h Thu Sep 23 17:15:03 2010 +0530
@@ -0,0 +1,360 @@
+/**
+ * Copyright (c) 2010 Sasken Communication Technologies Ltd.
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the "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:
+ * Chandradeep Gandhi, Sasken Communication Technologies Ltd - Initial contribution
+ *
+ * Contributors:
+ * Nalina Hariharan
+ *
+ * Description:
+ * The Plugin that does music services related functionalities from last.fm site
+ *
+ */
+
+#ifndef _LASTFMMUSICSERVICEPLUGIN_H
+#define _LASTFMMUSICSERVICEPLUGIN_H
+
+// Include files
+#include <smfmusicserviceplugin.h>
+
+// Class declaration
+class LastFmMusicServiceProviderBase;
+class QVariant;
+
+/**
+ * The Plugin does music services related functionalities from last.fm site
+ */
+class LastFmMusicServicePlugin : public QObject, public SmfMusicServicePlugin
+ {
+ Q_OBJECT
+ Q_INTERFACES( SmfMusicServicePlugin SmfPluginBase )
+
+public:
+ /**
+ * Destructor
+ */
+ virtual ~LastFmMusicServicePlugin ( );
+
+public: // From SmfMusicServicePlugin interface
+ /**
+ * Method to get self profile information
+ * @param aRequest [out] The request data to be sent to network
+ * @return Appropriate value of the enum SmfPluginError.
+ * Plugin error if any, else SmfPluginErrNone for success
+ */
+ SmfPluginError userMusicInfo( SmfPluginRequestData &aRequest );
+
+ /**
+ * Method to search information about artists. All information
+ * in SmfArtists is not required, however more available the better
+ * @param aRequest [out] The request data to be sent to network
+ * @param aArtist The artist which is the search criteria
+ * @param aPageNum The page to be extracted
+ * @param aItemsPerPage Number of items per page
+ * @return Appropriate value of the enum SmfPluginError.
+ * Plugin error if any, else SmfPluginErrNone for success
+ */
+ SmfPluginError searchArtist( SmfPluginRequestData &aRequest,
+ const SmfArtists &aArtist,
+ const int aPageNum = SMF_FIRST_PAGE,
+ const int aItemsPerPage = SMF_ITEMS_PER_PAGE );
+
+ /**
+ * Method to search information about album. All information
+ * in SmfAlbum is not required, however more available the better
+ * @param aRequest [out] The request data to be sent to network
+ * @param aAlbum [in] The album which is the search criteria
+ * @param aPageNum [in] The page to be extracted
+ * @param aItemsPerPage [in] Number of items per page
+ * @return Appropriate value of the enum SmfPluginError.
+ * Plugin error if any, else SmfPluginErrNone for success
+ */
+ SmfPluginError searchAlbum( SmfPluginRequestData &aRequest,
+ const SmfAlbum &aAlbum,
+ const int aPageNum = SMF_FIRST_PAGE,
+ const int aItemsPerPage = SMF_ITEMS_PER_PAGE );
+
+ /**
+ * Method to search information about events. All information
+ * in SmfEvent is not required, however more available the better
+ * @param aRequest [out] The request data to be sent to network
+ * @param aEvent [in] The event which is the search criteria
+ * @param aPageNum [in] The page to be extracted
+ * @param aItemsPerPage [in] Number of items per page
+ * @return Appropriate value of the enum SmfPluginError.
+ * Plugin error if any, else SmfPluginErrNone for success
+ */
+ SmfPluginError searchEvents( SmfPluginRequestData &aRequest,
+ const SmfEvent &aEvent,
+ const int aPageNum = SMF_FIRST_PAGE,
+ const int aItemsPerPage = SMF_ITEMS_PER_PAGE );
+
+ /**
+ * Method to search information about venue. All information
+ * in SmfLocation is not required, however more available the better
+ * @param aRequest [out] The request data to be sent to network
+ * @param aVenue [in] The venue which is the search criteria
+ * @param aPageNum [in] The page to be extracted
+ * @param aItemsPerPage [in] Number of items per page
+ * @return Appropriate value of the enum SmfPluginError.
+ * Plugin error if any, else SmfPluginErrNone for success
+ */
+ SmfPluginError searchVenue( SmfPluginRequestData &aRequest,
+ const SmfLocation &aVenue,
+ const int aPageNum = SMF_FIRST_PAGE,
+ const int aItemsPerPage = SMF_ITEMS_PER_PAGE );
+
+ /**
+ * Method to search information about other service users for a
+ * particular place
+ * @param aRequest [out] The request data to be sent to network
+ * @param aPlace [in] The place which is the search criteria
+ * @param aPageNum [in] The page to be extracted
+ * @param aItemsPerPage [in] Number of items per page
+ * @return Appropriate value of the enum SmfPluginError.
+ * Plugin error if any, else SmfPluginErrNone for success
+ */
+ SmfPluginError searchUser( SmfPluginRequestData &aRequest,
+ const SmfLocation &aPlace,
+ const int aPageNum = SMF_FIRST_PAGE,
+ const int aItemsPerPage = SMF_ITEMS_PER_PAGE );
+
+ /**
+ * Method to post the currently playing track
+ * @param aRequest [out] The request data to be sent to network
+ * @param aTrack [in] The current playing track, that should be posted
+ * @return Appropriate value of the enum SmfPluginError.
+ * Plugin error if any, else SmfPluginErrNone for success
+ */
+ SmfPluginError postCurrentPlaying(
+ SmfPluginRequestData &aRequest,
+ const SmfTrackInfo &aTrack );
+
+ /**
+ * Method to post the rating on a track
+ * @param aRequest [out] The request data to be sent to network
+ * @param aTrack [in] The track on which rating should be posted
+ * @param aRating [in] The rating values
+ * @return Appropriate value of the enum SmfPluginError.
+ * Plugin error if any, else SmfPluginErrNone for success
+ */
+ SmfPluginError postRating(
+ SmfPluginRequestData &aRequest,
+ const SmfTrackInfo &aTrack,
+ const SmfMusicRating &aRating );
+
+ /**
+ * Method to post comment on a track
+ * @param aRequest [out] The request data to be sent to network
+ * @param aTrack [in] The track on which comment should be posted
+ * @param aComment [in] The comment content
+ * @return Appropriate value of the enum SmfPluginError.
+ * Plugin error if any, else SmfPluginErrNone for success
+ */
+ SmfPluginError postComments(
+ SmfPluginRequestData &aRequest,
+ const SmfTrackInfo &aTrack,
+ const SmfComment &aComment );
+
+ /**
+ * Customised method for SmfMusicServicePlugin interface
+ * @param aRequest [out] The request data to be sent to network
+ * @param aOperation [in] The operation type (should be known between
+ * the client interface and the plugin)
+ * @param aData [in] The data required to form the request (The type
+ * of data should be known between client and the plugin)
+ * @return Appropriate value of the enum SmfPluginError.
+ * Plugin error if any, else SmfPluginErrNone for success
+ */
+ SmfPluginError customRequest( SmfPluginRequestData &aRequest,
+ const int &aOperation, QByteArray *aData );
+
+
+public: // From SmfPluginBase interface
+ /**
+ * The first method to be called in the plugin that implements this interface.
+ * If this method is not called, plugin may not behave as expected.
+ */
+ void initialize( );
+
+ /**
+ * Method to get the provider information
+ * @return Instance of SmfProviderBase
+ */
+ SmfProviderBase* getProviderInfo( );
+
+ /**
+ * Method to get the result for a network request.
+ * @param aOperation The type of operation to be requested
+ * @param aTransportResult The result of transport operation
+ * @param aResponse The QByteArray instance containing the network response.
+ * The plugins should delete this instance once they have read the
+ * data from it.
+ * @param aResult [out] An output parameter to the plugin manager.If the
+ * return value is SmfSendRequestAgain, QVariant will be of type
+ * SmfPluginRequestData.
+ * For SmfMusicServicePlugin: If last operation was userMusicInfo(), aResult
+ * will be of type SmfMusicProfile. If last operation was searchArtist(),
+ * aResult will be of type QList<SmfArtists>. If last operation was searchAlbum(),
+ * aResult will be of type QList<SmfAlbum>. If last operation was searchEvents(),
+ * aResult will be of type QList<SmfEvent>. If last operation was searchVenue(),
+ * aResult will be of type QList<Smfocation>. If last operation was searchUser(),
+ * aResult will be of type QList<SmfMusicProfile>. If last operation was
+ * postCurrentPlaying() or postRating() or postComments(), aResult will be of
+ * type bool.
+ * @param aRetType [out] SmfPluginRetType
+ * @param aPageResult [out] The SmfResultPage structure variable
+ */
+ SmfPluginError responseAvailable(
+ const SmfRequestTypeID aOperation,
+ const SmfTransportResult &aTransportResult,
+ QByteArray *aResponse,
+ QVariant* aResult,
+ SmfPluginRetType &aRetType,
+ SmfResultPage &aPageResult );
+
+private:
+ /**
+ * Method called by plugins to generate a signature string from a base string
+ * @param aBaseString The base string
+ * @return The md5 hash of the base string
+ */
+ QString generateSignature(const QString aBaseString);
+
+ /**
+ * Method to interpret the key sets obtained from credential manager
+ * @param aApiKey [out] The api key
+ * @param aApiSecret [out] The api secret
+ * @param aSessionKey [out] The session key
+ * @param aToken [out] The session token
+ * @param aName [out] The user name
+ */
+ void fetchKeys( QString &aApiKey,
+ QString &aApiSecret,
+ QString &aToken,
+ QString &aName );
+
+private: // Data
+ LastFmMusicServiceProviderBase *m_provider;
+ };
+
+
+
+/**
+ * The Plugin class that implements SmfProviderBase for this last.fm plugin
+ */
+class LastFmMusicServiceProviderBase : public QObject, public SmfProviderBase
+ {
+ Q_OBJECT
+ Q_INTERFACES( SmfProviderBase )
+
+public:
+ /**
+ * Destructor
+ */
+ virtual ~LastFmMusicServiceProviderBase( );
+
+ /**
+ * Method to get the Localisable name of the service.
+ * @return The Localisable name of the service.
+ */
+ QString serviceName( ) const;
+
+ /**
+ * Method to get the Logo of the service
+ * @return The Logo of the service
+ */
+ QImage serviceIcon( ) const;
+
+ /**
+ * Method to get the Readable service description
+ * @return The Readable service description
+ */
+ QString description( ) const;
+
+ /**
+ * Method to get the Website of the service
+ * @return The Website of the service
+ */
+ QUrl serviceUrl( ) const;
+
+ /**
+ * Method to get the URL of the Application providing this service
+ * @return The URL of the Application providing this service
+ */
+ QUrl applicationUrl( ) const;
+
+ /**
+ * Method to get the Icon of the application
+ * @return The Icon of the application
+ */
+ QImage applicationIcon( ) const;
+
+ /**
+ * Method to get the list of interfaces that this provider support
+ * @return List of supported Interafces
+ */
+ QList<QString> supportedInterfaces( ) const;
+
+ /**
+ * Method to get the list of languages supported by this service provider
+ * @return a QStringList of languages supported by this service
+ * provider in 2 letter ISO 639-1 format.
+ */
+ QStringList supportedLanguages( ) const;
+
+ /**
+ * Method to get the Plugin specific ID
+ * @return The Plugin specific ID
+ */
+ QString pluginId( ) const;
+
+ /**
+ * Method to get the ID of the authentication application
+ * for this service
+ * @param aProgram The authentication application name
+ * @param aArguments List of arguments required for authentication app
+ * @param aMode Strting mode for authentication application
+ * @return The ID of the authentication application
+ */
+ QString authenticationApp( QString &aProgram, QStringList & aArguments,
+ QIODevice::OpenModeFlag aMode = QIODevice::ReadWrite ) const;
+
+ /**
+ * Method to get the unique registration ID provided by the
+ * Smf for authorised plugins
+ * @return The unique registration ID/token provided by the Smf for
+ * authorised plugins
+ */
+ QString smfRegistrationId( ) const;
+
+private:
+ /**
+ * Method that initializes this class. This method should be called
+ * from the initialize() method of the LastFmMusicServicePlugin class
+ */
+ void initialize();
+
+private:
+ friend class LastFmMusicServicePlugin;
+ QString m_serviceName;
+ QImage m_serviceIcon;
+ QString m_description;
+ QUrl m_serviceUrl;
+ QUrl m_applicationUrl;
+ QImage m_applicationIcon;
+ QString m_pluginId;
+ QString m_authAppId;
+ QString m_smfRegToken;
+ QList<QString> m_supportedInterfaces;
+ QStringList m_supportedLangs;
+ QDateTime m_validity;
+ };
+
+#endif //_LASTFMMUSICSERVICEPLUGIN_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/example/lastfmmusicserviceplugin/lastfmmusicserviceplugin.pro Thu Sep 23 17:15:03 2010 +0530
@@ -0,0 +1,43 @@
+TEMPLATE = lib
+
+CONFIG += plugin \
+ mobility
+
+MOBILITY += contacts \
+ location
+
+QT += core \
+ network
+
+HEADERS = lastfmmusicserviceplugin.h
+
+SOURCES = lastfmmusicserviceplugin.cpp
+
+TARGET = $$qtLibraryTarget(lastfmmusicserviceplugin)
+
+symbian: {
+ # Load predefined include paths (e.g. QT_PLUGINS_BASE_DIR) to be used in the pro-files
+ load(data_caging_paths)
+
+ # EPOCALLOWDLLDATA have to set true because Qt macros has initialised global data
+ TARGET.EPOCALLOWDLLDATA = 1
+
+ # Defines plugin files into Symbian .pkg package
+ pluginDep.sources = lastfmmusicserviceplugin.dll
+ pluginDep.path = $$QT_PLUGINS_BASE_DIR/smf/plugin/music.service
+ DEPLOYMENT += pluginDep
+
+ TARGET.CAPABILITY = NetworkServices \
+ ReadUserData \
+ WriteUserData \
+ LocalServices \
+ UserEnvironment \
+ ReadDeviceData \
+ WriteDeviceData
+
+ LIBS += -lsmfcommon
+}
+
+target.path += $$[QT_INSTALL_PLUGINS]/smf/plugin/music.service
+
+INSTALLS += target
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/example/lastfmmusicserviceplugin/plugin_commonU.def Thu Sep 23 17:15:03 2010 +0530
@@ -0,0 +1,16 @@
+; ==============================================================================
+; Generated by qmake (2.01a) (Qt 4.6.2) on: 2010-09-23T11:35:50
+; This file is generated by qmake and should not be modified by the
+; user.
+; Name : plugin_commonU.def
+; Part of : lastfmmusicserviceplugin
+; Description : Fixes common plugin symbols to known ordinals
+; Version :
+;
+; ==============================================================================
+
+
+EXPORTS
+ qt_plugin_query_verification_data @ 1 NONAME
+ qt_plugin_instance @ 2 NONAME
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/example/lastfmmusicserviceplugin/qmakepluginstubs/lastfmmusicserviceplugin.qtplugin Thu Sep 23 17:15:03 2010 +0530
@@ -0,0 +1,1 @@
+This file is a Qt plugin stub file. The real Qt plugin is located in \sys\bin. Created:2010-09-23T11:35:50
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/example/lastfmplaylistserviceplugin/lastfmplaylistserviceplugin.cpp Thu Sep 23 17:15:03 2010 +0530
@@ -0,0 +1,918 @@
+/**
+ * Copyright (c) 2010 Sasken Communication Technologies Ltd.
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the "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:
+ * Chandradeep Gandhi, Sasken Communication Technologies Ltd - Initial contribution
+ *
+ * Contributors:
+ * Sangeeta Prasad, Nalina Hariharan
+ *
+ * Description:
+ * The Plugin that does music services related functionalities from last.fm site
+ *
+ */
+
+// Include files
+#include <QtPlugin>
+#include <QDebug>
+#include <QCryptographicHash>
+#include <QTextStream>
+#include <QFile>
+#include <QMap>
+#include <QListIterator>
+#include <QSettings>
+#include <smfpluginutil.h>
+
+#include "lastfmplaylistserviceplugin.h"
+
+
+static int gPageNum = 0;
+static int gItemsPerPage = 0;
+
+//Payload data array
+QByteArray payload;
+
+/**
+ * Destructor
+ */
+LastFmPlaylistServicePlugin::~LastFmPlaylistServicePlugin( )
+ {
+ if(m_provider)
+ delete m_provider;
+ }
+
+/**
+ * Method to interpret the key sets obtained from credential manager
+ * @param aApiKey [out] The api key
+ * @param aApiSecret [out] The api secret
+ * @param aSessionKey [out] The session key
+ * @param aToken [out] The session token
+ * @param aName [out] The user name
+ */
+void LastFmPlaylistServicePlugin::fetchKeys( QString &aApiKey,
+ QString &aApiSecret,
+ QString &aToken,
+ QString &aName )
+ {
+ qDebug()<<"Reg Token = "<<m_provider->m_smfRegToken;
+ qDebug()<<"Expiry Date as int = "<<m_provider->m_validity.toTime_t();
+
+ SmfAuthParams keys;
+ SmfPluginUtil util;
+ util.getAuthKeys(keys, m_provider->m_smfRegToken,
+ m_provider->m_validity, m_provider->m_pluginId);
+
+ QByteArray keyName;
+ keyName.append("ApiKey");
+ aApiKey.append(keys.value(keyName));
+
+ keyName.clear();
+ keyName.append("ApiSecret");
+ aApiSecret.append(keys.value(keyName));
+
+ keyName.clear();
+ keyName.append("Token");
+ aToken.append(keys.value(keyName));
+
+ keyName.clear();
+ keyName.append("Name");
+ aName.append(keys.value(keyName));
+
+ qDebug()<<"Api Key = "<<aApiKey;
+ qDebug()<<"Api Secret = "<<aApiSecret;
+ qDebug()<<"Token = "<<aToken;
+ qDebug()<<"Name = "<<aName;
+ }
+
+/**
+ * Method called by plugins to generate a signature string from a base string
+ * @param aBaseString The base string
+ * @return The md5 hash of the base string
+ */
+QString LastFmPlaylistServicePlugin::generateSignature(const QString aBaseString)
+ {
+ // Create md5 hash of the signature string
+ QByteArray byteArray;
+ byteArray.insert(0, aBaseString.toAscii());
+
+ QByteArray md5Hash = QCryptographicHash::hash(byteArray,QCryptographicHash::Md5 ).toHex();
+ QString returnString (md5Hash);
+ return returnString;
+ }
+
+/**
+ * Method to get the playlist
+ * @param aRequest [out] The request data to be sent to network
+ * @param aPageNum [in] The page to be extracted
+ * @param aItemsPerPage [in] Number of items per page
+ * @return Appropriate value of the enum SmfPluginError.
+ * Plugin error if any, else SmfPluginErrNone for success
+ */
+SmfPluginError LastFmPlaylistServicePlugin::playlists(
+ SmfPluginRequestData &aRequest,
+ const int aPageNum,
+ const int aItemsPerPage )
+ {
+ qDebug()<<"Inside LastFmPlaylistServicePlugin::playlists()";
+
+ SmfPluginError error = SmfPluginErrInvalidArguments;
+
+ // invalid arguments
+ if( aPageNum < 0 || aItemsPerPage < 0 )
+ {
+ qDebug()<<"Invalid arguments";
+ return error;
+ }
+
+ qDebug()<<"Valid arguments";
+
+ gPageNum = aPageNum;
+ gItemsPerPage = aItemsPerPage;
+
+ // Get the key sets from SMF Plugin Utility class.
+ QString apiKey;
+ QString apiSecret;
+ QString token;
+ QString userName;
+ fetchKeys(apiKey, apiSecret, token, userName);
+
+ // Create the API signature string
+ QString baseString;
+ baseString.append("api_key"+apiKey);
+ baseString.append("methoduser.getPlaylists");
+ baseString.append("user"+userName);
+ baseString.append(apiSecret);
+
+ // Create the url
+ QUrl url("http://ws.audioscrobbler.com/2.0/?");
+ url.addQueryItem("api_key", apiKey);
+ url.addQueryItem("format", "json");
+ url.addQueryItem("method", "user.getPlaylists");
+ url.addQueryItem("user", userName);
+ url.addQueryItem("api_sig", generateSignature(baseString));
+
+ // Create the request, set the url
+ aRequest.iNetworkRequest.setUrl(url);
+ aRequest.iRequestType = SmfMusicGetPlaylists;
+ aRequest.iPostData = NULL;
+ aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation;
+ error = SmfPluginErrNone;
+
+ qDebug()<<"Url string is : "<<aRequest.iNetworkRequest.url().toString();
+ return error;
+ }
+
+/**
+ * Method to get the playlist of a particular user
+ * @param aRequest [out] The request data to be sent to network
+ * @param aUser [in] The user whose playlists need to be fetched
+ * @param aPageNum [in] The page to be extracted
+ * @param aItemsPerPage [in] Number of items per page
+ * @return Appropriate value of the enum SmfPluginError.
+ * Plugin error if any, else SmfPluginErrNone for success
+ */
+SmfPluginError LastFmPlaylistServicePlugin::playlistsOf(
+ SmfPluginRequestData &aRequest,
+ const SmfContact &aUser,
+ const int aPageNum,
+ const int aItemsPerPage )
+ {
+ qDebug()<<"Inside LastFmPlaylistServicePlugin::playlistsOf()";
+
+ SmfPluginError error = SmfPluginErrInvalidArguments;
+
+ // invalid arguments
+ if( aPageNum < 0 || aItemsPerPage < 0 ||
+ aUser.value("Name").value<QContactName>().firstName().isEmpty() )
+ {
+ qDebug()<<"Invalid arguments";
+ return error;
+ }
+
+ qDebug()<<"Valid arguments";
+
+ gPageNum = aPageNum;
+ gItemsPerPage = aItemsPerPage;
+
+ // Get the key sets from SMF Plugin Utility class.
+ QString apiKey;
+ QString apiSecret;
+ QString token;
+ QString userName;
+ fetchKeys(apiKey, apiSecret, token, userName);
+
+ userName.clear();
+ userName = aUser.value("Name").value<QContactName>().firstName();
+
+ // Create the API signature string
+ QString baseString;
+ baseString.append("api_key"+apiKey);
+ baseString.append("methoduser.getPlaylists");
+ baseString.append("user"+userName);
+ baseString.append(apiSecret);
+
+ // Create the url
+ QUrl url("http://ws.audioscrobbler.com/2.0/?");
+ url.addQueryItem("api_key", apiKey);
+ url.addQueryItem("format", "json");
+ url.addQueryItem("method", "user.getPlaylists");
+ url.addQueryItem("user", userName);
+ url.addQueryItem("api_sig", generateSignature(baseString));
+
+ // Create the request, set the url
+ aRequest.iNetworkRequest.setUrl(url);
+ aRequest.iRequestType = SmfMusicGetPlaylistsOfUser;
+ aRequest.iPostData = NULL;
+ aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation;
+ error = SmfPluginErrNone;
+
+ qDebug()<<"Url string is : "<<aRequest.iNetworkRequest.url().toString();
+ return error;
+ }
+
+/**
+ * Method to add tracks to a playlist
+ * @param aRequest [out] The request data to be sent to network
+ * @param aPlaylist [in] The playlist where tracks should be added
+ * @param aTracks [in] The tracks to be added to the playlist
+ * @return Appropriate value of the enum SmfPluginError.
+ * Plugin error if any, else SmfPluginErrNone for success
+ */
+SmfPluginError LastFmPlaylistServicePlugin::addToPlaylist(
+ SmfPluginRequestData &aRequest,
+ const SmfPlaylist &aPlaylist,
+ const QList<SmfTrackInfo> &aTracks )
+ {
+ qDebug()<<"Inside LastFmPlaylistServicePlugin::addToPlaylist()";
+
+ SmfPluginError error = SmfPluginErrInvalidArguments;
+
+ // invalid arguments
+ if( aPlaylist.id().isEmpty() || (0 == aTracks.count()) )
+ {
+ qDebug()<<"Invalid arguments";
+ return error;
+ }
+ else if(aTracks.at(0).title().isEmpty() || aTracks.at(0).artists().names().at(0).isEmpty())
+ {
+ qDebug()<<"Invalid arguments";
+ return error;
+ }
+ else
+ qDebug()<<"Valid arguments";
+
+
+ // Get the key sets from SMF Plugin Utility class.
+ QString apiKey;
+ QString apiSecret;
+ QString token;
+ QString userName;
+ fetchKeys(apiKey, apiSecret, token, userName);
+
+ // Create the API signature string
+ QString baseString;
+ baseString.append("api_key"+apiKey);
+ baseString.append("artist"+aTracks.at(0).artists().names().at(0));
+ baseString.append("methodplaylist.addTrack");
+ baseString.append("playlistID"+aPlaylist.id());
+ baseString.append("sk"+token);
+ baseString.append("track"+aTracks.at(0).title());
+ baseString.append(apiSecret);
+
+ QUrl postData;
+ postData.addQueryItem("api_key", apiKey);
+ postData.addQueryItem("artist", aTracks.at(0).artists().names().at(0));
+ postData.addQueryItem("format","json");
+ postData.addQueryItem("method", "playlist.addTrack");
+ postData.addQueryItem("playlistID",aPlaylist.id());
+ postData.addQueryItem("sk",token);
+ postData.addQueryItem("track",aTracks.at(0).title());
+ postData.addQueryItem("api_sig", generateSignature(baseString));
+
+ QString data(postData.toString());
+ data.remove(0, 1); // Remove the first ?
+
+ payload.clear();
+ payload.append(data.toAscii());
+
+ qDebug()<<"Data = "<<QString(payload);
+
+ // Create the url
+ QUrl url("http://ws.audioscrobbler.com/2.0/");
+
+ // Create the request, set the url
+ aRequest.iNetworkRequest.setUrl(url);
+ aRequest.iNetworkRequest.setRawHeader("Content-Type", "application/x-www-form-urlencoded");
+ aRequest.iRequestType = SmfMusicAddToPlaylist;
+ aRequest.iPostData = new QBuffer(&payload);
+ aRequest.iHttpOperationType = QNetworkAccessManager::PostOperation;
+ error = SmfPluginErrNone;
+
+ qDebug()<<"Url string is : "<<aRequest.iNetworkRequest.url().toString();
+ return error;
+ }
+
+/**
+ * Method to post the current playing playlist
+ * @param aRequest [out] The request data to be sent to network
+ * @param aPlaylist [in] The current playing playlist which should be posted
+ * @return Appropriate value of the enum SmfPluginError.
+ * Plugin error if any, else SmfPluginErrNone for success
+ */
+SmfPluginError LastFmPlaylistServicePlugin::postCurrentPlayingPlaylist(
+ SmfPluginRequestData &aRequest,
+ const SmfPlaylist &aPlaylist )
+ {
+ qDebug()<<"Inside LastFmPlaylistServicePlugin::postCurrentPlayingPlaylist()";
+
+ SmfPluginError error = SmfPluginErrInvalidArguments;
+
+ // invalid arguments
+/* if( aPlaylist.playListTitle().isEmpty() )
+ {
+ qDebug()<<"Invalid arguments";
+ return error;
+ }*/
+
+ qDebug()<<"Valid arguments";
+
+ // Get the key sets from SMF Plugin Utility class.
+ QString apiKey;
+ QString apiSecret;
+ QString token;
+ QString userName;
+ fetchKeys(apiKey, apiSecret, token, userName);
+
+ // Create the API signature string
+ QString baseString;
+ baseString.append("api_key"+apiKey);
+ baseString.append("methodplaylist.create");
+ baseString.append("sk"+token);
+ if( !aPlaylist.playListTitle().isEmpty()) //you can create a playlist without name also
+ baseString.append("title"+aPlaylist.playListTitle());
+ baseString.append(apiSecret);
+
+ QUrl postData;
+ postData.addQueryItem("api_key", apiKey);
+ postData.addQueryItem("format","json");
+ postData.addQueryItem("method", "playlist.create");
+ postData.addQueryItem("sk",token);
+ if( !aPlaylist.playListTitle().isEmpty())
+ postData.addQueryItem("title",aPlaylist.playListTitle());
+ postData.addQueryItem("api_sig", generateSignature(baseString));
+
+ QString data(postData.toString());
+ data.remove(0, 1);
+
+ payload.clear();
+ payload.append(data.toAscii());
+
+ qDebug()<<"Data = "<<QString(payload);
+
+ // Create the url
+ QUrl url("http://ws.audioscrobbler.com/2.0/");
+
+ // Create the request, set the url
+ aRequest.iNetworkRequest.setUrl(url);
+ aRequest.iNetworkRequest.setRawHeader("Content-Type", "application/x-www-form-urlencoded");
+ aRequest.iRequestType = SmfMusicPostCurrentPlayingPlaylist;
+ aRequest.iPostData = new QBuffer(&payload);
+ aRequest.iHttpOperationType = QNetworkAccessManager::PostOperation;
+ error = SmfPluginErrNone;
+
+ qDebug()<<"Url string is : "<<aRequest.iNetworkRequest.url().toString();
+ return error;
+ }
+
+/**
+ * Customised method for SmfPlaylistServicePlugin interface
+ * @param aRequest [out] The request data to be sent to network
+ * @param aOperation [in] The operation type (should be known between
+ * the client interface and the plugin)
+ * @param aData [in] The data required to form the request (The type
+ * of data should be known between client and the plugin)
+ * @return Appropriate value of the enum SmfPluginError.
+ * Plugin error if any, else SmfPluginErrNone for success
+ */
+SmfPluginError LastFmPlaylistServicePlugin::customRequest( SmfPluginRequestData &aRequest,
+ const int &aOperation, QByteArray *aData )
+ {
+ Q_UNUSED(aRequest)
+ Q_UNUSED(aOperation)
+ Q_UNUSED(aData)
+ qDebug()<<"Inside LastFmPlaylistServicePlugin::customRequest()";
+ SmfPluginError error = SmfPluginErrInvalidRequest;
+ return error;
+ }
+
+/**
+ * The first method to be called in the plugin that implements this interface.
+ * If this method is not called, plugin may not behave as expected.
+ */
+void LastFmPlaylistServicePlugin::initialize( )
+ {
+ // Create an instance of LastFmMusicServiceProviderBase
+ m_provider = new LastFmPlaylistServiceProviderBase;
+ m_provider->initialize();
+ }
+
+/**
+ * Method to get the provider information
+ * @return Instance of SmfProviderBase
+ */
+SmfProviderBase* LastFmPlaylistServicePlugin::getProviderInfo( )
+ {
+ return m_provider;
+ }
+
+/**
+ * Method to get the result for a network request.
+ * @param aOperation The type of operation to be requested
+ * @param aTransportResult The result of transport operation
+ * @param aResponse The QByteArray instance containing the network response.
+ * The plugins should delete this instance once they have read the
+ * data from it.
+ * @param aResult [out] An output parameter to the plugin manager.If the
+ * return value is SmfSendRequestAgain, QVariant will be of type
+ * SmfPluginRequestData.
+ * For SmfMusicServicePlugin: If last operation was userMusicInfo(), aResult
+ * will be of type SmfMusicProfile. If last operation was searchArtist(),
+ * aResult will be of type QList<SmfArtists>. If last operation was searchAlbum(),
+ * aResult will be of type QList<SmfAlbum>. If last operation was searchEvents(),
+ * aResult will be of type QList<SmfEvent>. If last operation was searchVenue(),
+ * aResult will be of type QList<Smfocation>. If last operation was searchUser(),
+ * aResult will be of type QList<SmfMusicProfile>. If last operation was
+ * postCurrentPlaying() or postRating() or postComments(), aResult will be of
+ * type bool.
+ * @param aRetType [out] SmfPluginRetType
+ * @param aPageResult [out] The SmfResultPage structure variable
+ */
+SmfPluginError LastFmPlaylistServicePlugin::responseAvailable(
+ const SmfRequestTypeID aOperation,
+ const SmfTransportResult &aTransportResult,
+ QByteArray *aResponse,
+ QVariant* aResult,
+ SmfPluginRetType &aRetType,
+ SmfResultPage &aPageResult )
+ {
+
+ Q_UNUSED(aPageResult)
+ qDebug()<<"Inside LastFmPlaylistServicePlugin::responseAvailable()";
+
+ SmfPluginError error = SmfPluginErrNetworkError;
+
+ if( !aResponse || (0 == aResponse->size()) )
+ {
+ qDebug()<<"Response is NULL or empty";
+ aRetType = SmfRequestError;
+ return error;
+ }
+
+ QByteArray response(*aResponse);
+ delete aResponse;
+
+ QFile respFile("c://data//SmfMusicPlaylistPluginResponse.txt");
+ if(!respFile.open(QIODevice::WriteOnly))
+ qDebug()<<"File to write the response could not be opened";
+ else
+ {
+ respFile.write(response);
+ respFile.close();
+ qDebug()<<"Writing FB response to a file named 'SmfMusicPlaylistPluginResponse.txt'";
+ }
+ qDebug()<<"FB response size = "<<response.size();
+
+ if(SmfTransportOpNoError == aTransportResult)
+ {
+ qDebug()<<"No transport error";
+
+ // Get user's playlists
+ if(SmfMusicGetPlaylists == aOperation)
+ {
+ qDebug()<<"Response for getting user's playlist";
+ QList<SmfPlaylist> list;
+ QString errStr;
+ errStr.clear();
+
+ bool ok;
+ SmfPluginUtil util;
+ QVariantMap result = util.parse(response, &ok).toMap();
+ if (!ok)
+ {
+ qDebug()<<"An error occurred during json parsing";
+ aRetType = SmfRequestError;
+ return SmfPluginErrParsingFailed;
+ }
+
+ qDebug()<<"Json parsing complete";
+
+ if(response.contains(QByteArray("error")))
+ {
+ errStr.append(result["message"].toString());
+ }
+ else
+ {
+ QVariantMap map1 = result["playlists"].toMap();
+ QList<QVariant> list1 = map1["playlist"].toList();
+ QListIterator<QVariant> iter1(list1);
+ bool ifList = false;
+ while(iter1.hasNext())
+ {
+ ifList = true;
+ QVariantMap map2 = iter1.next().toMap();
+ SmfPlaylist playlist;
+
+ playlist.setPlayListTitle(map2["title"].toString());
+ playlist.setId(map2["id"].toString());
+ playlist.setAuthor(map2["creator"].toString());
+ QUrl url(map2["url"].toString());
+ playlist.setInfo(url);
+ playlist.setLocation(url);
+
+
+ QList<QVariant> list2 = map2["image"].toList();
+ QListIterator<QVariant> iter2(list2);
+ while(iter2.hasNext())
+ {
+ QVariantMap map3 = iter2.next().toMap();
+ QUrl imageUrl(map3["#text"].toString());
+ playlist.setImage(imageUrl);
+ }
+
+ list.append((playlist));
+
+ if(gItemsPerPage == list.count())
+ break;
+ }
+ if(!ifList)
+ {
+ QVariantMap map2 = map1["playlist"].toMap();
+ SmfPlaylist playlist;
+
+ playlist.setPlayListTitle(map2["title"].toString());
+ playlist.setId(map2["id"].toString());
+ playlist.setAuthor(map2["creator"].toString());
+ QUrl url(map2["url"].toString());
+ playlist.setInfo(url);
+ playlist.setLocation(url);
+
+
+ QList<QVariant> list2 = map2["image"].toList();
+ QListIterator<QVariant> iter2(list2);
+ while(iter2.hasNext())
+ {
+ QVariantMap map3 = iter2.next().toMap();
+ QUrl imageUrl(map3["#text"].toString());
+ playlist.setImage(imageUrl);
+ }
+
+ list.append((playlist));
+ }
+
+ if(errStr.size())
+ {
+ qDebug()<<"Response error found = "<<errStr;
+ error = SmfPluginErrInvalidRequest;
+ aRetType = SmfRequestError;
+ aResult->setValue(errStr);
+ }
+ else
+ {
+ qDebug()<<"Count of user's recent tracks = "<<list.count();
+ aResult->setValue(list);
+ aRetType = SmfRequestComplete;
+ error = SmfPluginErrNone;
+ }
+ }
+ }
+
+ // Playlists of another user
+ else if ( SmfMusicGetPlaylistsOfUser == aOperation )
+ {
+ qDebug()<<"Response for getting another user's playlist";
+ QList<SmfPlaylist> list;
+ QString errStr;
+ errStr.clear();
+
+ bool ok;
+ SmfPluginUtil util;
+ QVariantMap result = util.parse(response, &ok).toMap();
+ if (!ok)
+ {
+ qDebug()<<"An error occurred during json parsing";
+ aRetType = SmfRequestError;
+ return SmfPluginErrParsingFailed;
+ }
+
+ qDebug()<<"Json parsing complete";
+
+ if(response.contains(QByteArray("error")))
+ {
+ errStr.append(result["message"].toString());
+ }
+ else
+ {
+ QVariantMap map1 = result["playlists"].toMap();
+ QList<QVariant> list1 = map1["playlist"].toList();
+ QListIterator<QVariant> iter1(list1);
+ bool ifList = false;
+ while(iter1.hasNext())
+ {
+ ifList = true;
+ QVariantMap map2 = iter1.next().toMap();
+ SmfPlaylist playlist;
+
+ playlist.setPlayListTitle(map2["title"].toString());
+ playlist.setId(map2["id"].toString());
+ playlist.setAuthor(map2["creator"].toString());
+ QUrl url(map2["url"].toString());
+ playlist.setInfo(url);
+ playlist.setLocation(url);
+
+
+ QList<QVariant> list2 = map2["image"].toList();
+ QListIterator<QVariant> iter2(list2);
+ while(iter2.hasNext())
+ {
+ QVariantMap map3 = iter2.next().toMap();
+ QUrl imageUrl(map3["#text"].toString());
+ playlist.setImage(imageUrl);
+ }
+
+ list.append((playlist));
+
+ if(gItemsPerPage == list.count())
+ break;
+ }
+ if(!ifList)
+ {
+ QVariantMap map2 = map1["playlist"].toMap();
+ SmfPlaylist playlist;
+
+ playlist.setPlayListTitle(map2["title"].toString());
+ playlist.setId(map2["id"].toString());
+ playlist.setAuthor(map2["creator"].toString());
+ QUrl url(map2["url"].toString());
+ playlist.setInfo(url);
+ playlist.setLocation(url);
+
+
+ QList<QVariant> list2 = map2["image"].toList();
+ QListIterator<QVariant> iter2(list2);
+ while(iter2.hasNext())
+ {
+ QVariantMap map3 = iter2.next().toMap();
+ QUrl imageUrl(map3["#text"].toString());
+ playlist.setImage(imageUrl);
+ }
+
+ list.append((playlist));
+ }
+
+ if(errStr.size())
+ {
+ qDebug()<<"Response error found = "<<errStr;
+ error = SmfPluginErrInvalidRequest;
+ aRetType = SmfRequestError;
+ aResult->setValue(errStr);
+ }
+ else
+ {
+ qDebug()<<"Count of friend's playlists = "<<list.count();
+ aResult->setValue(list);
+ aRetType = SmfRequestComplete;
+ error = SmfPluginErrNone;
+ }
+ }
+ }
+
+ // Adding track to playlist AND
+ // Post current playing playlist
+ else if ((SmfMusicAddToPlaylist == aOperation) || (SmfMusicPostCurrentPlayingPlaylist == aOperation))
+ {
+ qDebug()<<"Response for adding track to playlist";
+ bool reqSuccess = false;
+ QString errStr;
+ errStr.clear();
+
+ bool ok;
+ SmfPluginUtil util;
+ QVariantMap result = util.parse(response, &ok).toMap();
+ if (!ok)
+ {
+ qDebug()<<"An error occurred during json parsing";
+ aRetType = SmfRequestError;
+ return SmfPluginErrParsingFailed;
+ }
+
+ qDebug()<<"Json parsing complete";
+
+ if(response.contains(QByteArray("error")))
+ {
+ errStr.append(result["message"].toString());
+ }
+ else
+ {
+ reqSuccess = true;
+ }
+
+ if(errStr.size())
+ {
+ qDebug()<<"Response error found = "<<errStr;
+ error = SmfPluginErrInvalidRequest;
+ aRetType = SmfRequestError;
+ aResult->setValue(errStr);
+ }
+ else
+ {
+ qDebug()<<"Track added to playlist?? "<<reqSuccess;
+ aResult->setValue(reqSuccess);
+ aRetType = SmfRequestComplete;
+ error = SmfPluginErrNone;
+ }
+ }
+
+ // Other Service requests - NOT SUPPORTED
+ else
+ {
+ qDebug()<<"Service unsupported!!!";
+ aRetType = SmfRequestError;
+ error = SmfPluginErrServiceNotSupported;
+ }
+ }
+
+ else if(SmfTransportOpOperationCanceledError == aTransportResult)
+ {
+ qDebug()<<"Operation Cancelled !!!";
+ error = SmfPluginErrCancelComplete;
+ aRetType = SmfRequestComplete;
+ }
+
+ else
+ {
+ qDebug()<<"Transport Error !!!";
+ error = SmfPluginErrNetworkError;
+ aRetType = SmfRequestError;
+ }
+
+ return error;
+
+ }
+
+
+
+/**
+ * Destructor
+ */
+LastFmPlaylistServiceProviderBase::~LastFmPlaylistServiceProviderBase( )
+ {
+ }
+
+/**
+ * Method to get the Localisable name of the service.
+ * @return The Localisable name of the service.
+ */
+QString LastFmPlaylistServiceProviderBase::serviceName( ) const
+ {
+ return m_serviceName;
+ }
+
+
+/**
+ * Method to get the Logo of the service
+ * @return The Logo of the service
+ */
+QImage LastFmPlaylistServiceProviderBase::serviceIcon( ) const
+ {
+ return m_serviceIcon;
+ }
+
+
+/**
+ * Method to get the Readable service description
+ * @return The Readable service description
+ */
+QString LastFmPlaylistServiceProviderBase::description( ) const
+ {
+ return m_description;
+ }
+
+
+/**
+ * Method to get the Website of the service
+ * @return The Website of the service
+ */
+QUrl LastFmPlaylistServiceProviderBase::serviceUrl( ) const
+ {
+ return m_serviceUrl;
+ }
+
+
+/**
+ * Method to get the URL of the Application providing this service
+ * @return The URL of the Application providing this service
+ */
+QUrl LastFmPlaylistServiceProviderBase::applicationUrl( ) const
+ {
+ return m_applicationUrl;
+ }
+
+
+/**
+ * Method to get the Icon of the application
+ * @return The Icon of the application
+ */
+QImage LastFmPlaylistServiceProviderBase::applicationIcon( ) const
+ {
+ return m_applicationIcon;
+ }
+
+/**
+* Method to get the list of interfaces that this provider support
+* @return List of supported Interafces
+*/
+QList<QString> LastFmPlaylistServiceProviderBase::supportedInterfaces( ) const
+ {
+ return m_supportedInterfaces;
+ }
+
+/**
+* Method to get the list of languages supported by this service provider
+* @return a QStringList of languages supported by this service
+* provider in 2 letter ISO 639-1 format.
+*/
+QStringList LastFmPlaylistServiceProviderBase::supportedLanguages( ) const
+ {
+ return m_supportedLangs;
+ }
+
+/**
+ * Method to get the Plugin specific ID
+ * @return The Plugin specific ID
+ */
+QString LastFmPlaylistServiceProviderBase::pluginId( ) const
+ {
+ return m_pluginId;
+ }
+
+
+/**
+ * Method to get the ID of the authentication application
+ * for this service
+ * @param aProgram The authentication application name
+ * @param aArguments List of arguments required for authentication app
+ * @param aMode Strting mode for authentication application
+ * @return The ID of the authentication application
+ */
+QString LastFmPlaylistServiceProviderBase::authenticationApp( QString &aProgram,
+ QStringList & aArguments,
+ QIODevice::OpenModeFlag aMode ) const
+ {
+ Q_UNUSED(aProgram)
+ Q_UNUSED(aArguments)
+ Q_UNUSED(aMode)
+ return m_authAppId;
+ }
+
+
+/**
+ * Method to get the unique registration ID provided by the
+ * Smf for authorised plugins
+ * @return The unique registration ID/token provided by the Smf for
+ * authorised plugins
+ */
+QString LastFmPlaylistServiceProviderBase::smfRegistrationId( ) const
+ {
+ return m_smfRegToken;
+ }
+
+
+/**
+ * Method that initializes this class. This method should be called
+ * from the initialize() method of the FBContactFetcherPlugin class
+ */
+void LastFmPlaylistServiceProviderBase::initialize()
+ {
+ m_serviceName = "last.fm";
+ m_description = "Last.fm music playlist plugin description";
+ m_serviceUrl = QUrl(QString("http://www.last.fm"));
+ m_pluginId = "lastfmplaylistserviceplugin.qtplugin";
+ m_authAppId = "0x12345678";
+ m_supportedInterfaces.append("org.symbian.smf.plugin.music.playlist/v0.2");
+ QSettings iSettings;
+ m_smfRegToken = iSettings.value("LastFmRegToken").toString();
+ m_validity = iSettings.value("LastFmExpiryTime").toDateTime();
+ }
+
+
+/*
+ * Export Macro
+ * plugin name : lastfmplaylistserviceplugin
+ * plugin class : LastFmPlaylistServicePlugin
+ */
+Q_EXPORT_PLUGIN2( lastfmplaylistserviceplugin, LastFmPlaylistServicePlugin )
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/example/lastfmplaylistserviceplugin/lastfmplaylistserviceplugin.h Thu Sep 23 17:15:03 2010 +0530
@@ -0,0 +1,285 @@
+/**
+ * Copyright (c) 2010 Sasken Communication Technologies Ltd.
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the "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:
+ * Chandradeep Gandhi, Sasken Communication Technologies Ltd - Initial contribution
+ *
+ * Contributors:
+ * Sangeeta Prasad, Nalina Hariharan
+ *
+ * Description:
+ * The Plugin that does music playlist services related
+ * functionalities from last.fm site
+ *
+ */
+
+#ifndef _LASTFMPLAYLISTSERVICEPLUGIN_H_
+#define _LASTFMPLAYLISTSERVICEPLUGIN_H_
+
+//Include files
+#include <smfplaylistserviceplugin.h>
+
+// Forward declarations
+class LastFmPlaylistServiceProviderBase;
+class QVariant;
+
+// Class declaration
+class LastFmPlaylistServicePlugin : public QObject, public SmfPlaylistServicePlugin
+{
+ Q_OBJECT
+ Q_INTERFACES( SmfPlaylistServicePlugin SmfPluginBase )
+
+public:
+ /**
+ * Destructor
+ */
+ virtual ~LastFmPlaylistServicePlugin ( );
+
+public: // From SmfPlaylistServicePlugin
+ /**
+ * Method to get the playlist
+ * @param aRequest [out] The request data to be sent to network
+ * @param aPageNum [in] The page to be extracted
+ * @param aItemsPerPage [in] Number of items per page
+ * @return Appropriate value of the enum SmfPluginError.
+ * Plugin error if any, else SmfPluginErrNone for success
+ */
+ SmfPluginError playlists( SmfPluginRequestData &aRequest,
+ const int aPageNum = SMF_FIRST_PAGE,
+ const int aItemsPerPage = SMF_ITEMS_PER_PAGE );
+
+ /**
+ * Method to get the playlist of a particular user
+ * @param aRequest [out] The request data to be sent to network
+ * @param aUser [in] The user whose playlists need to be fetched
+ * @param aPageNum [in] The page to be extracted
+ * @param aItemsPerPage [in] Number of items per page
+ * @return Appropriate value of the enum SmfPluginError.
+ * Plugin error if any, else SmfPluginErrNone for success
+ */
+ SmfPluginError playlistsOf( SmfPluginRequestData &aRequest,
+ const SmfContact &aUser,
+ const int aPageNum = SMF_FIRST_PAGE,
+ const int aItemsPerPage = SMF_ITEMS_PER_PAGE );
+
+ /**
+ * Method to add tracks to a playlist
+ * @param aRequest [out] The request data to be sent to network
+ * @param aPlaylist [in] The playlist where tracks should be added
+ * @param aTracks [in] The tracks to be added to the playlist
+ * @return Appropriate value of the enum SmfPluginError.
+ * Plugin error if any, else SmfPluginErrNone for success
+ */
+ SmfPluginError addToPlaylist( SmfPluginRequestData &aRequest,
+ const SmfPlaylist &aPlaylist,
+ const QList<SmfTrackInfo> &aTracks );
+
+ /**
+ * Method to post the current playing playlist
+ * @param aRequest [out] The request data to be sent to network
+ * @param aPlaylist [in] The current playing playlist which should be posted
+ * @return Appropriate value of the enum SmfPluginError.
+ * Plugin error if any, else SmfPluginErrNone for success
+ */
+ SmfPluginError postCurrentPlayingPlaylist(
+ SmfPluginRequestData &aRequest,
+ const SmfPlaylist &aPlaylist );
+
+ /**
+ * Customised method for SmfPlaylistServicePlugin interface
+ * @param aRequest [out] The request data to be sent to network
+ * @param aOperation [in] The operation type (should be known between
+ * the client interface and the plugin)
+ * @param aData [in] The data required to form the request (The type
+ * of data should be known between client and the plugin)
+ * @return Appropriate value of the enum SmfPluginError.
+ * Plugin error if any, else SmfPluginErrNone for success
+ */
+ SmfPluginError customRequest( SmfPluginRequestData &aRequest,
+ const int &aOperation, QByteArray *aData );
+
+public: // From SmfPluginBase interface
+ /**
+ * The first method to be called in the plugin that implements this interface.
+ * If this method is not called, plugin may not behave as expected.
+ */
+ void initialize( );
+
+ /**
+ * Method to get the provider information
+ * @return Instance of SmfProviderBase
+ */
+ SmfProviderBase* getProviderInfo( );
+
+ /**
+ * Method to get the result for a network request.
+ * @param aOperation The type of operation to be requested
+ * @param aTransportResult The result of transport operation
+ * @param aResponse The QByteArray instance containing the network response.
+ * The plugins should delete this instance once they have read the
+ * data from it.
+ * @param aResult [out] An output parameter to the plugin manager.If the
+ * return value is SmfSendRequestAgain, QVariant will be of type
+ * SmfPluginRequestData.
+ * For SmfMusicServicePlugin: If last operation was userMusicInfo(), aResult
+ * will be of type SmfMusicProfile. If last operation was searchArtist(),
+ * aResult will be of type QList<SmfArtists>. If last operation was searchAlbum(),
+ * aResult will be of type QList<SmfAlbum>. If last operation was searchEvents(),
+ * aResult will be of type QList<SmfEvent>. If last operation was searchVenue(),
+ * aResult will be of type QList<Smfocation>. If last operation was searchUser(),
+ * aResult will be of type QList<SmfMusicProfile>. If last operation was
+ * postCurrentPlaying() or postRating() or postComments(), aResult will be of
+ * type bool.
+ * @param aRetType [out] SmfPluginRetType
+ * @param aPageResult [out] The SmfResultPage structure variable
+ */
+ SmfPluginError responseAvailable(
+ const SmfRequestTypeID aOperation,
+ const SmfTransportResult &aTransportResult,
+ QByteArray *aResponse,
+ QVariant* aResult,
+ SmfPluginRetType &aRetType,
+ SmfResultPage &aPageResult );
+
+private:
+ /**
+ * Method called by plugins to generate a signature string from a base string
+ * @param aBaseString The base string
+ * @return The md5 hash of the base string
+ */
+ QString generateSignature( const QString aBaseString );
+
+ /**
+ * Method to interpret the key sets obtained from credential manager
+ * @param aApiKey [out] The api key
+ * @param aApiSecret [out] The api secret
+ * @param aSessionKey [out] The session key
+ * @param aToken [out] The session token
+ * @param aName [out] The user name
+ */
+ void fetchKeys( QString &aApiKey,
+ QString &aApiSecret,
+ QString &aToken,
+ QString &aName );
+
+private:
+ LastFmPlaylistServiceProviderBase *m_provider;
+ };
+
+/**
+ * The Plugin class that implements SmfProviderBase for this last.fm plugin
+ */
+class LastFmPlaylistServiceProviderBase : public QObject, public SmfProviderBase
+ {
+ Q_OBJECT
+ Q_INTERFACES( SmfProviderBase )
+
+public:
+ /**
+ * Destructor
+ */
+ virtual ~LastFmPlaylistServiceProviderBase( );
+
+ /**
+ * Method to get the Localisable name of the service.
+ * @return The Localisable name of the service.
+ */
+ QString serviceName( ) const;
+
+ /**
+ * Method to get the Logo of the service
+ * @return The Logo of the service
+ */
+ QImage serviceIcon( ) const;
+
+ /**
+ * Method to get the Readable service description
+ * @return The Readable service description
+ */
+ QString description( ) const;
+
+ /**
+ * Method to get the Website of the service
+ * @return The Website of the service
+ */
+ QUrl serviceUrl( ) const;
+
+ /**
+ * Method to get the URL of the Application providing this service
+ * @return The URL of the Application providing this service
+ */
+ QUrl applicationUrl( ) const;
+
+ /**
+ * Method to get the Icon of the application
+ * @return The Icon of the application
+ */
+ QImage applicationIcon( ) const;
+
+ /**
+ * Method to get the list of interfaces that this provider support
+ * @return List of supported Interafces
+ */
+ QList<QString> supportedInterfaces( ) const;
+
+ /**
+ * Method to get the list of languages supported by this service provider
+ * @return a QStringList of languages supported by this service
+ * provider in 2 letter ISO 639-1 format.
+ */
+ QStringList supportedLanguages( ) const;
+
+ /**
+ * Method to get the Plugin specific ID
+ * @return The Plugin specific ID
+ */
+ QString pluginId( ) const;
+
+ /**
+ * Method to get the ID of the authentication application
+ * for this service
+ * @param aProgram The authentication application name
+ * @param aArguments List of arguments required for authentication app
+ * @param aMode Strting mode for authentication application
+ * @return The ID of the authentication application
+ */
+ QString authenticationApp( QString &aProgram, QStringList & aArguments,
+ QIODevice::OpenModeFlag aMode = QIODevice::ReadWrite ) const;
+
+ /**
+ * Method to get the unique registration ID provided by the
+ * Smf for authorised plugins
+ * @return The unique registration ID/token provided by the Smf for
+ * authorised plugins
+ */
+ QString smfRegistrationId( ) const;
+
+private:
+ /**
+ * Method that initializes this class. This method should be called
+ * from the initialize() method of the LastFmPlaylistServicePlugin class
+ */
+ void initialize();
+
+private:
+ friend class LastFmPlaylistServicePlugin;
+ QString m_serviceName;
+ QImage m_serviceIcon;
+ QString m_description;
+ QUrl m_serviceUrl;
+ QUrl m_applicationUrl;
+ QImage m_applicationIcon;
+ QString m_pluginId;
+ QString m_authAppId;
+ QString m_smfRegToken;
+ QList<QString> m_supportedInterfaces;
+ QStringList m_supportedLangs;
+ QDateTime m_validity;
+ };
+
+#endif /* _LASTFMPLAYLISTSERVICEPLUGIN_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/example/lastfmplaylistserviceplugin/lastfmplaylistserviceplugin.pro Thu Sep 23 17:15:03 2010 +0530
@@ -0,0 +1,43 @@
+TEMPLATE = lib
+
+CONFIG += plugin \
+ mobility
+
+MOBILITY += contacts \
+ location
+
+QT += core \
+ network
+
+HEADERS = lastfmplaylistserviceplugin.h
+
+SOURCES = lastfmplaylistserviceplugin.cpp
+
+TARGET = $$qtLibraryTarget(lastfmplaylistserviceplugin)
+
+symbian: {
+ # Load predefined include paths (e.g. QT_PLUGINS_BASE_DIR) to be used in the pro-files
+ load(data_caging_paths)
+
+ # EPOCALLOWDLLDATA have to set true because Qt macros has initialised global data
+ TARGET.EPOCALLOWDLLDATA = 1
+
+ # Defines plugin files into Symbian .pkg package
+ pluginDep.sources = lastfmplaylistserviceplugin.dll
+ pluginDep.path = $$QT_PLUGINS_BASE_DIR/smf/plugin/music.playlist
+ DEPLOYMENT += pluginDep
+
+ TARGET.CAPABILITY = NetworkServices \
+ ReadUserData \
+ WriteUserData \
+ LocalServices \
+ UserEnvironment \
+ ReadDeviceData \
+ WriteDeviceData
+
+ LIBS += -lsmfcommon
+}
+
+target.path += $$[QT_INSTALL_PLUGINS]/smf/plugin/music.playlist
+
+INSTALLS += target
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/example/lastfmplaylistserviceplugin/plugin_commonU.def Thu Sep 23 17:15:03 2010 +0530
@@ -0,0 +1,16 @@
+; ==============================================================================
+; Generated by qmake (2.01a) (Qt 4.6.2) on: 2010-09-23T11:35:50
+; This file is generated by qmake and should not be modified by the
+; user.
+; Name : plugin_commonU.def
+; Part of : lastfmplaylistserviceplugin
+; Description : Fixes common plugin symbols to known ordinals
+; Version :
+;
+; ==============================================================================
+
+
+EXPORTS
+ qt_plugin_query_verification_data @ 1 NONAME
+ qt_plugin_instance @ 2 NONAME
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/example/lastfmplaylistserviceplugin/qmakepluginstubs/lastfmplaylistserviceplugin.qtplugin Thu Sep 23 17:15:03 2010 +0530
@@ -0,0 +1,1 @@
+This file is a Qt plugin stub file. The real Qt plugin is located in \sys\bin. Created:2010-09-23T11:35:50
--- a/example/smfclientapp/ui_displaywidget.h Thu Sep 16 11:15:30 2010 +0530
+++ b/example/smfclientapp/ui_displaywidget.h Thu Sep 23 17:15:03 2010 +0530
@@ -1,7 +1,7 @@
/********************************************************************************
** Form generated from reading UI file 'displaywidget.ui'
**
-** Created: Fri Jul 30 14:06:51 2010
+** Created: Wed Sep 22 18:28:30 2010
** by: Qt User Interface Compiler version 4.6.2
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
--- a/example/smfclientapp/ui_posttestui.h Thu Sep 16 11:15:30 2010 +0530
+++ b/example/smfclientapp/ui_posttestui.h Thu Sep 23 17:15:03 2010 +0530
@@ -1,7 +1,7 @@
/********************************************************************************
** Form generated from reading UI file 'posttestui.ui'
**
-** Created: Fri Jul 30 14:06:50 2010
+** Created: Wed Sep 22 18:28:30 2010
** by: Qt User Interface Compiler version 4.6.2
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
--- a/example/smfclientapp/ui_smfclientapp.h Thu Sep 16 11:15:30 2010 +0530
+++ b/example/smfclientapp/ui_smfclientapp.h Thu Sep 23 17:15:03 2010 +0530
@@ -1,7 +1,7 @@
/********************************************************************************
** Form generated from reading UI file 'smfclientapp.ui'
**
-** Created: Fri Jul 30 14:06:53 2010
+** Created: Wed Sep 22 18:28:33 2010
** by: Qt User Interface Compiler version 4.6.2
**
** WARNING! All changes made in this file will be lost when recompiling UI file!