--- a/messagingapp/msgui/unifiededitor/src/msgunieditoraddress.cpp Fri Apr 16 14:56:15 2010 +0300
+++ b/messagingapp/msgui/unifiededitor/src/msgunieditoraddress.cpp Mon May 03 12:29:07 2010 +0300
@@ -22,35 +22,37 @@
#include <HbAction>
#include <hbinputeditorinterface.h>
#include <cntservicescontact.h>
+#include <xqaiwrequest.h>
+#include <xqappmgr.h>
+#include <telconfigcrkeys.h> // KCRUidTelephonyConfiguration
+#include <centralrepository.h>
// USER INCLUDES
#include "msgunieditoraddress.h"
#include "msgunifiededitorlineedit.h"
-#include "msguiutilsmanager.h"
-#include "matchphnumberutil.h"
-const QString PBK_ICON(":/qtg_mono_contacts.svg");
-const QString SEND_ICON(":/qtg_mono_send.svg");
+const QString PBK_ICON("qtg_mono_contacts");
+const QString SEND_ICON("qtg_mono_send");
// Constants
+const int KDefaultGsmNumberMatchLength = 7; //matching unique ph numbers
MsgUnifiedEditorAddress::MsgUnifiedEditorAddress( const QString& label,
const QString& pluginPath,
QGraphicsItem *parent ) :
HbWidget(parent),
-mPluginPath(pluginPath),
-mUtilsManager(0)
+mPluginPath(pluginPath)
{
#ifdef _DEBUG_TRACES_
qDebug() << "MsgUnifiedEditorAddress calling HbStyle::registerPlugin";
#endif
+ this->setContentsMargins(0,0,0,0);
setPluginBaseId(style()->registerPlugin(mPluginPath));
- mUtilsManager = new MsgUiUtilsManager(this);
-
+
mLaunchBtn = new HbPushButton(this);
HbStyle::setItemName(mLaunchBtn,"launchBtn");
- connect(mLaunchBtn,SIGNAL(clicked()),mUtilsManager,SLOT(fetchContacts()));
+ connect(mLaunchBtn,SIGNAL(clicked()),this,SLOT(fetchContacts()));
mLaunchBtn->setIcon(HbIcon(PBK_ICON));
@@ -58,17 +60,16 @@
HbStyle::setItemName(mAddressEdit,"addressField");
mAddressEdit->setMaxRows(40);
- connect(mAddressEdit, SIGNAL(addressTextChanged(const QString&)),
- this, SLOT(onTextChanged(const QString&)));
+ connect(mAddressEdit, SIGNAL(contentsChanged(const QString&)),
+ this, SLOT(onContentsAdded(const QString&)));
// add "Send" action in VKB
HbEditorInterface editorInterface(mAddressEdit);
+ mAddressEdit->setInputMethodHints(Qt::ImhPreferNumbers);
HbAction *sendAction = new HbAction(HbIcon(SEND_ICON), QString(),this);
connect(sendAction, SIGNAL(triggered()),this, SIGNAL(sendMessage()));
editorInterface.addAction(sendAction);
- connect(mUtilsManager, SIGNAL(contactsFetched(const QVariant&)),
- this, SLOT(contactsFetched(const QVariant&)));
}
MsgUnifiedEditorAddress::~MsgUnifiedEditorAddress()
@@ -76,7 +77,33 @@
style()->unregisterPlugin(mPluginPath);
}
-void MsgUnifiedEditorAddress::contactsFetched(const QVariant& value)
+void MsgUnifiedEditorAddress::fetchContacts()
+{
+ QList<QVariant> args;
+ QString serviceName("com.nokia.services.phonebookservices");
+ QString operation("fetch(QString,QString,QString)");
+ XQAiwRequest* request;
+ XQApplicationManager appManager;
+ request = appManager.create(serviceName, "Fetch", operation, true); // embedded
+ if ( request == NULL )
+ {
+ return;
+ }
+
+ // Result handlers
+ connect (request, SIGNAL(requestOk(const QVariant&)), this, SLOT(handleOk(const QVariant&)));
+ connect (request, SIGNAL(requestError(int,const QString&)), this, SLOT(handleError(int,const QString&)));
+
+ args << QString(tr("Phonebook"));
+ args << KCntActionAll;
+ args << KCntFilterDisplayAll;
+
+ request->setArguments(args);
+ request->send();
+ delete request;
+}
+
+void MsgUnifiedEditorAddress::handleOk(const QVariant& value)
{
CntServicesContactList contactList;
contactList = qVariantValue<CntServicesContactList>(value);
@@ -95,6 +122,12 @@
}
}
+void MsgUnifiedEditorAddress::handleError(int errorCode, const QString& errorMessage)
+{
+ Q_UNUSED(errorMessage)
+ Q_UNUSED(errorCode)
+}
+
ConvergedMessageAddressList MsgUnifiedEditorAddress::addresses()
{
#ifdef _DEBUG_TRACES_
@@ -146,27 +179,44 @@
}
}
-void MsgUnifiedEditorAddress::onTextChanged(const QString& text)
+int MsgUnifiedEditorAddress::contactMatchDigits()
+ {
+ // Read the amount of digits to be used in contact matching
+ // The key is owned by PhoneApp
+ CRepository* repository = CRepository::NewLC(KCRUidTelConfiguration);
+ int matchDigitCount = 0;
+ if ( repository->Get(KTelMatchDigits, matchDigitCount) == KErrNone )
+ {
+ // Min is 7
+ matchDigitCount = Max(matchDigitCount, KDefaultGsmNumberMatchLength);
+ }
+ CleanupStack::PopAndDestroy(); // repository
+
+ return matchDigitCount;
+
+ }
+
+void MsgUnifiedEditorAddress::onContentsAdded(const QString& text)
{
if(!text.isEmpty())
{
- disconnect(mAddressEdit, SIGNAL(addressTextChanged(const QString&)),
- this, SLOT(onTextChanged(const QString&)));
- emit mmContentAdded(true);
- connect(mAddressEdit, SIGNAL(addressTextChanged(const QString&)),
- this, SLOT(onTextRemoved(const QString&)));
+ disconnect(mAddressEdit, SIGNAL(contentsChanged(const QString&)),
+ this, SLOT(onContentsAdded(const QString&)));
+ emit contentChanged();
+ connect(mAddressEdit, SIGNAL(contentsChanged(const QString&)),
+ this, SLOT(onContentsRemoved(const QString&)));
}
}
-void MsgUnifiedEditorAddress::onTextRemoved(const QString& text)
+void MsgUnifiedEditorAddress::onContentsRemoved(const QString& text)
{
if(text.isEmpty())
{
- disconnect(mAddressEdit, SIGNAL(addressTextChanged(const QString&)),
- this, SLOT(onTextRemoved(const QString&)));
- emit mmContentAdded(false);
- connect(mAddressEdit, SIGNAL(addressTextChanged(const QString&)),
- this, SLOT(onTextChanged(const QString&)));
+ disconnect(mAddressEdit, SIGNAL(contentsChanged(const QString&)),
+ this, SLOT(onContentsRemoved(const QString&)));
+ emit contentChanged();
+ connect(mAddressEdit, SIGNAL(contentsChanged(const QString&)),
+ this, SLOT(onContentsAdded(const QString&)));
}
}
@@ -211,7 +261,7 @@
QStringList MsgUnifiedEditorAddress::uniqueAddressList()
{
- int matchDigitCount = MatchPhNumberUtil::matchDigits();
+ int matchDigitCount = MsgUnifiedEditorAddress::contactMatchDigits();
QStringList mapAddrList = mAddressMap.keys();
for(int j = 0;j<mapAddrList.count()-1;j++)
{