messagingapp/msgnotifications/msgindicatorplugin/inc/msgindicator.h
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Fri, 16 Apr 2010 14:56:15 +0300
changeset 23 238255e8b033
child 25 84d9eb65b26f
permissions -rw-r--r--
Revision: 201011 Kit: 201015

/*
 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
 * which accompanies this distribution, and is available
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
 *
 * Initial Contributors:
 * Nokia Corporation - initial contribution.
 *
 * Contributors:
 *
 * Description: Message Indicator class
 *
 */

#ifndef MSGINDICATOR_H
#define MSGINDICATOR_H

#include <QObject>

#include <hbindicatorinterface.h>

class MsgIndicatorPrivate;

/**
 * Utility class used pass indication data 
 * from private to Qt- class.
 */
class IndicatorData
    {
public:
    /**
     * Constructor
     */
    IndicatorData():mFromSingle(false),
    mConversationId(-1),
    mUnreadMsgCount(0){};
    
    /**
     * Message from single contact or many
     */
    bool mFromSingle; 
    
    /**
     * Conversation id
     */
    int mConversationId; 
    
    /**
     * Unread message count
     */
    int mUnreadMsgCount;
    
    /**
     * First name
     */
    QString mFirstName; 
    
    /**
     * Last name
     */
    QString mLastName; 
    
    /**
     * Nick name
     */
    QString mNickName; 
    
    /**
     * Phone number
     */
    QString mContactNum; 
    
    /**
     * Description
     */
    QString mDescription;
    };

/**
 * Message indicator class. 
 * Handles client request and showing the indications. 
 */
class MsgIndicator : public HbIndicatorInterface
{
public:
    /**
     * Constructor
     */
    MsgIndicator(const QString &indicatorType);
    
    /**
     * Destructor
     */
    ~MsgIndicator();
    
    /**
     * @see HbIndicatorInterface
     */
    bool handleInteraction(InteractionType type);
    
    /**
     * @see HbIndicatorInterface
     */
    QVariant indicatorData(int role) const;
    
protected:
    /**
     * @see HbIndicatorInterface
     */
    bool handleClientRequest(RequestType type, const QVariant &parameter);
    
private: 
    /**
     * Prepares the display name from stream.
     * @param IindicatorData inidcator data.
     */
    QString prepareDisplayName(IndicatorData& indicatorData) const;
    
private:
    
    /**
     * Body text
     */
    mutable QString mBodyText;
    
    /**
     * Conversation id
     */
    mutable qint64 mConversationId;
    
    /**
     * Message from single or multiple contact
     */
    mutable bool mConversationFromSingleContact;
    
    /**
     * Private implementaion object.
     * Owned.
     */
    MsgIndicatorPrivate* d_ptr;
};

#endif // MSGINDICATOR_H