messagingapp/msgui/msgapp/inc/msgviewmanager.h
branchRCL_3
changeset 57 ebe688cedc25
equal deleted inserted replaced
54:fa1df4b99609 57:ebe688cedc25
       
     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  * class to manage differnt messaging views.
       
    16  *
       
    17  */
       
    18 
       
    19 #ifndef MSGVIEWMANAGER_H_
       
    20 #define MSGVIEWMANAGER_H_
       
    21 
       
    22 #include <QObject>
       
    23 #include <QVariantList>
       
    24 #include <QVariant>
       
    25 
       
    26 class HbMainWindow;
       
    27 class MsgUnifiedEditorView;
       
    28 class MsgListView;
       
    29 class MsgConversationBaseView;
       
    30 class UnifiedViewer;
       
    31 class MsgBaseView;
       
    32 class DraftsListView;
       
    33 class MsgSettingsView;
       
    34 class HbAction;
       
    35 class HbView;
       
    36 class MsgAudioFetcherView;
       
    37 
       
    38 class MsgViewManager: public QObject
       
    39 {
       
    40 Q_OBJECT
       
    41 
       
    42 public:
       
    43     /**
       
    44      * constructor
       
    45      */
       
    46     MsgViewManager(bool serviceRequest, HbMainWindow* mainWindow, 
       
    47                    QObject* parent = 0,int activityMsgId = -1);
       
    48 
       
    49     /**
       
    50      * Destructor.
       
    51      */
       
    52     ~MsgViewManager();
       
    53 
       
    54     /**
       
    55      * call back function will be called from MsgServiceInterface.
       
    56      */
       
    57     void send(const qint32 contactId, const QString phoneNumber, const QString displayName);
       
    58 
       
    59     /**
       
    60      * call back function called from MsgServiceInterface to set service request flag.
       
    61      */
       
    62     void setServiceRequest(bool request);
       
    63 
       
    64     /**
       
    65      * call back function called MsgServiceInterface.
       
    66      */
       
    67     void open(qint64 conversationId);
       
    68 
       
    69     /**
       
    70      * call back function called MsgServiceInterface.
       
    71      */
       
    72     void send(QVariant data);
       
    73 
       
    74     /**
       
    75      * depricated api. will be removed in future.
       
    76      */
       
    77     void openEditor(QString number, QString name);
       
    78 
       
    79     /**
       
    80      * call back function will be called from MsgServiceInterface.
       
    81      */
       
    82     void send(const QString phoneNumber, const QString alias, const QString bodyText);
       
    83 
       
    84     /**
       
    85      * Opens the viewer to view the message.
       
    86      * @param msgId message id of the message.
       
    87      */
       
    88     void view(int msgId);
       
    89 
       
    90     /**
       
    91      * Returns the current active view.
       
    92      */
       
    93     int currentView();
       
    94 	
       
    95     /**
       
    96 	 * Saves the content of editor or Cv to draft.
       
    97 	 */
       
    98     int saveContentToDraft();
       
    99 private:
       
   100     /**
       
   101      * swiches back to last view after service request is complete.
       
   102      */
       
   103     void switchToLastSavedView();
       
   104 
       
   105     /**
       
   106      * find conversation id corresponding to given phone no.
       
   107      * @param phoneNum
       
   108      */
       
   109     qint64 findConversationId(const QString phoneNum);
       
   110 
       
   111     /**
       
   112      * helper method to complete back action.
       
   113      */
       
   114     void completeServiceRequest();
       
   115 
       
   116     /*
       
   117      * switch to clv.
       
   118      */
       
   119     void switchToClv(const QVariantList& data);
       
   120 
       
   121     /*
       
   122      * switch to cv.
       
   123      */
       
   124     void switchToCv(const QVariantList& data);
       
   125 
       
   126     /*
       
   127      * switch to dlv.
       
   128      */
       
   129     void switchToDlv(const QVariantList& data);
       
   130 
       
   131     /*
       
   132      * switch to unieditor.
       
   133      */
       
   134     void switchToUniEditor(const QVariantList& data);
       
   135 
       
   136     /*
       
   137      * switch to univiewer.
       
   138      */
       
   139     void switchToUniViewer(const QVariantList& data);
       
   140 
       
   141     /*
       
   142      * switch to settings.
       
   143      */
       
   144     void switchToMsgSettings(const QVariantList& data);
       
   145 
       
   146     /*
       
   147      * handle other cases.
       
   148      */
       
   149     void handleDefault(const QVariantList& data);
       
   150 
       
   151     /**
       
   152      * handle sms and mms messge
       
   153      * @param msgId message id
       
   154      */
       
   155     void handleSmsMmsMsg(int msgId);
       
   156 
       
   157     /**
       
   158      * handle ringtone message
       
   159      * @param msgId message id
       
   160      */
       
   161     void handleRingtoneMsg(int msgId);
       
   162 
       
   163     /**
       
   164      * handle provisioning message
       
   165      * @param msgId message id
       
   166      */
       
   167     void handleProvisoningMsg(int msgId);
       
   168     
       
   169 	/**
       
   170 	* Appends the views to be deleted into a QList to be deleted when view is ready
       
   171 	*/
       
   172     void appendViewToBeDeleted(HbView* view);
       
   173 
       
   174 	 /**
       
   175 	  * Save the editor data to be populated
       
   176 	  * @param editorData QVariantList
       
   177 	  */    
       
   178     void populateUniEditorAfterViewReady(const QVariantList& editorData);
       
   179     
       
   180     /**
       
   181      * Launch Audio fetcher view
       
   182      */
       
   183     void switchToAudioFetcher(const QVariantList& data);
       
   184 	
       
   185 	/**
       
   186 	 * opens unieditor as activity.
       
   187 	 * @param activityMsgId activity msg id.
       
   188 	 */
       
   189 	void openUniEditorActivity(int activityMsgId);
       
   190 
       
   191     /**
       
   192     * find contact id corresponding to given phone no.
       
   193     * @param phoneNum
       
   194     */
       
   195     qint32 findContactId(const QString address);
       
   196     
       
   197 private slots:
       
   198     /**
       
   199      * this slot is called on mainwindows back action.
       
   200      */
       
   201     void onBackAction();
       
   202 
       
   203     /**
       
   204      * This slot is called when switchView signal is emitted from a view.
       
   205      */
       
   206     void switchView(const QVariantList& data);
       
   207 
       
   208     /**
       
   209      * This slot is called when viewReady signal is emitted from main window.
       
   210      */
       
   211     void setViewInteractive();
       
   212 
       
   213     /**
       
   214      * Slot to delete previous view instances on view switch
       
   215      */
       
   216     void deletePreviousView();
       
   217 	
       
   218 	/**
       
   219      * This slot is called when delete message dialog is launched.
       
   220      * @param action selected action (yes or no).
       
   221      */	
       
   222     void onDialogDeleteMsg(HbAction* action);
       
   223     
       
   224 	/**
       
   225      * This slot is called when save tone dialog is launched.
       
   226      * @param action selected action (yes or no).
       
   227      */	
       
   228     void onDialogSaveTone(HbAction* action);
       
   229     
       
   230     /**
       
   231      * When this slot is called the saved editor data is set to the editor
       
   232      */
       
   233     void populateUniEditorView();
       
   234 	
       
   235 private:
       
   236     /**
       
   237      * main window reference not owned.
       
   238      */
       
   239     HbMainWindow* mMainWindow;
       
   240 
       
   241     /**
       
   242      * different views.
       
   243      */
       
   244     MsgUnifiedEditorView* mUniEditor;
       
   245     MsgListView* mListView;
       
   246     MsgConversationBaseView* mConversationView;
       
   247     UnifiedViewer* mUniViewer;
       
   248     DraftsListView* mDraftsListView;
       
   249     MsgSettingsView* mSettingsView;
       
   250     MsgAudioFetcherView* mAudioFetcherView;
       
   251     HbAction* mBackAction;
       
   252 
       
   253     int mPreviousView;
       
   254     int mCurrentView;
       
   255     int mViewAtServiceRequest;
       
   256     bool mServiceRequest;
       
   257     qint64 mConversationId;
       
   258     bool mViewServiceRequest;
       
   259     QList<HbView*> mViewTobeDeleted;
       
   260     HbView* mDummyview;
       
   261     int mMessageId;
       
   262     
       
   263     QVariantList mEditorData;
       
   264     QVariantList mViewerData;
       
   265 };
       
   266 
       
   267 #endif /* MSGVIEWMANAGER_H_ */