imstutils/imconversationview/imcvuiengine/src/imcvenginemessageutils.cpp
changeset 0 5e5d6b214f4f
equal deleted inserted replaced
-1:000000000000 0:5e5d6b214f4f
       
     1 /*
       
     2 * Copyright (c) 2007-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 class for engine
       
    15 *
       
    16 */
       
    17 
       
    18 #include "imcvenginemessageutils.h"
       
    19 
       
    20 #include <e32std.h>
       
    21 #include <StringLoader.h>
       
    22 #include "mimcvenginemessage.h"
       
    23 #include "mimcvenginemessagecreator.h"
       
    24 #include "mimcvenginemessageswriteinterface.h"
       
    25 #include <avkon.rsg>
       
    26 #include "imcvuiliterals.h"
       
    27 #include "imcvlogger.h"
       
    28 #include <StringLoader.h>
       
    29 
       
    30 // ======== MEMBER FUNCTIONS ========
       
    31 
       
    32 // ---------------------------------------------------------------------------
       
    33 // IMCVEngineMessageUtils::AppendDateStampL
       
    34 // ---------------------------------------------------------------------------
       
    35 //
       
    36 void IMCVEngineMessageUtils::AppendDateStampL( 
       
    37                           TTime /*aNewTime*/,
       
    38                           MIMCVEngineMessageWriteInterface& aWriteInterface,
       
    39                           MIMCVEngineMessageCreator& /*aMessageCreator */)
       
    40     {
       
    41     // DateStamp is NOT appended if:
       
    42     // 1. There are no previous messages
       
    43     // 2. Previous message is from the same day as aNewTime
       
    44     IM_CV_LOGS(TXT("IMCVEngineMessageUtils::AppendDateStampL() start") );
       
    45    
       
    46     TTime lastTime = aWriteInterface.Time();
       
    47     
       
    48     if( lastTime == Time::NullTTime() )
       
    49         {
       
    50         // no previous messages
       
    51         return;
       
    52         }
       
    53    else
       
    54        {
       
    55        	// implementation needed
       
    56        }
       
    57     IM_CV_LOGS(TXT("IMCVEngineMessageUtils::AppendDateStampL() end") );
       
    58     }
       
    59 
       
    60 
       
    61 // ---------------------------------------------------------------------------
       
    62 // CIMCVEngineMessageUtils::AppendMessageWithDateStampL
       
    63 // ---------------------------------------------------------------------------
       
    64 //
       
    65 void IMCVEngineMessageUtils::AppendMessageWithDateStampL( 
       
    66                               MIMCVEngineMessage& aNewMessage,
       
    67                               MIMCVEngineMessageWriteInterface& aWriteInterface,
       
    68                               MIMCVEngineMessageCreator& aMessageCreator,
       
    69                               TBool aSharedOwnership )
       
    70     {
       
    71     // Make sure this does not leave before the new message is
       
    72     // appended to interface,
       
    73     IM_CV_LOGS(TXT("IMCVEngineMessageUtils::AppendMessageWithDateStampL() start") );
       
    74     TRAP_IGNORE( AppendDateStampL( aNewMessage.TimeStamp(), 
       
    75                                    aWriteInterface, 
       
    76                                    aMessageCreator ) );
       
    77     aWriteInterface.AppendL( &aNewMessage, aSharedOwnership );
       
    78     IM_CV_LOGS(TXT("IMCVEngineMessageUtils::AppendMessageWithDateStampL() end") );
       
    79     }
       
    80 
       
    81 // -----------------------------------------------------------------------------
       
    82 // IMCVEngineMessageUtils::LoadResourceL
       
    83 // give ownership to caller
       
    84 // -----------------------------------------------------------------------------
       
    85 // 
       
    86 HBufC* IMCVEngineMessageUtils::LoadResourceL( TInt aResourceId, const TDesC& aText )
       
    87 	{
       
    88 	CCoeEnv* env = CCoeEnv::Static();
       
    89 	HBufC* ret = NULL;
       
    90 	if(env)
       
    91 		{
       
    92 		ret = StringLoader::LoadL( aResourceId, aText  );
       
    93 		}
       
    94 	return ret;
       
    95 	}
       
    96 	
       
    97 // End of file