|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <hbapplication.h> |
|
19 #include <qstringlist.h> |
|
20 |
|
21 #include "musicservices.h" |
|
22 #include "getmusicservice.h" |
|
23 #include "mptrace.h" |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 /*! |
|
29 Constructs music fetcher service |
|
30 */ |
|
31 GetMusicService::GetMusicService( MusicServices* parent ) |
|
32 : XQServiceProvider( QLatin1String( "musicplayer.com.nokia.symbian.IMusicFetch" ), parent ), |
|
33 mRequestIndex( 0 ), |
|
34 mServiceApp( parent ) |
|
35 { |
|
36 TX_ENTRY |
|
37 publishAll(); |
|
38 TX_EXIT |
|
39 } |
|
40 |
|
41 /*! |
|
42 Destructs music fetcher service |
|
43 */ |
|
44 GetMusicService::~GetMusicService() |
|
45 { |
|
46 TX_LOG |
|
47 } |
|
48 |
|
49 /*! |
|
50 Returns whether current service is still active |
|
51 */ |
|
52 bool GetMusicService::isActive() |
|
53 { |
|
54 return mRequestIndex > 0; |
|
55 } |
|
56 |
|
57 /*! |
|
58 Completes current request |
|
59 */ |
|
60 void GetMusicService::complete(QStringList filesList) |
|
61 { |
|
62 if ( isActive() ) { |
|
63 connect( this, SIGNAL( returnValueDelivered() ), qApp, SLOT( quit() ) ); |
|
64 completeRequest( mRequestIndex, filesList ); |
|
65 mRequestIndex = 0; |
|
66 } |
|
67 } |
|
68 |
|
69 /*! |
|
70 Returns title of calling application |
|
71 */ |
|
72 QString GetMusicService::contextTitle() const |
|
73 { |
|
74 return mTitle; |
|
75 } |
|
76 |
|
77 |
|
78 /*! |
|
79 Music Fetcher service interface defined in service registration xml. |
|
80 Service client needs to create a request using interface name |
|
81 "com.nokia.services.media.Music" and set string to show in |
|
82 opened views title as a request argument. |
|
83 |
|
84 Example usage: |
|
85 \code |
|
86 XQApplicationManager appMgr; |
|
87 XQAiwRequest* req = appMgr.create("com.nokia.services.media.IMusicFetch", |
|
88 "fetch(QString)", true); |
|
89 |
|
90 if (req) |
|
91 { |
|
92 connect(req, SIGNAL(requestOk(const QVariant&)), |
|
93 SLOT(handleRequestOk(const QVariant&))); |
|
94 connect(req, SIGNAL(requestError(int,const QString&)), |
|
95 SLOT(handleRequestError(int,const QString&))); |
|
96 |
|
97 // Set argument for request (title for opened views) |
|
98 QList<QVariant> args; |
|
99 args << QVariant(QString("<title to show>")); |
|
100 req->setArguments(args); |
|
101 |
|
102 // Make the request |
|
103 if (!req->send()) |
|
104 { |
|
105 qDebug() << "Failed to send REQ"; |
|
106 } |
|
107 delete req; |
|
108 } |
|
109 \endcode |
|
110 */ |
|
111 void GetMusicService::fetch() |
|
112 { |
|
113 TX_ENTRY |
|
114 //TODO: change to string constant when available |
|
115 mTitle = requestInfo().info("WindowTitle").toString(); |
|
116 mServiceApp->setCurrentService( MusicServices::EUriFetcher ); |
|
117 TUid uid = TUid::Uid( requestInfo().clientSecureId() ); |
|
118 emit mServiceApp->serviceActive( uid ); |
|
119 connect(this, SIGNAL( clientDisconnected() ), qApp, SLOT( quit() ) ); |
|
120 mRequestIndex = setCurrentRequestAsync(); |
|
121 |
|
122 TX_EXIT |
|
123 } |