smf/smfservermodule/smfclient/client/smfmusic_p.cpp
changeset 14 a469c0e6e7fb
equal deleted inserted replaced
13:b5d63d5fc252 14:a469c0e6e7fb
       
     1 /**
       
     2  * Copyright (c) 2010 Sasken Communication Technologies Ltd.
       
     3  * All rights reserved.
       
     4  * This component and the accompanying materials are made available
       
     5  * under the terms of the "Eclipse Public License v1.0" 
       
     6  * which accompanies  this distribution, and is available
       
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html"
       
     8  *
       
     9  * Initial Contributors:
       
    10  * Chandradeep Gandhi, Sasken Communication Technologies Ltd - Initial contribution
       
    11  *
       
    12  * Contributors:
       
    13  * Manasij Roy, Nalina Hariharan
       
    14  * 
       
    15  * Description:
       
    16  * 
       
    17  */
       
    18 #include "smfmusic_p.h"
       
    19 
       
    20 
       
    21 SmfMusicServicePrivate::SmfMusicServicePrivate(SmfMusicService* aMusicService)
       
    22 :m_musicService(aMusicService)
       
    23 	{
       
    24 	//private impl for symbian
       
    25 	#ifdef Q_OS_SYMBIAN
       
    26 	m_SmfClientPrivate = CSmfClientSymbian::NewL(this);
       
    27 	#else
       
    28 	//TODO:- Use private impl for other platforms or else Qt impl
       
    29 	#endif
       
    30 	}
       
    31 
       
    32 void SmfMusicServicePrivate::searchUser(SmfLocation venue, int pageNum, int perPage)
       
    33 	{
       
    34 	  //We need to pass Opcode and SmfProvider serialized into bytearray 
       
    35 	  m_baseProvider = m_musicService->getProvider();
       
    36 	  QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly);
       
    37 	  write<<*(m_baseProvider);
       
    38 	  m_pageInfoFlag = 1;
       
    39 	  write<<m_pageInfoFlag;
       
    40 	  write<<pageNum;
       
    41 	  write<<perPage;
       
    42 	  m_xtraInfoSerialized.clear();
       
    43 	  QDataStream Xtrawrite(&m_xtraInfoSerialized,QIODevice::WriteOnly);
       
    44 	  //TODO:- provide serialization/deserialization of SmfLocation
       
    45 	  Xtrawrite<<venue;
       
    46 	  m_xtraInfoFlag = m_xtraInfoSerialized.size();
       
    47 	  write<<m_xtraInfoFlag;
       
    48 
       
    49 	  QString intfName(musicServiceInterface);
       
    50 	  int maxalloc = SmfMusicProfileMaxSize*perPage;
       
    51 	  //call private impl's send method
       
    52 	  m_SmfClientPrivate->sendRequest(m_serializedDataToServer,intfName,SmfMusicSearchUser,maxalloc,m_xtraInfoSerialized);
       
    53 	}
       
    54 void SmfMusicServicePrivate::userinfo()
       
    55 	{
       
    56 	  //We need to pass Opcode and SmfProvider serialized into bytearray 
       
    57 	  m_baseProvider = m_musicService->getProvider();
       
    58 	  QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly);
       
    59 	  write<<*(m_baseProvider);
       
    60 	  m_pageInfoFlag = 0;
       
    61 	  m_xtraInfoSerialized.clear();
       
    62 	  m_xtraInfoFlag = 0;
       
    63 	  write<<m_xtraInfoFlag;
       
    64 
       
    65 	  QString intfName(musicServiceInterface);
       
    66 	  int maxalloc = 1000;
       
    67 	  //call private impl's send method
       
    68 	  m_SmfClientPrivate->sendRequest(m_serializedDataToServer,intfName,SmfMusicGetUserInfo,maxalloc,m_xtraInfoSerialized);
       
    69 	}
       
    70 void SmfMusicServicePrivate::resultsAvailable(QByteArray result, SmfRequestTypeID opcode, SmfError error)
       
    71 	{
       
    72 	//note:- "result" is serialized and we need to de-serialize it as per opcode
       
    73 	//Order of serialization Error value followed by data
       
    74 	
       
    75 	QDataStream reader(&result,QIODevice::ReadOnly);
       
    76 	
       
    77 	//Now de-serialize it based on opcode
       
    78 	switch(opcode)
       
    79 		{
       
    80 		case SmfMusicGetUserInfo:
       
    81 				{
       
    82 					if(m_profile)
       
    83 						{
       
    84 						delete m_profile;
       
    85 						m_profile = NULL;
       
    86 						}
       
    87 		
       
    88 					m_profile = new SmfMusicProfile;
       
    89 					//TODO:- serialization/deserialization of SmfMusicProfile
       
    90 					reader>>*(m_profile);
       
    91 					//not incorporating paging now
       
    92 					SmfResultPage page;
       
    93 		
       
    94 					emit m_musicService->userInfoAvailable(m_profile,error);
       
    95 				
       
    96 				}
       
    97 				break;
       
    98 		case SmfMusicSearchUser:
       
    99 				{
       
   100 					m_profileList.clear();
       
   101 					//TODO:- serialization/deserialization of SmfMusicProfile
       
   102 					reader>>m_profileList;
       
   103 					//not incorporating paging now
       
   104 					SmfResultPage page;
       
   105 		
       
   106 					emit m_musicService->searchInfoAvailable(m_profileList,error,page);
       
   107 				
       
   108 				}
       
   109 				break;
       
   110 		}
       
   111 	}
       
   112 
       
   113 SmfMusicServicePrivate::~SmfMusicServicePrivate()
       
   114 	{
       
   115 		if(m_SmfClientPrivate)
       
   116 		{
       
   117 			delete m_SmfClientPrivate;
       
   118 			m_SmfClientPrivate = NULL;
       
   119 		}
       
   120 	}
       
   121 
       
   122 SmfMusicSearchPrivate::SmfMusicSearchPrivate(SmfMusicSearch *aMusicSearch)
       
   123 : m_musicSearch(aMusicSearch)
       
   124 	{
       
   125 		//private impl for symbian
       
   126 		#ifdef Q_OS_SYMBIAN
       
   127 		m_SmfClientPrivate = CSmfClientSymbian::NewL(this);
       
   128 		#else
       
   129 		//TODO:- Use private impl for other platforms or else Qt impl
       
   130 		#endif
       
   131 	}
       
   132 
       
   133 SmfMusicSearchPrivate::~SmfMusicSearchPrivate()
       
   134 	{
       
   135 		if(m_SmfClientPrivate)
       
   136 		{
       
   137 			delete m_SmfClientPrivate;
       
   138 			m_SmfClientPrivate = NULL;
       
   139 		}
       
   140 	}
       
   141 
       
   142 void SmfMusicSearchPrivate::stores(SmfTrackInfo track, int pageNum, int perPage)
       
   143 	{
       
   144 	  //We need to pass Opcode and SmfProvider serialized into bytearray 
       
   145 	  m_baseProvider = m_musicSearch->getProvider();
       
   146 	  QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly);
       
   147 	  write<<*(m_baseProvider);
       
   148 	  m_pageInfoFlag = 1;
       
   149 	  write<<m_pageInfoFlag;
       
   150 	  write<<pageNum;
       
   151 	  write<<perPage;
       
   152 	  m_xtraInfoSerialized.clear();
       
   153 	  QDataStream Xtrawrite(&m_xtraInfoSerialized,QIODevice::WriteOnly);
       
   154 	  //TODO:- provide serialization/deserialization of SmfTrackInfo
       
   155 	  Xtrawrite<<track;
       
   156 	  m_xtraInfoFlag = m_xtraInfoSerialized.size();
       
   157 	  write<<m_xtraInfoFlag;
       
   158 
       
   159 	  QString intfName(musicSearchInterface);
       
   160 	  /** @TODO:-revisit all the maxalloc */
       
   161 	  int maxalloc = 1000;
       
   162 	  //call private impl's send method
       
   163 	  m_SmfClientPrivate->sendRequest(m_serializedDataToServer,intfName,SmfMusicGetStores,maxalloc,m_xtraInfoSerialized);
       
   164 	}
       
   165 void SmfMusicSearchPrivate::recommendations(SmfTrackInfo track, int pageNum, int perPage)
       
   166 	{
       
   167 	  //We need to pass Opcode and SmfProvider serialized into bytearray 
       
   168 	  m_baseProvider = m_musicSearch->getProvider();
       
   169 	  QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly);
       
   170 	  write<<*(m_baseProvider);
       
   171 	  m_pageInfoFlag = 1;
       
   172 	  write<<m_pageInfoFlag;
       
   173 	  write<<pageNum;
       
   174 	  write<<perPage;
       
   175 	  m_xtraInfoSerialized.clear();
       
   176 	  QDataStream Xtrawrite(&m_xtraInfoSerialized,QIODevice::WriteOnly);
       
   177 	  //TODO:- provide serialization/deserialization of SmfTrackInfo
       
   178 	  Xtrawrite<<track;
       
   179 	  m_xtraInfoFlag = m_xtraInfoSerialized.size();
       
   180 	  write<<m_xtraInfoFlag;
       
   181 
       
   182 	  QString intfName(musicSearchInterface);
       
   183 	  //TODO:-revisit all the maxalloc
       
   184 	  int maxalloc = 1000;
       
   185 	  //call private impl's send method
       
   186 	  m_SmfClientPrivate->sendRequest(m_serializedDataToServer,intfName,SmfMusicGetRecommendations,maxalloc,m_xtraInfoSerialized);
       
   187 	}
       
   188 
       
   189 void SmfMusicSearchPrivate::tracks(SmfTrackInfo track, int pageNum, int perPage)
       
   190 	{
       
   191 	  //We need to pass Opcode and SmfProvider serialized into bytearray 
       
   192 	  m_baseProvider = m_musicSearch->getProvider();
       
   193 	  QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly);
       
   194 	  write<<*(m_baseProvider);
       
   195 	  m_pageInfoFlag = 1;
       
   196 	  write<<m_pageInfoFlag;
       
   197 	  write<<pageNum;
       
   198 	  write<<perPage;
       
   199 	  m_xtraInfoSerialized.clear();
       
   200 	  QDataStream Xtrawrite(&m_xtraInfoSerialized,QIODevice::WriteOnly);
       
   201 	  //TODO:- provide serialization/deserialization of SmfTrackInfo
       
   202 	  Xtrawrite<<track;
       
   203 	  m_xtraInfoFlag = m_xtraInfoSerialized.size();
       
   204 	  write<<m_xtraInfoFlag;
       
   205 
       
   206 	  QString intfName(musicSearchInterface);
       
   207 	  //TODO:-revisit all the maxalloc
       
   208 	  int maxalloc = 1000;
       
   209 	  //call private impl's send method
       
   210 	  m_SmfClientPrivate->sendRequest(m_serializedDataToServer,intfName,SmfMusicGetTracks,maxalloc,m_xtraInfoSerialized);
       
   211 	}
       
   212 
       
   213 void SmfMusicSearchPrivate::trackInfo(SmfMusicFingerPrint signature, int pageNum, int perPage)
       
   214 	{
       
   215 	  //We need to pass Opcode and SmfProvider serialized into bytearray 
       
   216 	  m_baseProvider = m_musicSearch->getProvider();
       
   217 	  QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly);
       
   218 	  write<<*(m_baseProvider);
       
   219 	  m_pageInfoFlag = 1;
       
   220 	  write<<m_pageInfoFlag;
       
   221 	  write<<pageNum;
       
   222 	  write<<perPage;
       
   223 	  m_xtraInfoSerialized.clear();
       
   224 	  QDataStream Xtrawrite(&m_xtraInfoSerialized,QIODevice::WriteOnly);
       
   225 	  //TODO:- provide serialization/deserialization of SmfTrackInfo
       
   226 	  Xtrawrite<<signature;
       
   227 	  m_xtraInfoFlag = m_xtraInfoSerialized.size();
       
   228 	  write<<m_xtraInfoFlag;
       
   229 
       
   230 	  QString intfName(musicSearchInterface);
       
   231 	  //TODO:-revisit all the maxalloc
       
   232 	  int maxalloc = 1000;
       
   233 	  //call private impl's send method
       
   234 	  m_SmfClientPrivate->sendRequest(m_serializedDataToServer,intfName,SmfMusicGetTrackInfo,maxalloc,m_xtraInfoSerialized);
       
   235 	}
       
   236 void SmfMusicSearchPrivate::postCurrentPlaying(SmfTrackInfo track) 
       
   237 	{
       
   238 	  //We need to pass Opcode and SmfProvider serialized into bytearray 
       
   239 	  m_baseProvider = m_musicSearch->getProvider();
       
   240 	  QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly);
       
   241 	  write<<*(m_baseProvider);
       
   242 	  m_pageInfoFlag = 0;
       
   243 	  write<<m_pageInfoFlag;
       
   244 
       
   245 	  m_xtraInfoSerialized.clear();
       
   246 	  QDataStream Xtrawrite(&m_xtraInfoSerialized,QIODevice::WriteOnly);
       
   247 	  //TODO:- provide serialization/deserialization of SmfTrackInfo
       
   248 	  Xtrawrite<<track;
       
   249 	  m_xtraInfoFlag = m_xtraInfoSerialized.size();
       
   250 	  write<<m_xtraInfoFlag;
       
   251 
       
   252 	  QString intfName(musicSearchInterface);
       
   253 	  //TODO:-revisit all the maxalloc
       
   254 	  int maxalloc = 1000;
       
   255 	  //call private impl's send method
       
   256 	  m_SmfClientPrivate->sendRequest(m_serializedDataToServer,intfName,SmfMusicPostCurrentPlaying,maxalloc,m_xtraInfoSerialized);
       
   257 	}
       
   258 void SmfMusicSearchPrivate::postRating(SmfTrackInfo track, SmfMusicRating rate) 
       
   259 	{
       
   260 	  //We need to pass Opcode and SmfProvider serialized into bytearray 
       
   261 	  m_baseProvider = m_musicSearch->getProvider();
       
   262 	  QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly);
       
   263 	  write<<*(m_baseProvider);
       
   264 	  m_pageInfoFlag = 0;
       
   265 	  write<<m_pageInfoFlag;
       
   266 
       
   267 	  m_xtraInfoSerialized.clear();
       
   268 	  QDataStream Xtrawrite(&m_xtraInfoSerialized,QIODevice::WriteOnly);
       
   269 	  //TODO:- provide serialization/deserialization of SmfTrackInfo
       
   270 	  Xtrawrite<<track;
       
   271 	  Xtrawrite<<rate;
       
   272 	  m_xtraInfoFlag = m_xtraInfoSerialized.size();
       
   273 	  write<<m_xtraInfoFlag;
       
   274 
       
   275 	  QString intfName(musicSearchInterface);
       
   276 	  //TODO:-revisit all the maxalloc
       
   277 	  int maxalloc = 1000;
       
   278 	  //call private impl's send method
       
   279 	  m_SmfClientPrivate->sendRequest(m_serializedDataToServer,intfName,SmfMusicPostRating,maxalloc,m_xtraInfoSerialized);
       
   280 	}
       
   281 void SmfMusicSearchPrivate::postComments(SmfTrackInfo track, SmfComment comment) 
       
   282 	{
       
   283 	  //We need to pass Opcode and SmfProvider serialized into bytearray 
       
   284 	  m_baseProvider = m_musicSearch->getProvider();
       
   285 	  QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly);
       
   286 	  write<<*(m_baseProvider);
       
   287 	  m_pageInfoFlag = 0;
       
   288 	  write<<m_pageInfoFlag;
       
   289 
       
   290 	  m_xtraInfoSerialized.clear();
       
   291 	  QDataStream Xtrawrite(&m_xtraInfoSerialized,QIODevice::WriteOnly);
       
   292 	  //TODO:- provide serialization/deserialization of SmfTrackInfo
       
   293 	  Xtrawrite<<track;
       
   294 	  Xtrawrite<<comment;
       
   295 	  m_xtraInfoFlag = m_xtraInfoSerialized.size();
       
   296 	  write<<m_xtraInfoFlag;
       
   297 
       
   298 	  QString intfName(musicSearchInterface);
       
   299 	  //TODO:-revisit all the maxalloc
       
   300 	  int maxalloc = 1000;
       
   301 	  //call private impl's send method
       
   302 	  m_SmfClientPrivate->sendRequest(m_serializedDataToServer,intfName,SmfMusicPostComment,maxalloc,m_xtraInfoSerialized);
       
   303 	}
       
   304 void SmfMusicSearchPrivate::resultsAvailable(QByteArray result, SmfRequestTypeID opcode, SmfError error)
       
   305 	{
       
   306 	//note:- "result" is serialized and we need to de-serialize it as per opcode
       
   307 	//Order of serialization Error value followed by data
       
   308 	
       
   309 	QDataStream reader(&result,QIODevice::ReadOnly);
       
   310 	
       
   311 	//Now de-serialize it based on opcode
       
   312 	switch(opcode)
       
   313 		{
       
   314 		case SmfMusicGetStores:
       
   315 				{
       
   316 					if(m_providers)
       
   317 						{
       
   318 						delete m_providers;
       
   319 						m_providers = NULL;
       
   320 						}
       
   321 		
       
   322 					m_providers = new SmfProviderList;
       
   323 					//TODO:- serialization/deserialization of SmfMusicProfile
       
   324 					reader>>*(m_providers);
       
   325 					//not incorporating paging now
       
   326 					SmfResultPage page;
       
   327 		
       
   328 					emit m_musicSearch->storeSearchAvailable(m_providers,error,page);
       
   329 				
       
   330 				}
       
   331 				break;
       
   332 		case SmfMusicGetRecommendations:
       
   333 		case SmfMusicGetTracks:
       
   334 		case SmfMusicGetTrackInfo:
       
   335 				{
       
   336 
       
   337 				if(m_trackInfoList)
       
   338 					{
       
   339 					delete m_trackInfoList;
       
   340 					m_trackInfoList = NULL;
       
   341 					}
       
   342 	
       
   343 				m_trackInfoList = new SmfTrackInfoList;
       
   344 				//TODO:- serialization/deserialization of SmfMusicProfile
       
   345 				reader>>*(m_trackInfoList);
       
   346 				//not incorporating paging now
       
   347 				SmfResultPage page;
       
   348 	
       
   349 				emit m_musicSearch->trackSearchAvailable(m_trackInfoList,error,page);
       
   350 			
       
   351 				//trackSearchAvailable(SmfTrackInfoList* result
       
   352 				}
       
   353 				break;
       
   354 		case SmfMusicPostCurrentPlaying:
       
   355 		case SmfMusicPostRating:
       
   356 		case SmfMusicPostComment:
       
   357 			{
       
   358 			emit m_musicSearch->postfinished(error);
       
   359 			}
       
   360 			break;
       
   361 		}
       
   362 	}
       
   363 
       
   364 SmfPlaylistServicePrivate::SmfPlaylistServicePrivate(SmfPlaylistService *aPlayLstSrvc)
       
   365 : m_playlstSrvc(aPlayLstSrvc)
       
   366 	{
       
   367 	//private impl for symbian
       
   368 	#ifdef Q_OS_SYMBIAN
       
   369 	m_SmfClientPrivate = CSmfClientSymbian::NewL(this);
       
   370 	#else
       
   371 	//TODO:- Use private impl for other platforms or else Qt impl
       
   372 	#endif
       
   373 	}
       
   374 SmfPlaylistServicePrivate::~SmfPlaylistServicePrivate()
       
   375 	{
       
   376 	
       
   377 	}
       
   378 int SmfPlaylistServicePrivate::postCurrentPlayingPlaylist(SmfPlaylist plst)
       
   379 	{
       
   380 	  //We need to pass Opcode and SmfProvider serialized into bytearray 
       
   381 	  m_baseProvider = m_playlstSrvc->getProvider();
       
   382 	  QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly);
       
   383 	  write<<*(m_baseProvider);
       
   384 	  m_pageInfoFlag = 0;
       
   385 	  write<<m_pageInfoFlag;
       
   386 	  m_xtraInfoSerialized.clear();
       
   387 	  QDataStream Xtrawrite(&m_xtraInfoSerialized,QIODevice::WriteOnly);
       
   388 	  //TODO:- provide serialization/deserialization of SmfTrackInfo
       
   389 	  Xtrawrite<<plst;
       
   390 	  m_xtraInfoFlag = m_xtraInfoSerialized.size();
       
   391 	  write<<m_xtraInfoFlag;
       
   392 
       
   393 	  QString intfName(playlistServiceInterface);
       
   394 	  //TODO:-revisit all the maxalloc
       
   395 	  int maxalloc = 1000;
       
   396 	  //call private impl's send method
       
   397 	  m_SmfClientPrivate->sendRequest(m_serializedDataToServer,intfName,SmfMusicPostCurrentPlayingPlaylist,maxalloc,m_xtraInfoSerialized);
       
   398 	}
       
   399 
       
   400 void SmfPlaylistServicePrivate::playlistsOf(SmfMusicProfile *user, int pageNum, int perPage)
       
   401 	{
       
   402 	  //We need to pass Opcode and SmfProvider serialized into bytearray 
       
   403 	  m_baseProvider = m_playlstSrvc->getProvider();
       
   404 	  QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly);
       
   405 	  write<<*(m_baseProvider);
       
   406 	  m_pageInfoFlag = 1;
       
   407 	  write<<m_pageInfoFlag;
       
   408 	  write<<pageNum;
       
   409 	  write<<perPage;
       
   410 	  m_xtraInfoSerialized.clear();
       
   411 	  QDataStream Xtrawrite(&m_xtraInfoSerialized,QIODevice::WriteOnly);
       
   412 	  //TODO:- provide serialization/deserialization of SmfTrackInfo
       
   413 	  Xtrawrite<<*(user);
       
   414 	  m_xtraInfoFlag = m_xtraInfoSerialized.size();
       
   415 	  write<<m_xtraInfoFlag;
       
   416 
       
   417 	  QString intfName(playlistServiceInterface);
       
   418 	  //TODO:-revisit all the maxalloc
       
   419 	  int maxalloc = 1000;
       
   420 	  //call private impl's send method
       
   421 	  m_SmfClientPrivate->sendRequest(m_serializedDataToServer,intfName,SmfMusicGetPlaylistsOfUser,maxalloc,m_xtraInfoSerialized);
       
   422 	}
       
   423 
       
   424 
       
   425 void SmfPlaylistServicePrivate::playlists(int pageNum, int perPage)
       
   426 	{
       
   427 	  //We need to pass Opcode and SmfProvider serialized into bytearray 
       
   428 	  m_baseProvider = m_playlstSrvc->getProvider();
       
   429 	  QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly);
       
   430 	  write<<*(m_baseProvider);
       
   431 	  m_pageInfoFlag = 1;
       
   432 	  write<<m_pageInfoFlag;
       
   433 	  write<<pageNum;
       
   434 	  write<<perPage;
       
   435 	  m_xtraInfoSerialized.clear();
       
   436 	  m_xtraInfoFlag = 0;
       
   437 	  write<<m_xtraInfoFlag;
       
   438 
       
   439 	  QString intfName(playlistServiceInterface);
       
   440 	  //TODO:-revisit all the maxalloc
       
   441 	  int maxalloc = 1000;
       
   442 	  //call private impl's send method
       
   443 	  m_SmfClientPrivate->sendRequest(m_serializedDataToServer,intfName,SmfMusicGetPlaylists,maxalloc);
       
   444 	}
       
   445 
       
   446 
       
   447 
       
   448 int SmfPlaylistServicePrivate::addToPlaylist(SmfPlaylist plst, SmfTrackInfoList *tracks)
       
   449 	{
       
   450 	  //We need to pass Opcode and SmfProvider serialized into bytearray 
       
   451 	  m_baseProvider = m_playlstSrvc->getProvider();
       
   452 	  QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly);
       
   453 	  write<<*(m_baseProvider);
       
   454 	  m_pageInfoFlag = 0;
       
   455 	  write<<m_pageInfoFlag;
       
   456 
       
   457 	  m_xtraInfoSerialized.clear();
       
   458 	  QDataStream Xtrawrite(&m_xtraInfoSerialized,QIODevice::WriteOnly);
       
   459 	  //TODO:- provide serialization/deserialization of SmfTrackInfo
       
   460 	  Xtrawrite<<plst;
       
   461 	  Xtrawrite<<*(tracks);
       
   462 	  m_xtraInfoFlag = m_xtraInfoSerialized.size();
       
   463 	  write<<m_xtraInfoFlag;
       
   464 
       
   465 	  QString intfName(playlistServiceInterface);
       
   466 	  //TODO:-revisit all the maxalloc
       
   467 	  int maxalloc = 1000;
       
   468 	  //call private impl's send method
       
   469 	  m_SmfClientPrivate->sendRequest(m_serializedDataToServer,intfName,SmfMusicAddToPlaylist,maxalloc,m_xtraInfoSerialized);
       
   470 	}
       
   471 void SmfPlaylistServicePrivate::resultsAvailable(QByteArray result, SmfRequestTypeID opcode, SmfError error)
       
   472 	{
       
   473 	//note:- "result" is serialized and we need to de-serialize it as per opcode
       
   474 	//Order of serialization Error value followed by data
       
   475 	
       
   476 	QDataStream reader(&result,QIODevice::ReadOnly);
       
   477 	
       
   478 	//Now de-serialize it based on opcode
       
   479 	switch(opcode)
       
   480 		{
       
   481 		case SmfMusicPostCurrentPlayingPlaylist:
       
   482 		case SmfMusicAddToPlaylist:
       
   483 				{
       
   484 				emit m_playlstSrvc->playlistUpdated(error);				
       
   485 				}
       
   486 				break;
       
   487 		case SmfMusicGetPlaylistsOfUser:
       
   488 		case SmfMusicGetPlaylists:
       
   489 			{
       
   490 			if(m_playlistList)
       
   491 				{
       
   492 				delete m_playlistList;
       
   493 				m_playlistList = NULL;
       
   494 				}
       
   495 
       
   496 			m_playlistList = new SmfPlaylistList;
       
   497 			//TODO:- serialization/deserialization
       
   498 			reader>>*(m_playlistList);
       
   499 			SmfResultPage page;
       
   500 			emit m_playlstSrvc->playlistsListAvailable(m_playlistList,error,page);
       
   501 			}
       
   502 			break;
       
   503 		default:
       
   504 			Q_ASSERT_X(1,"SmfPlaylistServicePrivate::resultsAvailable","default");
       
   505 		}
       
   506 	}
       
   507 
       
   508 SmfMusicEventsPrivate::SmfMusicEventsPrivate(SmfMusicEvents *aMusicEvent)
       
   509 :m_musicEvent(aMusicEvent)
       
   510 	{
       
   511 	//private impl for symbian
       
   512 	#ifdef Q_OS_SYMBIAN
       
   513 	m_SmfClientPrivate = CSmfClientSymbian::NewL(this);
       
   514 	#else
       
   515 	//TODO:- Use private impl for other platforms or else Qt impl
       
   516 	#endif
       
   517 	}
       
   518 
       
   519 SmfMusicEventsPrivate::~SmfMusicEventsPrivate()
       
   520 	{
       
   521 	
       
   522 	}
       
   523 
       
   524 void SmfMusicEventsPrivate::events(SmfLocation venue, int pageNum, int perPage)
       
   525 	{
       
   526 	  //We need to pass Opcode and SmfProvider serialized into bytearray 
       
   527 	  m_baseProvider = m_musicEvent->getProvider();
       
   528 	  QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly);
       
   529 	  write<<*(m_baseProvider);
       
   530 	  m_pageInfoFlag = 1;
       
   531 	  write<<m_pageInfoFlag;
       
   532 	  write<<pageNum;
       
   533 	  write<<perPage;
       
   534 	  m_xtraInfoSerialized.clear();
       
   535 	  QDataStream Xtrawrite(&m_xtraInfoSerialized,QIODevice::WriteOnly);
       
   536 	  //TODO:- provide serialization/deserialization of SmfTrackInfo
       
   537 	  Xtrawrite<<venue;
       
   538 	  m_xtraInfoFlag = m_xtraInfoSerialized.size();
       
   539 	  write<<m_xtraInfoFlag;
       
   540 
       
   541 	  QString intfName(musicEventServiceInterface);
       
   542 	  //TODO:-revisit all the maxalloc
       
   543 	  int maxalloc = 1000;
       
   544 	  //call private impl's send method
       
   545 	  m_SmfClientPrivate->sendRequest(m_serializedDataToServer,intfName,SmfMusicGetEventsOnVenue,maxalloc,m_xtraInfoSerialized);
       
   546 	}
       
   547 
       
   548 void SmfMusicEventsPrivate::events(QContactGeoLocation location, int pageNum, int perPage)
       
   549 {
       
   550 	  //We need to pass Opcode and SmfProvider serialized into bytearray 
       
   551 	  m_baseProvider = m_musicEvent->getProvider();
       
   552 	  QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly);
       
   553 	  write<<*(m_baseProvider);
       
   554 	  m_pageInfoFlag = 1;
       
   555 	  write<<m_pageInfoFlag;
       
   556 	  write<<pageNum;
       
   557 	  write<<perPage;
       
   558 	  m_xtraInfoSerialized.clear();
       
   559 	  QDataStream Xtrawrite(&m_xtraInfoSerialized,QIODevice::WriteOnly);
       
   560 	  //TODO:- provide serialization/deserialization of SmfTrackInfo
       
   561 	  QString latLong;
       
   562 	  latLong += QString::number(location.latitude());
       
   563 	  latLong += ",";
       
   564 	  latLong += QString::number(location.longitude());
       
   565 	  Xtrawrite<<latLong;
       
   566 	  m_xtraInfoFlag = m_xtraInfoSerialized.size();
       
   567 	  write<<m_xtraInfoFlag;
       
   568 
       
   569 	  QString intfName(musicEventServiceInterface);
       
   570 	  //TODO:-revisit all the maxalloc
       
   571 	  int maxalloc = 1000;
       
   572 	  //call private impl's send method
       
   573 	  m_SmfClientPrivate->sendRequest(m_serializedDataToServer,intfName,SmfMusicGetEventsOnLoc,maxalloc,m_xtraInfoSerialized);
       
   574 	}
       
   575 
       
   576 
       
   577 
       
   578 void SmfMusicEventsPrivate::venues(QContactGeoLocation location, int pageNum, int perPage)
       
   579 {
       
   580 	  //We need to pass Opcode and SmfProvider serialized into bytearray 
       
   581 	  m_baseProvider = m_musicEvent->getProvider();
       
   582 	  QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly);
       
   583 	  write<<*(m_baseProvider);
       
   584 	  m_pageInfoFlag = 1;
       
   585 	  write<<m_pageInfoFlag;
       
   586 	  write<<pageNum;
       
   587 	  write<<perPage;
       
   588 	  m_xtraInfoSerialized.clear();
       
   589 	  QDataStream Xtrawrite(&m_xtraInfoSerialized,QIODevice::WriteOnly);
       
   590 	  //TODO:- provide serialization/deserialization of SmfTrackInfo
       
   591 	  QString latLong;
       
   592 	  latLong += QString::number(location.latitude());
       
   593 	  latLong += ",";
       
   594 	  latLong += QString::number(location.longitude());
       
   595 	  Xtrawrite<<latLong;
       
   596 	  m_xtraInfoFlag = m_xtraInfoSerialized.size();
       
   597 	  write<<m_xtraInfoFlag;
       
   598 
       
   599 	  QString intfName(musicEventServiceInterface);
       
   600 	  //TODO:-revisit all the maxalloc
       
   601 	  int maxalloc = 1000;
       
   602 	  //call private impl's send method
       
   603 	  m_SmfClientPrivate->sendRequest(m_serializedDataToServer,intfName,SmfMusicGetVenueOnLoc,maxalloc,m_xtraInfoSerialized);
       
   604 	}
       
   605 
       
   606 void SmfMusicEventsPrivate::postEvents(SmfEventList events)
       
   607 {
       
   608 	  //We need to pass Opcode and SmfProvider serialized into bytearray 
       
   609 	  m_baseProvider = m_musicEvent->getProvider();
       
   610 	  QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly);
       
   611 	  write<<*(m_baseProvider);
       
   612 	  m_pageInfoFlag = 0;
       
   613 	  write<<m_pageInfoFlag;
       
   614 
       
   615 	  m_xtraInfoSerialized.clear();
       
   616 	  QDataStream Xtrawrite(&m_xtraInfoSerialized,QIODevice::WriteOnly);
       
   617 	  //TODO:- provide serialization/deserialization of SmfTrackInfo
       
   618 	  Xtrawrite<<events;
       
   619 	  m_xtraInfoFlag = m_xtraInfoSerialized.size();
       
   620 	  write<<m_xtraInfoFlag;
       
   621 
       
   622 	  QString intfName(musicEventServiceInterface);
       
   623 	  //TODO:-revisit all the maxalloc
       
   624 	  int maxalloc = 1000;
       
   625 	  //call private impl's send method
       
   626 	  m_SmfClientPrivate->sendRequest(m_serializedDataToServer,intfName,SmfMusicPostEvents,maxalloc,m_xtraInfoSerialized);
       
   627 	}
       
   628 void SmfMusicEventsPrivate::resultsAvailable(QByteArray result,SmfRequestTypeID opcode,SmfError error)
       
   629 	{
       
   630 	//note:- "result" is serialized and we need to de-serialize it as per opcode
       
   631 	//Order of serialization Error value followed by data
       
   632 	
       
   633 	QDataStream reader(&result,QIODevice::ReadOnly);
       
   634 	
       
   635 	//Now de-serialize it based on opcode
       
   636 	switch(opcode)
       
   637 		{
       
   638 		case SmfMusicGetEventsOnVenue:
       
   639 			{
       
   640 			if(m_events)
       
   641 				{
       
   642 				delete m_events;
       
   643 				m_events = NULL;
       
   644 				}
       
   645 			m_events = new SmfEventList;
       
   646 			reader>>*(m_events);
       
   647 			SmfResultPage page;
       
   648 			m_musicEvent->eventsAvailable(m_events,error,page);
       
   649 			}
       
   650 			break;
       
   651 		case SmfMusicGetVenueOnLoc:
       
   652 			{
       
   653 			if(m_venues)
       
   654 				{
       
   655 				delete m_venues;
       
   656 				m_venues = NULL;
       
   657 				}
       
   658 			m_venues = new SmfLocationList;
       
   659 			reader>>*(m_venues);
       
   660 			SmfResultPage page;
       
   661 			m_musicEvent->venuesAvailable(m_venues,error,page);
       
   662 			}
       
   663 			break;
       
   664 		case SmfMusicPostEvents:
       
   665 			{
       
   666 			m_musicEvent->eventsUpdated(error);
       
   667 			}
       
   668 			break;
       
   669 		case SmfMusicGetEventsOnLoc:
       
   670 			{
       
   671 			if(m_venues)
       
   672 				{
       
   673 				delete m_venues;
       
   674 				m_venues = NULL;
       
   675 				}
       
   676 			m_venues = new SmfLocationList;
       
   677 			reader>>*(m_venues);
       
   678 			SmfResultPage page;
       
   679 			m_musicEvent->venuesAvailable(m_venues,error,page);
       
   680 			}
       
   681 			break;
       
   682 		default:
       
   683 			Q_ASSERT_X(1,"SmfMusicEventsPrivate::resultsAvailable","default");
       
   684 		}
       
   685 	}
       
   686 SmfLyricsServicePrivate::SmfLyricsServicePrivate(SmfLyricsService *aLyricsSrvc)
       
   687 : m_lyricsSrvc(aLyricsSrvc)
       
   688 {
       
   689 	//private impl for symbian
       
   690 	#ifdef Q_OS_SYMBIAN
       
   691 	m_SmfClientPrivate = CSmfClientSymbian::NewL(this);
       
   692 	#else
       
   693 	//TODO:- Use private impl for other platforms or else Qt impl
       
   694 	#endif
       
   695 }
       
   696 
       
   697 SmfLyricsServicePrivate::~SmfLyricsServicePrivate()
       
   698 	{
       
   699 	
       
   700 	}
       
   701 
       
   702 
       
   703 
       
   704 void SmfLyricsServicePrivate::subtitles(SmfTrackInfo track, SmfSubtitleSearchFilter filter, int pageNum, int perPage)
       
   705 {
       
   706 	  //We need to pass Opcode and SmfProvider serialized into bytearray 
       
   707 	  m_baseProvider = m_lyricsSrvc->getProvider();
       
   708 	  QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly);
       
   709 	  write<<*(m_baseProvider);
       
   710 	  m_pageInfoFlag = 1;
       
   711 	  write<<m_pageInfoFlag;
       
   712 	  write<<pageNum;
       
   713 	  write<<perPage;
       
   714 	  m_xtraInfoSerialized.clear();
       
   715 	  QDataStream Xtrawrite(&m_xtraInfoSerialized,QIODevice::WriteOnly);
       
   716 	  //TODO:- provide serialization/deserialization of SmfTrackInfo
       
   717 	  Xtrawrite<<track;
       
   718 	  Xtrawrite<<filter;
       
   719 	  m_xtraInfoFlag = m_xtraInfoSerialized.size();
       
   720 	  write<<m_xtraInfoFlag;
       
   721 
       
   722 	  QString intfName(lyricsServiceInterface);
       
   723 	  //TODO:-revisit all the maxalloc
       
   724 	  int maxalloc = 1000;
       
   725 	  //call private impl's send method
       
   726 	  m_SmfClientPrivate->sendRequest(m_serializedDataToServer,intfName,SmfMusicGetSubtitle,maxalloc,m_xtraInfoSerialized);
       
   727 	}
       
   728 
       
   729 void SmfLyricsServicePrivate::lyrics(SmfTrackInfo track, int pageNum, int perPage)
       
   730 {
       
   731 	  //We need to pass Opcode and SmfProvider serialized into bytearray 
       
   732 	  m_baseProvider = m_lyricsSrvc->getProvider();
       
   733 	  QDataStream write(&m_serializedDataToServer,QIODevice::WriteOnly);
       
   734 	  write<<*(m_baseProvider);
       
   735 	  m_pageInfoFlag = 1;
       
   736 	  write<<m_pageInfoFlag;
       
   737 	  write<<pageNum;
       
   738 	  write<<perPage;
       
   739 	  m_xtraInfoSerialized.clear();
       
   740 	  QDataStream Xtrawrite(&m_xtraInfoSerialized,QIODevice::WriteOnly);
       
   741 	  //TODO:- provide serialization/deserialization of SmfTrackInfo
       
   742 	  Xtrawrite<<track;
       
   743 	  m_xtraInfoFlag = m_xtraInfoSerialized.size();
       
   744 	  write<<m_xtraInfoFlag;
       
   745 
       
   746 	  QString intfName(lyricsServiceInterface);
       
   747 	  //TODO:-revisit all the maxalloc
       
   748 	  int maxalloc = 1000;
       
   749 	  //call private impl's send method
       
   750 	  m_SmfClientPrivate->sendRequest(m_serializedDataToServer,intfName,SmfMusicGetLyrics,maxalloc,m_xtraInfoSerialized);
       
   751 	}
       
   752 void SmfLyricsServicePrivate::resultsAvailable(QByteArray result, SmfRequestTypeID opcode, SmfError error)
       
   753 	{
       
   754 	//note:- "result" is serialized and we need to de-serialize it as per opcode
       
   755 
       
   756 	QDataStream reader(&result,QIODevice::ReadOnly);
       
   757 	
       
   758 	//Now de-serialize it based on opcode
       
   759 	switch(opcode)
       
   760 		{
       
   761 		case SmfMusicGetLyrics:
       
   762 			{
       
   763 			if(m_lyricsList)
       
   764 				{
       
   765 				delete m_lyricsList;
       
   766 				m_lyricsList = NULL;
       
   767 				}
       
   768 			m_lyricsList = new SmfLyricsList;
       
   769 			reader>>*(m_lyricsList);
       
   770 			SmfResultPage page;
       
   771 			emit m_lyricsSrvc->lyricsAvailable(m_lyricsList,error,page);
       
   772 			}
       
   773 			break;
       
   774 		case SmfMusicGetSubtitle:
       
   775 			{
       
   776 			if(m_subList)
       
   777 				{
       
   778 				delete m_subList;
       
   779 				m_subList = NULL;
       
   780 				}
       
   781 			m_subList = new SmfSubtitleList;
       
   782 			reader>>*(m_subList);
       
   783 			SmfResultPage page;
       
   784 			emit m_lyricsSrvc->subtitleAvailable(m_subList,error,page);
       
   785 			}
       
   786 			break;
       
   787 		default:
       
   788 			Q_ASSERT_X(1,"SmfLyricsServicePrivate::resultsAvailable","default");
       
   789 		}
       
   790 	}
       
   791