--- a/emailuis/nmindicatorplugin/src/nmindicatorplugin.cpp Mon May 24 21:02:02 2010 +0300
+++ b/emailuis/nmindicatorplugin/src/nmindicatorplugin.cpp Fri May 28 13:56:43 2010 +0300
@@ -17,19 +17,20 @@
#include "nmindicatorplugin.h"
#include "nmindicator.h"
+#include "nmsendingindicator.h"
+#include "nmsyncindicator.h"
+#include "nmunreadindicator.h"
#include <QCoreApplication>
#include <QLocale>
#include <QVariant>
#include <QTimer>
-#include <xqservicerequest.h>
-#include <email_services_api.h>
-
Q_EXPORT_PLUGIN(NmIndicatorPlugin)
const int NmMaxIndicatorCount = 10;
-static const QString emailServiceNameMailbox = "nmail.com.nokia.symbian.IEmailInboxView";
+static const QString NmIndicatorName = "com.nokia.nmail.indicatorplugin_%1/1.0";
+
/*!
\class NmIndicatorPlugin
@@ -40,8 +41,9 @@
Class constructor.
*/
NmIndicatorPlugin::NmIndicatorPlugin()
-: mError(0), mTranslator(0), mStatusBarIndicator(0), mSending(false)
+: mError(0), mTranslator(0)
{
+ NM_FUNCTION;
}
/*!
@@ -49,7 +51,8 @@
*/
NmIndicatorPlugin::~NmIndicatorPlugin()
{
- NMLOG("NmIndicatorPlugin::~NmIndicatorPlugin");
+ NM_FUNCTION;
+
delete mTranslator;
}
@@ -58,11 +61,16 @@
*/
QStringList NmIndicatorPlugin::indicatorTypes() const
{
+ NM_FUNCTION;
+
QStringList types;
for (int i=0; i<NmMaxIndicatorCount; i++) {
- QString name = QString("com.nokia.nmail.indicatorplugin_%1/1.0").arg(i);
+ QString name = QString(NmIndicatorName).arg(i);
types << name;
}
+ types << NmSendingIndicatorType;
+ types << NmSyncIndicator::IndicatorType;
+ types << NmUnreadIndicatorType;
return types;
}
@@ -73,6 +81,8 @@
bool NmIndicatorPlugin::accessAllowed(const QString &indicatorType,
const QVariantMap &securityInfo) const
{
+ NM_FUNCTION;
+
Q_UNUSED(indicatorType)
Q_UNUSED(securityInfo)
@@ -81,30 +91,14 @@
return true;
}
-
-/*!
- Called when any of the indicator receive updated status of the global status
- */
-void NmIndicatorPlugin::globalStatusChanged(bool sending)
-{
- mSending = sending;
-
- // Pass the information to the indicator handling the status bar icon
- if (mStatusBarIndicator) {
- mStatusBarIndicator->acceptIcon(sending);
- }
- else {
- // No indicator is showing the status now.
- indicatorIconLost();
- }
-}
-
/*!
Creates an indicator of type indicatorType. Ownership is passed to the caller.
*/
HbIndicatorInterface* NmIndicatorPlugin::createIndicator(
const QString &indicatorType)
{
+ NM_FUNCTION;
+
if (!mTranslator) {
mTranslator = new QTranslator();
QString lang = QLocale::system().name();
@@ -114,12 +108,19 @@
QCoreApplication::installTranslator(mTranslator);
}
- NmIndicator* indicator = new NmIndicator(indicatorType);
- connect(indicator, SIGNAL(indicatorIconLost()), this, SLOT(indicatorIconLost()));
- connect(indicator, SIGNAL(destroyed(QObject *)), this, SLOT(indicatorDeactivated(QObject *)));
- connect(indicator, SIGNAL(globalStatusChanged(bool)), this, SLOT(globalStatusChanged(bool)));
- connect(indicator, SIGNAL(mailboxLaunched(quint64)), this, SLOT(showMailbox(quint64)));
- mIndicators.append(indicator);
+ HbIndicatorInterface *indicator;
+ if (indicatorType == NmSendingIndicatorType) {
+ indicator = new NmSendingIndicator(indicatorType);
+ }
+ else if (indicatorType == NmUnreadIndicatorType) {
+ indicator = new NmUnreadIndicator(indicatorType);
+ }
+ else if (indicatorType == NmSyncIndicator::IndicatorType) {
+ indicator = new NmSyncIndicator();
+ }
+ else {
+ indicator = new NmIndicator(indicatorType);
+ }
return indicator;
}
@@ -129,65 +130,7 @@
*/
int NmIndicatorPlugin::error() const
{
+ NM_FUNCTION;
+
return mError;
}
-
-/*!
- Called when an indicator signals about lost indicator.
- \param true if a new indicator was found
- */
-bool NmIndicatorPlugin::indicatorIconLost()
-{
- bool found(false);
- mStatusBarIndicator = NULL;
-
- foreach (NmIndicator* indicator, mIndicators) {
- // Find a new candidate to handle the status bar icon
- if (indicator->acceptIcon(mSending)) {
- mStatusBarIndicator = indicator;
- found = true;
- break;
- }
- }
- return found;
-}
-
-/*!
- Remove destroyed indicators from the list.
- \param indicator item that has been deleted
- */
-void NmIndicatorPlugin::indicatorDeactivated(QObject *indObject)
-{
- NMLOG(QString("NmIndicatorPlugin::indicatorDeactivated %1").arg((int)indObject));
- NmIndicator *indicator = static_cast<NmIndicator*>(indObject);
- mIndicators.removeAll(indicator);
- if (mStatusBarIndicator == indicator) {
- mStatusBarIndicator = NULL;
-
- // Find new indicator to take care of the status bar icon
- indicatorIconLost();
- }
-}
-
-/*!
- Opens inbox view to specific mailbox
- \return true if inbox is succesfully opened
-*/
-bool NmIndicatorPlugin::showMailbox(quint64 mailboxId)
-{
- NMLOG("NmIndicatorPlugin::showMailbox");
- XQServiceRequest request(
- emailServiceNameMailbox,
- emailOperationViewInbox,
- true);
-
- QList<QVariant> list;
- list.append(QVariant(mailboxId));
-
- request.setArguments(list);
-
- int returnValue(-1);
- return request.send(returnValue);
-}
-
-