|
1 // Copyright (c) 2007-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 <bluetooth/eirclient.h> |
|
17 #include <e32uid.h> |
|
18 #include <e32base.h> |
|
19 #include <bluetooth/eirmanshared.h> |
|
20 #include "eirmanclientlogger.h" |
|
21 |
|
22 // Don't allocate memory for dedicated message slots, just use the ones from |
|
23 // the global pool. |
|
24 const TInt KAsyncMessageSlots = -1; |
|
25 |
|
26 /* REirMan Client side class |
|
27 REirMan provides access to EIR Manager API |
|
28 */ |
|
29 REirMan::REirMan() |
|
30 : iBytesAvailablePckg(0) |
|
31 { |
|
32 LOG_FUNC |
|
33 } |
|
34 |
|
35 /** |
|
36 Connect the Handle to the Server |
|
37 Must be called before all other methods except Version() |
|
38 |
|
39 @return KErrNone if successful, otherwise the error that occurred |
|
40 */ |
|
41 void REirMan::Connect(TRequestStatus& aStatus) |
|
42 { |
|
43 LOG_FUNC |
|
44 |
|
45 // Don't start the Bluetooth Protocol Stack. It's either loaded and we'll use it, or else this will fail |
|
46 TInt err = CreateSession(KEirManServerName, Version(), KAsyncMessageSlots, EIpcSession_Unsharable, NULL, &aStatus); |
|
47 |
|
48 LOG1(_L8("CreateSession returned %d"), err); |
|
49 |
|
50 if(err != KErrNone) |
|
51 { |
|
52 TRequestStatus* status = &aStatus; |
|
53 *status = KRequestPending; |
|
54 User::RequestComplete(status, err); |
|
55 } |
|
56 } |
|
57 |
|
58 /** |
|
59 |
|
60 */ |
|
61 void REirMan::SpaceAvailableNotification(TUint& aBytesAvailable, TRequestStatus& aStatus) |
|
62 { |
|
63 LOG_FUNC |
|
64 |
|
65 iBytesAvailablePckg.Set((TUint8*)&aBytesAvailable, sizeof(TUint), sizeof(TUint)); |
|
66 |
|
67 SendReceive(EEirManSpaceAvailableNotification, TIpcArgs(&iBytesAvailablePckg), aStatus); |
|
68 } |
|
69 |
|
70 /** |
|
71 |
|
72 */ |
|
73 void REirMan::CancelSpaceAvailableNotification() |
|
74 { |
|
75 LOG_FUNC |
|
76 SendReceive(EEirManCancelSpaceAvailableNotification); |
|
77 } |
|
78 |
|
79 /** |
|
80 |
|
81 */ |
|
82 void REirMan::SetData(const TDesC8& aData, TEirDataMode aDataMode, TRequestStatus& aStatus) |
|
83 { |
|
84 LOG_FUNC |
|
85 |
|
86 SendReceive(EEirManSetData, TIpcArgs(&aData, aDataMode), aStatus); |
|
87 } |
|
88 |
|
89 /** |
|
90 |
|
91 */ |
|
92 void REirMan::RegisterTag(TEirTag aEirTag, TRequestStatus& aStatus) |
|
93 { |
|
94 LOG_FUNC |
|
95 |
|
96 SendReceive(EEirManRegisterTag, TIpcArgs(aEirTag), aStatus); |
|
97 } |
|
98 |
|
99 // private |
|
100 /** |
|
101 Extract the version of the server providing the REirMan API |
|
102 |
|
103 @return Version of the server |
|
104 */ |
|
105 TVersion REirMan::Version() const |
|
106 { |
|
107 return(TVersion(KEirManSrvMajorVersionNumber,KEirManSrvMinorVersionNumber,KEirManSrvBuildVersionNumber)); |
|
108 } |
|
109 |
|
110 TInt REirMan::RegisterTag(TEirTag aEirTag) |
|
111 { |
|
112 LOG_FUNC |
|
113 |
|
114 TInt ret = SendReceive(EEirManRegisterTag, TIpcArgs(aEirTag)); |
|
115 |
|
116 return ret; |
|
117 } |
|
118 |
|
119 void REirMan::NewData(TInt aRequiredLength, TRequestStatus& aStatus) |
|
120 { |
|
121 LOG_FUNC |
|
122 |
|
123 SendReceive(EEirManNewData, TIpcArgs(aRequiredLength), aStatus); |
|
124 } |
|
125 |