1 // Copyright (c) 1997-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
29 const TInt KErrIrtranpPeerDoesNotHaveIrtranp = -5530;
31 _LIT8(KDefaultPMID, "\x08\x00\x74\x00\x00\x00\x00\x01"); //Casio's number
32 _LIT8(KNullPMID, "\x00\x00\x00\x00\x00\x00\x00\x00");
35 /** Encodes the size of a picture.
39 /** Quarter VGA, 320x240 pixels. */
41 /** Full VGA, 640x480 pixels. */
43 /** Super VGA, 800x600 pixels. */
45 /** XGA, 1024x768 pixels. */
47 /** Super XGA, 1280x960 pixels. */
49 /** Arbitrary size. There is no implied width and height. These values must be
50 explicitly supplied. */
54 NONSHARABLE_CLASS(TTranpConfig)
56 /** Encapsulates configuration parameters for a session.
62 IMPORT_C TTranpConfig();
63 IMPORT_C ~TTranpConfig();
65 IMPORT_C void SetPrimaryMachine(const TDesC8& aPMID);
66 IMPORT_C void SetSecondaryMachine(const TDesC8& aSMID);
68 IMPORT_C const TDesC8& PrimaryMachine();
69 IMPORT_C const TDesC8& SecondaryMachine();
75 // This data padding has been added to help prevent future binary compatibility breaks
76 // Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
82 // Encapsulation the UPF file format.
84 NONSHARABLE_CLASS(TTranpPicture)
86 /** Represents a picture in Unified Picture Format (UPF), a standard for image
87 data transmitted via infrared communication.
89 An object of this type is used when transmitting pictures using the IrTranP
92 A received picture can be saved as a JPEG type for viewing or it can be saved
97 friend class CTranpProtocol;
99 IMPORT_C void SetFilename(const TDesC8& aName);
100 IMPORT_C void SetLongFilename(const TDesC8& aName);
101 IMPORT_C void SetTime(const TDesC8& aTime);
103 IMPORT_C const TDesC8& Filename();
104 IMPORT_C const TDesC8& LongFilename();
105 IMPORT_C const TDesC8& Time();
106 IMPORT_C const TDesC8* Picture();
108 IMPORT_C void SetDesiredLatticeSize(TLatticeSize aSize, TInt iWidth = 0, TInt iHeight = 0); // Default is EVGA
109 IMPORT_C void GetLatticeSize(TLatticeSize& aSize, TInt& iWidth, TInt& iHeight);
111 IMPORT_C const TDesC8* GetThumbNail();
113 IMPORT_C TInt SaveAsJpeg(const TFileName& aFileName);
114 IMPORT_C TInt LoadFromJpeg(const TFileName& aFileName);
115 IMPORT_C TInt SaveAsUPF(const TFileName& aFileName);
116 IMPORT_C TInt LoadFromUPF(const TFileName& aFileName);
119 IMPORT_C TTranpPicture();
120 IMPORT_C ~TTranpPicture();
123 TBuf8<31> iFilename; // fomatted in DOS 8.3 format
124 TBuf8<256> iLongFilename; // in SJIS or ISO8859-1 [Latin-1]
125 TBuf8<14> iTime; // Time string in format YYYYMMDDHHMMSS
126 TPtrC8 iPicture; // Pointer to a buffer conatining the image data [JPEG format]
127 TDesC8* iUPFPicture; // Pointer to a buffer conatining the image data [UPF format]
128 TPtrC8 iThumbNail; // Pointer to a buffer conatining the thumbnail image data [JPEG format] Not implemented.
129 TLatticeSize iLatticeSize; // Size of picture
130 TInt iWidth; // QVGA:=320x240, VGA:=640x480, SVGA:=800x600, XGA:=1024x768, SXGA:=1280x960, FREE:=m x n
132 TInt iX; // Aspect Ratio iX:iY
136 // This data padding has been added to help prevent future binary compatibility breaks
137 // Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
143 // Callback interface for Asynchrnous requests
145 class MTranpNotification
146 /** A callback interface providing notification of events that occur during a picture
147 transmission session.
149 Users of a picture transmission session must derive from this class an provide
150 implementation for all of the pure virtual functions.
154 @see CTranpSession */
158 /** This function is called when a peer device connects successfully to the host
159 device following an attempt to receive a picture. */
160 virtual void Connected() = 0;
162 /** This function is called when a peer device disconnects or is disconnected from
164 virtual void Disconnected() =0;
166 /** This function is called when the reception of picture data is complete. */
167 virtual void GetComplete() = 0;
169 /** This function is called during the sending or receiving of picture data and
170 indicates the percentage of the data that has been transmitted.
172 @param aPercent The percentage of picture data transmitted. */
173 virtual void ProgressIndication(TInt aPercent) = 0;
175 /** This function is called when the sending of picture data is complete. */
176 virtual void PutComplete() = 0;
178 /** This function is called when an operation querying the processing ability of
179 a peer device completes. */
180 virtual void QueryComplete(/*return result from query [what]*/)= 0;
182 /** This function is called when the connection with the peer device drops during
183 picture data transmission.
185 @param aError An error code associated with the connection drop. Normally,
186 one of the system wide error codes. */
187 virtual void Error(TInt aError) =0;
190 Returns a null aObject if the extension is not implemented, or a pointer to another interface if it is.
191 @param aInterface UID of the interface to return
192 @param aObject the container for another interface as specified by aInterface
194 IMPORT_C virtual void MTN_ExtensionInterfaceL(TUid aInterface, void*& aObject);
197 class CTranpProtocol;
199 NONSHARABLE_CLASS(CTranpSession) : public CBase
201 /** Encapsulates the behaviour for sending a picture to a peer device and for receiving
202 a picture from a peer device.
209 /** The type of information required from a peer device. */
211 /** Request still-information from the peer, e.g. resolution and size. */
213 /** Request information about the peer's battery status and free memory. */
215 /** Request how many commands can be executed in one SCEP session. */
220 // Constructs a TranP Session
221 IMPORT_C static CTranpSession* NewL(MTranpNotification& aNotifier);
224 void ConstructL(MTranpNotification& aNotifier);
227 // Methods for establishing a connection
228 IMPORT_C void Connect();
229 IMPORT_C void Disconnect();
230 IMPORT_C void Abort();
231 // Query capabilities of peer
232 IMPORT_C void Query(TTranP aWhat);
233 // Receive picture from peer
234 IMPORT_C void Get(TTranpPicture& aPicture);
235 // Send picture to peer
236 IMPORT_C void Put(const TTranpPicture& aPicture);
237 // Change configuration parameters
238 IMPORT_C void Config(const TTranpConfig& aConfig);
239 IMPORT_C TTranpConfig Config() const;
240 IMPORT_C ~CTranpSession();
246 CTranpProtocol* iTranpProtocol;
247 TTranpConfig iConfig;