00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include <QStringList>
00033 #include "nfcshareexample.h"
00034
00035
00036
00037
00038
00039
00040 NfcShareExample::NfcShareExample()
00041 {
00042 mNfcShare = new XQNfcShare(this);
00043
00044
00045 connect( mNfcShare, SIGNAL( busy(bool) ), this, SLOT( handleNfcShareBusy(bool) ) );
00046 connect( mNfcShare, SIGNAL( easySetupStarted() ), this, SLOT( handleEasySetupStarted()) );
00047 connect( mNfcShare, SIGNAL( shareStarted() ), this, SLOT( handleShareStarted() ) );
00048 connect( mNfcShare, SIGNAL( shareCompleted() ), this, SLOT( handleShareCompleted() ) );
00049 connect( mNfcShare, SIGNAL( easySetupCompleted() ), this, SLOT( handleEasySetupCompleted() ) );
00050 connect( mNfcShare, SIGNAL( error(XQNfcShare::Error) ), this, SLOT( handleNfcShareError(XQNfcShare::Error) ) );
00051 }
00052
00053
00054
00055
00056 NfcShareExample::~NfcShareExample()
00057 {
00058 if(mNfcShare)
00059 {
00060 delete mNfcShare;
00061 }
00062 }
00063
00067 void NfcShareExample::handleNfcShareBusy( bool value )
00068 {
00069 if(value == true){
00070 mDisplayText.append( "Nfc share is busy\n" );
00071 mDisplayText.append( "Wait till it completes your request.\n" );
00072 }
00073 else{
00074 mDisplayText.append( "Nfc share is not busy\n" );
00075 }
00076 emit displayText( mDisplayText );
00077 }
00078
00082 void NfcShareExample::handleEasySetupStarted()
00083 {
00084 mDisplayText.append( "Nfc share easy setup started\n" );
00085 emit displayText( mDisplayText );
00086 }
00087
00091 void NfcShareExample::handleEasySetupCompleted()
00092 {
00093 mDisplayText.append( "Nfc share easy setup completed\n" );
00094
00095
00096 if( mNfcShare->bearerType()== XQNfcShare::NoBearer ){
00097 mDisplayText.append( "Bearer type : No Bearer\n" );
00098 }
00099 else if( mNfcShare->bearerType()== XQNfcShare::Bluetooth ){
00100 mDisplayText.append( "Bearer type : Bluetooth\n" );
00101 mDisplayText.append( "Device Address : " );
00102 mDisplayText.append( mNfcShare->bluetoothDeviceAddress() );
00103 mDisplayText.append( "\nDevice Name : " );
00104 mDisplayText.append( mNfcShare->bluetoothDeviceName() );
00105 mDisplayText.append( "\n" );
00106 }
00107 emit displayText( mDisplayText );
00108 }
00109
00113 void NfcShareExample::handleShareStarted()
00114 {
00115 mDisplayText.append( "share started\n" );
00116
00117
00118 if( mNfcShare->bearerType()== XQNfcShare::NoBearer ){
00119 mDisplayText.append( "Bearer type : No Bearer\n" );
00120 }
00121 else if( mNfcShare->bearerType()== XQNfcShare::Bluetooth ){
00122 mDisplayText.append( "Bearer type : Bluetooth\n" );
00123 }
00124 mDisplayText.append( "Device Address : " );
00125 mDisplayText.append(mNfcShare->bluetoothDeviceAddress());
00126 mDisplayText.append( "\nDevice Name : " );
00127 mDisplayText.append(mNfcShare->bluetoothDeviceName());
00128
00129
00130 if( mShareOption == NfcShareExample::Single ){
00131 mDisplayText.append( "\nSharing single file." );
00132 mNfcShare->shareFile( "c:\\data\\dailymeeting.ics" );
00133 }
00134 else if( mShareOption == NfcShareExample::Multiple ){
00135 mDisplayText.append( "\nSharing multiple files.\n" );
00136 mNfcShare->shareFiles( QStringList()<<"c:\\data\\mycontact.vcf"<<"c:\\data\\dailymeeting.ics" );
00137 }
00138
00139 emit displayText(mDisplayText);
00140 }
00141
00145 void NfcShareExample::handleShareCompleted()
00146 {
00147 mDisplayText.append( "share completed\n" );
00148 emit displayText( mDisplayText );
00149 }
00150
00154 void NfcShareExample::handleNfcShareError( XQNfcShare::Error aError )
00155 {
00156 if( aError == XQNfcShare::NoError )
00157 mDisplayText.append( "Nfc share error cannot be determined\n" );
00158
00159
00160 else if( aError == XQNfcShare::NfcNotAvailable )
00161 mDisplayText.append( "Nfc is not available\n" );
00162
00163
00164 else if( aError == XQNfcShare::DeviceNotAvailable )
00165 mDisplayText.append( "Device is not available\n" );
00166
00167
00168 else if( aError == XQNfcShare::SystemError )
00169 mDisplayText.append( "System error\n" );
00170
00171
00172 else if( aError == XQNfcShare::ConnectionDenied )
00173 mDisplayText.append( "Connection denied error\n" );
00174
00175
00176 else if( aError == XQNfcShare::Cancelled )
00177 mDisplayText.append( "Cancelled error\n" );
00178
00179 emit displayText( mDisplayText );
00180 }
00181
00182
00183
00184
00185
00186
00187
00188 void NfcShareExample::startEasySetup()
00189 {
00190 mNfcShare->easySetup();
00191 }
00192
00196 void NfcShareExample::startEasySetupAndPair()
00197 {
00198 mNfcShare->easySetupAndPair();
00199 }
00200
00201
00202
00203
00204 void NfcShareExample::cancel()
00205 {
00206 mNfcShare->cancel();
00207 }
00208
00209
00210
00211
00212 void NfcShareExample::shareFile()
00213 {
00214 mShareOption = NfcShareExample::Single;
00215 mNfcShare->share();
00216 }
00217
00221 void NfcShareExample::shareFiles()
00222 {
00223 mShareOption = NfcShareExample::Multiple;
00224 mNfcShare->share();
00225 }
00226
00230 void NfcShareExample::clear()
00231 {
00232 mDisplayText.clear();
00233 }