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