omads/omadsappui/AspScheduleHandler/src/aspschedulehandler.cpp
branchRCL_3
changeset 24 8e7494275d3a
parent 23 2bb96f4ecad8
child 25 4f0867e42d62
equal deleted inserted replaced
23:2bb96f4ecad8 24:8e7494275d3a
     1 /*
       
     2 * Copyright (c) 2002-2005 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:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <schinfo.h>
       
    20 #include <schtask.h>
       
    21 #include <s32file.h>
       
    22 #include <e32math.h>
       
    23 #include <e32cons.h>
       
    24 
       
    25 #include "AspSyncUtilApi.h"
       
    26 #include "AspDebug.h"
       
    27 
       
    28 
       
    29 
       
    30 // -----------------------------------------------------------------------------
       
    31 // SynchronizeL
       
    32 //
       
    33 // -----------------------------------------------------------------------------
       
    34 //
       
    35 LOCAL_D void SynchronizeL(RFile& aTaskFile)
       
    36 	{
       
    37 	CSyncUtilApi* syncUtilApi = CSyncUtilApi::NewL();
       
    38 	CleanupStack::PushL(syncUtilApi);
       
    39 	
       
    40 	syncUtilApi->SynchronizeL(aTaskFile);
       
    41 	
       
    42 	CleanupStack::PopAndDestroy(syncUtilApi);
       
    43 	}
       
    44 
       
    45 
       
    46 // -----------------------------------------------------------------------------
       
    47 // ExecuteL
       
    48 //
       
    49 // -----------------------------------------------------------------------------
       
    50 //
       
    51 LOCAL_D TInt ExecuteL()
       
    52 	{
       
    53 	TInt err = KErrNoMemory;
       
    54 		
       
    55 	RFile file;
       
    56 		
       
    57 	// Adopt the task file from the Task Scheduler
       
    58 	err = file.AdoptFromCreator(TScheduledTaskFile::FsHandleIndex(),
       
    59 									TScheduledTaskFile::FileHandleIndex());
       
    60 	User::LeaveIfError(err);
       
    61 	
       
    62 	TRAP(err, SynchronizeL(file));
       
    63 	
       
    64 	file.Close();
       
    65 	
       
    66 	User::LeaveIfError(err);		
       
    67 	return err;
       
    68 	}
       
    69 
       
    70 
       
    71 // -----------------------------------------------------------------------------
       
    72 // Execute
       
    73 //
       
    74 // -----------------------------------------------------------------------------
       
    75 //
       
    76 LOCAL_D TInt Execute()
       
    77 	{
       
    78 	TInt err = KErrNoMemory;
       
    79 	
       
    80 	// construct and install active scheduler
       
    81 	CActiveScheduler* scheduler = new CActiveScheduler;
       
    82 	if (!scheduler)
       
    83 		{
       
    84 		return err;
       
    85 		}
       
    86 	CActiveScheduler::Install(scheduler);
       
    87 
       
    88 	CTrapCleanup* cleanupStack = CTrapCleanup::New();
       
    89 	
       
    90 	if (cleanupStack)
       
    91 		{
       
    92         TRAP(err, ExecuteL());
       
    93 		delete cleanupStack;
       
    94 		}
       
    95 
       
    96     delete scheduler;
       
    97     
       
    98 	return err;
       
    99 	}
       
   100 
       
   101 
       
   102 // -----------------------------------------------------------------------------
       
   103 // E32Main
       
   104 //
       
   105 // -----------------------------------------------------------------------------
       
   106 //
       
   107 GLDEF_C TInt E32Main()
       
   108 	{
       
   109 	return Execute();
       
   110 	}
       
   111 
       
   112 
       
   113