|
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 <obex/extensionapis/obexserverpacketaccessextension.h> |
|
17 #include <obexserver.h> |
|
18 #include <obex/internal/mobexserverrequestpacketnotifyregister.h> |
|
19 #include "obexextensionapifaults.h" |
|
20 |
|
21 //Category used for internal panics |
|
22 _LIT(KPanicCat, "ObexExtApis"); |
|
23 |
|
24 /** |
|
25 Factory function for CObexServerPacketAccessExtension. Will leave if the associated CObexServer |
|
26 does not support this extension type. |
|
27 |
|
28 Note that this object needs to be deleted before the CObexServer object it is registered to is |
|
29 deleted. |
|
30 |
|
31 @param aServer Reference to the instance of CObexServer being extended. |
|
32 @param aPacketNotify Reference to the instance of MObexRequestPacketNotify to be notified of |
|
33 incoming packets. Notifications will stop when this CObexServerPacketAccessExtension object is |
|
34 deleted. |
|
35 @return A pointer to a new CObexServerPacketAccessExtension object. |
|
36 */ |
|
37 EXPORT_C CObexServerPacketAccessExtension* CObexServerPacketAccessExtension::NewL(CObexServer& aServer, MObexServerRequestPacketNotify& aRequestPacketNotify) |
|
38 { |
|
39 CObexServerPacketAccessExtension* self = new (ELeave) CObexServerPacketAccessExtension(); |
|
40 CleanupStack::PushL(self); |
|
41 self->ConstructL(aServer, aRequestPacketNotify); |
|
42 CleanupStack::Pop(self); |
|
43 return self; |
|
44 } |
|
45 |
|
46 /** |
|
47 The destructor will not delete the instance of the MObexServerRequestPacketNotify |
|
48 it holds. It will signal to the CObexServer instance that packet notification is |
|
49 no longer required, and so re-allow another CObexServerPacketAccessExtension to bind |
|
50 to the CObexServer instance. |
|
51 |
|
52 This should be called before the CObexServer instance the object is registered to |
|
53 is deleted. |
|
54 */ |
|
55 CObexServerPacketAccessExtension::~CObexServerPacketAccessExtension() |
|
56 { |
|
57 if (iRequestPacketNotify) |
|
58 { |
|
59 iRequestPacketNotify->DeleteObexServerRequestPacketNotifyRegister(); |
|
60 } |
|
61 } |
|
62 |
|
63 /** |
|
64 Constructor. |
|
65 */ |
|
66 CObexServerPacketAccessExtension::CObexServerPacketAccessExtension() |
|
67 { |
|
68 |
|
69 } |
|
70 |
|
71 /** |
|
72 Performs the main construction of the CObexServerPacketAccessExtension. |
|
73 |
|
74 @param aServer The CObexServer instance to register request packet notification callbacks. |
|
75 @param aRequestPacketNotify The mixin instance that will receive notification of request packets. |
|
76 */ |
|
77 void CObexServerPacketAccessExtension::ConstructL(CObexServer& aServer, MObexServerRequestPacketNotify& aRequestPacketNotify) |
|
78 { |
|
79 iRequestPacketNotify = static_cast<MObexServerRequestPacketNotifyRegister*>(aServer.ExtensionInterfaceL(KObexServerRequestPacketNotifyRegisterInterface)); |
|
80 // by here we should have a correctly cast instance, as otherwise we should have already left. |
|
81 __ASSERT_ALWAYS(iRequestPacketNotify, User::Panic(KPanicCat, EInterfaceInstanceIsANullPointer)); |
|
82 iRequestPacketNotify->SetObexServerRequestPacketObserver(aRequestPacketNotify); |
|
83 } |
|
84 |