|
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include <e32cons.h> |
|
17 |
|
18 #include <lbs.h> |
|
19 #include <lbs/lbsx3p.h> |
|
20 #include <e32test.h> |
|
21 |
|
22 // Test |
|
23 _LIT(KTestName, "X3P Test"); |
|
24 LOCAL_D RTest test(KTestName); |
|
25 |
|
26 void mainL() |
|
27 { |
|
28 // An example of how to use the X3P API to send the current position to a third party. |
|
29 // Two requests are made simultaneously and then the test harness waits for both to complete. |
|
30 // For the sake of simplicity, the example calls User::WaitForRequest rather than using |
|
31 // active objects. |
|
32 |
|
33 test.Printf(_L("Transmit current position to both mother and sister\n")); |
|
34 RLbsTransmitPositionServer server; |
|
35 CleanupClosePushL(server); |
|
36 User::LeaveIfError(server.Connect()); |
|
37 |
|
38 RLbsTransmitPosition transmitPositionToMother; |
|
39 |
|
40 |
|
41 CleanupClosePushL(transmitPositionToMother); |
|
42 User::LeaveIfError(transmitPositionToMother.Open(server)); |
|
43 |
|
44 TLbsTransmitPositionOptions transmitPositionOptions(5000000); |
|
45 transmitPositionToMother.SetTransmitOptions(transmitPositionOptions); |
|
46 |
|
47 TRequestStatus transmitPositionToMotherStatus; |
|
48 _LIT(KMothersPhoneNumber,"01223987654"); |
|
49 |
|
50 |
|
51 //create a TPositionInfo object to hold the position transmitted |
|
52 TPositionInfo posInfo; |
|
53 |
|
54 // Send with priority of 6 |
|
55 transmitPositionToMother.TransmitPosition(KMothersPhoneNumber, 6, transmitPositionToMotherStatus, posInfo ); |
|
56 |
|
57 RLbsTransmitPosition transmitPositionToSis; |
|
58 CleanupClosePushL(transmitPositionToSis); |
|
59 User::LeaveIfError(transmitPositionToSis.Open(server)); |
|
60 |
|
61 TRequestStatus transmitPositionToSisterStatus; |
|
62 _LIT(KSistersEmailAddress,"sister@relative.com"); |
|
63 // This time send with priority of 7 - one higher than previous |
|
64 transmitPositionToSis.TransmitPosition(KSistersEmailAddress, 7, transmitPositionToSisterStatus, posInfo); |
|
65 |
|
66 // Wait for both to complete |
|
67 User::WaitForRequest(transmitPositionToMotherStatus); |
|
68 User::WaitForRequest(transmitPositionToSisterStatus); |
|
69 |
|
70 if ((transmitPositionToMotherStatus == KErrNone) && (transmitPositionToSisterStatus == KErrNone)) |
|
71 { |
|
72 test.Printf(_L("Two positions successfully transmitted\n")); |
|
73 } |
|
74 else |
|
75 { |
|
76 test.Printf(_L("Positions NOT successfully transmitted\n")); |
|
77 } |
|
78 |
|
79 CleanupStack::PopAndDestroy(3, &server); |
|
80 |
|
81 } |
|
82 |
|
83 |
|
84 void doMainL() |
|
85 { |
|
86 TRAPD(error, mainL()) |
|
87 if (error) |
|
88 test.Printf(_L("Error setting up the tests: %d\n"), error); |
|
89 } |
|
90 |
|
91 GLDEF_C TInt E32Main() |
|
92 { |
|
93 __UHEAP_MARK; |
|
94 test.Title(); |
|
95 test.Start(KTestName); |
|
96 |
|
97 CActiveScheduler* rootScheduler = new CActiveScheduler; |
|
98 CActiveScheduler::Install(rootScheduler); |
|
99 CTrapCleanup* theCleanup=CTrapCleanup::New(); |
|
100 |
|
101 TRAPD(ret,doMainL()); |
|
102 test.Printf(_L("\nTest Completion code: %d\n"), ret); |
|
103 test(ret==KErrNone); |
|
104 |
|
105 delete theCleanup; |
|
106 delete rootScheduler; |
|
107 |
|
108 test.End(); |
|
109 test.Close(); |
|
110 |
|
111 __UHEAP_MARKEND; |
|
112 return 0; |
|
113 } |
|
114 |
|
115 |
|
116 |
|
117 // |
|
118 // End of file |