messagingapp/msgservices/msgserviceapp/src/msgserviceviewmanager.cpp
author hgs
Fri, 06 Aug 2010 23:19:50 +0530
changeset 51 3507212d340e
parent 38 4e4b6adb1024
child 56 f42d9a78f435
permissions -rw-r--r--
201031_02
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
37
hgs
parents:
diff changeset
     1
/*
hgs
parents:
diff changeset
     2
 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
hgs
parents:
diff changeset
     3
 * All rights reserved.
hgs
parents:
diff changeset
     4
 * This component and the accompanying materials are made available
hgs
parents:
diff changeset
     5
 * under the terms of "Eclipse Public License v1.0"
hgs
parents:
diff changeset
     6
 * which accompanies this distribution, and is available
hgs
parents:
diff changeset
     7
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
hgs
parents:
diff changeset
     8
 *
hgs
parents:
diff changeset
     9
 * Initial Contributors:
hgs
parents:
diff changeset
    10
 * Nokia Corporation - initial contribution.
hgs
parents:
diff changeset
    11
 *
hgs
parents:
diff changeset
    12
 * Contributors:
hgs
parents:
diff changeset
    13
 *
hgs
parents:
diff changeset
    14
 * Description:  Manages differnt messaging views.
hgs
parents:
diff changeset
    15
 *
hgs
parents:
diff changeset
    16
 */
hgs
parents:
diff changeset
    17
hgs
parents:
diff changeset
    18
#include "msgserviceviewmanager.h"
hgs
parents:
diff changeset
    19
51
3507212d340e 201031_02
hgs
parents: 38
diff changeset
    20
#include <QPixmap>
37
hgs
parents:
diff changeset
    21
#include <HbMainWindow>
hgs
parents:
diff changeset
    22
#include <HbAction>
hgs
parents:
diff changeset
    23
#include <HbApplication>
hgs
parents:
diff changeset
    24
#include <hbmessagebox.h>
hgs
parents:
diff changeset
    25
hgs
parents:
diff changeset
    26
#include <xqserviceutil.h>
hgs
parents:
diff changeset
    27
#include <xqappmgr.h>
hgs
parents:
diff changeset
    28
hgs
parents:
diff changeset
    29
#include "msgunieditorview.h"
hgs
parents:
diff changeset
    30
#include "unifiedviewer.h"
hgs
parents:
diff changeset
    31
#include "msgstorehandler.h"
hgs
parents:
diff changeset
    32
hgs
parents:
diff changeset
    33
#include "msgsettingsview.h"
hgs
parents:
diff changeset
    34
#include "convergedmessageid.h"
hgs
parents:
diff changeset
    35
#include "ringbc.h"
hgs
parents:
diff changeset
    36
#include "unidatamodelloader.h"
hgs
parents:
diff changeset
    37
#include "unidatamodelplugininterface.h"
hgs
parents:
diff changeset
    38
51
3507212d340e 201031_02
hgs
parents: 38
diff changeset
    39
// CONSTANTS
3507212d340e 201031_02
hgs
parents: 38
diff changeset
    40
static const char SEND_EFFECT[] = "sendeffect";
3507212d340e 201031_02
hgs
parents: 38
diff changeset
    41
static const char SEND_EFFECT_FILE[] = ":/effects/sendeffect.fxml";
3507212d340e 201031_02
hgs
parents: 38
diff changeset
    42
37
hgs
parents:
diff changeset
    43
// LOCALIZATION
hgs
parents:
diff changeset
    44
#define LOC_DELETE_MESSAGE hbTrId("txt_messaging_dialog_delete_message")
hgs
parents:
diff changeset
    45
#define LOC_DLG_SAVE_RINGTONE hbTrId("txt_conversations_dialog_save_ringing_tone")
hgs
parents:
diff changeset
    46
hgs
parents:
diff changeset
    47
//----------------------------------------------------------------------------
hgs
parents:
diff changeset
    48
// MsgViewInterface::MsgViewInterface
hgs
parents:
diff changeset
    49
// @see header
hgs
parents:
diff changeset
    50
//----------------------------------------------------------------------------
hgs
parents:
diff changeset
    51
MsgServiceViewManager::MsgServiceViewManager(MsgStoreHandler* storeHandler,
hgs
parents:
diff changeset
    52
        HbMainWindow* mainWindow, QObject* parent) :
hgs
parents:
diff changeset
    53
        QObject(parent), mMainWindow(mainWindow), mUniEditor(NULL),
hgs
parents:
diff changeset
    54
        mUniViewer(NULL), mSettingsView(NULL), mBackAction(NULL),
hgs
parents:
diff changeset
    55
        mStoreHandler(storeHandler),mMessageId(-1)
hgs
parents:
diff changeset
    56
    {
hgs
parents:
diff changeset
    57
    //creating back action.
hgs
parents:
diff changeset
    58
    mBackAction = new HbAction(Hb::BackNaviAction, this);
hgs
parents:
diff changeset
    59
    connect(mBackAction, SIGNAL(triggered()), this, SLOT(onBackAction()));
hgs
parents:
diff changeset
    60
    
hgs
parents:
diff changeset
    61
    // create a temp view : which is required for lazy loading of other views
hgs
parents:
diff changeset
    62
    HbView* tempView = new HbView();
hgs
parents:
diff changeset
    63
    mMainWindow->addView(tempView);
hgs
parents:
diff changeset
    64
    mMainWindow->setCurrentView(tempView);
hgs
parents:
diff changeset
    65
    }
hgs
parents:
diff changeset
    66
hgs
parents:
diff changeset
    67
