appfw/apparchitecture/apparc/APAID.CPP
changeset 0 2e3d3ce01487
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // apaid.cpp
       
    15 //
       
    16 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    17 #if !defined(__APAID_PARTNER_H__)
       
    18 #include "apaidpartner.h"
       
    19 #endif
       
    20 #endif //SYMBIAN_ENABLE_SPLIT_HEADERS
       
    21 #include <apaid.h>
       
    22 #include <s32strm.h>
       
    23 #include "APASTD.H"
       
    24 
       
    25 const TInt KMaxOpaqueDataLength = 0x1000; // maximum length of opaque data that can be passed between client and apparc server via a TApaAppServiceInfo object - this can be increased in future if needed
       
    26 
       
    27 //
       
    28 // TApaAppIdentifier
       
    29 //
       
    30 
       
    31 /** Constructs an empty application identifier.
       
    32 
       
    33 The data is not initialised. */
       
    34 EXPORT_C TApaAppIdentifier::TApaAppIdentifier()
       
    35 	{}
       
    36 
       
    37 /** Constructs an application identifier from the specified application 
       
    38 DLL file name and extension, and the specified application UID.
       
    39 @param aAppUid The application specific UID.
       
    40 @param aDllName The filename and extension of the application DLL. */
       
    41 EXPORT_C TApaAppIdentifier::TApaAppIdentifier(TUid aAppUid,const TFileName& aDllName)
       
    42 	: iAppUid(aAppUid),
       
    43 	iFullName(aDllName)
       
    44 	{}
       
    45 
       
    46 /** Externalises the application identifier to a write stream.
       
    47 
       
    48 @param aStream The write stream. */
       
    49 EXPORT_C void TApaAppIdentifier::ExternalizeL(RWriteStream& aStream)const
       
    50 	{
       
    51 	aStream<< iAppUid;
       
    52 	aStream<< iFullName;
       
    53 	}
       
    54 
       
    55 /** Internalises the application identifier from a read stream.
       
    56 
       
    57 @param aStream The read stream. */
       
    58 EXPORT_C void TApaAppIdentifier::InternalizeL(RReadStream& aStream)
       
    59 	{
       
    60 	aStream>> iAppUid;
       
    61 	aStream>> iFullName;
       
    62 	}
       
    63 
       
    64 //
       
    65 // TApaAppInfo
       
    66 //
       
    67 
       
    68 /** Constructs an empty application information object.
       
    69 
       
    70 The full path name is empty, the captions are empty and the application specific 
       
    71 UID is set to the null UID. */
       
    72 EXPORT_C TApaAppInfo::TApaAppInfo()
       
    73 	: iUid(TUid()),
       
    74 	iFullName(KNullDesC),
       
    75 	iCaption(KNullDesC),
       
    76 	iShortCaption(KNullDesC)
       
    77 	{}
       
    78 
       
    79 /** Constructs an application information object from the specified full DLL path 
       
    80 name, UID and full length caption.
       
    81 
       
    82 @param aAppUid The application specific UID. 
       
    83 @param aDllName The full path name of the application DLL. 
       
    84 @param aCaption The application caption. */
       
    85 EXPORT_C TApaAppInfo::TApaAppInfo(TUid aAppUid,const TFileName& aDllName,const TApaAppCaption& aCaption)
       
    86 	: iUid(aAppUid),
       
    87 	iFullName(aDllName),
       
    88 	iCaption(aCaption),
       
    89 	iShortCaption(aCaption)
       
    90 	{}
       
    91 
       
    92 /** Constructs an application information object from the specified full DLL path 
       
    93 name, UID, caption and short caption.
       
    94 
       
    95 @param aAppUid The application specific UID. 
       
    96 @param aDllName The full path name of the application DLL. 
       
    97 @param aCaption The application caption. 
       
    98 @param aShortCaption The application short caption. */
       
    99 EXPORT_C TApaAppInfo::TApaAppInfo(TUid aAppUid,const TFileName& aDllName,const TApaAppCaption& aCaption,const TApaAppCaption& aShortCaption)
       
   100 	: iUid(aAppUid),
       
   101 	iFullName(aDllName),
       
   102 	iCaption(aCaption),
       
   103 	iShortCaption(aShortCaption)
       
   104 	{}
       
   105 
       
   106 /** Externalises the application information to a write stream.
       
   107 
       
   108 @param aStream The write stream. */
       
   109 EXPORT_C void TApaAppInfo::ExternalizeL(RWriteStream& aStream)const
       
   110 	{
       
   111 	aStream<< iUid;
       
   112 	aStream<< iFullName;
       
   113 	aStream<< iCaption;
       
   114 	aStream<< iShortCaption;
       
   115 	}
       
   116 
       
   117 /** Internalises the application information from a read stream.
       
   118 
       
   119 @param aStream The read stream. */
       
   120 EXPORT_C void TApaAppInfo::InternalizeL(RReadStream& aStream)
       
   121 	{
       
   122 	aStream>> iUid;
       
   123 	aStream>> iFullName;
       
   124 	aStream>> iCaption;
       
   125 	aStream>> iShortCaption;
       
   126 	}
       
   127 
       
   128 
       
   129 //
       
   130 // TApaAppViewInfo
       
   131 //
       
   132 
       
   133 /** Constructs an empty object.
       
   134 
       
   135 Specifically, it sets the view UID to KNullUid and empties the application 
       
   136 caption, i.e. sets it to KNullDesC. */
       
   137 EXPORT_C TApaAppViewInfo::TApaAppViewInfo()
       
   138 	: iUid(KNullUid),
       
   139 	iViewCaption(KNullDesC)
       
   140 	{}
       
   141 
       
   142 
       
   143 EXPORT_C TApaAppViewInfo::TApaAppViewInfo(TUid aAppUid,const TApaAppCaption& aViewCaption, TInt aScreenMode)
       
   144 	: iUid(aAppUid),
       
   145 	iViewCaption(aViewCaption),
       
   146 	iScreenMode(aScreenMode)
       
   147 	{}
       
   148 
       
   149 
       
   150 /** Externalises the application view information to a write stream.
       
   151 
       
   152 @param aStream The write stream. */
       
   153 EXPORT_C void TApaAppViewInfo::ExternalizeL(RWriteStream& aStream)const
       
   154 	{
       
   155 	aStream<< iUid;
       
   156 	aStream<< iViewCaption;
       
   157 	aStream.WriteInt32L(iScreenMode);
       
   158 	}
       
   159 
       
   160 
       
   161 /** Internalises the application view information from a read stream.
       
   162 
       
   163 @param aStream The read stream. */
       
   164 EXPORT_C void TApaAppViewInfo::InternalizeL(RReadStream& aStream)
       
   165 	{
       
   166 	aStream>> iUid;
       
   167 	aStream>> iViewCaption;
       
   168 	iScreenMode=aStream.ReadInt32L();
       
   169 	}
       
   170 
       
   171 
       
   172 //
       
   173 // class TApaAppCapability
       
   174 //
       
   175 
       
   176 EXPORT_C void TApaAppCapability::InternalizeL(RReadStream& aStream)
       
   177 	{
       
   178 	DoInternalizeL(aStream, iLaunchInBackground, iGroupName);
       
   179 	}
       
   180 	
       
   181 /** Internalises the application capabilities from a read stream.
       
   182 
       
   183 @param aStream The read stream.
       
   184 */
       
   185 void TApaAppCapability::DoInternalizeL(RReadStream& aStream, TBool& aLaunchInBackground, TApaAppGroupName& aGroupName)
       
   186 	{
       
   187 	TInt version = aStream.ReadInt32L();
       
   188 	iEmbeddability = TEmbeddability(aStream.ReadInt32L());
       
   189 	iSupportsNewFile = aStream.ReadInt32L();
       
   190 	iAppIsHidden = aStream.ReadInt32L();
       
   191 
       
   192 	// initialise values of members which may not be in the stream
       
   193 	aLaunchInBackground = EFalse;
       
   194 	aGroupName.Zero();
       
   195 
       
   196 	if (version==1)
       
   197 		return;
       
   198 
       
   199 	// Calypso extension to allow apps to be launched in the background
       
   200 	aLaunchInBackground = aStream.ReadInt32L();
       
   201 	if (version==2)
       
   202 		return;
       
   203 
       
   204 	aStream >> aGroupName;
       
   205 	if (version == 3)
       
   206 		return;
       
   207 
       
   208 	iAttributes = aStream.ReadUint32L();
       
   209 	if (version == 4)
       
   210 		return;
       
   211 	
       
   212 	Panic(EDPanicInvalidVersionNumber);
       
   213 	}
       
   214 
       
   215 /** Externalises the application capabilities to a write stream.
       
   216 
       
   217 @param aStream The write stream. 
       
   218 */
       
   219 EXPORT_C void TApaAppCapability::ExternalizeL(RWriteStream& aStream) const
       
   220 	{
       
   221 	aStream.WriteInt32L(EVersion);
       
   222 	aStream.WriteInt32L(iEmbeddability);
       
   223 	aStream.WriteInt32L(iSupportsNewFile);
       
   224 	aStream.WriteInt32L(iAppIsHidden);
       
   225 	aStream.WriteInt32L(iLaunchInBackground);
       
   226 	aStream << iGroupName;
       
   227 	aStream.WriteUint32L(iAttributes);
       
   228 	}
       
   229 			
       
   230 /** A utility function that can copy capability information from one descriptor 
       
   231 to another.
       
   232 
       
   233 @param aDest Target descriptor.
       
   234 @param aSource Source descriptor. 
       
   235 */
       
   236 EXPORT_C void TApaAppCapability::CopyCapability(TDes8& aDest,const TDesC8& aSource)
       
   237 	{
       
   238 	TInt maxLen=aDest.MaxLength();
       
   239 	aDest.FillZ(maxLen); // zero fill in case aSource is shorter
       
   240 	aDest.Copy(aSource.Left(Min(aSource.Length(),maxLen)));
       
   241 	aDest.SetLength(maxLen);
       
   242 	}
       
   243 
       
   244 
       
   245 //
       
   246 // class TApaEmbeddabilityFilter
       
   247 //
       
   248 
       
   249 /** Constructs an empty embeddability filter. */
       
   250 EXPORT_C TApaEmbeddabilityFilter::TApaEmbeddabilityFilter()
       
   251 	: iEmbeddabilityFlags(0)
       
   252 	{
       
   253 	}
       
   254 
       
   255 /** Adds aEmbeddability to the filter.
       
   256 
       
   257 @param aEmbeddability TEmbeddability value to add to the filter. */
       
   258 EXPORT_C void TApaEmbeddabilityFilter::AddEmbeddability(TApaAppCapability::TEmbeddability aEmbeddability)
       
   259 	{
       
   260 	__ASSERT_ALWAYS(aEmbeddability >= 0 && static_cast<TUint>(aEmbeddability) < (sizeof(TUint)*8), Panic(EPanicEmbeddabilityOutOfRange));
       
   261 	iEmbeddabilityFlags |= (1 << aEmbeddability);
       
   262 	}
       
   263 
       
   264 /** Compares aEmbeddability with the filter.
       
   265 
       
   266 @param aEmbeddability TEmbeddability value to compare.
       
   267 @return True, if aEmbeddability is included in the filter; false, otherwise. */
       
   268 EXPORT_C TBool TApaEmbeddabilityFilter::MatchesEmbeddability(TApaAppCapability::TEmbeddability aEmbeddability) const
       
   269 	{
       
   270 	__ASSERT_ALWAYS(aEmbeddability >= 0 && static_cast<TUint>(aEmbeddability) < (sizeof(TUint)*8), Panic(EPanicEmbeddabilityOutOfRange));
       
   271 	TUint embeddabilityFlag = (1 << aEmbeddability);
       
   272 	return (embeddabilityFlag & iEmbeddabilityFlags);
       
   273 	}
       
   274 
       
   275 
       
   276 //
       
   277 // class TApaAppServiceInfo
       
   278 //
       
   279 
       
   280 EXPORT_C TApaAppServiceInfo::TApaAppServiceInfo()
       
   281 	: iUid(KNullUid),
       
   282 	  iDataTypes(0),
       
   283 	  iOpaqueData(NULL)
       
   284 	{
       
   285 	}
       
   286 
       
   287 EXPORT_C TApaAppServiceInfo::TApaAppServiceInfo(TUid aUid, 
       
   288 	CArrayFixFlat<TDataTypeWithPriority>* aDataTypes, HBufC8* aOpaqueData)
       
   289 	: iUid(aUid),
       
   290 	  iDataTypes(aDataTypes),
       
   291 	  iOpaqueData(aOpaqueData)
       
   292 	{
       
   293 	__ASSERT_DEBUG(iDataTypes, Panic(EPanicNullPointer));
       
   294 	__ASSERT_DEBUG(iOpaqueData, Panic(EPanicNullPointer));
       
   295 	}
       
   296 
       
   297 EXPORT_C void TApaAppServiceInfo::ExternalizeL(RWriteStream& aStream) const
       
   298 	{
       
   299 	__ASSERT_DEBUG(iDataTypes, Panic(EPanicNullPointer));
       
   300 	__ASSERT_DEBUG(iOpaqueData, Panic(EPanicNullPointer));
       
   301 	aStream << iUid;
       
   302 	aStream << *iDataTypes; //lint !e613 Possible use of null pointer - Asserted above
       
   303 	aStream << *iOpaqueData;//lint !e613 Possible use of null pointer - Asserted above
       
   304 	}
       
   305 
       
   306 EXPORT_C void TApaAppServiceInfo::InternalizeL(RReadStream& aStream)
       
   307 	{
       
   308 	aStream >> iUid;
       
   309 	iDataTypes = new(ELeave) CArrayFixFlat<TDataTypeWithPriority>(1);
       
   310 	aStream >> *iDataTypes;
       
   311 	iOpaqueData = HBufC8::NewL(aStream, KMaxOpaqueDataLength);
       
   312 	}
       
   313 
       
   314 EXPORT_C void TApaAppServiceInfo::Release()
       
   315 	{
       
   316 	if (iDataTypes)
       
   317 		{
       
   318 		iDataTypes->Reset();
       
   319 		delete iDataTypes;		
       
   320 		}
       
   321 	if (iOpaqueData)
       
   322 		{
       
   323 		delete iOpaqueData;
       
   324 		iOpaqueData = NULL;
       
   325 		}
       
   326 	}
       
   327 
       
   328 EXPORT_C CArrayFixFlat<TDataTypeWithPriority>& TApaAppServiceInfo::DataTypes()
       
   329 	{
       
   330 	__ASSERT_DEBUG(iDataTypes, Panic(EPanicNullPointer));
       
   331 	return *iDataTypes; //lint !e613 Possible use of null pointer - Asserted above
       
   332 	}
       
   333 
       
   334 /** Returns the service UID.
       
   335 
       
   336 Note that some APIs may store a UID other than a service UID
       
   337 in a TApaAppServiceInfo object. Such APIs clearly state what
       
   338 the UID represents.
       
   339 
       
   340 @return the service UID.
       
   341 */
       
   342 EXPORT_C TUid TApaAppServiceInfo::Uid() const
       
   343 	{
       
   344 	return iUid;
       
   345 	}
       
   346 	
       
   347 EXPORT_C const CArrayFixFlat<TDataTypeWithPriority>& TApaAppServiceInfo::DataTypes() const
       
   348 	{
       
   349 	__ASSERT_DEBUG(iDataTypes, Panic(EPanicNullPointer));	
       
   350 	return *iDataTypes; //lint !e613 Possible use of null pointer - Asserted above
       
   351 	}
       
   352 
       
   353 /** Returns the service implementation's opaque data.
       
   354 
       
   355 For each service UID registered by an application, the associated
       
   356 opaque data indicates how the service is implemented by that application.
       
   357 
       
   358 The meaning of the opaque data is not known to the framework, it will vary
       
   359 according to the service.
       
   360 
       
   361 For some services the opaque data may be a name intended for user display,
       
   362 for others it may be structured data that the service's client-side code can interpret.
       
   363 
       
   364 @return the service implementation's opaque data.
       
   365 */
       
   366 EXPORT_C const TDesC8& TApaAppServiceInfo::OpaqueData() const
       
   367 	{
       
   368 	if (iOpaqueData)
       
   369 		return *iOpaqueData;
       
   370 
       
   371 	return KNullDesC8;
       
   372 	}
       
   373 
       
   374 	
       
   375 //
       
   376 // class CApaAppServiceInfoArray
       
   377 //
       
   378 
       
   379 EXPORT_C CApaAppServiceInfoArray::CApaAppServiceInfoArray()
       
   380 	{
       
   381 	}
       
   382 	
       
   383 EXPORT_C void CApaAppServiceInfoArray::CApaAppServiceInfoArray_Reserved1()
       
   384 	{
       
   385 	}
       
   386 
       
   387 EXPORT_C void CApaAppServiceInfoArray::CApaAppServiceInfoArray_Reserved2()
       
   388 	{
       
   389 	}