sapi_logging/tsrc/dev/tloggingservice/src/tgetevent1.cpp
changeset 0 14df0fbfcc4e
equal deleted inserted replaced
-1:000000000000 0:14df0fbfcc4e
       
     1 /*
       
     2 * Copyright (c) 2009 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 the License "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:  
       
    15 *
       
    16 */
       
    17 
       
    18 #include <e32svr.h>
       
    19 #include <e32std.h>
       
    20 #include <StifParser.h>
       
    21 #include <Stiftestinterface.h>
       
    22 #include <logcli.h>
       
    23 #include <logwrap.h>
       
    24 
       
    25 #include "loggingasyncservice.h"
       
    26 #include "loggingservice.h"
       
    27 #include "loggingfilter.h"
       
    28 
       
    29 #include "tlogging.h"
       
    30 #include "tlogcallback.h"
       
    31 #include "loggingevent.h"
       
    32 #include "logiter.h"
       
    33 
       
    34 //------------------------------------------------------------
       
    35 // Get an event details on the eventid
       
    36 //-------------------------------------------------------------
       
    37 
       
    38 TInt getEvent1(void) 
       
    39 {
       
    40 	_LIT(KOwnEventSubject, "RandomLogEvent");
       
    41 	_LIT(KOwnEventRemoteParty, "OwnContact");
       
    42 	CLoggingService *LogService = CLoggingService :: NewL() ;
       
    43 
       
    44 
       
    45 	CLogsEvent* event = CLogsEvent::NewL();
       
    46 
       
    47 	// Sets the duration of the event in seconds.
       
    48 	// Randomize something between 0-299 
       
    49 
       
    50 	event->SetDuration(301);
       
    51 
       
    52 	TBuf<KLogMaxDirectionLength> direction;
       
    53 
       
    54 	// Direction of the event is randomized
       
    55 
       
    56 	TInt dirID = R_LOG_DIR_IN;
       
    57 	TUid eventTypeID = KLogCallEventTypeUid; 
       
    58 	event->SetEventType(eventTypeID);
       
    59 	event->SetSubject(KOwnEventSubject);
       
    60 	TTime time;			// creation time from the device clock
       
    61 	time.HomeTime();
       
    62 	event->SetTime(time); 
       
    63 
       
    64 	TBuf<KLogMaxNumberLength> number; // Randomize number
       
    65 	number.AppendNum(7000008);
       
    66 	event->SetNumber(number);
       
    67 	event->SetRemoteParty(KOwnEventRemoteParty);
       
    68 
       
    69 	TLogId id= LogService->AddEventL(event) ;
       
    70 
       
    71 	CLogsEvent *updatedEvent   = CLogsEvent :: NewL() ;
       
    72 	updatedEvent->SetId(id) ;
       
    73 	
       
    74 	CLogsFilter *filter = CLogsFilter :: NewL() ;
       
    75 	
       
    76 	filter->SetRequestType(EGetEvent)  ;
       
    77 	filter->SetEventL(updatedEvent) ;
       
    78 	
       
    79 	CLogIter *iter = LogService->GetListL(filter) ;
       
    80 	CLogsEvent *iterevents ;
       
    81 	
       
    82 	while(iterevents = iter->NextL())
       
    83 		{
       
    84 		 delete iterevents ;
       
    85 		}
       
    86 	
       
    87 	delete updatedEvent ;
       
    88 	delete iter ;
       
    89 
       
    90     delete filter ; 
       
    91 	delete event ;
       
    92 	delete LogService ;
       
    93 	return KErrNone ;
       
    94 }