epoc32/include/csmsgetdetdescinterface.inl
author William Roberts <williamr@symbian.org>
Tue, 16 Mar 2010 16:12:26 +0000
branchSymbian2
changeset 2 2fe1408b6811
permissions -rw-r--r--
Final list of Symbian^2 public API header files
     1 // Copyright (c) 2006-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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #include <ecom/ecom.h>
    17 
    18 const TUid KUidSmsGetDetDesc = {0x10282FA5};
    19 
    20 static void CleanUpEComSmsInfoArray(TAny* aInfoArray);
    21 
    22 /**
    23 Static factory constructor.
    24 
    25 @return The constructed CSmsGetDetDescInterface object
    26 */
    27 inline CSmsGetDetDescInterface* CSmsGetDetDescInterface::NewL()
    28 	{
    29 	RImplInfoPtrArray implInfoArray;
    30 	TCleanupItem cleanup(CleanUpEComSmsInfoArray, &implInfoArray);
    31     CleanupStack::PushL(cleanup);
    32     // get all implementations of the SMS GetDetDesc interface
    33 	REComSession::ListImplementationsL(KUidSmsGetDetDesc, implInfoArray);
    34 	TInt count = implInfoArray.Count();
    35 
    36 	if (count == 0)
    37 		{
    38 		implInfoArray.ResetAndDestroy();
    39 		implInfoArray.Close();
    40 		CleanupStack::PopAndDestroy(&implInfoArray);
    41 		User::Leave(KErrNotFound);
    42 		}
    43 		
    44 	CSmsGetDetDescInterface* interface = NULL;
    45 
    46 	for (TInt impl = 0; impl < count; ++impl)
    47 		{
    48 		if (implInfoArray[impl]->VendorId() != 0x70000001)
    49 			{
    50 			interface = REINTERPRET_CAST(
    51 							CSmsGetDetDescInterface*,
    52 							REComSession::CreateImplementationL(
    53 								implInfoArray[impl]->ImplementationUid(),
    54 								_FOFF(CSmsGetDetDescInterface, iDtor_ID_Key)));
    55 			}
    56 		}
    57 	
    58 	if (!interface)
    59 		{
    60 		interface = REINTERPRET_CAST(
    61 						CSmsGetDetDescInterface*,
    62 						REComSession::CreateImplementationL(
    63 							implInfoArray[0]->ImplementationUid(),
    64 							_FOFF(CSmsGetDetDescInterface, iDtor_ID_Key)));
    65 		}
    66 				
    67 	implInfoArray.ResetAndDestroy();
    68 	implInfoArray.Close();
    69     CleanupStack::PopAndDestroy(&implInfoArray);
    70 	return interface;
    71 	}
    72 
    73 /**
    74 Class constructor.
    75 */
    76 inline CSmsGetDetDescInterface::CSmsGetDetDescInterface()
    77 	{
    78 	}
    79 
    80 /**
    81 Class destructor.
    82 Destroy the ECOM implementation
    83 */
    84 inline CSmsGetDetDescInterface::~CSmsGetDetDescInterface()
    85 	{
    86 	REComSession::DestroyedImplementation(iDtor_ID_Key);
    87 	}
    88 
    89 
    90 /**
    91 CleanUpEComSmsInfoArray function for cleanup support of locally declared arrays.
    92 */
    93 void CleanUpEComSmsInfoArray(TAny* aInfoArray)
    94 	{
    95 	RImplInfoPtrArray* infoArray = (static_cast<RImplInfoPtrArray*>(aInfoArray));
    96 	infoArray->ResetAndDestroy();
    97 	infoArray->Close();
    98 	}
    99 
   100