williamr@2
|
1 |
// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
|
williamr@2
|
2 |
// All rights reserved.
|
williamr@2
|
3 |
// This component and the accompanying materials are made available
|
williamr@4
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
williamr@2
|
5 |
// which accompanies this distribution, and is available
|
williamr@4
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
williamr@2
|
7 |
//
|
williamr@2
|
8 |
// Initial Contributors:
|
williamr@2
|
9 |
// Nokia Corporation - initial contribution.
|
williamr@2
|
10 |
//
|
williamr@2
|
11 |
// Contributors:
|
williamr@2
|
12 |
//
|
williamr@2
|
13 |
// Description:
|
williamr@2
|
14 |
//
|
williamr@2
|
15 |
|
williamr@2
|
16 |
/**
|
williamr@2
|
17 |
@file
|
williamr@2
|
18 |
@publishedAll
|
williamr@2
|
19 |
@released
|
williamr@2
|
20 |
*/
|
williamr@2
|
21 |
|
williamr@2
|
22 |
#ifndef __OBEXBASEOBJECT_H
|
williamr@2
|
23 |
#define __OBEXBASEOBJECT_H
|
williamr@2
|
24 |
|
williamr@2
|
25 |
#include <obextypes.h>
|
williamr@2
|
26 |
#include <f32file.h>
|
williamr@2
|
27 |
|
williamr@2
|
28 |
const TUint32 KConnIDInvalid = 0xffffffff;
|
williamr@2
|
29 |
|
williamr@2
|
30 |
/**
|
williamr@2
|
31 |
Objects of this class are used to describe the objects to be transferred and
|
williamr@2
|
32 |
those received via Obex.
|
williamr@2
|
33 |
Consists of a number of attributes describing the object, along with
|
williamr@2
|
34 |
methods to set them. CObexBaseObject is an abstract base class, which defines
|
williamr@2
|
35 |
attribute setting and transferring functionality, but does not specify the
|
williamr@2
|
36 |
storage mechanism for the data part (called the object body) of the object.
|
williamr@2
|
37 |
This body part is defined in derived classes.
|
williamr@2
|
38 |
|
williamr@2
|
39 |
Object description attributes are tracked for validity automatically, so
|
williamr@2
|
40 |
that only valid attributes are sent to the remote machine. Also has the
|
williamr@2
|
41 |
concept of "header masks". This selects which of the various attributes
|
williamr@2
|
42 |
will actually be sent out/read in when the object is used in an operation
|
williamr@2
|
43 |
with the remote machine. Objects default to transferring all valid
|
williamr@2
|
44 |
attributes, use the header mask if restriction is required on the headers
|
williamr@2
|
45 |
exchanged.
|
williamr@2
|
46 |
|
williamr@2
|
47 |
See the various derived classes for description of object body
|
williamr@2
|
48 |
representation.
|
williamr@2
|
49 |
|
williamr@2
|
50 |
The common attributes are defined to be as close to the underlying OBEX
|
williamr@2
|
51 |
headers as usefully possible, hence any OBEX header specified as a Unicode
|
williamr@2
|
52 |
string (e.g. Name) translate to TDes (variant) EPOC descriptors, "byte
|
williamr@2
|
53 |
sequences" (e.g. Type) are TDes8 (or ASCII invariant), and byte and 32 bit
|
williamr@2
|
54 |
integers (e.g. Length) are TUint32s.
|
williamr@2
|
55 |
|
williamr@2
|
56 |
This class is not designed for user derivation (ie. outside of this dll).
|
williamr@2
|
57 |
|
williamr@2
|
58 |
@see CObexHeader
|
williamr@2
|
59 |
@publishedAll
|
williamr@2
|
60 |
@released
|
williamr@2
|
61 |
*/
|
williamr@2
|
62 |
NONSHARABLE_CLASS(CObexBaseObject) : public CBase
|
williamr@2
|
63 |
{
|
williamr@2
|
64 |
// required for access to iValidHeaders in CObexServer::CheckForConnectionID
|
williamr@2
|
65 |
friend class CObexServer;
|
williamr@2
|
66 |
|
williamr@2
|
67 |
public:
|
williamr@2
|
68 |
virtual ~CObexBaseObject();
|
williamr@2
|
69 |
IMPORT_C void SetHeaderMask(const TObexHeaderMask aHeaderMask);
|
williamr@2
|
70 |
IMPORT_C void SetNameL(const TDesC& aDesc);
|
williamr@2
|
71 |
IMPORT_C void SetTypeL(const TDesC8& aDesc);
|
williamr@2
|
72 |
IMPORT_C void SetLengthL(const TUint32 aLength);
|
williamr@2
|
73 |
IMPORT_C void SetTimeL(const TTime aLocalTime);
|
williamr@2
|
74 |
IMPORT_C void SetDescriptionL(const TDesC& aDesc);
|
williamr@2
|
75 |
IMPORT_C void SetTargetL(const TDesC8& aDesc);
|
williamr@2
|
76 |
IMPORT_C void AddHttpL(const TDesC8& aDesc);
|
williamr@2
|
77 |
IMPORT_C void SetAppParamL(const TDesC8& aDesc);
|
williamr@2
|
78 |
|
williamr@2
|
79 |
IMPORT_C void AddHeaderL(CObexHeader& aHeader);
|
williamr@2
|
80 |
IMPORT_C TInt BytesSent();
|
williamr@2
|
81 |
IMPORT_C TInt BytesReceived();
|
williamr@2
|
82 |
IMPORT_C TObexHeaderMask HeaderMask();
|
williamr@2
|
83 |
IMPORT_C TObexHeaderMask ValidHeaders();
|
williamr@2
|
84 |
IMPORT_C const TDesC& Name();
|
williamr@2
|
85 |
IMPORT_C const TDesC8& Type();
|
williamr@2
|
86 |
IMPORT_C TUint32 Length();
|
williamr@2
|
87 |
IMPORT_C const TTime Time();
|
williamr@2
|
88 |
IMPORT_C const TDesC& Description();
|
williamr@2
|
89 |
IMPORT_C const TDesC8& Target();
|
williamr@2
|
90 |
IMPORT_C const RPointerArray<HBufC8>* Http() const;
|
williamr@2
|
91 |
IMPORT_C const TDesC8& AppParam() const;
|
williamr@2
|
92 |
IMPORT_C void Reset();
|
williamr@2
|
93 |
IMPORT_C const CObexHeaderSet& HeaderSet() const;
|
williamr@2
|
94 |
IMPORT_C CObexHeaderSet& HeaderSet();
|
williamr@2
|
95 |
|
williamr@2
|
96 |
// Public unexported functions used by CObexServer, CObexClient, etc
|
williamr@2
|
97 |
enum TProgress { EContinue,EComplete,EError,ELastPacket };
|
williamr@2
|
98 |
TInt InitSend(TObexOpcode aOpcode);
|
williamr@2
|
99 |
TProgress PrepareNextSendPacket(CObexPacket& aPacket);
|
williamr@2
|
100 |
TInt InitReceive();
|
williamr@2
|
101 |
TProgress ParseNextReceivePacket(CObexPacket& aPacket);
|
williamr@2
|
102 |
void PrepareConnectionHeader( CObexPacket& aPacket );
|
williamr@2
|
103 |
void SetConnectionIdL(TUint32 aFourByte);
|
williamr@2
|
104 |
TUint32 ConnectionID();
|
williamr@2
|
105 |
TObexResponse GetLastError() const;
|
williamr@2
|
106 |
|
williamr@2
|
107 |
protected:
|
williamr@2
|
108 |
CObexBaseObject();
|
williamr@2
|
109 |
void GuessTypeFromExtL(const TDesC& aExt);
|
williamr@2
|
110 |
void ResetHeaders();
|
williamr@2
|
111 |
// Pure virtuals that all derived objects must implement
|
williamr@2
|
112 |
virtual void GetData(TInt aPos, TDes8& aDes) =0;
|
williamr@2
|
113 |
virtual void NewData(TInt aPos, TDes8& aDes) =0;
|
williamr@2
|
114 |
virtual TInt DataSize() =0;
|
williamr@2
|
115 |
virtual void ResetData() =0;
|
williamr@2
|
116 |
void CreateHeaderStorageDataL();
|
williamr@2
|
117 |
void SetTimeHeaderL(const TDesC8& aTimeDes);
|
williamr@2
|
118 |
void SetUtcTimeL(const TTime aUtcTime);
|
williamr@2
|
119 |
|
williamr@2
|
120 |
// Data
|
williamr@2
|
121 |
private:
|
williamr@2
|
122 |
TObexHeaderMask iHeaderMask;
|
williamr@2
|
123 |
TObexHeaderMask iValidHeaders;
|
williamr@2
|
124 |
|
williamr@2
|
125 |
mutable RPointerArray<HBufC8>* iHttp;
|
williamr@2
|
126 |
|
williamr@2
|
127 |
CObexHeaderSet* iHeaderSet;
|
williamr@2
|
128 |
|
williamr@2
|
129 |
TProgress iSendProgress;
|
williamr@2
|
130 |
TProgress iRecvProgress;
|
williamr@2
|
131 |
TObexOpcode iSendOpcode;
|
williamr@2
|
132 |
|
williamr@2
|
133 |
// This data item is used to store a CObexHeader which is used as a temporary
|
williamr@2
|
134 |
// store when finding headers
|
williamr@2
|
135 |
CObexHeader* iObexHeader;
|
williamr@2
|
136 |
|
williamr@2
|
137 |
TObexHeaderMask iSendHeaders;
|
williamr@2
|
138 |
TInt iSendBytes;
|
williamr@2
|
139 |
TInt iRecvBytes;
|
williamr@2
|
140 |
|
williamr@2
|
141 |
TObexResponse iLastError;
|
williamr@2
|
142 |
|
williamr@2
|
143 |
};
|
williamr@2
|
144 |
|
williamr@2
|
145 |
#endif // __OBEXBASEOBJECT_H
|