messagingapp/msgnotifications/inc/msginfodefs.h
changeset 25 84d9eb65b26f
equal deleted inserted replaced
23:238255e8b033 25:84d9eb65b26f
       
     1 /*
       
     2  * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3  * All rights reserved.
       
     4  * This component and the accompanying materials are made available
       
     5  * under the terms of "Eclipse Public License v1.0"
       
     6  * which accompanies this distribution, and is available
       
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8  *
       
     9  * Initial Contributors:
       
    10  * Nokia Corporation - initial contribution.
       
    11  *
       
    12  * Contributors:
       
    13  *
       
    14  * Description: Interface between msgindicatorplugin and msgnotifier.
       
    15  *
       
    16  */
       
    17 
       
    18 
       
    19 #ifndef MSGINFODEFS_H
       
    20 #define MSGINFODEFS_H
       
    21 
       
    22 #include <QMetaType>
       
    23 #include <QString>
       
    24 #include <QStringList>
       
    25 #include <QByteArray>
       
    26 #include <QDataStream>
       
    27 
       
    28 
       
    29 /**
       
    30  * Indicator types
       
    31  */
       
    32 enum IndicatorTypes
       
    33 {
       
    34     Unknown = 0, 
       
    35     NewIndicatorPlugin = 1, 
       
    36     FailedIndicatorPlugin = 2, 
       
    37     PendingIndicatorPlugin = 3
       
    38 };
       
    39 
       
    40 
       
    41 /**
       
    42  * return the indicator name
       
    43  * @return QString the name of the indicator
       
    44  */
       
    45 inline QString indicatorName(IndicatorTypes type)
       
    46 {
       
    47     switch(type){
       
    48    	case NewIndicatorPlugin:
       
    49           return QString("com.nokia.messaging.newindicatorplugin");
       
    50     case FailedIndicatorPlugin:
       
    51     	    return QString("com.nokia.messaging.failedindicatorplugin");
       
    52     case PendingIndicatorPlugin:
       
    53           return QString("com.nokia.messaging.pendingindicatorplugin");
       
    54     default:
       
    55     	    return QString();
       
    56     }
       
    57 }
       
    58 
       
    59 /**
       
    60  * Interface class used by indications between msgnotifier 
       
    61  * and msgindications.
       
    62  * @class MsgInfo
       
    63  * 
       
    64  */
       
    65 class MsgInfo
       
    66 {
       
    67 public:
       
    68     MsgInfo() {
       
    69        mMsgCount = 0; 
       
    70        mIndicatorType = Unknown; 
       
    71        mConversationId = -1;
       
    72        mFromSingle = false;
       
    73        mDescription = QString();  
       
    74        mMessageType = 0;
       
    75     }
       
    76     virtual ~MsgInfo(){}
       
    77     
       
    78     /**
       
    79      * the count of messages
       
    80      */
       
    81     int mMsgCount;
       
    82     
       
    83     /**
       
    84      * The type of indicator
       
    85      */
       
    86     IndicatorTypes mIndicatorType;
       
    87     
       
    88     /**
       
    89      * The indicator type in int.
       
    90      */
       
    91     int mIndicatorTypeInt;
       
    92     
       
    93     /**
       
    94      * The conversation id.
       
    95      */
       
    96     int mConversationId;
       
    97     
       
    98     /**
       
    99      * The message type
       
   100      */
       
   101     int mMessageType;
       
   102     
       
   103     /**
       
   104      * Indication of number of senders/recipients
       
   105      * True if one, false if many
       
   106      */
       
   107     bool mFromSingle;
       
   108     
       
   109     /**
       
   110      * List of Names of the contacts, or phone numbers 
       
   111      */
       
   112     QStringList mDisplayName;
       
   113     
       
   114     /**
       
   115      * Any body text if present
       
   116      */
       
   117     QString mDescription;
       
   118     // TODO: check if the serialize/deserialize is okay
       
   119     /**
       
   120      * serialize
       
   121      * @param stream QDataStream serialize into this data stream.
       
   122      */
       
   123     inline void serialize(QDataStream& stream) const
       
   124        {
       
   125         stream << mMsgCount;
       
   126         stream << mIndicatorType;
       
   127         stream << mDisplayName;
       
   128         stream << mConversationId;
       
   129         stream << mFromSingle;
       
   130         stream << mDisplayName;
       
   131         stream << mDescription;
       
   132        }
       
   133 
       
   134     /**
       
   135      * deserialize
       
   136      * @param stream QDataStream deserialize from this data stream.
       
   137      */
       
   138     inline void deserialize(QDataStream& stream)
       
   139        {
       
   140         int indicatorType;
       
   141         stream >> mMsgCount;
       
   142         stream >> indicatorType;
       
   143         stream >> mDisplayName;
       
   144         stream >> mConversationId;
       
   145         stream >> mFromSingle;
       
   146         stream >> mDisplayName;
       
   147         stream >> mDescription;
       
   148         
       
   149         mIndicatorType = static_cast<IndicatorTypes>(indicatorType);
       
   150        }
       
   151 };
       
   152 
       
   153 
       
   154 Q_DECLARE_METATYPE(MsgInfo)
       
   155 
       
   156 #endif