1 /* |
|
2 * Copyright (c) 2002-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: Implementation of obexservicemanager core. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 |
|
21 #include "obexserviceman.h" |
|
22 #include "obexsm.h" |
|
23 #include "SrcsSession.h" |
|
24 #include "SrcsServiceManager.h" |
|
25 #include "debug.h" |
|
26 #include "SrcsSecurityPolicy.h" |
|
27 #include "obexutilsmessagehandler.h" |
|
28 |
|
29 |
|
30 // ================= MEMBER FUNCTIONS ======================= |
|
31 |
|
32 // --------------------------------------------------------- |
|
33 // C++ default constructor can NOT contain any code, that |
|
34 // might leave. |
|
35 // --------------------------------------------------------- |
|
36 // |
|
37 CObexSM::CObexSM(TInt aPriority) |
|
38 // aPriority: priority of AO |
|
39 // KSrcsPolicy: TPolicy structure of Faxmodem |
|
40 :CPolicyServer( aPriority, KSrcsPolicy ) |
|
41 { |
|
42 } |
|
43 // --------------------------------------------------------- |
|
44 // Destructor |
|
45 // --------------------------------------------------------- |
|
46 // |
|
47 CObexSM::~CObexSM() |
|
48 { |
|
49 FLOG(_L("[SRCS]\tserver\tCSrcs: Destructor") ); |
|
50 |
|
51 delete iServiceHandler; |
|
52 |
|
53 } |
|
54 |
|
55 // --------------------------------------------------------- |
|
56 // NewL |
|
57 // --------------------------------------------------------- |
|
58 // |
|
59 CObexSM* CObexSM::NewL() |
|
60 { |
|
61 FLOG(_L("[SRCS]\tserver\tCSrcs: NewL") ); |
|
62 CObexSM* self=new(ELeave) CObexSM( EPriorityBackground ); |
|
63 CleanupStack::PushL(self); |
|
64 self->ConstructL(); |
|
65 CleanupStack::Pop(); |
|
66 return self; |
|
67 } |
|
68 |
|
69 // --------------------------------------------------------- |
|
70 // ConstructL |
|
71 // --------------------------------------------------------- |
|
72 // |
|
73 void CObexSM::ConstructL() |
|
74 { |
|
75 FLOG(_L("[SRCS]\tserver\tCSrcs: ConstrucL") ); |
|
76 // and class for service handling |
|
77 iServiceHandler = CSrcsServiceManager::NewL(); |
|
78 // Then we are ready to start server |
|
79 StartL(KSrcsName); |
|
80 // Do server initialisation |
|
81 InitialiseServerL(); |
|
82 } |
|
83 |
|
84 // --------------------------------------------------------- |
|
85 // NewSessionL |
|
86 // Create session(s) to client(s) |
|
87 // |
|
88 // --------------------------------------------------------- |
|
89 // |
|
90 CSession2* CObexSM::NewSessionL( const TVersion& aVersion, const RMessage2& ) const |
|
91 { |
|
92 FLOG(_L("[SRCS]\tserver\tCSrcs NewSessionL")); |
|
93 |
|
94 // check we're the right version |
|
95 TVersion srvVersion(KSrcsMajorVersionNumber, |
|
96 KSrcsMinorVersionNumber, |
|
97 KSrcsBuildVersionNumber); |
|
98 |
|
99 if (!User::QueryVersionSupported(srvVersion,aVersion)) |
|
100 { |
|
101 User::Leave(KErrNotSupported); |
|
102 } |
|
103 |
|
104 // make new session |
|
105 |
|
106 return ( CSrcsSession::NewL(const_cast<CObexSM*>(this)) ); |
|
107 } |
|
108 |
|
109 // --------------------------------------------------------- |
|
110 // InitialiseServerL |
|
111 // Start Media Watchers at this point. |
|
112 // --------------------------------------------------------- |
|
113 // |
|
114 void CObexSM::InitialiseServerL() |
|
115 { |
|
116 FLOG(_L("[SRCS]\tserver\tSrcs Initialise Server")); |
|
117 // If phone battery is removed during file receiving, |
|
118 // There will be two temp file objects left in Received Folders. |
|
119 // We clean those temp files here. |
|
120 TFileName filename; |
|
121 TObexUtilsMessageHandler::RemoveTemporaryRFileL (filename); |
|
122 FLOG(_L("[SRCS]\tserver\tSrcs Initialize server complete.")); |
|
123 } |
|
124 |
|
125 // --------------------------------------------------------- |
|
126 // ManageServices |
|
127 // Initialise services according to parameter value. |
|
128 // --------------------------------------------------------- |
|
129 // |
|
130 TInt CObexSM::ManageServices(TSrcsTransport aTransport, TBool aState, |
|
131 MObexSMRequestObserver* aObserver, const RMessage2& aMessage) |
|
132 { |
|
133 FLOG(_L("[SRCS]\tserver\tSrcs ManageServicesL")); |
|
134 // Simply forward call |
|
135 return iServiceHandler->ManageServices( aTransport, aState, aObserver, aMessage); |
|
136 } |
|
137 // --------------------------------------------------------- |
|
138 // IncSessionCount |
|
139 // Increase session count. |
|
140 // --------------------------------------------------------- |
|
141 // |
|
142 void CObexSM::IncSessionCount() |
|
143 { |
|
144 FLOG(_L("[SRCS]\tserver\tSrcs IncSessionCount")); |
|
145 iSessionCount++; |
|
146 } |
|
147 // --------------------------------------------------------- |
|
148 // DecSessionCount |
|
149 // Decrease session count |
|
150 // --------------------------------------------------------- |
|
151 // |
|
152 void CObexSM::DecSessionCount() |
|
153 { |
|
154 FLOG(_L("[SRCS]\tserver\tSrcs DecSessionCount")); |
|
155 if ( iSessionCount>0 ) |
|
156 { |
|
157 iSessionCount--; |
|
158 if (iSessionCount == 0) |
|
159 { |
|
160 FLOG(_L("[SRCS]\tserver\tSrcs StoppingServer")); |
|
161 CActiveScheduler::Stop(); |
|
162 } |
|
163 } |
|
164 } |
|
165 // End of file |
|