1 /* |
|
2 * Copyright (c) 2006-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: Common utility methods for DUN |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <e32base.h> |
|
20 #include "DunUtils.h" |
|
21 #include "DunDebug.h" |
|
22 |
|
23 // ======== MEMBER FUNCTIONS ======== |
|
24 |
|
25 // --------------------------------------------------------------------------- |
|
26 // Connects to comms server |
|
27 // --------------------------------------------------------------------------- |
|
28 // |
|
29 EXPORT_C TInt CDunUtils::ConnectCommsServer( RCommServ& aCommServer ) |
|
30 { |
|
31 FTRACE(FPrint(_L( "CDunUtils::ConnectCommsServer()") )); |
|
32 TInt retTemp; |
|
33 #ifndef PRJ_USE_NETWORK_STUBS |
|
34 retTemp = StartC32(); |
|
35 if ( retTemp!=KErrNone && retTemp!=KErrAlreadyExists ) |
|
36 { |
|
37 FTRACE(FPrint(_L( "CDunUtils::ConnectCommsServer() StartC32 %d" ), retTemp)); |
|
38 return retTemp; |
|
39 } |
|
40 #endif |
|
41 retTemp = aCommServer.Connect(); |
|
42 if ( retTemp != KErrNone ) |
|
43 { |
|
44 FTRACE(FPrint(_L( "CDunUtils::ConnectCommsServer() aCommServer.Connect %d" ), retTemp)); |
|
45 return retTemp; |
|
46 } |
|
47 FTRACE(FPrint(_L( "CDunUtils::ConnectCommsServer() complete") )); |
|
48 return KErrNone; |
|
49 } |
|
50 |
|
51 // --------------------------------------------------------------------------- |
|
52 // Sets RComm buffer length |
|
53 // --------------------------------------------------------------------------- |
|
54 // |
|
55 EXPORT_C TInt CDunUtils::SetRCommBufferLength( RComm& aComm, TInt aLength ) |
|
56 { |
|
57 FTRACE(FPrint(_L( "CDunUtils::SetRCommBufferLength()") )); |
|
58 TInt retTemp = aComm.SetReceiveBufferLength( aLength ); |
|
59 if ( retTemp != KErrNone ) |
|
60 { |
|
61 FTRACE(FPrint(_L( "CDunUtils::SetRCommBufferLength() (set failed) complete (%d)"), retTemp)); |
|
62 return retTemp; |
|
63 } |
|
64 TInt setLength = aComm.ReceiveBufferLength(); |
|
65 if ( setLength != aLength ) |
|
66 { |
|
67 FTRACE(FPrint(_L( "CDunUtils::SetRCommBufferLength() (get failed) complete") )); |
|
68 return KErrGeneral; |
|
69 } |
|
70 FTRACE(FPrint(_L( "CDunUtils::SetRCommBufferLength() complete") )); |
|
71 return KErrNone; |
|
72 } |
|