uiservicetab/vimpstutils/src/vimpstutils.cpp
branchRCL_3
changeset 23 9a48e301e94b
equal deleted inserted replaced
22:3104fc151679 23:9a48e301e94b
       
     1 /*
       
     2 * Copyright (c) 2008 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 "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:  Utils for IMUiServiceTab modules.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDES
       
    20 #include	"vimpstutils.h"
       
    21 #include "StringLoader.h"
       
    22 //#include "vimpstdebugprint.h" //TODO: for later use
       
    23 #include <coemain.h>
       
    24 #include "uiservicetabtracer.h"
       
    25 
       
    26 // CONSTANTS
       
    27 // TODO: For later use
       
    28 // general colon needed in various places
       
    29 //_LIT( KColon, ":" );
       
    30 // general slash needed in various places
       
    31 //_LIT( KSlash, "/" );
       
    32 // general slash needed in various places
       
    33 _LIT( KAt, "@" );
       
    34 
       
    35 
       
    36 
       
    37 // -----------------------------------------------------------------------------
       
    38 // VIMPSTUtils::DisplayId
       
    39 // -----------------------------------------------------------------------------
       
    40 //
       
    41 EXPORT_C TPtrC VIMPSTUtils::DisplayId( const TDesC& aId, TBool /*aListHiding*/ )
       
    42     {
       
    43 	TRACER_AUTO;
       
    44     TPtrC ret( aId );
       
    45     
       
    46     //TODO: Modify the function body when it is required later 
       
    47    
       
    48     
       
    49     /*MCAStoredContacts* contacts = NULL;
       
    50     TRAPD( err, contacts = CCAStorageManagerFactory::ContactListInterfaceL() );
       
    51     if ( err != KErrNone || !contacts )
       
    52         {
       
    53         // some error, don't modify
       
    54         CHAT_DP_FUNC_DP("DisplayId", "Got some error, not hiding");
       
    55         return ret;
       
    56         }
       
    57 
       
    58     // if we've branded the feature out, don't modify anything
       
    59     if ( contacts->WVHiding() )
       
    60         {
       
    61         // locate ":" for userid, groupid.
       
    62         // locate "/" for list id.
       
    63         TInt pos = aId.F//TODO : Modify the function body when required laterindC( aListHiding ? KSlash : KColon );
       
    64 
       
    65         if ( ( pos != KErrNotFound) && ( pos != aId.Length()-1) )
       
    66             {
       
    67             // contains the special character, and it is not the last char
       
    68             // remove everything before the special char (including the char)
       
    69             ret.Set( aId.Mid( pos + 1 ) );
       
    70             }
       
    71          */
       
    72         // remove also the domain part
       
    73         TInt domainPos = ret.FindC( KAt );
       
    74         if ( ( domainPos != KErrNotFound ) && ( domainPos != 0 ) )
       
    75             {
       
    76             ret.Set( ret.Mid( 0, domainPos ) );
       
    77             }
       
    78        // }
       
    79     
       
    80  
       
    81     return ret;
       
    82     }
       
    83  
       
    84 
       
    85 // -----------------------------------------------------------------------------
       
    86 // VIMPSTUtils::LoadResourceL
       
    87 // give ownership to caller
       
    88 // -----------------------------------------------------------------------------
       
    89 // 
       
    90 EXPORT_C HBufC* VIMPSTUtils::LoadResourceL( TInt aResourceId )
       
    91 	{
       
    92 	TRACER_AUTO;
       
    93 	CCoeEnv* env = CCoeEnv::Static();
       
    94 	HBufC* ret = NULL;
       
    95 	if(env)
       
    96 		{
       
    97 		ret = env->AllocReadResourceL(aResourceId);
       
    98 		return ret;
       
    99 		}
       
   100 	else
       
   101 		{
       
   102 		return ret;
       
   103 		}
       
   104 
       
   105 	}
       
   106 
       
   107 // -----------------------------------------------------------------------------
       
   108 // VIMPSTUtils::LoadResourceL
       
   109 // give ownership to caller
       
   110 // -----------------------------------------------------------------------------
       
   111 // 
       
   112 EXPORT_C HBufC* VIMPSTUtils::LoadResourceL( TInt aResourceId , const TDesC& aPrompt)
       
   113     {
       
   114 	TRACER_AUTO;
       
   115     CCoeEnv* env = CCoeEnv::Static();
       
   116     HBufC* ret = NULL;
       
   117     if(env)
       
   118         {
       
   119         ret = StringLoader::LoadL(aResourceId,aPrompt);
       
   120         return ret;
       
   121         }
       
   122     else
       
   123         {
       
   124         return ret;
       
   125         }
       
   126 
       
   127     }
       
   128 
       
   129 // ---------------------------------------------------------
       
   130 // VIMPSTUtils::CombineStringFromResourceLC()
       
   131 // See header for details.
       
   132 // ---------------------------------------------------------
       
   133 //
       
   134 EXPORT_C HBufC* VIMPSTUtils::CombineStringFromResourceLC( TInt aResourceId1, TInt aResourceId2 )
       
   135 	{
       
   136 	TRACER_AUTO;
       
   137 	// empty texts
       
   138     _LIT ( KPSUIEmptyStringHeader, "%S\n%S" );
       
   139     HBufC* emptyText = CCoeEnv::Static()->AllocReadResourceLC( 
       
   140         aResourceId1 );
       
   141     
       
   142     HBufC* emptyText2 = CCoeEnv::Static()->AllocReadResourceLC( 
       
   143         aResourceId2 );  
       
   144     
       
   145     HBufC* emptyFinal = HBufC::NewLC( 
       
   146         emptyText->Length() + emptyText2->Length() + 2 );// 2 is length of "\n" 
       
   147         
       
   148     CleanupStack::Pop(emptyFinal);
       
   149         
       
   150     emptyFinal->Des().Format( KPSUIEmptyStringHeader, emptyText, emptyText2 );
       
   151     
       
   152     CleanupStack::PopAndDestroy( 2 );// emptyText, emptyText2
       
   153     
       
   154     CleanupStack::PushL(emptyFinal);
       
   155     
       
   156     return emptyFinal; 
       
   157           	
       
   158 	}
       
   159 
       
   160 
       
   161 // End of file