ItemScriptable *ItemTagsLoader::scriptableObject() { return new ItemTagsScriptable(userTags()); }
void WebService::requestResult( Request *r ) { Q_ASSERT( r ); switch (r->type()) { case TypeHandshake: { //TODO mxcl before I refactored, the handshake success if block was still // executed, but the result code was set to an error, I considered this a // bug and hopefully I'll remember to ask someone if that is the case or not Handshake *handshake = static_cast<Handshake*>(r); Q_ASSERT( m_username == handshake->username() ); Q_ASSERT( m_password == handshake->password() ); if (handshake->succeeded()) { m_streamUrl = handshake->streamUrl(); // legacy m_isSubscriber = handshake->isSubscriber(); } if (handshake->isMessage()) QMessageBox::information( qApp->activeWindow(), tr( "Last.fm Information" ), handshake->message() ); emit handshakeResult( handshake ); break; } // these macros makes the code more readable #define CASE( T ) case Type##T: { T##Request *request = static_cast<T##Request*>(r); #define break } break CASE( ChangeStation ) StationUrl url = request->stationUrl(); QString name = request->stationName(); emit changeStationResult( request ); if (r->succeeded()) emit stationChanged( url, name ); break; CASE( SetTag ) emit setTagResult( request ); break; CASE( ProxyTest ) if ( request->succeeded() || request->resultCode() == Request_ProxyAuthenticationRequired ) { m_isAutoDetectedProxy = request->proxyUsed(); emit proxyTestResult( m_isAutoDetectedProxy, request->resultCode() ); } break; default: ; } /// these are emitted only for the currentUsername() switch (r->type()) { CASE( Love ) emit loved( request->track() ); break; CASE( UnLove ) emit unloved( request->track() ); break; CASE( Ban ) emit banned( request->track() ); break; CASE( UnBan ) emit unbanned( request->track() ); break; CASE( UserTags ) if (request->username() == currentUsername()) emit userTags( request->tags() ); break; CASE( DeleteFriend ) emit friendDeleted( request->deletedUsername() ); break; CASE( Friends ) emit friends( request->usernames() ); break; CASE( Neighbours ) emit neighbours( request->usernames() ); break; CASE( RecentTracks ) emit recentTracks( request->tracks() ); break; CASE( RecentlyLovedTracks ) emit recentLovedTracks( request->tracks() ); break; CASE( RecentlyBannedTracks ) emit recentBannedTracks( request->tracks() ); break; default: ; } #undef CASE #undef break if ( r->failed() && r->resultCode() != Request_ProxyAuthenticationRequired ) emit failure( r ); else emit success( r ); emit result( r ); if (r->autoDelete()) // do last in case one of the signals is queued r->deleteLater(); }