//----------------------------------------------------------------------------
hgs
parents:
diff changeset
    68
// MsgServiceViewManager::~MsgServiceViewManager
hgs
parents:
diff changeset
    69
// @see header
hgs
parents:
diff changeset
    70
//----------------------------------------------------------------------------
hgs
parents:
diff changeset
    71
MsgServiceViewManager::~MsgServiceViewManager()
hgs
parents:
diff changeset
    72
    {
hgs
parents:
diff changeset
    73
  
hgs
parents:
diff changeset
    74
    }
hgs
parents:
diff changeset
    75
hgs
parents:
diff changeset
    76
//----------------------------------------------------------------------------
hgs
parents:
diff changeset
    77
// MsgServiceViewManager::onBackAction
hgs
parents:
diff changeset
    78
// @see header
hgs
parents:
diff changeset
    79
//----------------------------------------------------------------------------
hgs
parents:
diff changeset
    80
void MsgServiceViewManager::onBackAction()
hgs
parents:
diff changeset
    81
    {
hgs
parents:
diff changeset
    82
    switch(mCurrentView)
hgs
parents:
diff changeset
    83
        {
hgs
parents:
diff changeset
    84
        case MsgBaseView::UNIEDITOR:
hgs
parents:
diff changeset
    85
            {
hgs
parents:
diff changeset
    86
            mUniEditor->saveContentToDrafts();
hgs
parents:
diff changeset
    87
            HbApplication::quit();
hgs
parents:
diff changeset
    88
            break;
hgs
parents:
diff changeset
    89
            }
hgs
parents:
diff changeset
    90
        case MsgBaseView::MSGSETTINGS:
hgs
parents:
diff changeset
    91
            {
hgs
parents:
diff changeset
    92
            //delete the settings instance
hgs
parents:
diff changeset
    93
            if (mSettingsView)
hgs
parents:
diff changeset
    94
            {
hgs
parents:
diff changeset
    95
                mMainWindow->removeView(mSettingsView);
hgs
parents:
diff changeset
    96
                delete mSettingsView;
hgs
parents:
diff changeset
    97
                mSettingsView = NULL;
hgs
parents:
diff changeset
    98
            }
hgs
parents:
diff changeset
    99
            if(mUniEditor)
hgs
parents:
diff changeset
   100
                {
hgs
parents:
diff changeset
   101
                mMainWindow->setCurrentView(mUniEditor);
hgs
parents:
diff changeset
   102
                mCurrentView = MsgBaseView::UNIEDITOR;
hgs
parents:
diff changeset
   103
                }
hgs
parents:
diff changeset
   104
            else 
hgs
parents:
diff changeset
   105
                {
hgs
parents:
diff changeset
   106
                ConvergedMessage message;
hgs
parents:
diff changeset
   107
                QVariantList param;
hgs
parents:
diff changeset
   108
                QByteArray dataArray;
hgs
parents:
diff changeset
   109
                QDataStream messageStream(&dataArray, 
hgs
parents:
diff changeset
   110
                        QIODevice::WriteOnly | QIODevice::Append);
hgs
parents:
diff changeset
   111
                message.serialize(messageStream);
hgs
parents:
diff changeset
   112
                param << dataArray;
hgs
parents:
diff changeset
   113
hgs
parents:
diff changeset
   114
                // switch to editor
hgs
parents:
diff changeset
   115
                switchToUniEditor(param);
hgs
parents:
diff changeset
   116
                }
hgs
parents:
diff changeset
   117
            break;
hgs
parents:
diff changeset
   118
            }
hgs
parents:
diff changeset
   119
        case MsgBaseView::UNIVIEWER: 
hgs
parents:
diff changeset
   120
        default:
hgs
parents:
diff changeset
   121
            {
hgs
parents:
diff changeset
   122
            HbApplication::quit();
hgs
parents:
diff changeset
   123
            break;
hgs
parents:
diff changeset
   124
            }
hgs
parents:
diff changeset
   125
            
hgs
parents:
diff changeset
   126
        }
hgs
parents:
diff changeset
   127
    }
hgs
parents:
diff changeset
   128
hgs
parents:
diff changeset
   129
//----------------------------------------------------------------------------
hgs
parents:
diff changeset
   130
// MsgServiceViewManager::switchView
hgs
parents:
diff changeset
   131
// @see header
hgs
parents:
diff changeset
   132
//----------------------------------------------------------------------------
hgs
parents:
diff changeset
   133
void MsgServiceViewManager::switchView(const QVariantList& data)
hgs
parents:
diff changeset
   134
    {
hgs
parents:
diff changeset
   135
    int viewId = data.at(0).toInt();
51
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   136
    switch (viewId)
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   137
        {
37
hgs
parents:
diff changeset
   138
        case MsgBaseView::UNIEDITOR:
hgs
parents:
diff changeset
   139
            {
hgs
parents:
diff changeset
   140
            // except first 2 parameters pass other parameters
hgs
parents:
diff changeset
   141
            QVariantList editorData;
hgs
parents:
diff changeset
   142
            for(int a = 2; a < data.length(); ++a)
hgs
parents:
diff changeset
   143
                {
hgs
parents:
diff changeset
   144
                editorData << data.at(a);
hgs
parents:
diff changeset
   145
                }
hgs
parents:
diff changeset
   146
            switchToUniEditor(editorData);
hgs
parents:
diff changeset
   147
            break;
hgs
parents:
diff changeset
   148
            }
hgs
parents:
diff changeset
   149
hgs
parents:
diff changeset
   150
        case MsgBaseView::MSGSETTINGS:
hgs
parents:
diff changeset
   151
            {
hgs
parents:
diff changeset
   152
            switchToMsgSettings(data);
hgs
parents:
diff changeset
   153
            break;
hgs
parents:
diff changeset
   154
            }
hgs
parents:
diff changeset
   155
        default: 
hgs
parents:
diff changeset
   156
            {
51
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   157
            // if send from editor is successful, then run effects
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   158
            int previousView = data.at(1).toInt();
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   159
            if(previousView == MsgBaseView::UNIEDITOR)
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   160
                {
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   161
                startAnimation(SEND_EFFECT);
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   162
                }
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   163
            else
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   164
                {
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   165
                HbApplication::quit();
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   166
                }
37
hgs
parents:
diff changeset
   167
            }
51
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   168
        }
37
hgs
parents:
diff changeset
   169
    }
