|
1 /* |
|
2 * Copyright (c) 2007 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: Entry point for executable, creates and then runs the |
|
15 * predefined contacts engine. |
|
16 * |
|
17 */ |
|
18 |
|
19 // System includes |
|
20 #include <e32base.h> // CActiveScheduler, CTrapCleanup |
|
21 |
|
22 // User includes |
|
23 #include "PdcEngine.h" // CPdcEngine |
|
24 |
|
25 // ======== MEMBER FUNCTIONS ======== |
|
26 |
|
27 // --------------------------------------------------------------------------- |
|
28 // Leaving main functions, creates the predefined contacts engine |
|
29 // and starts the active scheduler. |
|
30 // --------------------------------------------------------------------------- |
|
31 // |
|
32 void StartPdcEngineL() |
|
33 { |
|
34 // Create and install the active scheduler |
|
35 CActiveScheduler* activeScheduler = new (ELeave) CActiveScheduler(); |
|
36 CleanupStack::PushL( activeScheduler ); |
|
37 CActiveScheduler::Install( activeScheduler ); |
|
38 |
|
39 // Create the engine |
|
40 CPdcEngine* engine = CPdcEngine::NewLC(); |
|
41 |
|
42 RProcess::Rendezvous(KErrNone); |
|
43 |
|
44 // Check if the predefined contacts need to be added to contacts |
|
45 if ( engine->PredefinedContactsNeedAddingL() ) |
|
46 { |
|
47 // Begin the process of adding the predefined contacts |
|
48 engine->AddPredefinedContactsL(); |
|
49 |
|
50 // Start the active scheduler, the active scheduler is stopped |
|
51 // by the engine, when the adding of the predefined contacts |
|
52 // has finished. |
|
53 CActiveScheduler::Start(); |
|
54 } |
|
55 |
|
56 // Cleanup. |
|
57 CleanupStack::PopAndDestroy( engine ); |
|
58 CleanupStack::PopAndDestroy( activeScheduler ); |
|
59 } |
|
60 |
|
61 // --------------------------------------------------------------------------- |
|
62 // Main function of the predefined contacts executable. |
|
63 // --------------------------------------------------------------------------- |
|
64 // |
|
65 TInt E32Main() |
|
66 { |
|
67 __UHEAP_MARK; |
|
68 |
|
69 // Create the cleanup stack |
|
70 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
71 if( !cleanup ) |
|
72 { |
|
73 return KErrNoMemory; |
|
74 } |
|
75 |
|
76 // Start the engine |
|
77 TRAPD( err, StartPdcEngineL() ); |
|
78 |
|
79 // Cleanup. |
|
80 delete cleanup; |
|
81 |
|
82 __UHEAP_MARKEND; |
|
83 |
|
84 return err; |
|
85 } |
|
86 |
|
87 |