messagingapp/msgui/conversationview/inc/msgconversationview.h
changeset 31 ebfee66fde93
child 34 84197e66a4bd
equal deleted inserted replaced
30:6a20128ce557 31:ebfee66fde93
       
     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:Message chat View for the messaging application.
       
    15  *
       
    16  */
       
    17 
       
    18 #ifndef MSG_CONVERSATION_VIEW_H
       
    19 #define MSG_CONVERSATION_VIEW_H
       
    20 
       
    21 // INCLUDES
       
    22 #include "msgbaseview.h"
       
    23 #include "convergedmessage.h"
       
    24 
       
    25 //Forward declarations
       
    26 class HbListView;
       
    27 class HbAbstractViewItem;
       
    28 class MsgSendUtil;
       
    29 class QStandardItemModel;
       
    30 class MsgEditorWidget;
       
    31 class MsgContactCardWidget;
       
    32 class MsgConversationViewItem;
       
    33 class HbStaticVkbHost;
       
    34 class QGraphicsLinearLayout;
       
    35 class HbAction;
       
    36 //Defines
       
    37 #define INVALID_MSG_ID -1
       
    38 
       
    39 /**
       
    40  * This class provides the message chat view for the messaging application.
       
    41  * Data source for this view is the conversation model.
       
    42  */
       
    43 class MsgConversationView : public MsgBaseView
       
    44 {
       
    45 Q_OBJECT
       
    46 
       
    47 public:
       
    48 
       
    49     /**
       
    50      * Constructor
       
    51      */
       
    52     MsgConversationView(MsgContactCardWidget *contactCardWidget,
       
    53         QGraphicsItem *parent = 0);
       
    54 
       
    55     /**
       
    56      * Destructor
       
    57      */
       
    58     ~MsgConversationView();
       
    59 
       
    60 
       
    61     /**
       
    62      * Clear editors
       
    63      * clear message and address editors
       
    64      */
       
    65     void clearEditors();
       
    66 
       
    67     /**
       
    68      * Save the content inside editor to drafts
       
    69      * @return true if save is success else false.
       
    70      */
       
    71     bool saveContentToDrafts();
       
    72 
       
    73 private slots:
       
    74 
       
    75     /**
       
    76      * Slot is called when menu is about to be shown.
       
    77      * Populates the menu with relevant actions.
       
    78      */
       
    79     void menuAboutToShow();
       
    80     
       
    81 	/**
       
    82      * This slot is called when settings dialog is launched.
       
    83      * @param action selected action (yes or no).
       
    84      */
       
    85     void onDialogSettingsLaunch(HbAction* action);
       
    86     
       
    87 	/**
       
    88      * This slot is called when delete message centre dialog is launched.
       
    89      * @param action selected action (yes or no).
       
    90      */	
       
    91     void onDialogdeleteMsg(HbAction* action);
       
    92 	
       
    93 	/**
       
    94      * This slot is called when download message centre dialog is launched.
       
    95      * @param action selected action (yes or no).
       
    96      */	    
       
    97     void onDialogDownLoadMsg(HbAction* action);
       
    98 	
       
    99 	/**
       
   100      * This slot is called when save tone dialog is launched.
       
   101      * @param action selected action (yes or no).
       
   102      */	
       
   103     void onDialogSaveTone(HbAction* action);
       
   104 
       
   105 private:
       
   106 
       
   107     /**
       
   108      * View initialization function.
       
   109      */
       
   110     void setupView();
       
   111 
       
   112     /**
       
   113      * Setup view menu items.
       
   114      */
       
   115     void setupMenu();
       
   116 
       
   117     /**
       
   118      * Populates ConvergedMessage for sending.
       
   119      * @param ConvergedMessage to be populated
       
   120      * @see ConvergedMessage::MessageType
       
   121      */
       
   122     void populateForSending(ConvergedMessage &message);
       
   123     
       
   124     /**
       
   125      * Adds context menu entries to context menu
       
   126      * @param HbMenu context menu
       
   127      * @param int sendingstate.
       
   128      * @see ConvergedMessage::MessageType
       
   129      */
       
   130     void setContextMenu(MsgConversationViewItem* item, HbMenu* contextMenu, int sendingState);
       
   131 	
       
   132     /**
       
   133      * Adds context menu entry to context menu for saving items
       
   134      * @param MsgConversationViewItem* item whose information is needed.
       
   135      * @param HbMenu context menu
       
   136      * @param int sendingstate.
       
   137      * @see ConvergedMessage::MessageType
       
   138      */    
       
   139     void addSaveItemToContextMenu(MsgConversationViewItem* item, HbMenu* contextMenu, int sendingState);
       
   140     
       
   141     /**
       
   142      * Adds context menu entry to context menu for Opening items
       
   143 	 * @param MsgConversationViewItem* item whose information is needed.
       
   144      * @param HbMenu context menu
       
   145      * @param int sendingstate.
       
   146      * @see ConvergedMessage::MessageType
       
   147      */
       
   148     void addOpenItemToContextMenu(MsgConversationViewItem* item, HbMenu* contextMenu, int sendingState);
       
   149 
       
   150     /**
       
   151      * Adds context menu entry to context menu for Resending items
       
   152      * @param MsgConversationViewItem* item whose information is needed.
       
   153      * @param HbMenu context menu
       
   154      * @param int sendingstate.
       
   155      * @see ConvergedMessage::MessageType
       
   156      */  
       
   157     void addResendItemToContextMenu(MsgConversationViewItem* item, HbMenu* contextMenu, int sendingState);
       
   158 
       
   159     /**
       
   160      * Adds context menu entry to context menu for Forwarding items
       
   161 	 * @param MsgConversationViewItem* item whose information is needed.
       
   162      * @param HbMenu context menu
       
   163      * @param int sendingstate.
       
   164      * @see ConvergedMessage::MessageType
       
   165      */
       
   166     void addForwardItemToContextMenu(MsgConversationViewItem* item, HbMenu* contextMenu, int sendingState);
       
   167 
       
   168     /**
       
   169      * Adds context menu entry to context menu for Deleting items
       
   170 	 * @param MsgConversationViewItem* item whose information is needed.
       
   171      * @param HbMenu context menu
       
   172      * @param int sendingstate.
       
   173      * @see ConvergedMessage::MessageType
       
   174      */
       
   175     void addDeleteItemToContextMenu(MsgConversationViewItem* item, HbMenu* contextMenu, int sendingState);
       
   176 
       
   177     /**
       
   178      * Adds context menu entry to context menu for Downloading items
       
   179      * @param MsgConversationViewItem* item whose information is needed.
       
   180      * @param HbMenu context menu    
       
   181      * @see ConvergedMessage::MessageType
       
   182      */
       
   183     void addDownloadItemToContextMenu(MsgConversationViewItem* item, HbMenu* contextMenu);
       
   184     
       
   185     /**
       
   186      * Validates if message can be forwarded
       
   187      * @param messageType
       
   188      * @param messageId
       
   189      * @return true if message can be forwarded
       
   190      *         false if message cant be forwarded
       
   191      */
       
   192     bool validateMsgForForward(int &messageType,qint32 &messageId);
       
   193 
       
   194     /**
       
   195      * Launches the BT message display service.
       
   196      * @param index Index of the item activated/touched
       
   197      */
       
   198     void launchBtDisplayService(const QModelIndex & index);
       
   199 
       
   200 public slots:
       
   201     /**
       
   202      * Refreshes all widgets in the conversation view according to latest model
       
   203      * data
       
   204      */
       
   205     void refreshView();
       
   206     
       
   207 private slots:
       
   208 
       
   209     /**
       
   210      * Utility method to scroll the list to show the bottom most item
       
   211      */
       
   212     void scrollToBottom();
       
   213 
       
   214     /**
       
   215      * Handler for long tap of a list item.
       
   216      * @param viewItem  Long tapped view item
       
   217      * @param point X and Y co-ordinates of long tap
       
   218      */
       
   219     void longPressed(HbAbstractViewItem* viewItem, const QPointF& point);
       
   220 
       
   221     /**
       
   222      * Handler for short tap/direct touch of a list item.
       
   223      * @param index index of the item activated/touched
       
   224      */
       
   225     void openItem(const QModelIndex & index);
       
   226 
       
   227     /**
       
   228      * Sends the message
       
   229      */
       
   230     void send();
       
   231 
       
   232     // ----------------------------- View Specific Menu Slots--------------------//
       
   233 
       
   234    
       
   235     /**
       
   236      * Fetch images 
       
   237      */
       
   238     void fetchImages();
       
   239 
       
   240     /**
       
   241      * Fectch conatcts
       
   242      */
       
   243     void fetchContacts();
       
   244 
       
   245     /**
       
   246      * Fectch audio
       
   247      */
       
   248     void fetchAudio();
       
   249 
       
   250     /*
       
   251      * Get the photos and launch editor
       
   252      */
       
   253     void imagesFetched(const QVariant& result );
       
   254     
       
   255     /**
       
   256      * slot to receive fetched contacts for addition
       
   257      */
       
   258     void contactsFetched(const QVariant& value);
       
   259 
       
   260     /*
       
   261      * Get audio files from audio-fetcher and launch editor
       
   262      */
       
   263     void audiosFetched(const QVariant& result );
       
   264     
       
   265     /**
       
   266      * slot to receive fetched contacts for vcard addition
       
   267      */
       
   268     void contactsFetchedForVCards(const QVariant& value);
       
   269     
       
   270     /*
       
   271      * Adds subject file to editor.
       
   272      */
       
   273     void addSubject();
       
   274 
       
   275 
       
   276     //----------------------Item Specific menu slots ---------------------//
       
   277 
       
   278     /**
       
   279      * Forwards the message
       
   280      */
       
   281     void forwardMessage();
       
   282 
       
   283     /**
       
   284      * Deletes the item
       
   285      */
       
   286     void deleteItem();
       
   287     
       
   288     /**
       
   289      * Resends the item. This is only valid in the failed message case.
       
   290      */
       
   291     void resendMessage();
       
   292 
       
   293     /**
       
   294      * Download the specified message
       
   295      */
       
   296     void downloadMessage();
       
   297 
       
   298     /**
       
   299      * Open the item
       
   300      */
       
   301     void openItem();
       
   302 
       
   303     /**
       
   304      * Set model to the view 
       
   305      */    
       
   306     void populateConversationsView();
       
   307 
       
   308     /**
       
   309      * Save ringing tone
       
   310      */
       
   311     void saveRingingTone();   
       
   312     
       
   313     /**
       
   314      * Launch Editor since sms character limit reached
       
   315      */
       
   316     void handleSmsCharLimitReached();   
       
   317     
       
   318 signals:
       
   319     /**
       
   320      * Signal emitted to inform close the conversation view.
       
   321      * When Conversation view has opened in send mode, after sending
       
   322      * the message, this signal is emitted.
       
   323      */
       
   324     void closeConversationView();
       
   325 
       
   326     /**
       
   327      * Emitted when editor is tapped to reply.
       
   328      */
       
   329     void replyStarted();
       
   330     
       
   331 	/**
       
   332 	* This signal is emitted when vkb is open.
       
   333 	*/
       
   334     void hideChrome(bool);
       
   335 
       
   336 private slots:
       
   337     /**
       
   338      * Resizes the view when VKB is opened.
       
   339      * This slot is triggered when user taps on the CV editor
       
   340      */
       
   341     void vkbOpened();
       
   342 
       
   343     /**
       
   344      * Resizes the view when VKB is closed.
       
   345      * This slot is triggered when VKB focus is lost.
       
   346      */
       
   347     void vkbClosed();
       
   348     
       
   349 private:
       
   350     /**
       
   351      * launch editor when attachment is inserted
       
   352      * @params data used for launching editor with pre-populated content
       
   353      */
       
   354     void launchUniEditor(const QVariantList& data);
       
   355     
       
   356     /**
       
   357      * Signal emitted when an error is generated.
       
   358      * @param errorCode Error code.
       
   359      * @param errorMessage Error description.
       
   360      */
       
   361     void serviceRequestError(int errorCode, const QString& errorMessage);
       
   362     
       
   363     /**
       
   364      * Activate Input Blocker
       
   365      */
       
   366     void activateInputBlocker();
       
   367 
       
   368     /**
       
   369      * Deactivate Input Blocker
       
   370      */
       
   371     void deactivateInputBlocker();
       
   372     
       
   373     /**
       
   374      * Handle provisioning message
       
   375      * @param msgId message id
       
   376      */
       
   377     void handleProvisoningMsg(int msgId);
       
   378 
       
   379 private:
       
   380 
       
   381     /**
       
   382      * List to hold the conversations
       
   383      * Owned
       
   384      */
       
   385     HbListView *mConversationList;
       
   386 
       
   387     /**
       
   388      * Model to facilitate filtering and sorting
       
   389      * Owned
       
   390      */
       
   391     QStandardItemModel *mMessageModel;
       
   392 
       
   393     /**
       
   394      * Instance of messaged editor widget.
       
   395      */
       
   396     MsgEditorWidget *mEditorWidget;
       
   397 
       
   398     /**
       
   399      * Instance of Contact Card widget.
       
   400      */
       
   401     MsgContactCardWidget* mContactCardWidget;
       
   402     
       
   403     /**
       
   404      * Send utils instance
       
   405      */
       
   406     MsgSendUtil *mSendUtil;
       
   407  
       
   408     /**
       
   409      * Instance of the main layout.
       
   410      */
       
   411     QGraphicsLinearLayout *mMainLayout;
       
   412 
       
   413 	/**
       
   414 	 * Flag to track if item has been long pressed.
       
   415 	 * TODO: Remove it, once unique longpress and click event signal released in week16
       
   416 	 */
       
   417     bool mItemLongPressed;
       
   418     /*
       
   419      * Instance of VKB 
       
   420      */
       
   421     HbStaticVkbHost* mVkbHost;
       
   422     
       
   423     /**
       
   424      * Flag to check it vkb is open.
       
   425      */
       
   426     bool mVkbopened;
       
   427 
       
   428 };
       
   429 
       
   430 #endif // MSG_CONVERSATION_VIEW_H
       
   431 // EOF