hgs
parents:
diff changeset
   170
hgs
parents:
diff changeset
   171
//----------------------------------------------------------------------------
hgs
parents:
diff changeset
   172
// MsgServiceViewManager::send
hgs
parents:
diff changeset
   173
// @see header
hgs
parents:
diff changeset
   174
//----------------------------------------------------------------------------
hgs
parents:
diff changeset
   175
void MsgServiceViewManager::send(const QString phoneNumber, 
hgs
parents:
diff changeset
   176
        const qint32 contactId, 
hgs
parents:
diff changeset
   177
        const QString displayName)
hgs
parents:
diff changeset
   178
    {
51
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   179
    Q_UNUSED(contactId);
37
hgs
parents:
diff changeset
   180
    ConvergedMessage message;
hgs
parents:
diff changeset
   181
    ConvergedMessageAddress address;
hgs
parents:
diff changeset
   182
    address.setAddress(phoneNumber);
hgs
parents:
diff changeset
   183
    address.setAlias(displayName);
hgs
parents:
diff changeset
   184
    message.addToRecipient(address);
hgs
parents:
diff changeset
   185
hgs
parents:
diff changeset
   186
    QVariantList param;
hgs
parents:
diff changeset
   187
    QByteArray dataArray;
hgs
parents:
diff changeset
   188
    QDataStream messageStream(&dataArray, 
hgs
parents:
diff changeset
   189
            QIODevice::WriteOnly | QIODevice::Append);
hgs
parents:
diff changeset
   190
    message.serialize(messageStream);
hgs
parents:
diff changeset
   191
    param << dataArray;
hgs
parents:
diff changeset
   192
    
hgs
parents:
diff changeset
   193
    // switch to editor
hgs
parents:
diff changeset
   194
    switchToUniEditor(param);
hgs
parents:
diff changeset
   195
    
hgs
parents:
diff changeset
   196
    XQServiceUtil::toBackground(false);
hgs
parents:
diff changeset
   197
    }
hgs
parents:
diff changeset
   198
hgs
parents:
diff changeset
   199
//----------------------------------------------------------------------------
hgs
parents:
diff changeset
   200
// MsgServiceViewManager::send
hgs
parents:
diff changeset
   201
// @see header
hgs
parents:
diff changeset
   202
//----------------------------------------------------------------------------
hgs
parents:
diff changeset
   203
void MsgServiceViewManager::send(const QString phoneNumber, 
hgs
parents:
diff changeset
   204
        const QString alias, 
hgs
parents:
diff changeset
   205
        const QString bodyText)
hgs
parents:
diff changeset
   206
    {
hgs
parents:
diff changeset
   207
    ConvergedMessage message;
hgs
parents:
diff changeset
   208
    ConvergedMessageAddress address;
hgs
parents:
diff changeset
   209
    address.setAddress(phoneNumber);
hgs
parents:
diff changeset
   210
    address.setAlias(alias);
hgs
parents:
diff changeset
   211
    message.addToRecipient(address);
hgs
parents:
diff changeset
   212
    message.setBodyText(bodyText);
hgs
parents:
diff changeset
   213
hgs
parents:
diff changeset
   214
    QVariantList param;
hgs
parents:
diff changeset
   215
    QByteArray dataArray;
hgs
parents:
diff changeset
   216
    QDataStream messageStream(&dataArray, 
hgs
parents:
diff changeset
   217
            QIODevice::WriteOnly | QIODevice::Append);
hgs
parents:
diff changeset
   218
    message.serialize(messageStream);
hgs
parents:
diff changeset
   219
    param << dataArray;
hgs
parents:
diff changeset
   220
hgs
parents:
diff changeset
   221
    // switch to editor
hgs
parents:
diff changeset
   222
    switchToUniEditor(param);
hgs
parents:
diff changeset
   223
    
hgs
parents:
diff changeset
   224
    XQServiceUtil::toBackground(false);
hgs
parents:
diff changeset
   225
    }
hgs
parents:
diff changeset
   226
hgs
parents:
diff changeset
   227
//----------------------------------------------------------------------------
hgs
parents:
diff changeset
   228
// MsgServiceViewManager::send
hgs
parents:
diff changeset
   229
// @see header
hgs
parents:
diff changeset
   230
//----------------------------------------------------------------------------
hgs
parents:
diff changeset
   231
void MsgServiceViewManager::send(const QVariantMap addressList, 
hgs
parents:
diff changeset
   232
              const QString bodyText)
