|
1 // Copyright (c) 2001-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 // $Workfile: btsmtm.cpp $ |
|
15 // $Author: Stevep $ |
|
16 // $Revision: 11 $ |
|
17 // $Date: 25/03/02 8:49 $ |
|
18 // |
|
19 // |
|
20 |
|
21 //class include |
|
22 #include "btsmtm.h" |
|
23 |
|
24 //system includes |
|
25 #include <msventry.h> |
|
26 #include "btmtmcmds.h" //EBtMtmCmdSend |
|
27 |
|
28 //user includes |
|
29 #include <btheader.h> |
|
30 #include "btsendop.h" |
|
31 #include <btcmtm.h> |
|
32 |
|
33 EXPORT_C CBtSrvMtm* CBtSrvMtm::NewL(CRegisteredMtmDll& aRegisteredMtmDll, CMsvServerEntry* aEntry) |
|
34 /** |
|
35 * NewL factory function. Calls ReleaseLibrary() if construction fails. |
|
36 * |
|
37 * @param aRegisteredMtmDll Registration data for MTM DLL. |
|
38 * @param aEntry Context on which to operate. |
|
39 * @return Pointer to a newly constructed CBtSrvMtm. |
|
40 * @leave KErrXXX System-wide error codes |
|
41 */ |
|
42 { |
|
43 CBtSrvMtm* mysvrmtm = new CBtSrvMtm(aRegisteredMtmDll, aEntry); |
|
44 if (mysvrmtm==NULL) |
|
45 { |
|
46 aRegisteredMtmDll.ReleaseLibrary(); |
|
47 User::Leave(KErrNoMemory); |
|
48 } |
|
49 CleanupStack::PushL(mysvrmtm); |
|
50 mysvrmtm->ConstructL(); |
|
51 CleanupStack::Pop(); |
|
52 return mysvrmtm; |
|
53 } |
|
54 |
|
55 CBtSrvMtm::CBtSrvMtm(CRegisteredMtmDll& aRegisteredMtmDll, CMsvServerEntry* aEntry): |
|
56 CObexSrvMtm(aRegisteredMtmDll, aEntry) |
|
57 /** |
|
58 * Constructor. Calls CObexSrvMtm's constructor in initialisation list. |
|
59 * @param aRegisteredMtmDll Registration data for MTM DLL. |
|
60 * @param aEntry Context on which to operate. |
|
61 */ |
|
62 { |
|
63 __DECLARE_NAME(_S("CBtSrvMtm")); |
|
64 } |
|
65 |
|
66 |
|
67 EXPORT_C void CBtSrvMtm::StartCommandL (CMsvEntrySelection& aSelection, |
|
68 TInt aCommand, |
|
69 const TDesC8& aParameter, |
|
70 TRequestStatus& aStatus) |
|
71 /** |
|
72 * Instantiates and initiates a CBtServerSemdOperation class to begin sending the specified OBEX object |
|
73 * via Bluetooth. Called in response to InvokeAsyncFunctionL() in the client MTM, and passes through |
|
74 * all the arguments passed in to that function. Only supports aCommand==CBtClientMtm::EBtcCmdSend |
|
75 * |
|
76 * @param aSelection Entry to operate on. |
|
77 * @param aCommand Command to start. Only CBtClientMtm::EBtcCmdSend is supported. |
|
78 * @param aParameter Package buffer containing timeout, port and password info needed for the send operation. |
|
79 * @param aStatus Used to notify observer of completion. |
|
80 * @leave KErrNotSupported if aCommand!=CBtClientMtm::EBtcCmdSend |
|
81 * @leave KErrXXX System-wide error codes |
|
82 */ |
|
83 { |
|
84 switch (aCommand) |
|
85 { |
|
86 //The only supported command is EBtcCmdSend; switch statement used for potential future extension |
|
87 case EBtMtmCmdSend: |
|
88 { |
|
89 TPckgBuf<CBtClientMtm::SBtcCmdSendServerParams> sendParamsBuf; |
|
90 sendParamsBuf.Copy(aParameter); |
|
91 iTimeouts = sendParamsBuf().iTimeouts; |
|
92 |
|
93 // we're going to find out the port number ourselves in the send operation |
|
94 TPtrC connectPassword(sendParamsBuf().iConnectPassword); |
|
95 |
|
96 //Zeroth selection is the TMsvId of the entry to send. |
|
97 iEntry = iServerEntry->NewEntryL(aSelection[0]); |
|
98 |
|
99 //Construct a header |
|
100 CBtHeader* header = CBtHeader::NewL(); |
|
101 CleanupStack::PushL(header); |
|
102 |
|
103 //Get the entry's store |
|
104 CMsvStore* store = iEntry->ReadStoreL(); |
|
105 CleanupStack::PushL(store); |
|
106 |
|
107 //read the header from the store, and destroy the store |
|
108 header->RestoreL(*store); |
|
109 CleanupStack::PopAndDestroy(); //store |
|
110 |
|
111 aStatus = KRequestPending; |
|
112 //remember the request status for the observer |
|
113 iReportStatus = &aStatus; |
|
114 |
|
115 iStatus = KRequestPending; |
|
116 //Now make the send operation, which will start automatically. iStatus is passed in to |
|
117 //report completion. |
|
118 iSendOperation = CBtServerSendOperation::NewL(*iEntry, header->BtProtocolInfo(), |
|
119 iTimeouts.iConnectTimeout, iTimeouts.iPutTimeout, &connectPassword, iStatus); |
|
120 SetActive(); |
|
121 |
|
122 CleanupStack::PopAndDestroy(); //header |
|
123 break; |
|
124 } |
|
125 default: |
|
126 User::Leave(KErrNotSupported); |
|
127 } |
|
128 |
|
129 } |