| 37 |      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 services manages all messaging Qt highway services. 
 | 
|  |     15 |  *
 | 
|  |     16 |  */
 | 
| 73 |     17 | #include <hbapplication.h>
 | 
| 37 |     18 | #include "msgservicewindow.h"
 | 
|  |     19 | 
 | 
|  |     20 | #include "msgviewinterface.h"
 | 
|  |     21 | #include "msgsendinterface.h"
 | 
|  |     22 | #include "msgshareuiinterface.h"
 | 
| 56 |     23 | #include "msgurihandlerinterface.h"
 | 
| 37 |     24 | 
 | 
|  |     25 | #include "msgstorehandler.h"
 | 
|  |     26 | #include "msgserviceviewmanager.h"
 | 
|  |     27 | 
 | 
| 62 |     28 | #include <QKeyEvent>
 | 
|  |     29 | 
 | 
| 37 |     30 | // LOCALIZATION
 | 
|  |     31 | #define LOC_BUTTON_DELETE hbTrId("txt_common_button_delete")
 | 
|  |     32 | #define LOC_BUTTON_CANCEL hbTrId("txt_common_button_cancel")
 | 
|  |     33 | #define LOC_DELETE_MESSAGE hbTrId("txt_messaging_dialog_delete_message")
 | 
|  |     34 | 
 | 
|  |     35 | 
 | 
|  |     36 | // ----------------------------------------------------------------------------
 | 
|  |     37 | // MsgServiceWindow::MsgServiceWindow
 | 
|  |     38 | // @see header
 | 
|  |     39 | // ----------------------------------------------------------------------------
 | 
| 51 |     40 | MsgServiceWindow::MsgServiceWindow():HbMainWindow(
 | 
|  |     41 |         NULL,Hb::WindowFlagTransparent),
 | 
|  |     42 | mSendInterface(NULL),
 | 
| 37 |     43 | mViewInterface(NULL),
 | 
|  |     44 | mShareUiInterface(NULL),
 | 
|  |     45 | mStoreHandler(NULL),
 | 
|  |     46 | mViewManager(NULL)
 | 
|  |     47 |     {
 | 
|  |     48 |     // create stote handler
 | 
| 51 |     49 |     mStoreHandler = q_check_ptr(new MsgStoreHandler());
 | 
| 37 |     50 |     
 | 
|  |     51 |     // create view manager
 | 
|  |     52 |     mViewManager = new MsgServiceViewManager(mStoreHandler,this);
 | 
|  |     53 |     
 | 
|  |     54 |     // create interfaces 
 | 
|  |     55 |     mSendInterface = new MsgSendInterface(mViewManager);
 | 
|  |     56 |     mViewInterface = new MsgViewInterface(mViewManager);
 | 
| 56 |     57 |     mUriInterface = new MsgUriHandlerInterface(mViewManager);
 | 
| 37 |     58 |     mShareUiInterface = new MsgShareUiInterface(mViewManager);
 | 
| 73 |     59 |     
 | 
|  |     60 |     // connect to aboutToQuit signal to save drafts content
 | 
|  |     61 |     QObject::connect(qApp, SIGNAL(aboutToQuit()), 
 | 
|  |     62 |                 this, SLOT(saveDraftContents()));
 | 
| 37 |     63 |     }
 | 
|  |     64 | 
 | 
|  |     65 | // ----------------------------------------------------------------------------
 | 
|  |     66 | // MsgServiceWindow::~MsgServiceWindow
 | 
|  |     67 | // @see header
 | 
|  |     68 | // ----------------------------------------------------------------------------
 | 
|  |     69 | MsgServiceWindow::~MsgServiceWindow()
 | 
|  |     70 |     {
 | 
|  |     71 |     if(mShareUiInterface)
 | 
|  |     72 |         {
 | 
|  |     73 |         delete mShareUiInterface;
 | 
|  |     74 |         }
 | 
| 56 |     75 | 	
 | 
|  |     76 | 	if(mUriInterface)
 | 
|  |     77 |         {
 | 
|  |     78 |         delete mUriInterface;
 | 
|  |     79 |         }
 | 
|  |     80 | 		
 | 
| 37 |     81 |     if(mViewInterface)
 | 
|  |     82 |         {
 | 
|  |     83 |         delete mViewInterface;
 | 
|  |     84 |         }
 | 
|  |     85 |     if(mSendInterface)
 | 
|  |     86 |         {
 | 
|  |     87 |         delete mSendInterface;
 | 
|  |     88 |         }
 | 
|  |     89 |     if(mViewManager)
 | 
|  |     90 |         {
 | 
|  |     91 |         delete mViewManager;
 | 
|  |     92 |         }
 | 
|  |     93 | 
 | 
|  |     94 |     if(mStoreHandler)
 | 
|  |     95 |         {
 | 
|  |     96 |         delete mStoreHandler;
 | 
|  |     97 |         }
 | 
|  |     98 |     }
 | 
|  |     99 | 
 | 
| 62 |    100 | //---------------------------------------------------------------
 | 
|  |    101 | // MsgServiceWindow::keyPressEvent
 | 
|  |    102 | // @see header
 | 
|  |    103 | //---------------------------------------------------------------
 | 
|  |    104 | void MsgServiceWindow::keyPressEvent(QKeyEvent *event)
 | 
|  |    105 | {
 | 
|  |    106 |     bool eventHandled = false;
 | 
|  |    107 |     if (Qt::Key_Yes == event->key()) {
 | 
|  |    108 |         eventHandled = mViewManager->handleKeyEvent(event->key());
 | 
|  |    109 |     }
 | 
| 37 |    110 | 
 | 
| 62 |    111 |     if (eventHandled) {
 | 
|  |    112 |         event->accept();
 | 
|  |    113 |     }
 | 
|  |    114 |     else {
 | 
|  |    115 |         HbMainWindow::keyPressEvent(event);
 | 
|  |    116 |     }
 | 
| 37 |    117 | 
 | 
| 62 |    118 | }
 | 
| 73 |    119 | 
 | 
|  |    120 | //---------------------------------------------------------------
 | 
|  |    121 | // MsgServiceWindow::saveActivity
 | 
|  |    122 | // @see header
 | 
|  |    123 | //---------------------------------------------------------------
 | 
|  |    124 | void MsgServiceWindow::saveDraftContents()
 | 
|  |    125 | {
 | 
|  |    126 |     mViewManager->saveContentToDraft();
 | 
|  |    127 | }
 | 
| 62 |    128 | // EOF
 |