examples/Qt/qtnfctags/nfctagsdiscovery_symbian.h

00001 /*
00002  * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
00003  *    
00004  * Redistribution and use in source and binary forms, with or without
00005  * modification, are permitted provided that the following conditions are met:
00006  *    
00007  *  * Redistributions of source code must retain the above copyright notice, this
00008  *    list of conditions and the following disclaimer.
00009  *  * Redistributions in binary form must reproduce the above copyright notice,
00010  *    this list of conditions and the following disclaimer in the documentation
00011  *    and/or other materials provided with the distribution.
00012  *  * Neither the name of Nokia Corporation nor the names of its contributors
00013  *    may be used to endorse or promote products derived from this software
00014  *    without specific prior written permission.
00015  *    
00016  *    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00017  *    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00018  *    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00019  *    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00020  *    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00021  *    DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00022  *    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00023  *    CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00024  *    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00025  *    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00026  *    
00027  *    Description:  
00028  */
00029 
00030 #ifndef NFCDISCOVERY_SYMBIAN_H
00031 #define NFCDISCOVERY_SYMBIAN_H
00032 
00033 #include <e32base.h>
00034 #include <nfcserver.h>
00035 #include <nfctag.h>
00036 #include <nfctagsubscription.h>
00037 #include <nfcconnection.h>
00038 
00039 #include <nfctagdiscovery.h>
00040 #include <nfctagconnectionlistener.h>
00041 #include <nfcconnectioninfo.h>
00042 #include <ndefmessagelistener.h>
00043 #include <ndefdiscovery.h>
00044 #include <ndefmessage.h>
00045 #include <mifareclassicsector.h>
00046 
00047 
00048 // FORWARD DECLARATIONS
00049 class NfcTagsDiscovery;
00050 class MNfcConnection;
00051 class CNfcType1Connection;
00052 class CNfcType2Connection;
00053 class CNfcType3Connection;
00054 class CIso14443Connection;
00055 class CMifareClassicConnection;
00056 class CActiveWait;
00057 
00058 // CLASS DECLARATION
00059 // A Class that waits for a tag and then opens a connection to it.
00060 class NfcTagsDiscoveryPrivate : public CBase, public MNfcTagConnectionListener,
00061                                 public MNdefMessageListener
00062   {
00063 public:
00064     
00065     static NfcTagsDiscoveryPrivate* NewL(NfcTagsDiscovery *aPublicAPI);
00066     static NfcTagsDiscoveryPrivate* NewLC(NfcTagsDiscovery *aPublicAPI);
00067     virtual ~NfcTagsDiscoveryPrivate();
00068 
00069     enum TDiscoveryOptions
00070         {
00071         ETagDiscovery =0,
00072         ENdefDiscovery,
00073         EExchangeData
00074         };
00075     enum TTagOperations
00076         {
00077         EExchangeDataWithIso14443Tag,
00078         EWriteToClass1Tag,
00079         EReadFromClass1Tag,
00080         EWriteToClass2Tag,
00081         EReadFromClass2Tag,
00082         EUpdateClass3Tag,
00083         ECheckClass3Tag,
00084         EWriteToMifareTag,
00085         EReadFromMifareTag,
00086         };
00087 public:    
00088     // Search for NDEF messages.
00089     void StartNdefDiscovery(); 
00090     
00091     // Search for tags.
00092     void StartTagDiscovery();
00093     
00094     // Stop discovering tags/NDEF messages.
00095     void StopTagDiscovery();
00096     void StopNdefDiscovery();
00097     
00098     void TagOperationCompleted();
00099     
00100 private:    
00101     NfcTagsDiscoveryPrivate(NfcTagsDiscovery *aPublicAPI);
00102     void ConstructL(NfcTagsDiscovery *aPublicAPI);
00103 
00104     // From MNfcTagConnectionListener. 
00105     void TagDetected( MNfcTag* aNfcTag );  
00106     void TagLost();
00107        
00108     // From MNdefMessageListener.
00109     void MessageDetected( CNdefMessage* aMessage );
00110     
00111     // Exchange data between NFC enabled device and Iso14443 tag.
00112     void ExchangeDataWithIso14443Tag();
00113     
00114     // Read/Write data to Class1 tag.
00115     void WriteToClass1Tag();
00116     void ReadFromClass1Tag();
00117     
00118     // Read/Write to Class2 Tag.
00119     void WriteToClass2Tag();
00120     void ReadFromClass2Tag();
00121     
00122     // Update/Check information in Class3 Tag.
00123     void UpdateClass3Tag();
00124     void CheckClass3Tag();
00125     
00126     // Read/Write to Data Blocks of Mifare Tag.
00127     void WriteToMifareTag();
00128     void ReadFromMifareTag();
00129    
00130     // Display the information read from the tag.
00131     void ShowTagInformation();
00132     
00133 public:
00134     RBuf8 iWriteBuffer; 
00135     RBuf8 iReadBuffer; 
00136     TInt iTagOperation;
00137     NfcTagsDiscovery* iPublicAPI;
00138     
00139 private:
00140     RNfcServer iServer;
00141     CNfcTagDiscovery* iNfcTagDiscovery;  
00142     CNdefDiscovery* iNdefDiscovery; 
00143     TRequestStatus iStatus;
00144     CIso14443Connection* iIso14443Connection; 
00145     CNfcType1Connection* iNfcType1Connection;
00146     CNfcType2Connection* iNfcType2Connection;
00147     CNfcType3Connection* iNfcType3Connection;
00148     CMifareClassicConnection* iMifareClassicConnection;
00149     CNfcTagSubscription* iSubscription;
00150     CMifareClassicSector* iMifareClassicDataSector;
00151     CActiveWait* iWriteWait;
00152     CActiveWait* iReadWait;
00153     CActiveSchedulerWait* iWait;
00154     };
00155 
00156 #endif //NFCDISCOVERY_SYMBIAN.H
00157 

Generated by  doxygen 1.6.2