installationservices/swcomponentregistry/source/client/scrclientsubsessions.cpp
branchRCL_3
changeset 26 8b7f4e561641
parent 25 7333d7932ef7
child 27 e8965914fac7
equal deleted inserted replaced
25:7333d7932ef7 26:8b7f4e561641
     1 /*
       
     2 * Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "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 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 * Implementation for the subsessions of RSoftwareComponentRegistry. 
       
    16 * See class and function declarations for more detail.
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 #include "scr.h"
       
    22 #include "scrclient.inl"
       
    23 #include "scrcommon.h"
       
    24 #include "usiflog.h"
       
    25 #include <scs/streamingarray.h>
       
    26 
       
    27 using namespace Usif;
       
    28 
       
    29 //
       
    30 // RSoftwareComponentRegistryView
       
    31 //
       
    32 
       
    33 TInt RSoftwareComponentRegistryView::SendSyncMessage(TInt aFunction, const TIpcArgs& aArgs) const
       
    34 	{
       
    35 	return CallSubsessionFunction(aFunction, aArgs);
       
    36 	}
       
    37 
       
    38 EXPORT_C RSoftwareComponentRegistryView::RSoftwareComponentRegistryView()
       
    39 /**
       
    40 	This constructor provides a single point of definition from
       
    41 	which the superclass constructor is called.
       
    42  */
       
    43 	: RScsClientSubsessionBase()
       
    44 	{
       
    45 	// empty
       
    46 	}
       
    47 
       
    48 EXPORT_C void RSoftwareComponentRegistryView::Close()
       
    49 	{
       
    50 	RScsClientSubsessionBase::Close();
       
    51 	}
       
    52 
       
    53 EXPORT_C void RSoftwareComponentRegistryView::OpenViewL(const RSoftwareComponentRegistry& aCompReg, CComponentFilter* aFilter)
       
    54 	{
       
    55 	DEBUG_PRINTF(_L("Creating a subsession to the SCR server for the components view."));
       
    56 	
       
    57 	Close(); //Close the SubSession before Re-Opening the same.
       
    58 	TInt err = CreateSubsession(aCompReg, ESubSessCreateComponentsView, TIpcArgs());
       
    59 	if(KErrNone != err)
       
    60 		{
       
    61 		DEBUG_PRINTF2(_L("Failed to create the subsession to the SCR server for the components view (Error:%d)"), err);
       
    62 		User::Leave(err);
       
    63 		}
       
    64 	
       
    65 	RBuf8 buf;
       
    66 	buf.CleanupClosePushL();
       
    67 	ExternalizeObjectL(aFilter, buf);
       
    68 	
       
    69 	DEBUG_PRINTF(_L("Sending the request to create a component view on the server side."));
       
    70 	TIpcArgs args(&buf);
       
    71 	User::LeaveIfError(CallSubsessionFunction(EOpenComponentsView, args));
       
    72 	CleanupStack::PopAndDestroy(&buf);
       
    73 	}
       
    74 
       
    75 EXPORT_C CComponentEntry* RSoftwareComponentRegistryView::NextComponentL(TLanguage aLocale) const
       
    76 	{
       
    77 	CComponentEntry* entry = CComponentEntry::NewLC();
       
    78 	if(!NextComponentL(*entry, aLocale))
       
    79 		{
       
    80 		CleanupStack::PopAndDestroy(entry);
       
    81 		return NULL;
       
    82 		}
       
    83 	CleanupStack::Pop(entry);
       
    84 	return entry;
       
    85 	}
       
    86 
       
    87 EXPORT_C TBool RSoftwareComponentRegistryView::NextComponentL(CComponentEntry& aEntry, TLanguage aLocale) const
       
    88 	{
       
    89 	DEBUG_PRINTF(_L("Sending the request to retrieve the next component from the component view."));
       
    90     //To avoid call to NextComponentL before calling OpenViewL 
       
    91 	CheckSubSessionHandleL();
       
    92     
       
    93 	TIpcArgs args(aLocale);
       
    94 	TInt argNum = 1;
       
    95 	return GetObjectL(*this, aEntry, EGetNextComponentSize, EGetNextComponentData, argNum, args);
       
    96 	}
       
    97 
       
    98 EXPORT_C void RSoftwareComponentRegistryView::NextComponentSetL(TInt aMaxCount, RPointerArray<CComponentEntry>& aComponentList, TLanguage aLocale) const
       
    99 	{
       
   100 	DEBUG_PRINTF(_L("Sending the request to retrieve the next set of components from the component view."));
       
   101     //To avoid call to NextComponentSetL before calling OpenViewL 
       
   102 	CheckSubSessionHandleL();
       
   103     
       
   104 	TIpcArgs args(aMaxCount, aLocale);
       
   105 	TInt argNum = 2;
       
   106 	GetObjectArrayL(*this, EGetNextComponentSetSize, EGetNextComponentSetData, argNum, args, aComponentList);
       
   107 	}
       
   108 
       
   109 void RSoftwareComponentRegistryView::CheckSubSessionHandleL() const
       
   110     {
       
   111     if(KNullHandle == SubSessionHandle())
       
   112         {
       
   113         DEBUG_PRINTF(_L("An invalid handle has been passed."));
       
   114         User::Leave(KErrBadHandle);
       
   115         }
       
   116     }
       
   117 
       
   118 //
       
   119 // RSoftwareComponentRegistryFilesList
       
   120 //
       
   121 
       
   122 TInt RSoftwareComponentRegistryFilesList::SendSyncMessage(TInt aFunction, const TIpcArgs& aArgs) const
       
   123 	{
       
   124 	return CallSubsessionFunction(aFunction, aArgs);
       
   125 	}
       
   126 
       
   127 EXPORT_C RSoftwareComponentRegistryFilesList::RSoftwareComponentRegistryFilesList()
       
   128 /**
       
   129 	This constructor provides a single point of definition from
       
   130 	which the superclass constructor is called.
       
   131  */
       
   132 	: RScsClientSubsessionBase()
       
   133 	{
       
   134 	// empty
       
   135 	}
       
   136 
       
   137 EXPORT_C void RSoftwareComponentRegistryFilesList::OpenListL(const RSoftwareComponentRegistry& aCompReg, TComponentId aComponentId)
       
   138 	{
       
   139 	DEBUG_PRINTF(_L("Creating a subsession to the SCR server for the file list."));
       
   140 	
       
   141 	Close(); //Close the SubSession before Re-Opening the same.
       
   142 	TInt err = CreateSubsession(aCompReg, ESubSessCreateFileList, TIpcArgs());
       
   143 	if(KErrNone != err)
       
   144 		{
       
   145 		DEBUG_PRINTF2(_L("Failed to create the subsession to the SCR server for the file list (Error:%d)."), err);
       
   146 		User::Leave(err);
       
   147 		}
       
   148 	
       
   149 	DEBUG_PRINTF(_L("Sending a request to create a file list on the server side."));
       
   150 	TIpcArgs args(aComponentId);
       
   151 	User::LeaveIfError(CallSubsessionFunction(EOpenFileList, args));
       
   152 	}
       
   153 
       
   154 EXPORT_C HBufC* RSoftwareComponentRegistryFilesList::NextFileL() const
       
   155 	{
       
   156     //To avoid call to NextFileL before calling OpenListL 
       
   157     CheckSubSessionHandleL();
       
   158     
       
   159 	TIpcArgs args(TIpcArgs::ENothing);
       
   160 	TInt argNum = 0;
       
   161 	return GetObjectL<HBufC>(*this, EGetNextFileSize, EGetNextFileData, argNum, args);
       
   162 	}
       
   163 
       
   164 EXPORT_C void RSoftwareComponentRegistryFilesList::NextFileSetL(TInt aMaxCount, RPointerArray<HBufC>& aFileList) const
       
   165 	{
       
   166 	DEBUG_PRINTF(_L("Sending the request to retrieve the next set of components from the component view."));
       
   167     //To avoid call to NextFileSetL before calling OpenListL 
       
   168 	CheckSubSessionHandleL();
       
   169     
       
   170 	TIpcArgs args(aMaxCount);
       
   171 	TInt argNum = 1;
       
   172 	GetObjectArrayL(*this, EGetNextFileSetSize, EGetNextFileSetData, argNum, args, aFileList);
       
   173 	}
       
   174 
       
   175 EXPORT_C void RSoftwareComponentRegistryFilesList::Close()
       
   176 	{
       
   177 	RScsClientSubsessionBase::Close();
       
   178 	}
       
   179 
       
   180 void RSoftwareComponentRegistryFilesList::CheckSubSessionHandleL() const
       
   181     {
       
   182     if(KNullHandle == SubSessionHandle())
       
   183         {
       
   184         DEBUG_PRINTF(_L("An invalid handle has been passed."));
       
   185         User::Leave(KErrBadHandle);
       
   186         }
       
   187     }
       
   188 
       
   189 //
       
   190 // RApplicationInfoView
       
   191 //
       
   192 
       
   193 TInt RApplicationInfoView::SendSyncMessage(TInt aFunction, const TIpcArgs& aArgs) const
       
   194     {
       
   195     return CallSubsessionFunction(aFunction, aArgs);
       
   196     }
       
   197 
       
   198 EXPORT_C RApplicationInfoView::RApplicationInfoView()
       
   199 /**
       
   200     This constructor provides a single point of definition from
       
   201     which the superclass constructor is called.
       
   202  */
       
   203     : RScsClientSubsessionBase()
       
   204     {
       
   205     }
       
   206 
       
   207 EXPORT_C void RApplicationInfoView::Close()
       
   208     {
       
   209     RScsClientSubsessionBase::Close();
       
   210     }
       
   211 
       
   212 EXPORT_C void RApplicationInfoView::OpenViewL(const RSoftwareComponentRegistry& aCompReg, CAppInfoFilter* aAppInfoFilter,TLanguage aLocale)
       
   213     {
       
   214 
       
   215     DEBUG_PRINTF(_L("Creating a subsession to the SCR server for the AppInfo view."));
       
   216     
       
   217     Close(); //Close the SubSession before Re-Opening the same.
       
   218     TInt err = CreateSubsession(aCompReg, ESubSessCreateAppInfoView, TIpcArgs());
       
   219     if(KErrNone != err)
       
   220         {
       
   221         DEBUG_PRINTF2(_L("Failed to create the subsession to the SCR server for the appinfo view (Error:%d)"), err);
       
   222         User::Leave(err);
       
   223         }
       
   224     
       
   225     RBuf8 buf;
       
   226     buf.CleanupClosePushL();
       
   227     ExternalizeObjectL(aAppInfoFilter, buf);
       
   228     
       
   229     DEBUG_PRINTF(_L("Sending the request to create a component view on the server side."));
       
   230     TIpcArgs args(&buf, aLocale);
       
   231     User::LeaveIfError(CallSubsessionFunction(EOpenAppInfoView, args));
       
   232     CleanupStack::PopAndDestroy(&buf);
       
   233     }
       
   234 
       
   235 
       
   236 EXPORT_C void  RApplicationInfoView::GetNextAppInfoL(TInt aNoOfEntries, RPointerArray<TAppRegInfo>& aAppInfoList) const
       
   237     {
       
   238     if(0 >= aNoOfEntries)
       
   239          {
       
   240          DEBUG_PRINTF(_L("No of Required AppInfo entries passed should be greater than 0"));
       
   241          User::Leave(KErrArgument);
       
   242          }
       
   243 
       
   244     //To avoid call to GetNextAppInfoL before calling OpenAppInfoViewL 
       
   245     if(KNullHandle == SubSessionHandle())
       
   246         {
       
   247         DEBUG_PRINTF(_L("An invalid handle has been passed."));
       
   248         User::Leave(KErrBadHandle);
       
   249         }
       
   250     
       
   251     TAppRegInfo* appInfo = NULL;         
       
   252     TBool isAppInfoPresent = EFalse;
       
   253     for(TInt i=0; i < aNoOfEntries ; ++i)
       
   254        {
       
   255        appInfo = new(ELeave) TAppRegInfo();
       
   256        DEBUG_PRINTF(_L("Sending the request to retrieve the next Application Info from the AppInfo view."));
       
   257        TIpcArgs args(TIpcArgs::ENothing);
       
   258        TInt argNum = 1;
       
   259             
       
   260        TRAPD(err,isAppInfoPresent = GetObjectL(*this, *appInfo, EGetNextAppInfoSize, EGetNextAppInfoData, argNum, args));
       
   261        if(KErrNone != err)
       
   262            {
       
   263            delete appInfo;
       
   264            User::Leave(err);
       
   265            }
       
   266                         
       
   267        if(!isAppInfoPresent)
       
   268          {
       
   269          DEBUG_PRINTF(_L8("Reached the end of the view."));     
       
   270          delete appInfo;
       
   271          break;
       
   272          }
       
   273        else
       
   274          {
       
   275          DEBUG_PRINTF2(_L("The Uid of the App received from the SCR server is 0x%x "), appInfo->Uid());
       
   276          DEBUG_PRINTF2(_L("The App filename of the App received from the SCR server is %s "), appInfo->FullName().PtrZ());
       
   277          DEBUG_PRINTF2(_L("The Short caption of the received from the SCR server App is %s "), appInfo->ShortCaption().PtrZ());
       
   278          DEBUG_PRINTF2(_L("The Caption of the App received from the SCR server is %s "), appInfo->Caption().PtrZ());
       
   279          aAppInfoList.AppendL(appInfo);
       
   280          }            
       
   281        }
       
   282     }
       
   283 
       
   284 //
       
   285 // RRegistrationInfoForApplication
       
   286 
       
   287 TInt RRegistrationInfoForApplication::SendSyncMessage(TInt aFunction, const TIpcArgs& aArgs) const
       
   288 	{
       
   289 	return CallSubsessionFunction(aFunction, aArgs);
       
   290 	}
       
   291 
       
   292 EXPORT_C RRegistrationInfoForApplication::RRegistrationInfoForApplication()	: RScsClientSubsessionBase()
       
   293 	{
       
   294 	// empty
       
   295 	}
       
   296 
       
   297 EXPORT_C void RRegistrationInfoForApplication::OpenL(const RSoftwareComponentRegistry& aCompReg,const TUid aAppUid,TLanguage aLocale)
       
   298 	{
       
   299 	DEBUG_PRINTF(_L("Creating a subsession to the SCR server for the App list based on AppId."));
       
   300 	
       
   301 	Close(); //Close the SubSession before Re-Opening the same.
       
   302 	TInt err = CreateSubsession(aCompReg, ESubSessCreateRegInfoForApp, TIpcArgs());
       
   303 	if(KErrNone != err)
       
   304 		{
       
   305 		DEBUG_PRINTF2(_L("Failed to create the subsession to the SCR server (Error:%d)."), err);
       
   306 		User::Leave(err);
       
   307 		}
       
   308 	
       
   309 	DEBUG_PRINTF(_L("Sending a request to set the AppId on the server side."));
       
   310 	TIpcArgs args(aAppUid.iUid,aLocale);
       
   311 	User::LeaveIfError(CallSubsessionFunction(ESetAppUid, args));
       
   312 	}
       
   313 
       
   314 EXPORT_C  void RRegistrationInfoForApplication::GetAppServicesUidsL(RArray<TUid>& aServiceUids) const
       
   315 	{
       
   316 	DEBUG_PRINTF(_L("Getting the Service UID array for the subsession appUid"));
       
   317     //To avoid call to GetAppServicesUidsL before calling OpenL 
       
   318 	CheckSubSessionHandleL();
       
   319     
       
   320 	TIpcArgs args(TIpcArgs::ENothing);
       
   321 	TInt argNum = 1;
       
   322 	
       
   323 	GetObjectArrayL(*this, EGetServiceUidSize,EGetServiceUidList,argNum, args, aServiceUids);	
       
   324 	}
       
   325 
       
   326 EXPORT_C  TLanguage RRegistrationInfoForApplication::ApplicationLanguageL() const
       
   327 	{
       
   328 	DEBUG_PRINTF(_L("Getting the Locale of the specified App that best fits the current device language"));
       
   329     //To avoid call to GetApplicationLanguageL before calling OpenL 
       
   330 	CheckSubSessionHandleL();
       
   331     
       
   332 	TLanguage aLanguage = ELangNone;
       
   333 	TPckg<TLanguage> applicationLanguage(aLanguage);
       
   334 	    
       
   335 	TIpcArgs args(&applicationLanguage);
       
   336 	
       
   337 	User::LeaveIfError(CallSubsessionFunction(EGetApplicationLanguage, args));
       
   338 	return(aLanguage);
       
   339 	}
       
   340 
       
   341 EXPORT_C  TInt RRegistrationInfoForApplication::DefaultScreenNumberL() const
       
   342 	{
       
   343 	DEBUG_PRINTF(_L("Getting the Default screen number from the App reg info"));
       
   344     //To avoid call to GetDefaultScreenNumberL before calling OpenL 
       
   345 	CheckSubSessionHandleL();
       
   346     
       
   347 	TInt aDefaultScreenNumber = 0;
       
   348 	TPckg<TInt> uidDes(aDefaultScreenNumber);
       
   349 	
       
   350 	TIpcArgs args(&uidDes);
       
   351 	User::LeaveIfError(CallSubsessionFunction(EGetDefaultScreenNumber, args));	
       
   352 	return(aDefaultScreenNumber);
       
   353 	}
       
   354 
       
   355 EXPORT_C  TInt RRegistrationInfoForApplication::NumberOfOwnDefinedIconsL() const
       
   356 	{
       
   357 	DEBUG_PRINTF(_L("Getting the number of defined icons for the associated application and locale "));
       
   358     //To avoid call to GetNumberOfOwnDefinedIconsL before calling OpenL 
       
   359 	CheckSubSessionHandleL();
       
   360     
       
   361 	TInt aCount = 0;
       
   362 	TPckg<TInt> uidDes(aCount);
       
   363 	TIpcArgs args(&uidDes);
       
   364 	
       
   365 	User::LeaveIfError(CallSubsessionFunction(EGetNumberOfOwnDefinedIcons, args));
       
   366 	return(aCount);
       
   367 	}
       
   368 
       
   369 EXPORT_C void RRegistrationInfoForApplication::GetAppViewsL(RPointerArray<Usif::CAppViewData>& aAppViewInfoArray) const
       
   370     {
       
   371         DEBUG_PRINTF(_L("Getting the view details associated with subsession appUid"));
       
   372         //To avoid call to GetAppViewsL before calling OpenL 
       
   373         CheckSubSessionHandleL();
       
   374         
       
   375         TIpcArgs args(TIpcArgs::ENothing);
       
   376 	 	TInt argNum = 1;
       
   377         GetObjectArrayL(*this, EGetViewSize, EGetViewData, argNum, args, aAppViewInfoArray);
       
   378     }
       
   379 
       
   380 EXPORT_C void RRegistrationInfoForApplication::Close()
       
   381     {
       
   382     RScsClientSubsessionBase::Close();
       
   383     }
       
   384 
       
   385 EXPORT_C void RRegistrationInfoForApplication::GetAppOwnedFilesL(RPointerArray<HBufC>& aAppOwnedFiles) const
       
   386     {
       
   387      DEBUG_PRINTF(_L("Sending the request to retrieve the list of files owned by appUid associated with subsession "));
       
   388      //To avoid call to GetAppOwnedFilesL before calling OpenL 
       
   389      CheckSubSessionHandleL();
       
   390      
       
   391      TIpcArgs args(TIpcArgs::ENothing);
       
   392      TInt argNum = 1;
       
   393      GetObjectArrayL(*this, EGetAppOwnedFilesSize, EGetAppOwnedFilesData, argNum, args,aAppOwnedFiles);
       
   394     }
       
   395 
       
   396 EXPORT_C void RRegistrationInfoForApplication::GetAppCharacteristicsL(TApplicationCharacteristics &aApplicationCharacteristics) const
       
   397     {
       
   398     DEBUG_PRINTF(_L("Sending the request to retrieve application characteristics."));
       
   399     //To avoid call to GetAppCharacteristicsL before calling OpenL 
       
   400     CheckSubSessionHandleL();
       
   401     
       
   402     TPckg<Usif::TApplicationCharacteristics> pckg(aApplicationCharacteristics);
       
   403     TIpcArgs args(&pckg);
       
   404     User::LeaveIfError(CallSubsessionFunction(EGetAppCharacteristics, args));
       
   405     }
       
   406 	
       
   407 EXPORT_C void RRegistrationInfoForApplication::GetAppIconL(HBufC*& aFullFileName) const
       
   408     {
       
   409     DEBUG_PRINTF(_L("Sending the request to get application icon file name ."));    
       
   410     //To avoid call to GetAppIconL before calling OpenL 
       
   411     CheckSubSessionHandleL();
       
   412     
       
   413     TFileName fileName;
       
   414     TPckg<TFileName> filenamePckg(fileName);
       
   415     TIpcArgs args(&filenamePckg);
       
   416 
       
   417     User::LeaveIfError(CallSubsessionFunction(EGetAppIconForFileName, args));
       
   418     
       
   419     aFullFileName = fileName.AllocL();
       
   420 
       
   421     }
       
   422 	
       
   423 EXPORT_C void RRegistrationInfoForApplication::GetAppViewIconL(TUid aViewUid,HBufC*& aFullFileName) const
       
   424     {
       
   425     DEBUG_PRINTF(_L("Sending the request to get application view icon file name ."));
       
   426     //To avoid call to GetAppViewIconL before calling OpenL 
       
   427     CheckSubSessionHandleL();
       
   428     
       
   429     TFileName fileName;
       
   430     TPckg<TFileName> filenamePckg(fileName);
       
   431     TIpcArgs args(aViewUid.iUid,&filenamePckg);
       
   432     
       
   433     User::LeaveIfError(CallSubsessionFunction(EGetAppViewIconFileName, args));
       
   434  
       
   435     aFullFileName = fileName.AllocL();
       
   436     }
       
   437 	
       
   438 void RRegistrationInfoForApplication::CheckSubSessionHandleL() const
       
   439     {
       
   440     if(KNullHandle == SubSessionHandle())
       
   441         {
       
   442         DEBUG_PRINTF(_L("An invalid handle has been passed."));
       
   443         User::Leave(KErrBadHandle);
       
   444         }
       
   445     }
       
   446 
       
   447 //
       
   448 // RApplicationRegistrationInfo
       
   449 
       
   450 TInt RApplicationRegistrationInfo::SendSyncMessage(TInt aFunction, const TIpcArgs& aArgs) const
       
   451     {
       
   452     return CallSubsessionFunction(aFunction, aArgs);
       
   453     }
       
   454 
       
   455 EXPORT_C RApplicationRegistrationInfo::RApplicationRegistrationInfo() : RScsClientSubsessionBase()
       
   456     {
       
   457     // empty
       
   458     }
       
   459 
       
   460 EXPORT_C void RApplicationRegistrationInfo::OpenL(const RSoftwareComponentRegistry& aCompReg)
       
   461     {
       
   462     DEBUG_PRINTF(_L("Creating a subsession to the SCR server for the App list."));
       
   463     
       
   464     Close(); //Close the SubSession before Re-Opening the same.
       
   465     TInt err = CreateSubsession(aCompReg, ESubSessCreateAppRegInfo, TIpcArgs());
       
   466     if(KErrNone != err)
       
   467         {
       
   468         DEBUG_PRINTF2(_L("Failed to create the subsession to the SCR server (Error:%d)."), err);
       
   469         User::Leave(err);
       
   470         }    
       
   471     }
       
   472 
       
   473 EXPORT_C  TUid RApplicationRegistrationInfo::GetAppForDataTypeAndServiceL(const TDesC &aName,const TUid aServiceUid) const
       
   474 	{
       
   475 	DEBUG_PRINTF(_L("Get the AppUid corresponding to the mentioned Service and Type with the highest priority"));
       
   476     //To avoid call to GetAppForDataTypeAndServiceL before calling OpenL 
       
   477 	CheckSubSessionHandleL();
       
   478     
       
   479 	TUid appUid;
       
   480 	
       
   481 	TPckg<TUid> uidDes(appUid);	    
       
   482 	TIpcArgs args(&aName, aServiceUid.iUid,&uidDes );
       
   483 	
       
   484 	User::LeaveIfError(CallSubsessionFunction(EGetAppForDataTypeAndService, args));
       
   485 	return(appUid);
       
   486 	}
       
   487 
       
   488 EXPORT_C  TUid RApplicationRegistrationInfo::GetAppForDataTypeL(const TDesC &aName) const
       
   489 	{
       
   490 	DEBUG_PRINTF(_L("Getting the AppUid corresponding to the mentioned Type with the highest priority"));
       
   491     //To avoid call to GetAppForDataTypeL before calling OpenL 
       
   492 	CheckSubSessionHandleL();
       
   493     
       
   494 	TUid appUid;
       
   495 	
       
   496     TPckg<TUid> uidDes(appUid);  
       
   497 	TIpcArgs args(&aName, &uidDes);
       
   498 	 
       
   499 	User::LeaveIfError(CallSubsessionFunction(EGetAppForDataType, args));
       
   500 	return(appUid);
       
   501 	
       
   502 	}
       
   503 
       
   504 EXPORT_C void RApplicationRegistrationInfo::GetServiceInfoL(CAppServiceInfoFilter* aAppServiceInfoFilter, RPointerArray<Usif::CServiceInfo>& aAppServiceInfoArray, TLanguage aLocale) const
       
   505     {
       
   506     DEBUG_PRINTF(_L("Getting the Service Info details associated with the parameters set in the filter."));
       
   507     //To avoid call to GetServiceInfoL before calling OpenL 
       
   508     CheckSubSessionHandleL();
       
   509     
       
   510     RBuf8 buf;
       
   511     buf.CleanupClosePushL();
       
   512     ExternalizeObjectL(aAppServiceInfoFilter, buf);
       
   513         
       
   514     TIpcArgs args(&buf, aLocale);
       
   515     TInt argNum = 2;
       
   516     GetObjectArrayL(*this, EGetAppServiceInfoSize, EGetAppServiceInfoData, argNum, args, aAppServiceInfoArray);
       
   517     CleanupStack::PopAndDestroy(&buf);
       
   518     }
       
   519 
       
   520 EXPORT_C TBool RApplicationRegistrationInfo::GetAppInfoL(TUid aAppUid, TAppRegInfo& aAppInfo, TLanguage aLocale)
       
   521     {
       
   522     DEBUG_PRINTF2(_L("Getting information details of app 0x%x."), aAppUid.iUid);
       
   523     
       
   524     //To avoid call to GetAppInfoL before calling OpenL 
       
   525     CheckSubSessionHandleL();
       
   526     
       
   527     TPckg<TAppRegInfo> appRegInfoPckg(aAppInfo);
       
   528    
       
   529     TIpcArgs args(aAppUid.iUid, aLocale, &appRegInfoPckg);
       
   530     User::LeaveIfError(CallSubsessionFunction(EGetApplicationInfo, args));
       
   531     if(aAppInfo.Uid().iUid!= NULL)
       
   532         {
       
   533         return ETrue;
       
   534         }
       
   535     else
       
   536         return EFalse;
       
   537     }
       
   538 
       
   539 
       
   540 EXPORT_C void RApplicationRegistrationInfo::Close()
       
   541 	{
       
   542 	RScsClientSubsessionBase::Close();
       
   543 	}
       
   544 
       
   545 void RApplicationRegistrationInfo::CheckSubSessionHandleL() const
       
   546     {
       
   547     if(KNullHandle == SubSessionHandle())
       
   548         {
       
   549         DEBUG_PRINTF(_L("An invalid handle has been passed."));
       
   550         User::Leave(KErrBadHandle);
       
   551         }
       
   552     }
       
   553 
       
   554 
       
   555 //
       
   556 // RApplicationRegistryView
       
   557 //
       
   558 
       
   559 TInt RApplicationRegistryView::SendSyncMessage(TInt aFunction, const TIpcArgs& aArgs) const
       
   560     {
       
   561     return CallSubsessionFunction(aFunction, aArgs);
       
   562     }
       
   563 
       
   564 EXPORT_C RApplicationRegistryView::RApplicationRegistryView() : RScsClientSubsessionBase()
       
   565     {
       
   566     }
       
   567 
       
   568 EXPORT_C void RApplicationRegistryView::Close()
       
   569     {
       
   570     RScsClientSubsessionBase::Close();
       
   571     }
       
   572 
       
   573 EXPORT_C void RApplicationRegistryView::OpenViewL(const RSoftwareComponentRegistry& aCompReg, TLanguage aLocale)
       
   574     {   
       
   575     DEBUG_PRINTF(_L("Creating a subsession to the SCR server for the Application Registration view."));
       
   576 
       
   577     Close(); //Close the SubSession before Re-Opening the same.
       
   578     
       
   579     TInt err = CreateSubsession(aCompReg, ESubSessCreateAppRegistryView, TIpcArgs());
       
   580     if(KErrNone != err)
       
   581         {
       
   582         DEBUG_PRINTF2(_L("Failed to create the subsession to the SCR server for the Application Registration view (Error:%d)"), err);
       
   583         User::Leave(err);
       
   584         }                
       
   585     DEBUG_PRINTF(_L("Sending the request to create an applicaiton registry view on the server side."));
       
   586     TIpcArgs args(aLocale);
       
   587     User::LeaveIfError(CallSubsessionFunction(EOpenApplicationRegistrationInfoView, args));        
       
   588     }
       
   589 	
       
   590 EXPORT_C void RApplicationRegistryView::OpenViewL(const RSoftwareComponentRegistry& aCompReg, const RArray<TUid>& aAppRegAppUids, TLanguage aLocale)
       
   591     {   
       
   592     DEBUG_PRINTF(_L("Creating a subsession to the SCR server for the Application Registration view with specified AppUids."));
       
   593     
       
   594     Close();  //Close the SubSession before Re-Opening the same.
       
   595     
       
   596     TInt err = CreateSubsession(aCompReg, ESubSessCreateAppRegistryView, TIpcArgs());
       
   597     if(KErrNone != err)
       
   598         {
       
   599         DEBUG_PRINTF2(_L("Failed to create the subsession to the SCR server for the Application Registration view with specified AppUids (Error:%d)"), err);
       
   600         User::Leave(err);
       
   601         }                
       
   602     DEBUG_PRINTF(_L("Sending the request to create an applicaiton registry view on the server side."));
       
   603      
       
   604     TInt32 size = aAppRegAppUids.Count();
       
   605     const TInt32 maxBufSize= sizeof(TInt32)+ size*sizeof(TInt32);   // number of entries +  number of entry * size of AppUid stored as TUid
       
   606       
       
   607     // allocate buffer for the array
       
   608     HBufC8* bufForAppUids = HBufC8::NewMaxLC(maxBufSize);
       
   609     TPtr8 ptrBufForAppUids = bufForAppUids->Des();
       
   610     RDesWriteStream instream(ptrBufForAppUids);
       
   611     CleanupClosePushL(instream);
       
   612     instream.WriteInt32L(size);
       
   613     for (TInt i = 0; i < size; ++i)
       
   614         {
       
   615         instream.WriteInt32L(aAppRegAppUids[i].iUid);
       
   616         }
       
   617         
       
   618     instream.CommitL();
       
   619  
       
   620     TIpcArgs args(aLocale);
       
   621     args.Set(1,&ptrBufForAppUids);
       
   622     User::LeaveIfError(CallSubsessionFunction(EOpenApplicationRegistrationInfoForAppUidsView, args));  
       
   623    
       
   624     CleanupStack::PopAndDestroy(2,bufForAppUids); // bufForAppUid, instream 
       
   625     }
       
   626 
       
   627 EXPORT_C void RApplicationRegistryView::GetNextApplicationRegistrationInfoL(TInt aNoOfEntries, RPointerArray<CApplicationRegistrationData>& aApplicationRegistration) const
       
   628     {
       
   629     if(0 >= aNoOfEntries)
       
   630       {
       
   631       DEBUG_PRINTF(_L("No of Required View entries passed should be greater than 0"));
       
   632       User::Leave(KErrArgument);
       
   633       }
       
   634    //To avoid call to GetNextApplicationRegistrationInfoL before calling OpenApplicationRegistrationViewL 
       
   635    if(KNullHandle == SubSessionHandle())
       
   636      {
       
   637      DEBUG_PRINTF(_L("An invalid handle has been passed."));
       
   638      User::Leave(KErrBadHandle);
       
   639      }
       
   640     
       
   641     CApplicationRegistrationData* applicationRegistration = NULL;
       
   642     for(TInt i = 0 ; i < aNoOfEntries ; ++i)
       
   643         {
       
   644           applicationRegistration = CApplicationRegistrationData::NewLC();
       
   645           TBool isApplicationRegistrationDataPresent = EFalse;                                    
       
   646           DEBUG_PRINTF(_L("Sending the request to retrieve the next application details from the Application Registration view."));
       
   647           TIpcArgs args;
       
   648           TInt argNum = 1;
       
   649           isApplicationRegistrationDataPresent = GetObjectL(*this, *applicationRegistration, EGetApplicationRegistrationSize, EGetApplicationRegistrationData, argNum, args);
       
   650           if(!isApplicationRegistrationDataPresent)
       
   651             {
       
   652             DEBUG_PRINTF(_L8("Reached the end of the view."));  
       
   653             CleanupStack::PopAndDestroy(applicationRegistration);
       
   654             break;
       
   655             }
       
   656           else
       
   657             {
       
   658             DEBUG_PRINTF(_L("received the application registration data from the SCR Server "));                                       
       
   659             aApplicationRegistration.AppendL(applicationRegistration);
       
   660             CleanupStack::Pop(applicationRegistration);
       
   661             }            
       
   662         }
       
   663     }