13 * |
13 * |
14 * Description: |
14 * Description: |
15 * |
15 * |
16 */ |
16 */ |
17 #include "cppersonalizationentryitemdata.h" |
17 #include "cppersonalizationentryitemdata.h" |
18 #include <xqaiwrequest.h> |
|
19 #include <cpitemdatahelper.h> |
18 #include <cpitemdatahelper.h> |
20 #include <cpprofilemodel.h> |
19 #include <cpprofilemodel.h> |
21 #include <cplogger.h> |
20 #include <cplogger.h> |
22 #include <qdir.h> |
21 #include <qdir.h> |
|
22 #include <xqsettingsmanager.h> |
|
23 #include <xqcentralrepositoryutils.h> |
|
24 #include <xqcentralrepositorysearchcriteria.h> |
|
25 #include <ProfileEngineInternalCRKeys.h> |
23 |
26 |
|
27 #include "cpringtoneview.h" |
|
28 |
|
29 |
|
30 const QString g_strNoTone("Z:\\resource\\No_Sound.wav"); |
24 CpPersonalizationEntryItemData::CpPersonalizationEntryItemData(CpItemDataHelper &itemDataHelper, |
31 CpPersonalizationEntryItemData::CpPersonalizationEntryItemData(CpItemDataHelper &itemDataHelper, |
25 const QString &text, |
32 const QString &text, |
26 const QString &description, |
33 const QString &description, |
27 const HbIcon &icon, |
34 const HbIcon &icon, |
|
35 Profile_Tone_Types toneType, |
|
36 int profileId, |
28 const HbDataFormModelItem *parent) |
37 const HbDataFormModelItem *parent) |
29 :CpSettingFormEntryItemData(itemDataHelper,text,description, |
38 :CpSettingFormEntryItemData( itemDataHelper,text,description,icon,parent), |
30 icon,parent),mReq(0),mProfileModel(0) |
39 mProfileModel(0), |
|
40 m_profileID(profileId), |
|
41 mToneType(toneType), |
|
42 mSettingManager(0) |
31 { |
43 { |
|
44 Q_UNUSED(itemDataHelper); //reserve for future |
32 CPFW_LOG("CpPersonalizationEntryItemData::CpPersonalizationEntryItemData(), START"); |
45 CPFW_LOG("CpPersonalizationEntryItemData::CpPersonalizationEntryItemData(), START"); |
33 mProfileModel = new CpProfileModel(); |
46 mProfileModel = new CpProfileModel(); |
34 if(mProfileModel) |
47 if( mProfileModel ) |
35 { |
48 { |
36 setDescription( mProfileModel->ringTone().section(QDir::separator (),-1) ); |
49 QString strRing = loadStringValue(); |
|
50 if( strRing.contains( "No_Sound.wav", Qt::CaseInsensitive) ) |
|
51 { |
|
52 setDescription( hbTrId("txt_cp_list_no_tone" ) ); //sepcial handling about NoTone |
|
53 } |
|
54 else |
|
55 { |
|
56 setDescription( strRing.section(QDir::separator (),-1) ); |
|
57 } |
37 } |
58 } |
38 else |
59 else |
39 { |
60 { |
40 CPFW_LOG("CpPersonalizationEntryItemData::mProfileModel:NULL!"); |
61 CPFW_LOG("CpPersonalizationEntryItemData::mProfileModel:NULL!"); |
41 } |
62 } |
|
63 mSettingManager = new XQSettingsManager(); |
|
64 XQCentralRepositorySettingsKey key(KCRUidProfileEngine.iUid,KProEngSilenceMode); |
|
65 |
|
66 QVariant silenceMode = mSettingManager->readItemValue( key,XQSettingsManager::TypeInt ); |
|
67 setEnabled( !silenceMode.toInt() ); |
|
68 mSettingManager->startMonitoring( key,XQSettingsManager::TypeInt ); |
|
69 connect(mSettingManager, SIGNAL(valueChanged (XQSettingsKey, QVariant)), |
|
70 this, SLOT(settingValueChanged(XQSettingsKey, QVariant))); |
|
71 |
42 } |
72 } |
|
73 void CpPersonalizationEntryItemData::settingValueChanged( const XQSettingsKey& key, const QVariant& value ) |
|
74 { |
|
75 Q_UNUSED(key); |
|
76 setEnabled( !value.toInt() ); |
|
77 } |
|
78 |
43 CpPersonalizationEntryItemData::~CpPersonalizationEntryItemData() |
79 CpPersonalizationEntryItemData::~CpPersonalizationEntryItemData() |
44 { |
80 { |
45 if( mProfileModel ) |
81 if( mProfileModel ) |
46 { |
82 { |
47 delete mProfileModel; |
83 delete mProfileModel; |
48 mProfileModel = NULL; |
84 mProfileModel = 0; |
|
85 } |
|
86 if( mSettingManager ) |
|
87 { |
|
88 delete mSettingManager; |
49 } |
89 } |
50 } |
90 } |
51 void CpPersonalizationEntryItemData::onLaunchView() |
91 |
|
92 QString CpPersonalizationEntryItemData::loadStringValue() const |
52 { |
93 { |
53 CPFW_LOG("CpPersonalizationEntryItemData::onLaunchView, START"); |
94 QString strRing; |
54 |
95 switch( mToneType ) |
55 //launch media fetcher |
|
56 if (!mReq) |
|
57 { |
96 { |
58 mReq = mAppMgr.create("com.nokia.services.media.Music", "fetch(QString)", true); |
97 case TONE_Message: |
59 |
98 if( m_profileID>=0 ) |
60 if (!mReq) |
|
61 { |
99 { |
62 CPFW_LOG("CpPersonalizationEntryItemData::onLaunchView, Mediafetcher start failed"); |
100 strRing = mProfileModel->messageTone( m_profileID ); |
63 return; |
101 } |
|
102 break; |
|
103 case TONE_Email: |
|
104 if( m_profileID >=0 ) |
|
105 { |
|
106 strRing = mProfileModel->emailTone( m_profileID ); |
|
107 } |
|
108 break; |
|
109 case TONE_Reminder: |
|
110 if( m_profileID >=0 ) |
|
111 { |
|
112 strRing = mProfileModel->reminderTone( m_profileID ); |
|
113 } |
|
114 break; |
|
115 case TONE_Ring: |
|
116 default: |
|
117 if( m_profileID <0 ) |
|
118 { |
|
119 strRing = mProfileModel->ringTone(); |
64 } |
120 } |
65 else |
121 else |
66 { |
122 { |
67 connect(mReq, SIGNAL(requestOk(const QVariant&)), SLOT(handleOk(const QVariant&))); |
123 strRing = mProfileModel->ringTone( m_profileID ); |
68 connect(mReq, SIGNAL(requestError(int,const QString&)), SLOT(handleError(int,const QString&))); |
|
69 } |
124 } |
|
125 break; |
70 } |
126 } |
71 |
127 |
72 // Set arguments for request (music fetcher application title) |
128 return strRing; |
73 QList<QVariant> args; |
129 } |
74 args << QVariant( text() ); |
130 void CpPersonalizationEntryItemData::storeStringValue( const QString &strValue ) const |
75 mReq->setArguments(args); |
131 { |
|
132 QString strInput = strValue; |
|
133 if( strInput.length() == 0 ) |
|
134 { |
|
135 strInput = g_strNoTone; |
|
136 } |
|
137 switch( mToneType ) |
|
138 { |
|
139 case TONE_Message: |
|
140 if( m_profileID >=0 ) |
|
141 { |
|
142 mProfileModel->setMessageTone( m_profileID, strInput ); |
|
143 } |
|
144 break; |
|
145 case TONE_Email: |
|
146 if( m_profileID >=0 ) |
|
147 { |
|
148 mProfileModel->setEmailTone( m_profileID, strInput ); |
|
149 } |
|
150 break; |
|
151 case TONE_Reminder: |
|
152 if( m_profileID >=0 ) |
|
153 { |
|
154 mProfileModel->setReminderTone( m_profileID, strInput ); |
|
155 } |
|
156 break; |
|
157 case TONE_Ring: |
|
158 default: |
|
159 if( m_profileID <0 ) |
|
160 { |
|
161 mProfileModel->setRingTone( strInput ); |
|
162 } |
|
163 else |
|
164 { |
|
165 mProfileModel->setRingTone( m_profileID, strInput ); |
|
166 } |
|
167 break; |
|
168 } |
|
169 } |
76 |
170 |
77 // Make the request |
171 void CpPersonalizationEntryItemData::handleOk(const QString &strFname) |
78 if (!mReq->send()) |
172 { |
|
173 if(strFname.length()) |
79 { |
174 { |
80 CPFW_LOG("CpPersonalizationEntryItemData::onLaunchView, Mediafetcher calling failed"); |
175 setDescription( strFname.section(QDir::separator (),-1) ); |
81 //report error |
|
82 return; |
|
83 } |
|
84 CPFW_LOG("CpPersonalizationEntryItemData::onLaunchView, successful END"); |
|
85 |
|
86 } |
|
87 void CpPersonalizationEntryItemData::handleOk(const QVariant &result) |
|
88 { |
|
89 CPFW_LOG("CpPersonalizationEntryItemData::handleOk"); |
|
90 if (!result.canConvert<QString>()) |
|
91 { |
|
92 setDescription( "Corrupt result" ); |
|
93 } |
176 } |
94 else |
177 else |
95 { |
178 { |
96 QString strRet = result.value<QString>(); |
179 setDescription( hbTrId("txt_cp_list_no_tone" ) ); |
97 if(strRet.length()) |
|
98 { |
|
99 setDescription( strRet.section(QDir::separator (),-1) ); |
|
100 } |
|
101 else |
|
102 { |
|
103 setDescription( "No tone" ); |
|
104 } |
|
105 mProfileModel->setRingTone( strRet ); |
|
106 } |
180 } |
|
181 storeStringValue(strFname); |
107 } |
182 } |
|
183 |
|
184 |
108 void CpPersonalizationEntryItemData::handleError(int errorCode, const QString& errorMessage) |
185 void CpPersonalizationEntryItemData::handleError(int errorCode, const QString& errorMessage) |
109 { |
186 { |
110 CPFW_LOG("CpPersonalizationEntryItemData::handleError"); |
|
111 //handling error return |
|
112 Q_UNUSED(errorCode); |
187 Q_UNUSED(errorCode); |
113 Q_UNUSED(errorMessage); |
188 Q_UNUSED(errorMessage); |
114 setDescription("Error media fetcher"); |
|
115 } |
189 } |
116 |
190 |
117 CpBaseSettingView *CpPersonalizationEntryItemData::createSettingView() const |
191 CpBaseSettingView *CpPersonalizationEntryItemData::createSettingView() const |
118 { |
192 { |
119 return NULL; |
193 CpRingToneView *pView = new CpRingToneView( ); |
|
194 connect( pView, SIGNAL( selOK( const QString&)),SLOT(handleOk(const QString &)) ); |
|
195 connect( pView, SIGNAL( selError( int, const QString& ) ), SLOT( handleOk(const QString &)) ); |
|
196 return pView; |
120 } |
197 } |