hgs
parents:
diff changeset
   233
    {
hgs
parents:
diff changeset
   234
    QStringList phoneNumList = addressList.keys();
hgs
parents:
diff changeset
   235
 
hgs
parents:
diff changeset
   236
    ConvergedMessageAddressList addrList; 
hgs
parents:
diff changeset
   237
	
hgs
parents:
diff changeset
   238
    int count = phoneNumList.count();
hgs
parents:
diff changeset
   239
    for( int i = 0; i < count; ++ i )
hgs
parents:
diff changeset
   240
        {
hgs
parents:
diff changeset
   241
        QString phNum = phoneNumList[i];
hgs
parents:
diff changeset
   242
        ConvergedMessageAddress* address = new ConvergedMessageAddress(phNum,
hgs
parents:
diff changeset
   243
                addressList.value(phNum).toString());	
hgs
parents:
diff changeset
   244
        addrList.append(address);
hgs
parents:
diff changeset
   245
        }
hgs
parents:
diff changeset
   246
    
hgs
parents:
diff changeset
   247
    ConvergedMessage message;
hgs
parents:
diff changeset
   248
    message.addToRecipients(addrList);
hgs
parents:
diff changeset
   249
    message.setBodyText(bodyText);
hgs
parents:
diff changeset
   250
    
hgs
parents:
diff changeset
   251
    QVariantList param;
hgs
parents:
diff changeset
   252
    QByteArray dataArray;
hgs
parents:
diff changeset
   253
    QDataStream messageStream(&dataArray, 
hgs
parents:
diff changeset
   254
            QIODevice::WriteOnly | QIODevice::Append);
hgs
parents:
diff changeset
   255
    message.serialize(messageStream);
hgs
parents:
diff changeset
   256
    param << dataArray;
hgs
parents:
diff changeset
   257
hgs
parents:
diff changeset
   258
    // switch to editor
hgs
parents:
diff changeset
   259
    switchToUniEditor(param);
hgs
parents:
diff changeset
   260
hgs
parents:
diff changeset
   261
    XQServiceUtil::toBackground(false);
hgs
parents:
diff changeset
   262
    }
hgs
parents:
diff changeset
   263
hgs
parents:
diff changeset
   264
//----------------------------------------------------------------------------
hgs
parents:
diff changeset
   265
// MsgServiceViewManager::send
hgs
parents:
diff changeset
   266
// @see header
hgs
parents:
diff changeset
   267
//----------------------------------------------------------------------------
hgs
parents:
diff changeset
   268
void MsgServiceViewManager::send(QVariant data)
hgs
parents:
diff changeset
   269
    {
hgs
parents:
diff changeset
   270
    ConvergedMessage message;
hgs
parents:
diff changeset
   271
    ConvergedMessageAttachmentList attachmentList;
hgs
parents:
diff changeset
   272
    // handle multiple files from sendUI
hgs
parents:
diff changeset
   273
    // e.g. contacts can send multiple vcards
hgs
parents:
diff changeset
   274
    QStringList receivedFiles = data.toStringList();
hgs
parents:
diff changeset
   275
    int recFileCount = receivedFiles.count();
hgs
parents:
diff changeset
   276
    for (int i = 0; i < recFileCount; i++) {
hgs
parents:
diff changeset
   277
    ConvergedMessageAttachment *attachment =
hgs
parents:
diff changeset
   278
    new ConvergedMessageAttachment(receivedFiles.at(i));
hgs
parents:
diff changeset
   279
    attachmentList.append(attachment);
hgs
parents:
diff changeset
   280
    }
hgs
parents:
diff changeset
   281
    message.addAttachments(attachmentList);
hgs
parents:
diff changeset
   282
hgs
parents:
diff changeset
   283
    QVariantList param;
hgs
parents:
diff changeset
   284
    QByteArray dataArray;
hgs
parents:
diff changeset
   285
    QDataStream messageStream(&dataArray, 
hgs
parents:
diff changeset
   286
            QIODevice::WriteOnly | QIODevice::Append);
hgs
parents:
diff changeset
   287
    message.serialize(messageStream);
hgs
parents:
diff changeset
   288
    param << dataArray;
hgs
parents:
diff changeset
   289
hgs
parents:
diff changeset
   290
    // switch to editor
hgs
parents:
diff changeset
   291
    switchToUniEditor(param);
hgs
parents:
diff changeset
   292
    
hgs
parents:
diff changeset
   293
    XQServiceUtil::toBackground(false);
hgs
parents:
diff changeset
   294
    }
hgs
parents:
diff changeset
   295
hgs
parents:
diff changeset
   296
//----------------------------------------------------------------------------
hgs
parents:
diff changeset
   297
// MsgServiceViewManager::switchToUniEditor
hgs
parents:
diff changeset
   298
// @see header
hgs
parents:
diff changeset
   299
//----------------------------------------------------------------------------
hgs
parents:
diff changeset
   300
void MsgServiceViewManager::switchToUniEditor(const QVariantList& editorData)
hgs
parents:
diff changeset
   301
    {
hgs
parents:
diff changeset
   302
    // construct
hgs
parents:
diff changeset
   303
    if (!mUniEditor) {
hgs
parents:
diff changeset
   304
    mUniEditor = new MsgUnifiedEditorView();
hgs
parents:
diff changeset
   305
    mMainWindow->addView(mUniEditor);
hgs
parents:
diff changeset
   306
    mUniEditor->setNavigationAction(mBackAction);
hgs
parents:
diff changeset
   307
    connect(mUniEditor, SIGNAL(switchView(const QVariantList&)), this,
hgs
parents:
diff changeset
   308
            SLOT(switchView(const QVariantList&)));
hgs
parents:
diff changeset
   309
    // construct completion : viewReady() signal was not called when 
hgs
parents:
diff changeset
   310
    // editor is constructed first time.
hgs
parents:
diff changeset
   311
   // mUniEditor->doDelayedConstruction();
hgs
parents:
diff changeset
   312
    }
hgs
parents:
diff changeset
   313
    
hgs
parents:
diff changeset
   314
    // populate
hgs
parents:
diff changeset
   315
    mUniEditor->populateContent(editorData);
hgs
parents:
diff changeset
   316
    
hgs
parents:
diff changeset
   317
    // set current view as editor
hgs
parents:
diff changeset
   318
    mMainWindow->setCurrentView(mUniEditor);
hgs
parents:
diff changeset
   319
    mCurrentView = MsgBaseView::UNIEDITOR;
hgs
parents:
diff changeset
   320
    }
