messagingappbase/smsmtm/clientmtm/inc/csmsgetdetdescinterface.inl
changeset 25 84d9eb65b26f
parent 23 238255e8b033
child 27 e4592d119491
child 37 518b245aa84c
child 79 2981cb3aa489
equal deleted inserted replaced
23:238255e8b033 25:84d9eb65b26f
     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 "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 //
       
    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