installationservices/swcomponentregistry/source/server/scrsubsession.cpp
changeset 24 84a16765cd86
child 25 98b66e4fb0be
equal deleted inserted replaced
6:aba6b8104af3 24:84a16765cd86
       
     1 /*
       
     2 * Copyright (c) 2008-2009 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 * Implements CScrSubsession. See class and function definitions for more information.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 /**
       
    21  @file
       
    22 */
       
    23 
       
    24 #include "scrsubsession.h"
       
    25 #include "scrrequestimpl.h"
       
    26 #include "scrdatabase.h"
       
    27 #include <scs/ipcstream.h>
       
    28 #include <scs/cleanuputils.h>
       
    29 
       
    30 using namespace Usif;
       
    31 
       
    32 /////////////////
       
    33 // CScrSubsession
       
    34 /////////////////
       
    35 
       
    36 CScrSubsession::CScrSubsession(CScrSession &aSession)
       
    37 /**
       
    38 	This constructor is protected and prevents direct instantiation.
       
    39  */
       
    40 	: CScsSubsession(aSession)
       
    41 	{
       
    42 	iSession = static_cast<CScrSession *>(&aSession);
       
    43 	iServer = static_cast<CScrServer *>(&iSession->iServer);
       
    44 	}
       
    45 
       
    46 void CScrSubsession::ConstructL()
       
    47 /**
       
    48 	Second-phase constructor.
       
    49  */
       
    50 	{
       
    51 	iServer->AddSubsessionOwnerL(iSession);
       
    52 	}
       
    53 
       
    54 CScrSubsession::~CScrSubsession()
       
    55 /**
       
    56  	Virtual destructor. Closes the database session handle.
       
    57  */
       
    58 	{
       
    59 	iServer->RemoveSubsessionOwner(iSession);
       
    60 	delete iStatement;
       
    61 	}
       
    62 	
       
    63 ///////////////////////////
       
    64 // CCompViewSubsessionContext
       
    65 ///////////////////////////	
       
    66 	
       
    67 CCompViewSubsessionContext::~CCompViewSubsessionContext()
       
    68 	{
       
    69 	delete iLastSoftwareTypeName;
       
    70 	iComponentFilterSuperset.Close();
       
    71 	}
       
    72 	
       
    73 ///////////////////////////
       
    74 // CComponentViewSubsession
       
    75 ///////////////////////////
       
    76 
       
    77 CComponentViewSubsession* CComponentViewSubsession::NewL(CScrSession &aSession)
       
    78 /**
       
    79 	Factory function allocates a new instance of CComponentViewSubsession.
       
    80 	
       
    81 	Note that CComponentViewSubsession derives from CObject and therefore it MUST NOT be deleted directly,
       
    82 	instead it should be closed.
       
    83 	 
       
    84 	@return					The newly created instance of CComponentViewSubsession.
       
    85 							Ownership is transferred to the caller.
       
    86  */
       
    87 	{
       
    88 	CComponentViewSubsession* self = new(ELeave) CComponentViewSubsession(aSession);
       
    89 	CleanupClosePushL(*self);
       
    90 	self->ConstructL();
       
    91 	CleanupStack::Pop(self);
       
    92 	return self;
       
    93 	}
       
    94 
       
    95 CComponentViewSubsession::CComponentViewSubsession(CScrSession &aSession)
       
    96 /**
       
    97 	This constructor is private and prevents direct instantiation. It provides
       
    98 	a single point of definition from which to call the superclass c'tor.
       
    99  */
       
   100 	:	CScrSubsession(aSession)
       
   101 	{	
       
   102 	}
       
   103 
       
   104 void CComponentViewSubsession::ConstructL()
       
   105 /**
       
   106 	Second-phase constructor.
       
   107  */
       
   108 	{
       
   109 	iSubsessionContext = new (ELeave) CCompViewSubsessionContext;		
       
   110 	CScrSubsession::ConstructL();
       
   111 	}
       
   112 
       
   113 CComponentViewSubsession::~CComponentViewSubsession()
       
   114 /**
       
   115 	Destructor for the subsession object.
       
   116  */
       
   117 	{
       
   118 	delete iFilter;
       
   119 	delete iComponentEntry;
       
   120 	iComponentEntryList.ResetAndDestroy();
       
   121 	delete iSubsessionContext;
       
   122 	}
       
   123 
       
   124 TBool CComponentViewSubsession::DoServiceL(TInt aFunction, const RMessage2& aMessage)
       
   125 /**
       
   126 	Implement CComponentViewSubsession by handling the supplied message.
       
   127 
       
   128 	@param	aFunction		Function identifier without SCS code.
       
   129 	@param	aMessage		Standard server-side handle to message.
       
   130 	@return ETrue means complete client request now. EFalse for asynchronous tasks.
       
   131  */
       
   132 	{
       
   133 	TScrSubSessionFunction f = static_cast<TScrSubSessionFunction>(aFunction);
       
   134 	
       
   135 	switch (f)
       
   136 		{
       
   137 		case EOpenComponentsView:
       
   138 			{
       
   139 			DeleteObjectZ(iFilter);
       
   140 			iFilter = iServer->RequestImpL()->ReadComponentFilterL(aMessage);
       
   141 			DeleteObjectZ(iStatement);
       
   142 			iStatement = iServer->RequestImpL()->OpenComponentViewL(*iFilter, iSubsessionContext->iComponentFilterSuperset, iSubsessionContext->iFilterSupersetInUse);
       
   143 			break;
       
   144 			}
       
   145 		case EGetNextComponentSize:
       
   146 			iServer->RequestImpL()->NextComponentSizeL(aMessage, iStatement, iFilter, iComponentEntry, this->iSubsessionContext);
       
   147 			break;
       
   148 		case EGetNextComponentData:
       
   149 			iServer->RequestImpL()->NextComponentDataL(aMessage, iComponentEntry);
       
   150 			break;
       
   151 		case EGetNextComponentSetSize:
       
   152 			iServer->RequestImpL()->NextComponentSetSizeL(aMessage, iStatement, iFilter, iComponentEntryList, this->iSubsessionContext);
       
   153 			break;
       
   154 		case EGetNextComponentSetData:
       
   155 			iServer->RequestImpL()->NextComponentSetDataL(aMessage, iComponentEntryList);
       
   156 			break;
       
   157 		default:
       
   158 			User::Leave(KErrNotSupported);
       
   159 			break;
       
   160 		}
       
   161 	return ETrue;
       
   162 	}
       
   163 
       
   164 
       
   165 ///////////////////////
       
   166 // CFileListSubsession
       
   167 ///////////////////////
       
   168 
       
   169 CFileListSubsession* CFileListSubsession::NewL(CScrSession &aSession)
       
   170 /**
       
   171 	Factory function allocates a new instance of CFileListSubsession.
       
   172 	
       
   173 	Note that CFileListSubsession derives from CObject and therefore it MUST NOT be deleted directly,
       
   174 	instead it should be closed.
       
   175 	 
       
   176 	@return					The newly created instance of CFileListSubsession.
       
   177 							Ownership is transferred to the caller.
       
   178  */
       
   179 	{
       
   180 	CFileListSubsession* self = new(ELeave) CFileListSubsession(aSession);
       
   181 	CleanupStack::PushL(self);
       
   182 	self->ConstructL();
       
   183 	CleanupStack::Pop(self);
       
   184 	return self;
       
   185 	}
       
   186 
       
   187 CFileListSubsession::CFileListSubsession(CScrSession &aSession)
       
   188 /**
       
   189 	This constructor is private and prevents direct instantiation. It provides
       
   190 	a single point of definition from which to call the superclass c'tor.
       
   191  */
       
   192 	:	CScrSubsession(aSession)
       
   193 	{
       
   194 	// empty.
       
   195 	}
       
   196 
       
   197 CFileListSubsession::~CFileListSubsession()
       
   198 /**
       
   199 	Destructor for the subsession object.
       
   200  */
       
   201 	{		
       
   202 	delete iFilePath;
       
   203 	iFileList.Close();
       
   204 	}
       
   205 
       
   206 TBool CFileListSubsession::DoServiceL(TInt aFunction, const RMessage2& aMessage)
       
   207 /**
       
   208 	Implement CFileListSubsession by handling the supplied message.
       
   209 
       
   210 	@param	aFunction		Function identifier without SCS code.
       
   211 	@param	aMessage		Standard server-side handle to message.
       
   212 	@return ETrue means complete client request now. EFalse for asynchronous tasks.
       
   213  */
       
   214 	{
       
   215 	TScrSessionFunction f = static_cast<TScrSessionFunction>(aFunction);
       
   216 	
       
   217 	switch (f)
       
   218 		{
       
   219 		case EOpenFileList:
       
   220 			{
       
   221 			DeleteObjectZ(iStatement);
       
   222 			iStatement = iServer->RequestImpL()->OpenFileListL(aMessage);
       
   223 			break;
       
   224 			}
       
   225 		case EGetNextFileSize:
       
   226 			iServer->RequestImpL()->NextFileSizeL(aMessage, iStatement, iFilePath);
       
   227 			break;
       
   228 		case EGetNextFileData:
       
   229 			iServer->RequestImpL()->NextFileDataL(aMessage, iFilePath);
       
   230 			break;
       
   231 		case EGetNextFileSetSize:
       
   232 			iServer->RequestImpL()->NextFileSetSizeL(aMessage, iStatement, iFileList);
       
   233 			break;
       
   234 		case EGetNextFileSetData:
       
   235 			iServer->RequestImpL()->NextFileSetDataL(aMessage, iFileList);
       
   236 			break;
       
   237 		default:
       
   238 			User::Leave(KErrNotSupported);
       
   239 			break;
       
   240 		}
       
   241 	return ETrue;
       
   242 	}