hgs
parents:
diff changeset
   321
hgs
parents:
diff changeset
   322
//----------------------------------------------------------------------------
hgs
parents:
diff changeset
   323
// MsgServiceViewManager::switchToMsgSettings
hgs
parents:
diff changeset
   324
// @see header
hgs
parents:
diff changeset
   325
//----------------------------------------------------------------------------
hgs
parents:
diff changeset
   326
void MsgServiceViewManager::switchToMsgSettings(const QVariantList& data)
hgs
parents:
diff changeset
   327
    {
hgs
parents:
diff changeset
   328
    MsgSettingsView::SettingsView view = MsgSettingsView::DefaultView;
hgs
parents:
diff changeset
   329
    
hgs
parents:
diff changeset
   330
    if (mCurrentView == MsgBaseView::UNIEDITOR)
hgs
parents:
diff changeset
   331
    {
hgs
parents:
diff changeset
   332
        view = (MsgSettingsView::SettingsView)data.at(2).toInt();
hgs
parents:
diff changeset
   333
    }
hgs
parents:
diff changeset
   334
    
hgs
parents:
diff changeset
   335
    mCurrentView = MsgBaseView::MSGSETTINGS;
hgs
parents:
diff changeset
   336
hgs
parents:
diff changeset
   337
    if (!mSettingsView) {        
hgs
parents:
diff changeset
   338
    mSettingsView = new MsgSettingsView(view);
hgs
parents:
diff changeset
   339
    mSettingsView->setNavigationAction(mBackAction);
hgs
parents:
diff changeset
   340
    mMainWindow->addView(mSettingsView);
hgs
parents:
diff changeset
   341
    }
hgs
parents:
diff changeset
   342
    mMainWindow->setCurrentView(mSettingsView);
hgs
parents:
diff changeset
   343
    }
hgs
parents:
diff changeset
   344
hgs
parents:
diff changeset
   345
//----------------------------------------------------------------------------
hgs
parents:
diff changeset
   346
// MsgServiceViewManager::view
hgs
parents:
diff changeset
   347
// @see header
hgs
parents:
diff changeset
   348
//----------------------------------------------------------------------------
hgs
parents:
diff changeset
   349
void MsgServiceViewManager::view(int msgId)
hgs
parents:
diff changeset
   350
    {
hgs
parents:
diff changeset
   351
    int msgType;
hgs
parents:
diff changeset
   352
    int msgSubType;
hgs
parents:
diff changeset
   353
   
hgs
parents:
diff changeset
   354
    mMessageId = msgId;
hgs
parents:
diff changeset
   355
    // Mark as read and get message type
hgs
parents:
diff changeset
   356
    mStoreHandler->markAsReadAndGetType(msgId,msgType,msgSubType);
hgs
parents:
diff changeset
   357
    
hgs
parents:
diff changeset
   358
    switch (msgType) {
hgs
parents:
diff changeset
   359
        case ConvergedMessage::Sms:
hgs
parents:
diff changeset
   360
        case ConvergedMessage::Mms:
hgs
parents:
diff changeset
   361
        case ConvergedMessage::MmsNotification:
hgs
parents:
diff changeset
   362
            {
38
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   363
            handleSmsMmsMsg(msgId,msgType);
37
hgs
parents:
diff changeset
   364
            break;
hgs
parents:
diff changeset
   365
            }
hgs
parents:
diff changeset
   366
        case ConvergedMessage::BioMsg:
hgs
parents:
diff changeset
   367
            {
hgs
parents:
diff changeset
   368
            if (msgSubType == ConvergedMessage::RingingTone) {
hgs
parents:
diff changeset
   369
            handleRingtoneMsg(msgId);
hgs
parents:
diff changeset
   370
            }
hgs
parents:
diff changeset
   371
            else if (msgSubType == ConvergedMessage::Provisioning) {
hgs
parents:
diff changeset
   372
            handleProvisoningMsg(msgId);
hgs
parents:
diff changeset
   373
            }
hgs
parents:
diff changeset
   374
            break;
hgs
parents:
diff changeset
   375
            }
hgs
parents:
diff changeset
   376
        case ConvergedMessage::BT:
hgs
parents:
diff changeset
   377
            {
hgs
parents:
diff changeset
   378
            handleBTMessage(msgId);
hgs
parents:
diff changeset
   379
            break;
hgs
parents:
diff changeset
   380
            }
hgs
parents:
diff changeset
   381
        default:
hgs
parents:
diff changeset
   382
            {
hgs
parents:
diff changeset
   383
            // for un supported message show delete option
hgs
parents:
diff changeset
   384
            HbMessageBox::question(LOC_DELETE_MESSAGE, 
hgs
parents:
diff changeset
   385
                                   this,SLOT(onDialogDeleteMsg(HbAction*)),    
hgs
parents:
diff changeset
   386
                                   HbMessageBox::Delete | HbMessageBox::Cancel);
hgs
parents:
diff changeset
   387
            break;
hgs
parents:
diff changeset
   388
            }
hgs
parents:
diff changeset
   389
    }
hgs
parents:
diff changeset
   390
    }
