32 Song scanner interfaces with MPX Harvesting Framework to harvest |
26 Song scanner interfaces with MPX Harvesting Framework to harvest |
33 music files in the device. |
27 music files in the device. |
34 */ |
28 */ |
35 |
29 |
36 /*! |
30 /*! |
37 \fn void scanEnd() |
31 \fn void scanStarted() |
38 |
32 |
39 This signal is emitted when scanning is ended. |
33 This signal is emitted when scanning has started. |
40 |
34 |
41 \sa scan() |
35 */ |
42 */ |
36 |
|
37 /*! |
|
38 \fn void scanCountChanged( int count ) |
|
39 |
|
40 This signal is emitted to notify that scan count has changed. |
|
41 |
|
42 */ |
|
43 |
|
44 /*! |
|
45 \fn void scanFinished( int error, int itemsAdded ) |
|
46 |
|
47 Emitted when scanning has finished. |
|
48 |
|
49 */ |
43 |
50 |
44 /*! |
51 /*! |
45 Constructs the song scanner. |
52 Constructs the song scanner. |
46 */ |
53 */ |
47 MpSongScanner::MpSongScanner( MpMpxHarvesterFrameworkWrapper *wrapper, QObject *parent ) |
54 MpSongScanner::MpSongScanner( MpMpxHarvesterFrameworkWrapper *wrapper, QObject *parent ) |
48 : QObject( parent ), |
55 : QObject( parent ), |
49 mMpxWrapper(wrapper), |
56 mMpxHarvesterWrapper(wrapper), |
50 mScanProgressNote(0), |
57 mScanning( false ), |
51 mScanning(false) |
58 mAutomaticScan( true ) |
52 { |
59 { |
53 TX_ENTRY |
60 TX_ENTRY |
54 connect( mMpxWrapper, SIGNAL(scanStarted()), this, SLOT(handleScanStarted()) ); |
61 connect( mMpxHarvesterWrapper, SIGNAL( scanStarted() ), |
55 connect( mMpxWrapper, SIGNAL(scanEnded( int, int )), this, SLOT(handleScanEnded( int, int )) ); |
62 this, SIGNAL( scanStarted() ), Qt::QueuedConnection ); |
56 connect( mMpxWrapper, SIGNAL(scanCountChanged(int)), this, SLOT(handleScanCountChanged(int)) ); |
63 connect( mMpxHarvesterWrapper, SIGNAL( scanEnded( int, int ) ), |
|
64 this, SLOT( handleScanEnded( int, int ) ), Qt::QueuedConnection ); |
|
65 connect( mMpxHarvesterWrapper, SIGNAL( scanCountChanged( int ) ), |
|
66 this, SIGNAL( scanCountChanged( int ) ), Qt::QueuedConnection ); |
|
67 connect( mMpxHarvesterWrapper, SIGNAL( diskEvent( MpxDiskEvents ) ), |
|
68 this, SLOT( handleDiskEvent(MpxDiskEvents) ), Qt::QueuedConnection ); |
57 TX_EXIT |
69 TX_EXIT |
58 } |
70 } |
59 |
71 |
60 /*! |
72 /*! |
61 Destructs the song scanner. |
73 Destructs the song scanner. |
66 } |
78 } |
67 |
79 |
68 /*! |
80 /*! |
69 Initiates song scanning. |
81 Initiates song scanning. |
70 */ |
82 */ |
71 void MpSongScanner::scan() |
83 void MpSongScanner::scan( bool automaticScan ) |
72 { |
84 { |
|
85 TX_ENTRY |
73 if ( !mScanning ) { |
86 if ( !mScanning ) { |
74 mScanning = true; |
87 mScanning = true; |
75 mMpxWrapper->scan(); |
88 mAutomaticScan = automaticScan; |
|
89 mMpxHarvesterWrapper->scan(); |
76 } |
90 } |
|
91 TX_EXIT |
77 } |
92 } |
78 |
93 |
79 /*! |
94 /*! |
80 Returns true if scanning is ongoing. |
95 Returns mAutomaticScan value. |
81 */ |
96 */ |
82 bool MpSongScanner::isScanning() |
97 bool MpSongScanner::isAutomaticScan() |
83 { |
98 { |
84 return mScanning; |
99 return mAutomaticScan; |
85 } |
100 } |
86 |
101 |
87 /*! |
102 /*! |
88 Cancels ongoing song scanning, if any. |
103 Cancels ongoing song scanning, if any. |
89 |
104 |
90 \sa scan() |
105 \sa scan() |
91 */ |
106 */ |
92 void MpSongScanner::cancelScan() |
107 void MpSongScanner::cancelScan() |
93 { |
108 { |
|
109 TX_ENTRY |
94 if ( mScanning ) { |
110 if ( mScanning ) { |
95 mScanning = false; |
111 mScanning = false; |
96 mMpxWrapper->cancelScan(); |
112 mMpxHarvesterWrapper->cancelScan(); |
97 } |
113 } |
98 } |
114 TX_EXIT |
99 |
|
100 /*! |
|
101 Slot called upon notification from MPX Harvesting FW indicating start of |
|
102 scanning process. |
|
103 */ |
|
104 void MpSongScanner::handleScanStarted() |
|
105 { |
|
106 if ( !mScanProgressNote ) { |
|
107 mScanProgressNote = new HbProgressDialog( HbProgressDialog::WaitDialog ); |
|
108 connect( mScanProgressNote, SIGNAL( cancelled() ), this, SLOT( cancelScan() ) ); |
|
109 connect( mScanProgressNote, SIGNAL( aboutToClose() ), this, SLOT( handleProgressNoteClosing() ) ); |
|
110 } |
|
111 mScanProgressNote->setModal( true ); |
|
112 HbLabel *title = new HbLabel( hbTrId( "txt_mus_title_refreshing" ) ); |
|
113 title->setFontSpec(HbFontSpec(HbFontSpec::Primary)); |
|
114 |
|
115 mScanProgressNote->setHeadingWidget( title ); |
|
116 mScanProgressNote->setText( QString("") ); |
|
117 mScanProgressNote->setAttribute( Qt::WA_DeleteOnClose ); |
|
118 mScanProgressNote->show(); |
|
119 } |
115 } |
120 |
116 |
121 /*! |
117 /*! |
122 Slot called upon notification from MPX Harvesting FW indicating end of |
118 Slot called upon notification from MPX Harvesting FW indicating end of |
123 scanning process. |
119 scanning process. |
124 */ |
120 */ |
125 void MpSongScanner::handleScanEnded( int numItemsAdded, int error ) |
121 void MpSongScanner::handleScanEnded( int numItemsAdded, int error ) |
126 { |
122 { |
|
123 TX_ENTRY |
127 if (error == KErrDiskFull) { |
124 if (error == KErrDiskFull) { |
128 if ( mScanProgressNote ) { |
125 emit scanFinished( ScanErrorDiskFull, 0 ); |
129 mScanProgressNote->cancel(); |
|
130 } |
|
131 HbMessageBox *diskFullDialog = new HbMessageBox(); |
|
132 diskFullDialog->setIcon( HbIcon( QString("qtg_small_fail") ) ); |
|
133 diskFullDialog->setText( hbTrId( "txt_mus_title_refresh_cancelled" ) ); |
|
134 diskFullDialog->setTimeout( HbPopup::NoTimeout); |
|
135 diskFullDialog->setAttribute( Qt::WA_DeleteOnClose ); |
|
136 diskFullDialog->show(); |
|
137 mScanning = false; |
126 mScanning = false; |
138 |
|
139 } |
127 } |
140 else{ |
128 else{ |
141 QString added; |
|
142 HbNotificationDialog *finishedDialog = new HbNotificationDialog(); |
|
143 finishedDialog->setModal(true); |
|
144 finishedDialog->setAttribute( Qt::WA_DeleteOnClose ); |
|
145 |
|
146 added = hbTrId( "txt_mus_dpopinfo_ln_songs_added", numItemsAdded ); |
|
147 finishedDialog->setText( added ); |
|
148 |
|
149 if( error < 0) { |
129 if( error < 0) { |
150 if ( mScanProgressNote ) { |
130 emit scanFinished( ScanGeneralError, numItemsAdded ); |
151 mScanProgressNote->cancel(); |
|
152 } |
|
153 finishedDialog->setIcon( HbIcon( QString("qtg_small_fail") ) ); |
|
154 finishedDialog->setTitle( hbTrId( "txt_mus_dpophead_refresh_cancelled" ) ); |
|
155 } |
131 } |
156 else if ( mScanning ) { |
132 else if ( mScanning ) { |
157 if ( mScanProgressNote ) { |
133 emit scanFinished( ScanErrorNone, numItemsAdded ); |
158 mScanProgressNote->cancel(); |
|
159 } |
|
160 finishedDialog->setIcon( HbIcon( QString("qtg_large_ok") ) ); |
|
161 finishedDialog->setTitle( hbTrId( "txt_mus_dpophead_refresh_complete" ) ); |
|
162 } |
134 } |
163 else { |
135 else { |
164 finishedDialog->setIcon( HbIcon( QString("qtg_small_fail") ) ); |
136 // Scan canceled |
165 finishedDialog->setTitle( hbTrId( "txt_mus_dpophead_refresh_cancelled" ) ); |
137 emit scanFinished( ScanGeneralError, numItemsAdded ); |
166 } |
138 } |
167 mScanning = false; |
139 mScanning = false; |
168 finishedDialog->show(); |
|
169 } |
140 } |
170 } |
141 TX_EXIT |
171 |
|
172 /*! |
|
173 Slot called upon notification from MPX Harvesting FW indicating the number of |
|
174 songs scanned so far. |
|
175 */ |
|
176 void MpSongScanner::handleScanCountChanged(int count) |
|
177 { |
|
178 QString added; |
|
179 |
|
180 added = hbTrId( "txt_mus_info_ln_songs_added" , count ); |
|
181 if ( mScanProgressNote ) { |
|
182 mScanProgressNote->setText( added ); |
|
183 } |
|
184 } |
142 } |
185 |
143 |
186 /*! |
144 /*! |
187 Slot to be called when disk event is received from MPX framework. |
145 Slot to be called when disk event is received from MPX framework. |
188 */ |
146 */ |
189 void MpSongScanner::handleDiskEvent( MpxDiskEvents event ) |
147 void MpSongScanner::handleDiskEvent( MpxDiskEvents event ) |
190 { |
148 { |
|
149 TX_ENTRY |
191 Q_UNUSED( event ); |
150 Q_UNUSED( event ); |
192 if ( mScanning ) { |
151 if ( mScanning ) { |
193 if ( mScanProgressNote ) { |
152 emit scanFinished( ScanInterrupted, 0 ); |
194 mScanProgressNote->cancel(); |
|
195 } |
|
196 mScanning = false; |
153 mScanning = false; |
197 // AK - Should we show a dialog? |
|
198 } |
154 } |
199 TX_EXIT |
155 TX_EXIT |
200 } |
156 } |
201 |
157 |
202 /*! |
|
203 Slot used to clear mScanProgressNote when dialog is closing. |
|
204 */ |
|
205 void MpSongScanner::handleProgressNoteClosing() |
|
206 { |
|
207 mScanProgressNote = 0; |
|
208 } |
|
209 |
|