epoc32/include/tranp.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:27:01 +0100
branchSymbian2
changeset 3 e1b950c65cb4
parent 0 061f57f2323e
child 4 837f303aceeb
permissions -rw-r--r--
Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
     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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // IrTranp API 
    15 // 
    16 //
    17 
    18 
    19 
    20 /**
    21  @file
    22  @publishedAll
    23  @released
    24 */
    25 
    26 #ifndef _TRANP_H_
    27 #define _TRANP_H_
    28 
    29 #include <e32base.h>
    30 
    31 const TInt KErrIrtranpPeerDoesNotHaveIrtranp = -5530;
    32 
    33 _LIT8(KDefaultPMID, "\x08\x00\x74\x00\x00\x00\x00\x01"); //Casio's number
    34 _LIT8(KNullPMID, "\x00\x00\x00\x00\x00\x00\x00\x00");
    35 
    36 enum TLatticeSize 
    37 /** Encodes the size of a picture.
    38 
    39 @see TTranpPicture */
    40 	{
    41 	/** Quarter VGA, 320x240 pixels. */
    42 	EQVGA,
    43 	/** Full VGA, 640x480 pixels. */
    44 	EVGA,
    45 	/** Super VGA, 800x600 pixels. */
    46 	ESVGA,
    47     /** XGA, 1024x768 pixels. */
    48 	EXGA,
    49 	/** Super XGA, 1280x960 pixels. */
    50 	ESXGA,
    51 	/** Arbitrary size. There is no implied width and height. These values must be 
    52 	explicitly supplied. */
    53 	EFREE
    54 };
    55 
    56 NONSHARABLE_CLASS(TTranpConfig)
    57 
    58 /** Encapsulates configuration parameters for a session.
    59 @publishedAll
    60 @released
    61 @see CTranpSession */
    62 	{
    63 public:
    64 	IMPORT_C TTranpConfig();
    65 	IMPORT_C ~TTranpConfig();
    66 
    67 	IMPORT_C void SetPrimaryMachine(const TDesC8& aPMID);
    68 	IMPORT_C void SetSecondaryMachine(const TDesC8& aSMID);
    69 
    70 	IMPORT_C const TDesC8& PrimaryMachine();
    71 	IMPORT_C const TDesC8& SecondaryMachine();
    72 
    73 private:
    74 	TBufC8<8> iPMID;
    75 	TBufC8<8> iSMID;
    76 
    77 	// This data padding has been added to help prevent future binary compatibility breaks	
    78 	// Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
    79 	TUint32     iPadding1; 
    80 	TUint32     iPadding2; 	
    81 	};
    82 
    83 //
    84 // Encapsulation the UPF file format.
    85 //
    86 NONSHARABLE_CLASS(TTranpPicture)
    87 
    88 /** Represents a picture in Unified Picture Format (UPF), a standard for image 
    89 data transmitted via infrared communication.
    90 
    91 An object of this type is used when transmitting pictures using the IrTranP 
    92 protocol.
    93 
    94 A received picture can be saved as a JPEG type for viewing or it can be saved 
    95 in native UPF format. 
    96 @publishedAll
    97 @released */
    98 	{
    99 friend class CTranpProtocol;
   100 public:
   101 	IMPORT_C void SetFilename(const TDesC8& aName);
   102 	IMPORT_C void SetLongFilename(const TDesC8& aName);    
   103 	IMPORT_C void SetTime(const TDesC8& aTime);
   104 
   105 	IMPORT_C const TDesC8& Filename();
   106 	IMPORT_C const TDesC8& LongFilename();
   107 	IMPORT_C const TDesC8& Time();
   108 	IMPORT_C const TDesC8* Picture();
   109 	
   110 	IMPORT_C void SetDesiredLatticeSize(TLatticeSize aSize, TInt iWidth = 0, TInt iHeight = 0); // Default is EVGA
   111 	IMPORT_C void GetLatticeSize(TLatticeSize& aSize, TInt& iWidth, TInt& iHeight);
   112 
   113 	IMPORT_C const TDesC8* GetThumbNail();
   114 
   115 	IMPORT_C TInt SaveAsJpeg(const TFileName& aFileName);
   116 	IMPORT_C TInt LoadFromJpeg(const TFileName& aFileName);
   117 	IMPORT_C TInt SaveAsUPF(const TFileName& aFileName);
   118 	IMPORT_C TInt LoadFromUPF(const TFileName& aFileName);
   119 
   120 public:
   121 	IMPORT_C TTranpPicture();
   122 	IMPORT_C ~TTranpPicture();
   123 
   124 private:
   125 	TBuf8<31> iFilename;		// fomatted in DOS 8.3 format
   126 	TBuf8<256> iLongFilename;	// in SJIS or ISO8859-1 [Latin-1]
   127 	TBuf8<14> iTime;			// Time string in format YYYYMMDDHHMMSS
   128 	TPtrC8 iPicture;			// Pointer to a buffer conatining the image data [JPEG format]
   129 	TDesC8* iUPFPicture;		// Pointer to a buffer conatining the image data [UPF format]
   130 	TPtrC8 iThumbNail;			// Pointer to a buffer conatining the thumbnail image data [JPEG format] Not implemented.
   131 	TLatticeSize iLatticeSize;	// Size of picture 
   132 	TInt iWidth;	// QVGA:=320x240, VGA:=640x480, SVGA:=800x600, XGA:=1024x768, SXGA:=1280x960, FREE:=m x n
   133 	TInt iHeight;
   134 	TInt iX;		// Aspect Ratio iX:iY
   135 	TInt iY;
   136 	HBufC8* iHeapData;
   137 	
   138 	// This data padding has been added to help prevent future binary compatibility breaks	
   139 	// Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
   140 	TUint32     iPadding1; 
   141 	TUint32     iPadding2; 	
   142 	};
   143 
   144 // 
   145 // Callback interface for Asynchrnous requests
   146 //
   147 class MTranpNotification
   148 /** A callback interface providing notification of events that occur during a picture 
   149 transmission session.
   150 
   151 Users of a picture transmission session must derive from this class an provide 
   152 implementation for all of the pure virtual functions.
   153 
   154 @publishedAll
   155 @released
   156 @see CTranpSession */
   157 	{
   158 public:
   159 	
   160 	/** This function is called when a peer device connects successfully to the host 
   161 	device following an attempt to receive a picture. */
   162 	virtual void Connected() = 0;
   163 	
   164 	/** This function is called when a peer device disconnects or is disconnected from 
   165 	the host device. */
   166 	virtual void Disconnected() =0;
   167 	
   168 	/** This function is called when the reception of picture data is complete. */
   169 	virtual void GetComplete() = 0;
   170 	
   171 	/** This function is called during the sending or receiving of picture data and 
   172 	indicates the percentage of the data that has been transmitted.
   173 	
   174 	@param aPercent The percentage of picture data transmitted. */
   175 	virtual void ProgressIndication(TInt aPercent) = 0;
   176 	
   177 	/** This function is called when the sending of picture data is complete. */
   178 	virtual void PutComplete() = 0;
   179 	
   180 	/** This function is called when an operation querying the processing ability of 
   181 	a peer device completes. */
   182 	virtual void QueryComplete(/*return result from query [what]*/)= 0;
   183 	
   184 	/** This function is called when the connection with the peer device drops during 
   185 	picture data transmission.
   186 	
   187 	@param aError An error code associated with the connection drop. Normally, 
   188 	one of the system wide error codes. */
   189 	virtual void Error(TInt aError) =0;
   190 
   191     /**
   192  	 Returns a null aObject if the extension is not implemented, or a pointer to another interface if it is.
   193 	 @param aInterface UID of the interface to return
   194 	 @param aObject the container for another interface as specified by aInterface
   195 	 */
   196 	IMPORT_C virtual void MTN_ExtensionInterfaceL(TUid aInterface, void*& aObject);	
   197 	};
   198 
   199 class CTranpProtocol;
   200 
   201 NONSHARABLE_CLASS(CTranpSession) : public CBase
   202 
   203 /** Encapsulates the behaviour for sending a picture to a peer device and for receiving 
   204 a picture from a peer device. 
   205 
   206 @publishedAll
   207 @released */
   208 	{
   209 public: 
   210     enum TTranP
   211     /** The type of information required from a peer device. */
   212     {
   213      /** Request still-information from the peer, e.g. resolution and size. */
   214      EReqImageInfo = 0, 
   215      /** Request information about the peer's battery status and free memory. */
   216      EReqStatus, 
   217      /** Request how many commands can be executed in one SCEP session. */
   218      EReqCommands
   219 	};
   220 
   221 public:
   222 	// Constructs a TranP Session
   223 	IMPORT_C static CTranpSession* NewL(MTranpNotification& aNotifier);
   224 
   225 private:
   226 	void ConstructL(MTranpNotification& aNotifier);
   227 
   228 public:
   229 	// Methods for establishing a connection
   230 	IMPORT_C void Connect();
   231 	IMPORT_C void Disconnect();
   232 	IMPORT_C void Abort();
   233 	// Query capabilities of peer
   234 	IMPORT_C void Query(TTranP aWhat);
   235 	// Receive picture from peer
   236 	IMPORT_C void Get(TTranpPicture& aPicture);
   237 	// Send picture to peer
   238 	IMPORT_C void Put(const TTranpPicture& aPicture);
   239 	// Change configuration parameters
   240 	IMPORT_C void Config(const TTranpConfig& aConfig);
   241 	IMPORT_C TTranpConfig Config() const;
   242 	IMPORT_C ~CTranpSession();
   243 
   244 private:
   245 	CTranpSession();	
   246 
   247 private:
   248 	CTranpProtocol* iTranpProtocol;
   249 	TTranpConfig iConfig;
   250 	};
   251 
   252 #endif //_TRANP_H_