hgs
parents:
diff changeset
   391
hgs
parents:
diff changeset
   392
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   393
// MsgServiceViewManager::handleSmsMmsMsg
hgs
parents:
diff changeset
   394
// @see header
hgs
parents:
diff changeset
   395
// ----------------------------------------------------------------------------
38
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   396
void MsgServiceViewManager::handleSmsMmsMsg(int msgId,int msgType)
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   397
{
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   398
    if(mStoreHandler->isDraftMessage(msgId))
37
hgs
parents:
diff changeset
   399
    {
38
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   400
        ConvergedMessageId convergedMsgId = ConvergedMessageId(msgId);
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   401
        ConvergedMessage message;
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   402
        message.setMessageType((ConvergedMessage::MessageType) msgType);
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   403
        message.setMessageId(convergedMsgId);
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   404
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   405
        // Launch uni-editor view
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   406
        QByteArray dataArray;
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   407
        QDataStream messageStream(&dataArray, QIODevice::WriteOnly | QIODevice::Append);
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   408
        message.serialize(messageStream);
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   409
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   410
        QVariantList params;
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   411
        params << MsgBaseView::UNIEDITOR; // target view
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   412
        params << MsgBaseView::SERVICE; // source view
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   413
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   414
        params << dataArray;
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   415
        
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   416
        // except first 2 parameters pass other parameters
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   417
        QVariantList editorData;
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   418
        for(int a = 2; a < params.length(); ++a)
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   419
        {
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   420
            editorData << params.at(a);
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   421
        }
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   422
        // construct
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   423
          if (!mUniEditor) {
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   424
          mUniEditor = new MsgUnifiedEditorView();
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   425
          mMainWindow->addView(mUniEditor);
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   426
          mUniEditor->setNavigationAction(mBackAction);
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   427
          connect(mUniEditor, SIGNAL(switchView(const QVariantList&)), this,
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   428
                  SLOT(switchView(const QVariantList&)));
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   429
          }
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   430
          
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   431
          // check if additional data for unieditor's consumption is available
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   432
          mUniEditor->openDraftsMessage(editorData);
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   433
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   434
          mMainWindow->setCurrentView(mUniEditor);
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   435
          mCurrentView = MsgBaseView::UNIEDITOR;
37
hgs
parents:
diff changeset
   436
    }
38
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   437
    else
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   438
    {
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   439
        if (!mUniViewer) {
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   440
            mUniViewer = new UnifiedViewer(msgId);
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   441
            mUniViewer->setNavigationAction(mBackAction);
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   442
            mMainWindow->addView(mUniViewer);
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   443
            connect(mUniViewer, SIGNAL(switchView(const QVariantList&)), this,
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   444
                SLOT(switchView(const QVariantList&)));
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   445
        }
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   446
        mUniViewer->populateContent(msgId, true, 1);
37
hgs
parents:
diff changeset
   447
38
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   448
        mMainWindow->setCurrentView(mUniViewer);
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   449
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   450
        // set current view as viewer
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   451
        mCurrentView = MsgBaseView::UNIVIEWER;
37
hgs
parents:
diff changeset
   452
    }
38
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   453
}
37
hgs
parents:
diff changeset
   454
hgs
parents:
diff changeset
   455
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   456
// MsgServiceViewManager::handleRingtoneMsg
hgs
parents:
diff changeset
   457
// @see header
hgs
parents:
diff changeset
   458
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   459
void MsgServiceViewManager::handleRingtoneMsg(int msgId)
hgs
parents:
diff changeset
   460
    {
hgs
parents:
diff changeset
   461
    mMessageId = msgId;
hgs
parents:
diff changeset
   462
    HbMessageBox::question(LOC_DLG_SAVE_RINGTONE, this,
hgs
parents:
diff changeset
   463
                           SLOT(onDialogSaveTone(HbAction*)),
hgs
parents:
diff changeset
   464
                           HbMessageBox::Save | HbMessageBox::Cancel);
hgs
parents:
diff changeset
   465
    }
hgs
parents:
diff changeset
   466
hgs
parents:
diff changeset
   467
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   468
// MsgServiceViewManager::handleProvisoningMsg
hgs
parents:
diff changeset
   469
// @see header
hgs
parents:
diff changeset
   470
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   471
void MsgServiceViewManager::handleProvisoningMsg(int msgId)
hgs
parents:
diff changeset
   472
    {
hgs
parents:
diff changeset
   473
    QString messageId;
hgs
parents:
diff changeset
   474
    messageId.setNum(msgId);
hgs
parents:
diff changeset
   475
hgs
parents:
diff changeset
   476
    XQApplicationManager* aiwMgr = new XQApplicationManager();
hgs
parents:
diff changeset
   477
hgs
parents:
diff changeset
   478
    XQAiwRequest* request = aiwMgr->create("com.nokia.services.MDM", 
hgs
parents:
diff changeset
   479
            "Provisioning",
hgs
parents:
diff changeset
   480
            "ProcessMessage(QString)", true); // embedded
hgs
parents:
diff changeset
   481
hgs
parents:
diff changeset
   482
    if (request) {
hgs
parents:
diff changeset
   483
    QList<QVariant> args;
hgs
parents:
diff changeset
   484
    args << QVariant(messageId);
hgs
parents:
diff changeset
   485
    request->setArguments(args);
hgs
parents:
diff changeset
   486
hgs
parents:
diff changeset
   487
    // Send the request
hgs
parents:
diff changeset
   488
    bool res = request->send();
hgs
parents:
diff changeset
   489
hgs
parents:
diff changeset
   490
    // Cleanup
hgs
parents:
diff changeset
   491
    delete request;
hgs
parents:
diff changeset
   492
    }
hgs
parents:
diff changeset
   493
hgs
parents:
diff changeset
   494
    delete aiwMgr;
hgs
parents:
diff changeset
   495
hgs
parents:
diff changeset
   496
    // close the application once its handled
hgs
parents:
diff changeset
   497
    HbApplication::quit();
hgs
parents:
diff changeset
   498
    }
