messagingapp/msgnotifications/msgindicatorplugin/src/msgindicatorplugin.cpp
changeset 25 84d9eb65b26f
parent 23 238255e8b033
child 27 e4592d119491
equal deleted inserted replaced
23:238255e8b033 25:84d9eb65b26f
    16  */
    16  */
    17 
    17 
    18 #include "msgindicatorplugin.h"
    18 #include "msgindicatorplugin.h"
    19 
    19 
    20 #include "msgindicator.h"
    20 #include "msgindicator.h"
       
    21 #include "msginfodefs.h"
       
    22 
    21 #include <QtPlugin>
    23 #include <QtPlugin>
    22 #include <QVariant>
    24 #include <QVariant>
    23 
    25 
    24 Q_EXPORT_PLUGIN(MsgIndicatorPlugin)
    26 Q_EXPORT_PLUGIN(MsgIndicatorPlugin)
    25 
    27 
    26 // ----------------------------------------------------------------------------
    28 // ----------------------------------------------------------------------------
    27 // MsgIndicatorPlugin::MsgIndicatorPlugin
    29 // MsgIndicatorPlugin::MsgIndicatorPlugin
    28 // @see msgindicatorplugin.h
    30 // @see msgindicatorplugin.h
    29 // ----------------------------------------------------------------------------
    31 // ----------------------------------------------------------------------------
    30 MsgIndicatorPlugin::MsgIndicatorPlugin() : mError(0)
    32 MsgIndicatorPlugin::MsgIndicatorPlugin() :
       
    33     mError(0)
    31 {
    34 {
    32    
    35     mIndicatorTypes.append(QString("com.nokia.messaging.newindicatorplugin"));
       
    36     mIndicatorTypes.append(QString("com.nokia.messaging.failedindicatorplugin"));
       
    37     mIndicatorTypes.append(QString("com.nokia.messaging.pendingindicatorplugin"));
       
    38 
    33 }
    39 }
    34 
    40 
    35 // ----------------------------------------------------------------------------
    41 // ----------------------------------------------------------------------------
    36 // MsgIndicatorPlugin::~MsgIndicatorPlugin
    42 // MsgIndicatorPlugin::~MsgIndicatorPlugin
    37 // @see msgindicatorplugin.h
    43 // @see msgindicatorplugin.h
    45 // Return notification types this plugin implements
    51 // Return notification types this plugin implements
    46 // @see msgindicatorplugin.h
    52 // @see msgindicatorplugin.h
    47 // ----------------------------------------------------------------------------
    53 // ----------------------------------------------------------------------------
    48 QStringList MsgIndicatorPlugin::indicatorTypes() const
    54 QStringList MsgIndicatorPlugin::indicatorTypes() const
    49 {
    55 {
    50   QStringList types; 
    56     return mIndicatorTypes;
    51   types << "com.nokia.messaging.indicatorplugin/1.0";
       
    52   return types;
       
    53 }
    57 }
    54 
    58 
    55 // ----------------------------------------------------------------------------
    59 // ----------------------------------------------------------------------------
    56 // MsgIndicatorPlugin::accessAllowed
    60 // MsgIndicatorPlugin::accessAllowed
    57 // Check if client is allowed to use notification widget
    61 // Check if client is allowed to use notification widget
    70 
    74 
    71 // ----------------------------------------------------------------------------
    75 // ----------------------------------------------------------------------------
    72 // MsgIndicatorPlugin::createIndicator
    76 // MsgIndicatorPlugin::createIndicator
    73 // @see msgindicatorplugin.h
    77 // @see msgindicatorplugin.h
    74 // ----------------------------------------------------------------------------
    78 // ----------------------------------------------------------------------------
    75 HbIndicatorInterface* MsgIndicatorPlugin::createIndicator(
    79 HbIndicatorInterface* MsgIndicatorPlugin::createIndicator(const QString &indicatorType)
    76         const QString &indicatorType)
       
    77 {
    80 {
    78     HbIndicatorInterface *indicator = new MsgIndicator(indicatorType);
    81     HbIndicatorInterface *indicator = NULL;
       
    82     int index(typeIndex(indicatorType));
       
    83     if (index >= 0) {
       
    84         indicator = new MsgIndicator(indicatorType);
       
    85     }
    79 
    86 
    80     return indicator;
    87     return indicator;
    81 }
    88 }
    82 
    89 
    83 // ----------------------------------------------------------------------------
    90 // ----------------------------------------------------------------------------
    87 int MsgIndicatorPlugin::error() const
    94 int MsgIndicatorPlugin::error() const
    88 {
    95 {
    89     return mError;
    96     return mError;
    90 }
    97 }
    91 
    98 
    92 
    99 // ----------------------------------------------------------------------------
    93 
   100 // MsgIndicatorPlugin::typeIndex
    94 
   101 // @see msgindicatorplugin.h
       
   102 // ----------------------------------------------------------------------------
       
   103 int MsgIndicatorPlugin::typeIndex(const QString &indicatorType) const
       
   104 {
       
   105     for (int i = 0; i < mIndicatorTypes.count(); ++i) {
       
   106         if (mIndicatorTypes.at(i) == indicatorType) {
       
   107             return i;
       
   108         }
       
   109     }
       
   110     return -1;
       
   111 }