messagingapp/msgui/appengine/inc/conversationsengine.h
changeset 23 238255e8b033
child 25 84d9eb65b26f
equal deleted inserted replaced
5:4697dfb2d7ad 23:238255e8b033
       
     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:
       
    15  *
       
    16  */
       
    17 
       
    18 #ifndef CONVERSATIONS_ENGINE_H
       
    19 #define CONVERSATIONS_ENGINE_H
       
    20 
       
    21 // INCLUDES
       
    22 #include <QObject>
       
    23 #include <QStandardItemModel>
       
    24 
       
    25 #ifdef BUILD_DLL
       
    26 #define CONVERSATIONS_ENGINE_API_EXPORT Q_DECL_EXPORT
       
    27 #else
       
    28 #define CONVERSATIONS_ENGINE_API_EXPORT Q_DECL_IMPORT
       
    29 #endif
       
    30 
       
    31 class ConversationsSummaryModel;
       
    32 class ConversationsModel;
       
    33 class DraftsModel;
       
    34 class ConversationMsgStoreHandler;
       
    35 class ConversationsEnginePrivate;
       
    36 
       
    37 /**
       
    38  * This is a singleton class which
       
    39  * implements the models for the model/view framework.
       
    40  * The models hold data for the conversations fetched from the
       
    41  * server.
       
    42  *
       
    43  */
       
    44 
       
    45 class CONVERSATIONS_ENGINE_API_EXPORT ConversationsEngine : public QObject
       
    46 {
       
    47     Q_OBJECT
       
    48 
       
    49 public:
       
    50 
       
    51     /**
       
    52      * Returns pointer to sole instance.
       
    53      * @return ConversationEngine object
       
    54      */
       
    55     static ConversationsEngine* instance();
       
    56 
       
    57     /**
       
    58      * Destructor
       
    59      */
       
    60     virtual ~ConversationsEngine();
       
    61 
       
    62 public:
       
    63 
       
    64     /**
       
    65      * Returns Conversations Summary Model instance
       
    66      */
       
    67     QStandardItemModel* getConversationsSummaryModel();
       
    68 
       
    69     /**
       
    70      * Returns Conversations Model instance
       
    71      */
       
    72     QStandardItemModel* getConversationsModel();
       
    73 
       
    74     /**
       
    75      * Returns drafts Model instance
       
    76      */
       
    77     QStandardItemModel* getDraftsModel();
       
    78 
       
    79     /**
       
    80      * Get all conversations.
       
    81      * @param conversationId, conversationId
       
    82      * @return returns true if call is successful
       
    83      */
       
    84     bool getConversations(qint64 conversationId);
       
    85 	
       
    86     /**
       
    87      * Deregisters the current conversationId and clears the model
       
    88      * @return returns true if call is successful
       
    89      */
       
    90     bool clearConversations();
       
    91 
       
    92     /**
       
    93      * Delete all conversations.
       
    94      * @param conversationId, conversationId
       
    95      * @return returns true if call is successful
       
    96      */    
       
    97     bool deleteConversations(qint64 conversationId);
       
    98 
       
    99     /**
       
   100      * Delete all messages.
       
   101      * @param msgIdList, message list.
       
   102      */  
       
   103     void deleteMessages(QList<int>& msgIdList);
       
   104 
       
   105     /**
       
   106      * Marks all the unread conversations to read
       
   107      * @param conversationId, conversationId
       
   108      * @return returns true if call is successful
       
   109      */        
       
   110     bool markConversationRead(qint64 conversationId);
       
   111     
       
   112     /**
       
   113      * Mark messages as read.
       
   114      * @param msgIdList, message list.
       
   115      * @return returns true if call is successful
       
   116      */      
       
   117     bool markMessagesRead(QList<int>& msgIdList);
       
   118     
       
   119     /**
       
   120      * Get Contact details firstname/lastname.
       
   121      * @param conversationId, conversationId
       
   122      * @param firstName, First Name
       
   123      * @param lastName, Last Name
       
   124      */  
       
   125     void getContactDetails(qint64 conversationId,
       
   126         QString& firstName,
       
   127         QString& lastName,
       
   128         QString& address);
       
   129 
       
   130     /**
       
   131      * Get conversationId for a given address.
       
   132      * @param address, Phone number
       
   133      * @return conversation id
       
   134      */  
       
   135     qint64 getConversationIdFromAddress(QString address);
       
   136 
       
   137     /**
       
   138      * Get current conversation id.
       
   139      */  
       
   140     qint64 getCurrentConversationId();
       
   141 
       
   142     /**
       
   143      * Get conversationId for a given contactId.
       
   144      * @param contactId, Contact Id
       
   145      * @return conversation id
       
   146      */ 
       
   147     qint64 getConversationIdFromContactId(qint32 contactId);
       
   148 
       
   149     /**
       
   150      * Emits conversationModelPopulated signal
       
   151      */ 
       
   152     void emitConversationModelPopulated();
       
   153     
       
   154     /**
       
   155      * Emits conversationModelUpdated signal
       
   156      */ 
       
   157     void emitConversationModelUpdated();
       
   158     
       
   159     /**
       
   160      * Emits conversationListModelPopulated signal
       
   161      */ 
       
   162     void emitConversationListModelPopulated();
       
   163 
       
   164     /**
       
   165      *  Starts fetching remaing conversations
       
   166      */
       
   167     void fetchMoreConversations();
       
   168     
       
   169 private:
       
   170 
       
   171     /**
       
   172      * Constructor
       
   173      */
       
   174     explicit ConversationsEngine(QObject* parent = 0);    
       
   175     
       
   176 signals:
       
   177 
       
   178     /**
       
   179      * ConversationListModelPopulated signal indicating 
       
   180      * that the model is ready to be displayed
       
   181      */ 
       
   182     void conversationModelPopulated();
       
   183     
       
   184     /**
       
   185      * ConversationModelUpdated signal indicating dynamic 
       
   186      * updates in the model
       
   187      */ 
       
   188     void conversationModelUpdated();
       
   189     
       
   190     /**
       
   191      * ConversationListModelPopulated signal indicating 
       
   192      * that the model is ready to be displayed
       
   193      */
       
   194     void conversationListModelPopulated();
       
   195     
       
   196 private:
       
   197 
       
   198     /**
       
   199      * Conversations Summary Model
       
   200      * Own
       
   201      */        
       
   202     ConversationsSummaryModel* mConversationsSummaryModel;
       
   203 
       
   204     /**
       
   205      * Conversations Model
       
   206      * Own
       
   207      */    
       
   208     ConversationsModel* mConversationsModel;
       
   209 
       
   210     /**
       
   211      * Drafts Model
       
   212      * Own
       
   213      */    
       
   214     DraftsModel* mDraftsModel;
       
   215 
       
   216     /**
       
   217      * MsgStoreHandler
       
   218      * Own
       
   219      */    
       
   220     ConversationMsgStoreHandler* mConversationMsgStoreHandler;
       
   221     
       
   222     /**
       
   223      * ConversationsEnginePrivate
       
   224      * Own
       
   225      */
       
   226     ConversationsEnginePrivate* d_ptr;
       
   227 
       
   228 };
       
   229 
       
   230 #endif // CONVERSATIONS_ENGINE_H