hgs
parents:
diff changeset
   499
hgs
parents:
diff changeset
   500
//-----------------------------------------------------------------------------
hgs
parents:
diff changeset
   501
//MsgServiceViewManager::handleBTMessage()
hgs
parents:
diff changeset
   502
//@see header
hgs
parents:
diff changeset
   503
//-----------------------------------------------------------------------------
hgs
parents:
diff changeset
   504
void MsgServiceViewManager::handleBTMessage(int msgId)
hgs
parents:
diff changeset
   505
    {
hgs
parents:
diff changeset
   506
    XQApplicationManager* aiwMgr = new XQApplicationManager();
hgs
parents:
diff changeset
   507
    XQAiwRequest* request = 
hgs
parents:
diff changeset
   508
    aiwMgr->create("com.nokia.services.btmsgdispservices", "displaymsg",
hgs
parents:
diff changeset
   509
            "displaymsg(int)", true); // embedded
hgs
parents:
diff changeset
   510
hgs
parents:
diff changeset
   511
    if (request) {
hgs
parents:
diff changeset
   512
    QList<QVariant> args;
hgs
parents:
diff changeset
   513
    args << QVariant(msgId);
hgs
parents:
diff changeset
   514
    request->setArguments(args);
hgs
parents:
diff changeset
   515
hgs
parents:
diff changeset
   516
    // Send the request
hgs
parents:
diff changeset
   517
    bool res = request->send();
hgs
parents:
diff changeset
   518
hgs
parents:
diff changeset
   519
    // Cleanup
hgs
parents:
diff changeset
   520
    delete request;
hgs
parents:
diff changeset
   521
    }
hgs
parents:
diff changeset
   522
hgs
parents:
diff changeset
   523
    delete aiwMgr;
hgs
parents:
diff changeset
   524
hgs
parents:
diff changeset
   525
    // close the application once its handled
hgs
parents:
diff changeset
   526
    HbApplication::quit();
hgs
parents:
diff changeset
   527
    }
hgs
parents:
diff changeset
   528
hgs
parents:
diff changeset
   529
//-----------------------------------------------------------------------------
hgs
parents:
diff changeset
   530
//MsgServiceViewManager::onDialogDeleteMsg()
hgs
parents:
diff changeset
   531
//@see header
hgs
parents:
diff changeset
   532
//-----------------------------------------------------------------------------
hgs
parents:
diff changeset
   533
void MsgServiceViewManager::onDialogDeleteMsg(HbAction* action)
hgs
parents:
diff changeset
   534
{
hgs
parents:
diff changeset
   535
    HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender());
hgs
parents:
diff changeset
   536
    if (action == dlg->actions().at(0)) {
hgs
parents:
diff changeset
   537
        mStoreHandler->deleteMessage(mMessageId);
hgs
parents:
diff changeset
   538
    }
hgs
parents:
diff changeset
   539
    HbApplication::quit(); // exit after handling
hgs
parents:
diff changeset
   540
}
hgs
parents:
diff changeset
   541
hgs
parents:
diff changeset
   542
//-----------------------------------------------------------------------------
hgs
parents:
diff changeset
   543
//MsgServiceViewManager::onDialogSaveTone()
hgs
parents:
diff changeset
   544
//@see header
hgs
parents:
diff changeset
   545
//-----------------------------------------------------------------------------
hgs
parents:
diff changeset
   546
hgs
parents:
diff changeset
   547
void MsgServiceViewManager::onDialogSaveTone(HbAction* action)
hgs
parents:
diff changeset
   548
    {
hgs
parents:
diff changeset
   549
        HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender());
hgs
parents:
diff changeset
   550
        if (action == dlg->actions().at(0)) {
hgs
parents:
diff changeset
   551
hgs
parents:
diff changeset
   552
            UniDataModelLoader* pluginLoader = new UniDataModelLoader();
hgs
parents:
diff changeset
   553
            UniDataModelPluginInterface* pluginInterface = pluginLoader->getDataModelPlugin(
hgs
parents:
diff changeset
   554
                ConvergedMessage::BioMsg);
hgs
parents:
diff changeset
   555
            pluginInterface->setMessageId(mMessageId);
hgs
parents:
diff changeset
   556
            UniMessageInfoList attachments = pluginInterface->attachmentList();
hgs
parents:
diff changeset
   557
hgs
parents:
diff changeset
   558
            QString attachmentPath = attachments.at(0)->path();
hgs
parents:
diff changeset
   559
hgs
parents:
diff changeset
   560
            RingBc* ringBc = new RingBc();
hgs
parents:
diff changeset
   561
            ringBc->saveTone(attachmentPath);
hgs
parents:
diff changeset
   562
hgs
parents:
diff changeset
   563
            // clear attachement list : its allocated at data model
hgs
parents:
diff changeset
   564
            while (!attachments.isEmpty()) {
hgs
parents:
diff changeset
   565
                delete attachments.takeFirst();
hgs
parents:
diff changeset
   566
            }
hgs
parents:
diff changeset
   567
hgs
parents:
diff changeset
   568
            delete ringBc;
hgs
parents:
diff changeset
   569
            delete pluginLoader;
hgs
parents:
diff changeset
   570
        }
