--- a/controlpanelui/src/cpplugins/ringtoneplugin/src/cppersonalizationentryitemdata.cpp Mon May 03 12:32:06 2010 +0300
+++ b/controlpanelui/src/cpplugins/ringtoneplugin/src/cppersonalizationentryitemdata.cpp Fri May 14 13:21:08 2010 +0800
@@ -15,106 +15,183 @@
*
*/
#include "cppersonalizationentryitemdata.h"
-#include <xqaiwrequest.h>
#include <cpitemdatahelper.h>
#include <cpprofilemodel.h>
#include <cplogger.h>
#include <qdir.h>
+#include <xqsettingsmanager.h>
+#include <xqcentralrepositoryutils.h>
+#include <xqcentralrepositorysearchcriteria.h>
+#include <ProfileEngineInternalCRKeys.h>
+#include "cpringtoneview.h"
+
+
+const QString g_strNoTone("Z:\\resource\\No_Sound.wav");
CpPersonalizationEntryItemData::CpPersonalizationEntryItemData(CpItemDataHelper &itemDataHelper,
const QString &text,
const QString &description,
const HbIcon &icon,
+ Profile_Tone_Types toneType,
+ int profileId,
const HbDataFormModelItem *parent)
- :CpSettingFormEntryItemData(itemDataHelper,text,description,
- icon,parent),mReq(0),mProfileModel(0)
+ :CpSettingFormEntryItemData( itemDataHelper,text,description,icon,parent),
+ mProfileModel(0),
+ m_profileID(profileId),
+ mToneType(toneType),
+ mSettingManager(0)
{
+ Q_UNUSED(itemDataHelper); //reserve for future
CPFW_LOG("CpPersonalizationEntryItemData::CpPersonalizationEntryItemData(), START");
mProfileModel = new CpProfileModel();
- if(mProfileModel)
+ if( mProfileModel )
{
- setDescription( mProfileModel->ringTone().section(QDir::separator (),-1) );
+ QString strRing = loadStringValue();
+ if( strRing.contains( "No_Sound.wav", Qt::CaseInsensitive) )
+ {
+ setDescription( hbTrId("txt_cp_list_no_tone" ) ); //sepcial handling about NoTone
+ }
+ else
+ {
+ setDescription( strRing.section(QDir::separator (),-1) );
+ }
}
else
{
CPFW_LOG("CpPersonalizationEntryItemData::mProfileModel:NULL!");
}
+ mSettingManager = new XQSettingsManager();
+ XQCentralRepositorySettingsKey key(KCRUidProfileEngine.iUid,KProEngSilenceMode);
+
+ QVariant silenceMode = mSettingManager->readItemValue( key,XQSettingsManager::TypeInt );
+ setEnabled( !silenceMode.toInt() );
+ mSettingManager->startMonitoring( key,XQSettingsManager::TypeInt );
+ connect(mSettingManager, SIGNAL(valueChanged (XQSettingsKey, QVariant)),
+ this, SLOT(settingValueChanged(XQSettingsKey, QVariant)));
+
}
+void CpPersonalizationEntryItemData::settingValueChanged( const XQSettingsKey& key, const QVariant& value )
+{
+ Q_UNUSED(key);
+ setEnabled( !value.toInt() );
+}
+
CpPersonalizationEntryItemData::~CpPersonalizationEntryItemData()
{
if( mProfileModel )
{
delete mProfileModel;
- mProfileModel = NULL;
+ mProfileModel = 0;
+ }
+ if( mSettingManager )
+ {
+ delete mSettingManager;
}
}
-void CpPersonalizationEntryItemData::onLaunchView()
+
+QString CpPersonalizationEntryItemData::loadStringValue() const
{
- CPFW_LOG("CpPersonalizationEntryItemData::onLaunchView, START");
-
- //launch media fetcher
- if (!mReq)
+ QString strRing;
+ switch( mToneType )
{
- mReq = mAppMgr.create("com.nokia.services.media.Music", "fetch(QString)", true);
-
- if (!mReq)
+ case TONE_Message:
+ if( m_profileID>=0 )
+ {
+ strRing = mProfileModel->messageTone( m_profileID );
+ }
+ break;
+ case TONE_Email:
+ if( m_profileID >=0 )
{
- CPFW_LOG("CpPersonalizationEntryItemData::onLaunchView, Mediafetcher start failed");
- return;
+ strRing = mProfileModel->emailTone( m_profileID );
+ }
+ break;
+ case TONE_Reminder:
+ if( m_profileID >=0 )
+ {
+ strRing = mProfileModel->reminderTone( m_profileID );
+ }
+ break;
+ case TONE_Ring:
+ default:
+ if( m_profileID <0 )
+ {
+ strRing = mProfileModel->ringTone();
}
else
{
- connect(mReq, SIGNAL(requestOk(const QVariant&)), SLOT(handleOk(const QVariant&)));
- connect(mReq, SIGNAL(requestError(int,const QString&)), SLOT(handleError(int,const QString&)));
+ strRing = mProfileModel->ringTone( m_profileID );
}
+ break;
}
- // Set arguments for request (music fetcher application title)
- QList<QVariant> args;
- args << QVariant( text() );
- mReq->setArguments(args);
-
- // Make the request
- if (!mReq->send())
+ return strRing;
+}
+void CpPersonalizationEntryItemData::storeStringValue( const QString &strValue ) const
+{
+ QString strInput = strValue;
+ if( strInput.length() == 0 )
+ {
+ strInput = g_strNoTone;
+ }
+ switch( mToneType )
{
- CPFW_LOG("CpPersonalizationEntryItemData::onLaunchView, Mediafetcher calling failed");
- //report error
- return;
+ case TONE_Message:
+ if( m_profileID >=0 )
+ {
+ mProfileModel->setMessageTone( m_profileID, strInput );
+ }
+ break;
+ case TONE_Email:
+ if( m_profileID >=0 )
+ {
+ mProfileModel->setEmailTone( m_profileID, strInput );
+ }
+ break;
+ case TONE_Reminder:
+ if( m_profileID >=0 )
+ {
+ mProfileModel->setReminderTone( m_profileID, strInput );
+ }
+ break;
+ case TONE_Ring:
+ default:
+ if( m_profileID <0 )
+ {
+ mProfileModel->setRingTone( strInput );
+ }
+ else
+ {
+ mProfileModel->setRingTone( m_profileID, strInput );
+ }
+ break;
}
- CPFW_LOG("CpPersonalizationEntryItemData::onLaunchView, successful END");
-
}
-void CpPersonalizationEntryItemData::handleOk(const QVariant &result)
+
+void CpPersonalizationEntryItemData::handleOk(const QString &strFname)
{
- CPFW_LOG("CpPersonalizationEntryItemData::handleOk");
- if (!result.canConvert<QString>())
+ if(strFname.length())
{
- setDescription( "Corrupt result" );
+ setDescription( strFname.section(QDir::separator (),-1) );
}
else
{
- QString strRet = result.value<QString>();
- if(strRet.length())
- {
- setDescription( strRet.section(QDir::separator (),-1) );
- }
- else
- {
- setDescription( "No tone" );
- }
- mProfileModel->setRingTone( strRet );
+ setDescription( hbTrId("txt_cp_list_no_tone" ) );
}
+ storeStringValue(strFname);
}
+
+
void CpPersonalizationEntryItemData::handleError(int errorCode, const QString& errorMessage)
{
- CPFW_LOG("CpPersonalizationEntryItemData::handleError");
- //handling error return
Q_UNUSED(errorCode);
Q_UNUSED(errorMessage);
- setDescription("Error media fetcher");
}
CpBaseSettingView *CpPersonalizationEntryItemData::createSettingView() const
{
- return NULL;
+ CpRingToneView *pView = new CpRingToneView( );
+ connect( pView, SIGNAL( selOK( const QString&)),SLOT(handleOk(const QString &)) );
+ connect( pView, SIGNAL( selError( int, const QString& ) ), SLOT( handleOk(const QString &)) );
+ return pView;
}