hgs
parents:
diff changeset
   571
hgs
parents:
diff changeset
   572
        // close the application once its handled
hgs
parents:
diff changeset
   573
        HbApplication::quit();
hgs
parents:
diff changeset
   574
}
hgs
parents:
diff changeset
   575
51
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   576
//-----------------------------------------------------------------------------
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   577
//MsgServiceViewManager::startAnimation
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   578
//@see header
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   579
//-----------------------------------------------------------------------------
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   580
void MsgServiceViewManager::startAnimation(QString effectEvent)
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   581
    {
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   582
    // take screen shot
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   583
    QGraphicsPixmapItem *animationScreenShot = screenShot();
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   584
    if (animationScreenShot)
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   585
        {
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   586
        // but don't show it yet.
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   587
        animationScreenShot->hide();
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   588
        animationScreenShot->setPos(0,0);
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   589
        animationScreenShot->setZValue(0);
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   590
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   591
        // hide items, so that background app's items are visible immediately
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   592
        mMainWindow->currentView()->hideItems(Hb::AllItems);
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   593
        
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   594
        // reset background & set the base transparent
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   595
        mMainWindow->setBackgroundImageName(
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   596
                mMainWindow->orientation(), QString("dummy_blank"));
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   597
        QPalette p = mMainWindow->viewport()->palette();
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   598
        p.setColor(QPalette::Base, Qt::transparent);
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   599
        mMainWindow->viewport()->setPalette(p);
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   600
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   601
        // add animating item directly to the scene
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   602
        mMainWindow->scene()->addItem(animationScreenShot);
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   603
        
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   604
        // hide other views
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   605
        QList<HbView*> vws = mMainWindow->views();
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   606
        while (!vws.isEmpty())
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   607
            {
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   608
            HbView* view = vws.takeLast();
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   609
            view->hide();
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   610
            }
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   611
        
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   612
        // now show the animating item, and start animation on it
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   613
        animationScreenShot->show();
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   614
        QString effectFile = getAnimationFile(effectEvent);
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   615
        HbEffect::add(animationScreenShot, effectFile, effectEvent);
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   616
        HbEffect::start(animationScreenShot, effectEvent, this,
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   617
                "onAnimationComplete");
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   618
        }
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   619
    }
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   620
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   621
//-----------------------------------------------------------------------------
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   622
//MsgServiceViewManager::resetAnimation
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   623
//@see header
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   624
//-----------------------------------------------------------------------------
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   625
void MsgServiceViewManager::resetAnimation(
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   626
        QString effectEvent,
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   627
        QGraphicsItem* item)
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   628
    {
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   629
    if (item) 
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   630
        {
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   631
        QString effectFile = getAnimationFile(effectEvent);
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   632
        HbEffect::remove(item, effectFile, effectEvent);
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   633
        mMainWindow->scene()->removeItem(item);
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   634
        delete item;
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   635
        item = NULL;
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   636
        }
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   637
    }
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   638
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   639
//-----------------------------------------------------------------------------
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   640
//MsgServiceViewManager::onAnimationComplete
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   641
//@see header
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   642
//-----------------------------------------------------------------------------
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   643
void MsgServiceViewManager::onAnimationComplete(
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   644
        const HbEffect::EffectStatus &status)
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   645
    {
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   646
    QGraphicsItem* item = status.item;
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   647
    QString effectEvent = status.effectEvent;
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   648
    resetAnimation(effectEvent, item);
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   649
    HbApplication::quit();
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   650
    }
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   651
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   652
//-----------------------------------------------------------------------------
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   653
//MsgServiceViewManager::screenShot
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   654
//@see header
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   655
//-----------------------------------------------------------------------------
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   656
QGraphicsPixmapItem* MsgServiceViewManager::screenShot()
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   657
    {
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   658
    // set fullscreen and hide unwanted items
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   659
    mMainWindow->currentView()->hideItems(Hb::ToolBarItem | Hb::DockWidgetItem | Hb::StatusBarItem);
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   660
    mMainWindow->currentView()->setContentFullScreen(true);
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   661
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   662
    // grab whole view into pixmap image
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   663
    QPixmap screenCapture = QPixmap::grabWindow(mMainWindow->internalWinId());
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   664
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   665
    // create an QGraphicsItem to do animation
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   666
    QGraphicsPixmapItem *ret(NULL);
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   667
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   668
    // for landscape, the screenshot must be rotated
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   669
    if(mMainWindow->orientation() == Qt::Horizontal)
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   670
        {
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   671
        QMatrix mat;
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   672
        mat.rotate(-90); // rotate 90 degrees counter-clockwise
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   673
        ret = new QGraphicsPixmapItem(screenCapture.transformed(mat));
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   674
        }
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   675
    else
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   676
        {
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   677
        ret = new QGraphicsPixmapItem(screenCapture);
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   678
        }
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   679
    return ret;
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   680
    }
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   681
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   682
//-----------------------------------------------------------------------------
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   683
//MsgServiceViewManager::getAnimationFile
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   684
//@see header
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   685
//-----------------------------------------------------------------------------
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   686
QString MsgServiceViewManager::getAnimationFile(QString effectEvent)
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   687
    {
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   688
    QString animFile;
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   689
    if(effectEvent == SEND_EFFECT)
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   690
        {
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   691
        animFile.append(SEND_EFFECT_FILE);
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   692
        }
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   693
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   694
    return animFile;
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   695
    }