messagingapp/msgservices/msgserviceapp/src/msgserviceviewmanager.cpp
author hgs
Tue, 19 Oct 2010 11:30:16 +0530
changeset 76 60a8a215b0ec
parent 73 ecf6a73a9186
permissions -rw-r--r--
201041
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
67
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
    20
#include <QFileInfo>
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
    21
#include <QDir>
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
    22
#include <QFile>
51
3507212d340e 201031_02
hgs
parents: 38
diff changeset
    23
#include <QPixmap>
37
hgs
parents:
diff changeset
    24
#include <HbMainWindow>
hgs
parents:
diff changeset
    25
#include <HbAction>
hgs
parents:
diff changeset
    26
#include <HbApplication>
67
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
    27
#include <HbMessageBox>
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
    28
#include <HbDeviceMessageBox>
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
    29
#include <HbSplashScreen>
37
hgs
parents:
diff changeset
    30
hgs
parents:
diff changeset
    31
#include <xqserviceutil.h>
hgs
parents:
diff changeset
    32
#include <xqappmgr.h>
73
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
    33
#include <xqaiwdecl.h>
37
hgs
parents:
diff changeset
    34
hgs
parents:
diff changeset
    35
#include "msgunieditorview.h"
hgs
parents:
diff changeset
    36
#include "unifiedviewer.h"
hgs
parents:
diff changeset
    37
#include "msgstorehandler.h"
hgs
parents:
diff changeset
    38
#include "msgsettingsview.h"
hgs
parents:
diff changeset
    39
#include "convergedmessageid.h"
hgs
parents:
diff changeset
    40
#include "ringbc.h"
hgs
parents:
diff changeset
    41
#include "unidatamodelloader.h"
hgs
parents:
diff changeset
    42
#include "unidatamodelplugininterface.h"
hgs
parents:
diff changeset
    43
51
3507212d340e 201031_02
hgs
parents: 38
diff changeset
    44
// CONSTANTS
3507212d340e 201031_02
hgs
parents: 38
diff changeset
    45
static const char SEND_EFFECT[] = "sendeffect";
3507212d340e 201031_02
hgs
parents: 38
diff changeset
    46
static const char SEND_EFFECT_FILE[] = ":/effects/sendeffect.fxml";
3507212d340e 201031_02
hgs
parents: 38
diff changeset
    47
37
hgs
parents:
diff changeset
    48
// LOCALIZATION
73
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
    49
#define LOC_DELETED_MESSAGE hbTrId("txt_messages_dialog_message_has_been_deleted")
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
    50
#define LOC_CANNOT_OPEN_MESSAGE hbTrId("txt_messages_dialog_message_is_outgoingcannot_be")
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
    51
#define LOC_UNKNOWN_MSG_TYPE hbTrId("txt_messages_dialog_unsupported_message_type")
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
    52
#define LOC_SAVE_RINGTONE hbTrId("txt_conversations_dialog_save_ringing_tone")
37
hgs
parents:
diff changeset
    53
hgs
parents:
diff changeset
    54
//----------------------------------------------------------------------------
hgs
parents:
diff changeset
    55
// MsgViewInterface::MsgViewInterface
hgs
parents:
diff changeset
    56
// @see header
hgs
parents:
diff changeset
    57
//----------------------------------------------------------------------------
hgs
parents:
diff changeset
    58
MsgServiceViewManager::MsgServiceViewManager(MsgStoreHandler* storeHandler,
hgs
parents:
diff changeset
    59
        HbMainWindow* mainWindow, QObject* parent) :
hgs
parents:
diff changeset
    60
        QObject(parent), mMainWindow(mainWindow), mUniEditor(NULL),
hgs
parents:
diff changeset
    61
        mUniViewer(NULL), mSettingsView(NULL), mBackAction(NULL),
67
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
    62
        mStoreHandler(storeHandler)
37
hgs
parents:
diff changeset
    63
    {
hgs
parents:
diff changeset
    64
    //creating back action.
hgs
parents:
diff changeset
    65
    mBackAction = new HbAction(Hb::BackNaviAction, this);
hgs
parents:
diff changeset
    66
    connect(mBackAction, SIGNAL(triggered()), this, SLOT(onBackAction()));
hgs
parents:
diff changeset
    67
    
hgs
parents:
diff changeset
    68
    // create a temp view : which is required for lazy loading of other views
hgs
parents:
diff changeset
    69
    HbView* tempView = new HbView();
hgs
parents:
diff changeset
    70
    mMainWindow->addView(tempView);
hgs
parents:
diff changeset
    71
    mMainWindow->setCurrentView(tempView);
hgs
parents:
diff changeset
    72
    }
hgs
parents:
diff changeset
    73
hgs
parents:
diff changeset
    74
//----------------------------------------------------------------------------
hgs
parents:
diff changeset
    75
// MsgServiceViewManager::~MsgServiceViewManager
hgs
parents:
diff changeset
    76
// @see header
hgs
parents:
diff changeset
    77
//----------------------------------------------------------------------------
hgs
parents:
diff changeset
    78
MsgServiceViewManager::~MsgServiceViewManager()
hgs
parents:
diff changeset
    79
    {
hgs
parents:
diff changeset
    80
  
hgs
parents:
diff changeset
    81
    }
hgs
parents:
diff changeset
    82
hgs
parents:
diff changeset
    83
//----------------------------------------------------------------------------
hgs
parents:
diff changeset
    84
// MsgServiceViewManager::onBackAction
hgs
parents:
diff changeset
    85
// @see header
hgs
parents:
diff changeset
    86
//----------------------------------------------------------------------------
hgs
parents:
diff changeset
    87
void MsgServiceViewManager::onBackAction()
hgs
parents:
diff changeset
    88
    {
hgs
parents:
diff changeset
    89
    switch(mCurrentView)
hgs
parents:
diff changeset
    90
        {
hgs
parents:
diff changeset
    91
        case MsgBaseView::UNIEDITOR:
hgs
parents:
diff changeset
    92
            {
hgs
parents:
diff changeset
    93
            HbApplication::quit();
hgs
parents:
diff changeset
    94
            break;
hgs
parents:
diff changeset
    95
            }
hgs
parents:
diff changeset
    96
        case MsgBaseView::MSGSETTINGS:
hgs
parents:
diff changeset
    97
            {
hgs
parents:
diff changeset
    98
            //delete the settings instance
hgs
parents:
diff changeset
    99
            if (mSettingsView)
hgs
parents:
diff changeset
   100
            {
hgs
parents:
diff changeset
   101
                mMainWindow->removeView(mSettingsView);
hgs
parents:
diff changeset
   102
                delete mSettingsView;
hgs
parents:
diff changeset
   103
                mSettingsView = NULL;
hgs
parents:
diff changeset
   104
            }
hgs
parents:
diff changeset
   105
            if(mUniEditor)
hgs
parents:
diff changeset
   106
                {
hgs
parents:
diff changeset
   107
                mMainWindow->setCurrentView(mUniEditor);
hgs
parents:
diff changeset
   108
                mCurrentView = MsgBaseView::UNIEDITOR;
hgs
parents:
diff changeset
   109
                }
hgs
parents:
diff changeset
   110
            else 
hgs
parents:
diff changeset
   111
                {
hgs
parents:
diff changeset
   112
                ConvergedMessage message;
hgs
parents:
diff changeset
   113
                QVariantList param;
hgs
parents:
diff changeset
   114
                QByteArray dataArray;
hgs
parents:
diff changeset
   115
                QDataStream messageStream(&dataArray, 
hgs
parents:
diff changeset
   116
                        QIODevice::WriteOnly | QIODevice::Append);
hgs
parents:
diff changeset
   117
                message.serialize(messageStream);
hgs
parents:
diff changeset
   118
                param << dataArray;
hgs
parents:
diff changeset
   119
hgs
parents:
diff changeset
   120
                // switch to editor
hgs
parents:
diff changeset
   121
                switchToUniEditor(param);
hgs
parents:
diff changeset
   122
                }
hgs
parents:
diff changeset
   123
            break;
hgs
parents:
diff changeset
   124
            }
hgs
parents:
diff changeset
   125
        case MsgBaseView::UNIVIEWER: 
hgs
parents:
diff changeset
   126
        default:
hgs
parents:
diff changeset
   127
            {
hgs
parents:
diff changeset
   128
            HbApplication::quit();
hgs
parents:
diff changeset
   129
            break;
hgs
parents:
diff changeset
   130
            }
hgs
parents:
diff changeset
   131
            
hgs
parents:
diff changeset
   132
        }
hgs
parents:
diff changeset
   133
    }
hgs
parents:
diff changeset
   134
hgs
parents:
diff changeset
   135
//----------------------------------------------------------------------------
hgs
parents:
diff changeset
   136
// MsgServiceViewManager::switchView
hgs
parents:
diff changeset
   137
// @see header
hgs
parents:
diff changeset
   138
//----------------------------------------------------------------------------
hgs
parents:
diff changeset
   139
void MsgServiceViewManager::switchView(const QVariantList& data)
hgs
parents:
diff changeset
   140
    {
hgs
parents:
diff changeset
   141
    int viewId = data.at(0).toInt();
51
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   142
    switch (viewId)
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   143
        {
37
hgs
parents:
diff changeset
   144
        case MsgBaseView::UNIEDITOR:
hgs
parents:
diff changeset
   145
            {
hgs
parents:
diff changeset
   146
            // except first 2 parameters pass other parameters
hgs
parents:
diff changeset
   147
            QVariantList editorData;
hgs
parents:
diff changeset
   148
            for(int a = 2; a < data.length(); ++a)
hgs
parents:
diff changeset
   149
                {
hgs
parents:
diff changeset
   150
                editorData << data.at(a);
hgs
parents:
diff changeset
   151
                }
hgs
parents:
diff changeset
   152
            switchToUniEditor(editorData);
hgs
parents:
diff changeset
   153
            break;
hgs
parents:
diff changeset
   154
            }
hgs
parents:
diff changeset
   155
        case MsgBaseView::MSGSETTINGS:
hgs
parents:
diff changeset
   156
            {
hgs
parents:
diff changeset
   157
            switchToMsgSettings(data);
hgs
parents:
diff changeset
   158
            break;
hgs
parents:
diff changeset
   159
            }
hgs
parents:
diff changeset
   160
        default: 
hgs
parents:
diff changeset
   161
            {
51
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   162
            // if send from editor is successful, then run effects
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   163
            int previousView = data.at(1).toInt();
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   164
            if(previousView == MsgBaseView::UNIEDITOR)
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   165
                {
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   166
                startAnimation(SEND_EFFECT);
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   167
                }
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   168
            else
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   169
                {
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   170
                HbApplication::quit();
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   171
                }
37
hgs
parents:
diff changeset
   172
            }
51
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   173
        }
37
hgs
parents:
diff changeset
   174
    }
hgs
parents:
diff changeset
   175
hgs
parents:
diff changeset
   176
//----------------------------------------------------------------------------
hgs
parents:
diff changeset
   177
// MsgServiceViewManager::send
hgs
parents:
diff changeset
   178
// @see header
hgs
parents:
diff changeset
   179
//----------------------------------------------------------------------------
hgs
parents:
diff changeset
   180
void MsgServiceViewManager::send(const QString phoneNumber, 
hgs
parents:
diff changeset
   181
        const qint32 contactId, 
hgs
parents:
diff changeset
   182
        const QString displayName)
hgs
parents:
diff changeset
   183
    {
51
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   184
    Q_UNUSED(contactId);
67
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   185
    mMainWindow->show();
37
hgs
parents:
diff changeset
   186
    ConvergedMessage message;
hgs
parents:
diff changeset
   187
    ConvergedMessageAddress address;
hgs
parents:
diff changeset
   188
    address.setAddress(phoneNumber);
hgs
parents:
diff changeset
   189
    address.setAlias(displayName);
hgs
parents:
diff changeset
   190
    message.addToRecipient(address);
hgs
parents:
diff changeset
   191
hgs
parents:
diff changeset
   192
    QVariantList param;
hgs
parents:
diff changeset
   193
    QByteArray dataArray;
hgs
parents:
diff changeset
   194
    QDataStream messageStream(&dataArray, 
hgs
parents:
diff changeset
   195
            QIODevice::WriteOnly | QIODevice::Append);
hgs
parents:
diff changeset
   196
    message.serialize(messageStream);
hgs
parents:
diff changeset
   197
    param << dataArray;
hgs
parents:
diff changeset
   198
    
hgs
parents:
diff changeset
   199
    // switch to editor
hgs
parents:
diff changeset
   200
    switchToUniEditor(param);
hgs
parents:
diff changeset
   201
    
hgs
parents:
diff changeset
   202
    XQServiceUtil::toBackground(false);
hgs
parents:
diff changeset
   203
    }
hgs
parents:
diff changeset
   204
hgs
parents:
diff changeset
   205
//----------------------------------------------------------------------------
hgs
parents:
diff changeset
   206
// MsgServiceViewManager::send
hgs
parents:
diff changeset
   207
// @see header
hgs
parents:
diff changeset
   208
//----------------------------------------------------------------------------
hgs
parents:
diff changeset
   209
void MsgServiceViewManager::send(const QString phoneNumber, 
hgs
parents:
diff changeset
   210
        const QString alias, 
hgs
parents:
diff changeset
   211
        const QString bodyText)
hgs
parents:
diff changeset
   212
    {
67
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   213
    mMainWindow->show();
37
hgs
parents:
diff changeset
   214
    ConvergedMessage message;
hgs
parents:
diff changeset
   215
    ConvergedMessageAddress address;
hgs
parents:
diff changeset
   216
    address.setAddress(phoneNumber);
hgs
parents:
diff changeset
   217
    address.setAlias(alias);
hgs
parents:
diff changeset
   218
    message.addToRecipient(address);
hgs
parents:
diff changeset
   219
    message.setBodyText(bodyText);
hgs
parents:
diff changeset
   220
hgs
parents:
diff changeset
   221
    QVariantList param;
hgs
parents:
diff changeset
   222
    QByteArray dataArray;
hgs
parents:
diff changeset
   223
    QDataStream messageStream(&dataArray, 
hgs
parents:
diff changeset
   224
            QIODevice::WriteOnly | QIODevice::Append);
hgs
parents:
diff changeset
   225
    message.serialize(messageStream);
hgs
parents:
diff changeset
   226
    param << dataArray;
hgs
parents:
diff changeset
   227
hgs
parents:
diff changeset
   228
    // switch to editor
hgs
parents:
diff changeset
   229
    switchToUniEditor(param);
hgs
parents:
diff changeset
   230
    
hgs
parents:
diff changeset
   231
    XQServiceUtil::toBackground(false);
hgs
parents:
diff changeset
   232
    }
hgs
parents:
diff changeset
   233
hgs
parents:
diff changeset
   234
//----------------------------------------------------------------------------
hgs
parents:
diff changeset
   235
// MsgServiceViewManager::send
hgs
parents:
diff changeset
   236
// @see header
hgs
parents:
diff changeset
   237
//----------------------------------------------------------------------------
hgs
parents:
diff changeset
   238
void MsgServiceViewManager::send(const QVariantMap addressList, 
hgs
parents:
diff changeset
   239
              const QString bodyText)
hgs
parents:
diff changeset
   240
    {
67
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   241
    mMainWindow->show();
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   242
    QStringList phoneNumList = addressList.keys(); 
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   243
    ConvergedMessageAddressList addrList;
37
hgs
parents:
diff changeset
   244
    int count = phoneNumList.count();
hgs
parents:
diff changeset
   245
    for( int i = 0; i < count; ++ i )
hgs
parents:
diff changeset
   246
        {
hgs
parents:
diff changeset
   247
        QString phNum = phoneNumList[i];
hgs
parents:
diff changeset
   248
        ConvergedMessageAddress* address = new ConvergedMessageAddress(phNum,
hgs
parents:
diff changeset
   249
                addressList.value(phNum).toString());	
hgs
parents:
diff changeset
   250
        addrList.append(address);
hgs
parents:
diff changeset
   251
        }
hgs
parents:
diff changeset
   252
    
hgs
parents:
diff changeset
   253
    ConvergedMessage message;
hgs
parents:
diff changeset
   254
    message.addToRecipients(addrList);
hgs
parents:
diff changeset
   255
    message.setBodyText(bodyText);
hgs
parents:
diff changeset
   256
    
hgs
parents:
diff changeset
   257
    QVariantList param;
hgs
parents:
diff changeset
   258
    QByteArray dataArray;
hgs
parents:
diff changeset
   259
    QDataStream messageStream(&dataArray, 
hgs
parents:
diff changeset
   260
            QIODevice::WriteOnly | QIODevice::Append);
hgs
parents:
diff changeset
   261
    message.serialize(messageStream);
hgs
parents:
diff changeset
   262
    param << dataArray;
hgs
parents:
diff changeset
   263
hgs
parents:
diff changeset
   264
    // switch to editor
hgs
parents:
diff changeset
   265
    switchToUniEditor(param);
hgs
parents:
diff changeset
   266
hgs
parents:
diff changeset
   267
    XQServiceUtil::toBackground(false);
hgs
parents:
diff changeset
   268
    }
hgs
parents:
diff changeset
   269
hgs
parents:
diff changeset
   270
//----------------------------------------------------------------------------
hgs
parents:
diff changeset
   271
// MsgServiceViewManager::send
hgs
parents:
diff changeset
   272
// @see header
hgs
parents:
diff changeset
   273
//----------------------------------------------------------------------------
hgs
parents:
diff changeset
   274
void MsgServiceViewManager::send(QVariant data)
hgs
parents:
diff changeset
   275
    {
67
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   276
    mMainWindow->show();
37
hgs
parents:
diff changeset
   277
    ConvergedMessage message;
hgs
parents:
diff changeset
   278
    ConvergedMessageAttachmentList attachmentList;
hgs
parents:
diff changeset
   279
    // handle multiple files from sendUI
hgs
parents:
diff changeset
   280
    // e.g. contacts can send multiple vcards
hgs
parents:
diff changeset
   281
    QStringList receivedFiles = data.toStringList();
hgs
parents:
diff changeset
   282
    int recFileCount = receivedFiles.count();
hgs
parents:
diff changeset
   283
    for (int i = 0; i < recFileCount; i++) {
hgs
parents:
diff changeset
   284
    ConvergedMessageAttachment *attachment =
hgs
parents:
diff changeset
   285
    new ConvergedMessageAttachment(receivedFiles.at(i));
hgs
parents:
diff changeset
   286
    attachmentList.append(attachment);
hgs
parents:
diff changeset
   287
    }
hgs
parents:
diff changeset
   288
    message.addAttachments(attachmentList);
hgs
parents:
diff changeset
   289
hgs
parents:
diff changeset
   290
    QVariantList param;
hgs
parents:
diff changeset
   291
    QByteArray dataArray;
hgs
parents:
diff changeset
   292
    QDataStream messageStream(&dataArray, 
hgs
parents:
diff changeset
   293
            QIODevice::WriteOnly | QIODevice::Append);
hgs
parents:
diff changeset
   294
    message.serialize(messageStream);
hgs
parents:
diff changeset
   295
    param << dataArray;
hgs
parents:
diff changeset
   296
hgs
parents:
diff changeset
   297
    // switch to editor
hgs
parents:
diff changeset
   298
    switchToUniEditor(param);
hgs
parents:
diff changeset
   299
    
hgs
parents:
diff changeset
   300
    XQServiceUtil::toBackground(false);
hgs
parents:
diff changeset
   301
    }
hgs
parents:
diff changeset
   302
hgs
parents:
diff changeset
   303
//----------------------------------------------------------------------------
hgs
parents:
diff changeset
   304
// MsgServiceViewManager::switchToUniEditor
hgs
parents:
diff changeset
   305
// @see header
hgs
parents:
diff changeset
   306
//----------------------------------------------------------------------------
hgs
parents:
diff changeset
   307
void MsgServiceViewManager::switchToUniEditor(const QVariantList& editorData)
67
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   308
{
37
hgs
parents:
diff changeset
   309
    // construct
67
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   310
    if (!mUniEditor)
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   311
    {
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   312
        mUniEditor = new MsgUnifiedEditorView();
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   313
        mMainWindow->addView(mUniEditor);
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   314
        mUniEditor->setNavigationAction(mBackAction);
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   315
        connect(mUniEditor, SIGNAL(switchView(const QVariantList&)), this,
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   316
                SLOT(switchView(const QVariantList&)));
37
hgs
parents:
diff changeset
   317
    }
hgs
parents:
diff changeset
   318
    
hgs
parents:
diff changeset
   319
    // populate
hgs
parents:
diff changeset
   320
    mUniEditor->populateContent(editorData);
hgs
parents:
diff changeset
   321
    
hgs
parents:
diff changeset
   322
    // set current view as editor
hgs
parents:
diff changeset
   323
    mMainWindow->setCurrentView(mUniEditor);
hgs
parents:
diff changeset
   324
    mCurrentView = MsgBaseView::UNIEDITOR;
67
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   325
}
37
hgs
parents:
diff changeset
   326
hgs
parents:
diff changeset
   327
//----------------------------------------------------------------------------
hgs
parents:
diff changeset
   328
// MsgServiceViewManager::switchToMsgSettings
hgs
parents:
diff changeset
   329
// @see header
hgs
parents:
diff changeset
   330
//----------------------------------------------------------------------------
hgs
parents:
diff changeset
   331
void MsgServiceViewManager::switchToMsgSettings(const QVariantList& data)
67
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   332
{
37
hgs
parents:
diff changeset
   333
    MsgSettingsView::SettingsView view = MsgSettingsView::DefaultView;
hgs
parents:
diff changeset
   334
    
hgs
parents:
diff changeset
   335
    if (mCurrentView == MsgBaseView::UNIEDITOR)
hgs
parents:
diff changeset
   336
    {
hgs
parents:
diff changeset
   337
        view = (MsgSettingsView::SettingsView)data.at(2).toInt();
hgs
parents:
diff changeset
   338
    }
67
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   339
37
hgs
parents:
diff changeset
   340
    mCurrentView = MsgBaseView::MSGSETTINGS;
hgs
parents:
diff changeset
   341
67
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   342
    if (!mSettingsView)
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   343
    {        
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   344
        mSettingsView = new MsgSettingsView(view);
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   345
        mSettingsView->setNavigationAction(mBackAction);
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   346
        mMainWindow->addView(mSettingsView);
37
hgs
parents:
diff changeset
   347
    }
hgs
parents:
diff changeset
   348
    mMainWindow->setCurrentView(mSettingsView);
67
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   349
}
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   350
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   351
//----------------------------------------------------------------------------
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   352
// MsgServiceViewManager::showPopup
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   353
// @see header
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   354
//----------------------------------------------------------------------------
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   355
void MsgServiceViewManager::showPopup(const QString& dispText)
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   356
{
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   357
    HbDeviceMessageBox msgbox;
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   358
    msgbox.setMessageBoxType(HbMessageBox::MessageTypeInformation);
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   359
    msgbox.setText(dispText);
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   360
    msgbox.setAction(NULL, HbDeviceMessageBox::AcceptButtonRole);
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   361
    msgbox.exec();
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   362
    msgbox.close();
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   363
}
37
hgs
parents:
diff changeset
   364
hgs
parents:
diff changeset
   365
//----------------------------------------------------------------------------
hgs
parents:
diff changeset
   366
// MsgServiceViewManager::view
hgs
parents:
diff changeset
   367
// @see header
hgs
parents:
diff changeset
   368
//----------------------------------------------------------------------------
hgs
parents:
diff changeset
   369
void MsgServiceViewManager::view(int msgId)
67
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   370
{
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   371
    // Check if the message is present in store
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   372
    if(!mStoreHandler->exists(msgId))
37
hgs
parents:
diff changeset
   373
    {
67
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   374
        showPopup(LOC_DELETED_MESSAGE);
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   375
        HbApplication::quit();
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   376
        return;
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   377
    }
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   378
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   379
    // Check if the given message is locked for viewing
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   380
    if(mStoreHandler->locked(msgId))
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   381
    {
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   382
        // if locked, then show info-note and exit
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   383
        showPopup(LOC_CANNOT_OPEN_MESSAGE);
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   384
        HbApplication::quit();
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   385
        return;
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   386
    }
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   387
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   388
    // Mark as read and get message type
37
hgs
parents:
diff changeset
   389
    int msgType;
67
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   390
    int msgSubType;   
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   391
    mStoreHandler->markAsRead(msgId);
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   392
    mStoreHandler->getMsgTypeInfo(msgId,msgType,msgSubType);
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   393
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   394
    // Open draft message in editor
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   395
    if(mStoreHandler->isDraftMessage(msgId))
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   396
    {
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   397
        handleDraftMsg(msgId,msgType);
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   398
        return;
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   399
    }
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   400
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   401
    switch (msgType) 
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   402
    {
37
hgs
parents:
diff changeset
   403
        case ConvergedMessage::Sms:
hgs
parents:
diff changeset
   404
        case ConvergedMessage::Mms:
67
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   405
        {
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   406
            if (msgSubType == ConvergedMessage::VCard)
37
hgs
parents:
diff changeset
   407
            {
67
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   408
                handleVCardMsg(msgId);
37
hgs
parents:
diff changeset
   409
            }
67
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   410
            else
37
hgs
parents:
diff changeset
   411
            {
67
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   412
                handleSmsMmsMsg(msgId);    
37
hgs
parents:
diff changeset
   413
            }
hgs
parents:
diff changeset
   414
            break;
67
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   415
        }
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   416
        case ConvergedMessage::MmsNotification:
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   417
        {
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   418
            handleMmsNotification(msgId);
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   419
            break;
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   420
        }
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   421
        case ConvergedMessage::BioMsg:
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   422
        {
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   423
            if (msgSubType == ConvergedMessage::RingingTone)
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   424
            {
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   425
                handleRingtoneMsg(msgId);
37
hgs
parents:
diff changeset
   426
            }
67
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   427
            else if (msgSubType == ConvergedMessage::Provisioning)
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   428
            {
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   429
                handleProvisoningMsg(msgId);
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   430
            }
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   431
            else if (msgSubType == ConvergedMessage::VCard)
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   432
            {
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   433
                handleVCardMsg(msgId);
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   434
            }
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   435
            break;
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   436
        }
37
hgs
parents:
diff changeset
   437
        case ConvergedMessage::BT:
67
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   438
        {
37
hgs
parents:
diff changeset
   439
            handleBTMessage(msgId);
hgs
parents:
diff changeset
   440
            break;
67
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   441
        }
37
hgs
parents:
diff changeset
   442
        default:
67
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   443
        {
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   444
            // For all remaining unsupported messages, show delete option
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   445
            showPopup(LOC_UNKNOWN_MSG_TYPE);
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   446
            HbApplication::quit();
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   447
        }
37
hgs
parents:
diff changeset
   448
    }
67
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   449
}
37
hgs
parents:
diff changeset
   450
hgs
parents:
diff changeset
   451
// ----------------------------------------------------------------------------
62
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
   452
// MsgServiceViewManager::handleKeyEvent
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
   453
// @see header
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
   454
// ----------------------------------------------------------------------------
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
   455
bool MsgServiceViewManager::handleKeyEvent(int key)
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
   456
{
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
   457
    MsgBaseView *baseView = static_cast<MsgBaseView *>(mMainWindow->currentView());
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
   458
    bool eventHandled = false;
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
   459
    if (baseView) {
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
   460
        eventHandled = baseView->handleKeyEvent(key);
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
   461
    }
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
   462
    return eventHandled;
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
   463
}
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
   464
fdbe8253b596 201035_03
hgs
parents: 56
diff changeset
   465
// ----------------------------------------------------------------------------
73
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   466
// MsgServiceViewManager::saveContentToDraft
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   467
// @see header
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   468
// ----------------------------------------------------------------------------
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   469
void MsgServiceViewManager::saveContentToDraft()
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   470
{
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   471
    if(mUniEditor)
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   472
    {
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   473
      mUniEditor->saveContentToDrafts();
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   474
    }
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   475
}
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   476
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   477
// ----------------------------------------------------------------------------
67
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   478
// MsgServiceViewManager::handleDraftMsg
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   479
// @see header
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   480
// ----------------------------------------------------------------------------
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   481
void MsgServiceViewManager::handleDraftMsg(int msgId, int msgType)
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   482
{
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   483
    // show the splash-screen
73
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   484
    // Note: This causes cancellation of view switching effects
67
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   485
//    HbSplashScreen::start();
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   486
    connect(mMainWindow, SIGNAL(viewReady()), this, SLOT(showOnViewReady()));
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   487
    mCurrentView = MsgBaseView::UNIEDITOR;
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   488
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   489
    // construct editor instance (keep it minimal)
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   490
    if (!mUniEditor)
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   491
    {
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   492
        mUniEditor = new MsgUnifiedEditorView();
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   493
        mMainWindow->addView(mUniEditor);
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   494
        mUniEditor->setNavigationAction(mBackAction);
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   495
        connect(mUniEditor, SIGNAL(switchView(const QVariantList&)), this,
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   496
                SLOT(switchView(const QVariantList&)));
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   497
    }
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   498
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   499
    // prepare data for unieditor
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   500
    ConvergedMessage message;
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   501
    ConvergedMessageId convergedMsgId = ConvergedMessageId(msgId);
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   502
    message.setMessageType((ConvergedMessage::MessageType) msgType);
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   503
    message.setMessageId(convergedMsgId);
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   504
    QByteArray dataArray;
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   505
    QDataStream messageStream(&dataArray, QIODevice::WriteOnly | QIODevice::Append);
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   506
    message.serialize(messageStream);
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   507
    QVariantList editorData;
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   508
    editorData << dataArray;
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   509
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   510
    mMainWindow->show();
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   511
    // populate data into editor
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   512
    mUniEditor->openDraftsMessage(editorData);
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   513
}
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   514
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   515
// ----------------------------------------------------------------------------
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   516
// MsgServiceViewManager::handleVCardMsg
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   517
// @see header
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   518
// ----------------------------------------------------------------------------
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   519
void MsgServiceViewManager::handleVCardMsg(int msgId)
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   520
{
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   521
    // Extract vCard filepath
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   522
    QString filepath;
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   523
    UniDataModelLoader* pluginLoader = new UniDataModelLoader();
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   524
    UniDataModelPluginInterface* pluginInterface = 
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   525
                    pluginLoader->getDataModelPlugin(ConvergedMessage::BioMsg);
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   526
    pluginInterface->setMessageId(msgId);
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   527
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   528
    // Get attachment list
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   529
    UniMessageInfoList attachments = pluginInterface->attachmentList();
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   530
    if(attachments.count() > 0)
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   531
    {
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   532
        filepath = attachments.at(0)->path();    
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   533
    }
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   534
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   535
    // Cleanup
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   536
    foreach(UniMessageInfo* attachmentInfo,attachments)
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   537
    {
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   538
        delete attachmentInfo;
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   539
    }
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   540
    delete pluginLoader;
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   541
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   542
    // copy private-vCard file to public location for contacts access
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   543
    QDir tempDir;
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   544
    QString sharedFilePath(QDir::toNativeSeparators(tempDir.tempPath()));
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   545
    sharedFilePath.append(QDir::separator());
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   546
    QFileInfo fInfo(filepath);
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   547
    sharedFilePath.append(fInfo.fileName());
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   548
    QFile::copy(filepath, sharedFilePath);
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   549
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   550
    // Launch vCard viewer service
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   551
    XQApplicationManager appManager;
73
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   552
    XQAiwRequest* request = appManager.create(XQI_CONTACTS_EDIT,
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   553
                                XQOP_CONTACTS_EDIT_CREATE_NEW_VCARD, 
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   554
                                true); //embedded
67
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   555
    if(request)
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   556
    {
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   557
        QList<QVariant> args;
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   558
        args << sharedFilePath;
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   559
        request->setArguments(args);
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   560
        QVariant retValue;
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   561
        bool res = request->send(retValue);
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   562
        delete request;
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   563
    }
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   564
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   565
    // Delete shared file now
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   566
    QFile::remove(sharedFilePath);
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   567
    HbApplication::quit();
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   568
}
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   569
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   570
// ----------------------------------------------------------------------------
37
hgs
parents:
diff changeset
   571
// MsgServiceViewManager::handleSmsMmsMsg
hgs
parents:
diff changeset
   572
// @see header
hgs
parents:
diff changeset
   573
// ----------------------------------------------------------------------------
67
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   574
void MsgServiceViewManager::handleSmsMmsMsg(int msgId)
38
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   575
{
67
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   576
    // show the splash-screen
73
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   577
    // Note: This causes cancellation of view switching effects
67
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   578
//    HbSplashScreen::start();
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   579
    connect(mMainWindow, SIGNAL(viewReady()), this, SLOT(showOnViewReady()));
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   580
    mCurrentView = MsgBaseView::UNIVIEWER;
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   581
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   582
    // construct viewer instance (keep it minimal)
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   583
    if(!mUniViewer)
37
hgs
parents:
diff changeset
   584
    {
67
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   585
        mUniViewer = new UnifiedViewer(msgId);
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   586
        mMainWindow->addView(mUniViewer);
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   587
        mUniViewer->setNavigationAction(mBackAction);
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   588
        connect(mUniViewer, SIGNAL(switchView(const QVariantList&)),
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   589
                        this, SLOT(switchView(const QVariantList&)));
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   590
    }
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   591
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   592
    // populate the viewer
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   593
    mUniViewer->populateContent(msgId, true, 1);
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   594
    mMainWindow->show();
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   595
}
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   596
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   597
// ----------------------------------------------------------------------------
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   598
// MsgServiceViewManager::handleMmsNotification
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   599
// @see header
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   600
// ----------------------------------------------------------------------------
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   601
void MsgServiceViewManager::handleMmsNotification(int msgId)
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   602
{
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   603
    // set context to current entry
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   604
    if( KErrNone != mStoreHandler->setNotificationMessageId(msgId))
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   605
    {
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   606
        return;
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   607
    }
38
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   608
67
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   609
    // notification state e.g. waiting, retrieving etc
73
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   610
    QString displayTxt;
67
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   611
    QString statusStr;
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   612
    int status;
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   613
    mStoreHandler->notificationStatus(status, statusStr);
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   614
    if(!statusStr.isEmpty())
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   615
    {
73
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   616
        displayTxt.append(statusStr).append(QChar::LineSeparator);
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   617
    }
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   618
    
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   619
    QString sender = mStoreHandler->notificationSender();
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   620
    if(!sender.isEmpty())
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   621
    {
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   622
        displayTxt.append(sender).append(QChar::LineSeparator);
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   623
    }
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   624
    
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   625
    QString timestamp = mStoreHandler->notificationTimeStamp();
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   626
    if(!timestamp.isEmpty())
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   627
    {
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   628
        displayTxt.append(timestamp).append(QChar::LineSeparator);
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   629
    }
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   630
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   631
    QString subject = mStoreHandler->notificationSubject();
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   632
    if(!subject.isEmpty())
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   633
    {
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   634
        displayTxt.append(subject).append(QChar::LineSeparator);
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   635
    }
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   636
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   637
    QString msgSize = mStoreHandler->notificationMsgSize();
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   638
    if(!msgSize.isEmpty())
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   639
    {
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   640
        displayTxt.append(msgSize).append(QChar::LineSeparator);
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   641
    }
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   642
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   643
    QString msgClass = mStoreHandler->notificationClass();
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   644
    if(!msgClass.isEmpty())
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   645
    {
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   646
        displayTxt.append(msgClass).append(QChar::LineSeparator);
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   647
    }
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   648
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   649
    QString exprDate = mStoreHandler->notificationExpiryDate();
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   650
    if(!exprDate.isEmpty())
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   651
    {
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   652
        displayTxt.append(exprDate);
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   653
    }
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   654
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   655
    HbDeviceMessageBox msgbox;
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   656
    msgbox.setText(displayTxt);
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   657
    msgbox.setDismissPolicy(HbPopup::NoDismiss);
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   658
    msgbox.setTimeout(HbPopup::NoTimeout);
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   659
    msgbox.exec();
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   660
    msgbox.close();
67
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   661
    HbApplication::quit();
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   662
}
38
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   663
67
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   664
// ----------------------------------------------------------------------------
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   665
// MsgServiceViewManager::showOnViewReady
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   666
// @see header
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   667
// ----------------------------------------------------------------------------
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   668
void MsgServiceViewManager::showOnViewReady()
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   669
{
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   670
    switch(mCurrentView)
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   671
    {
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   672
        case MsgBaseView::UNIVIEWER:
38
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   673
        {
67
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   674
            mMainWindow->setCurrentView(mUniViewer);
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   675
            break;
38
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   676
        }
67
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   677
        case MsgBaseView::UNIEDITOR:
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   678
        {
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   679
            mMainWindow->setCurrentView(mUniEditor);
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   680
            break;
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   681
        }
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   682
        default:
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   683
            break;
37
hgs
parents:
diff changeset
   684
    }
67
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   685
    disconnect(mMainWindow, SIGNAL(viewReady()), this, SLOT(showOnViewReady()));
38
4e4b6adb1024 201025_01
hgs
parents: 37
diff changeset
   686
}
37
hgs
parents:
diff changeset
   687
hgs
parents:
diff changeset
   688
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   689
// MsgServiceViewManager::handleRingtoneMsg
hgs
parents:
diff changeset
   690
// @see header
hgs
parents:
diff changeset
   691
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   692
void MsgServiceViewManager::handleRingtoneMsg(int msgId)
67
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   693
{
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   694
    // Extract rintone filepath
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   695
    UniDataModelLoader* pluginLoader = new UniDataModelLoader();
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   696
    UniDataModelPluginInterface* pluginInterface = 
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   697
                        pluginLoader->getDataModelPlugin(ConvergedMessage::BioMsg);
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   698
    pluginInterface->setMessageId(msgId);
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   699
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   700
    // Get attachment list
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   701
    UniMessageInfoList attachments = pluginInterface->attachmentList();
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   702
    QString filepath;
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   703
    if(attachments.count() > 0)
37
hgs
parents:
diff changeset
   704
    {
67
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   705
        filepath = attachments.at(0)->path();
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   706
    }
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   707
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   708
    // Cleanup
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   709
    foreach(UniMessageInfo* attachmentInfo,attachments)
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   710
    {
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   711
        delete attachmentInfo;
37
hgs
parents:
diff changeset
   712
    }
67
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   713
    delete pluginLoader;
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   714
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   715
    RingBc* ringBc = new RingBc();
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   716
    QString filename = ringBc->toneTitle(filepath);
73
ecf6a73a9186 201039_03
hgs
parents: 67
diff changeset
   717
    QString loc_str = LOC_SAVE_RINGTONE.arg(filename);
67
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   718
    bool save = HbDeviceMessageBox::question(loc_str,
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   719
                    HbMessageBox::Save | HbMessageBox::Cancel);
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   720
    if(save)
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   721
    {
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   722
        ringBc->saveTone(filepath);
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   723
    }
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   724
    delete ringBc;
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   725
    HbApplication::quit();
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   726
}
37
hgs
parents:
diff changeset
   727
hgs
parents:
diff changeset
   728
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   729
// MsgServiceViewManager::handleProvisoningMsg
hgs
parents:
diff changeset
   730
// @see header
hgs
parents:
diff changeset
   731
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   732
void MsgServiceViewManager::handleProvisoningMsg(int msgId)
hgs
parents:
diff changeset
   733
    {
hgs
parents:
diff changeset
   734
    QString messageId;
hgs
parents:
diff changeset
   735
    messageId.setNum(msgId);
hgs
parents:
diff changeset
   736
hgs
parents:
diff changeset
   737
    XQApplicationManager* aiwMgr = new XQApplicationManager();
hgs
parents:
diff changeset
   738
hgs
parents:
diff changeset
   739
    XQAiwRequest* request = aiwMgr->create("com.nokia.services.MDM", 
hgs
parents:
diff changeset
   740
            "Provisioning",
hgs
parents:
diff changeset
   741
            "ProcessMessage(QString)", true); // embedded
hgs
parents:
diff changeset
   742
hgs
parents:
diff changeset
   743
    if (request) {
hgs
parents:
diff changeset
   744
    QList<QVariant> args;
hgs
parents:
diff changeset
   745
    args << QVariant(messageId);
hgs
parents:
diff changeset
   746
    request->setArguments(args);
hgs
parents:
diff changeset
   747
hgs
parents:
diff changeset
   748
    // Send the request
hgs
parents:
diff changeset
   749
    bool res = request->send();
hgs
parents:
diff changeset
   750
hgs
parents:
diff changeset
   751
    // Cleanup
hgs
parents:
diff changeset
   752
    delete request;
hgs
parents:
diff changeset
   753
    }
hgs
parents:
diff changeset
   754
hgs
parents:
diff changeset
   755
    delete aiwMgr;
hgs
parents:
diff changeset
   756
hgs
parents:
diff changeset
   757
    // close the application once its handled
hgs
parents:
diff changeset
   758
    HbApplication::quit();
hgs
parents:
diff changeset
   759
    }
hgs
parents:
diff changeset
   760
hgs
parents:
diff changeset
   761
//-----------------------------------------------------------------------------
hgs
parents:
diff changeset
   762
//MsgServiceViewManager::handleBTMessage()
hgs
parents:
diff changeset
   763
//@see header
hgs
parents:
diff changeset
   764
//-----------------------------------------------------------------------------
hgs
parents:
diff changeset
   765
void MsgServiceViewManager::handleBTMessage(int msgId)
hgs
parents:
diff changeset
   766
    {
hgs
parents:
diff changeset
   767
    XQApplicationManager* aiwMgr = new XQApplicationManager();
hgs
parents:
diff changeset
   768
    XQAiwRequest* request = 
hgs
parents:
diff changeset
   769
    aiwMgr->create("com.nokia.services.btmsgdispservices", "displaymsg",
hgs
parents:
diff changeset
   770
            "displaymsg(int)", true); // embedded
hgs
parents:
diff changeset
   771
hgs
parents:
diff changeset
   772
    if (request) {
hgs
parents:
diff changeset
   773
    QList<QVariant> args;
hgs
parents:
diff changeset
   774
    args << QVariant(msgId);
hgs
parents:
diff changeset
   775
    request->setArguments(args);
hgs
parents:
diff changeset
   776
hgs
parents:
diff changeset
   777
    // Send the request
hgs
parents:
diff changeset
   778
    bool res = request->send();
hgs
parents:
diff changeset
   779
hgs
parents:
diff changeset
   780
    // Cleanup
hgs
parents:
diff changeset
   781
    delete request;
hgs
parents:
diff changeset
   782
    }
hgs
parents:
diff changeset
   783
hgs
parents:
diff changeset
   784
    delete aiwMgr;
hgs
parents:
diff changeset
   785
hgs
parents:
diff changeset
   786
    // close the application once its handled
hgs
parents:
diff changeset
   787
    HbApplication::quit();
hgs
parents:
diff changeset
   788
    }
hgs
parents:
diff changeset
   789
hgs
parents:
diff changeset
   790
//-----------------------------------------------------------------------------
51
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   791
//MsgServiceViewManager::startAnimation
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   792
//@see header
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   793
//-----------------------------------------------------------------------------
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   794
void MsgServiceViewManager::startAnimation(QString effectEvent)
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   795
    {
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   796
    // take screen shot
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   797
    QGraphicsPixmapItem *animationScreenShot = screenShot();
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   798
    if (animationScreenShot)
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   799
        {
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   800
        // but don't show it yet.
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   801
        animationScreenShot->hide();
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   802
        animationScreenShot->setPos(0,0);
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   803
        animationScreenShot->setZValue(0);
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   804
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   805
        // hide items, so that background app's items are visible immediately
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   806
        mMainWindow->currentView()->hideItems(Hb::AllItems);
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   807
        
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   808
        // reset background & set the base transparent
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   809
        mMainWindow->setBackgroundImageName(
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   810
                mMainWindow->orientation(), QString("dummy_blank"));
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   811
        QPalette p = mMainWindow->viewport()->palette();
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   812
        p.setColor(QPalette::Base, Qt::transparent);
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   813
        mMainWindow->viewport()->setPalette(p);
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   814
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   815
        // add animating item directly to the scene
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   816
        mMainWindow->scene()->addItem(animationScreenShot);
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   817
        
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   818
        // hide other views
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   819
        QList<HbView*> vws = mMainWindow->views();
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   820
        while (!vws.isEmpty())
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   821
            {
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   822
            HbView* view = vws.takeLast();
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   823
            view->hide();
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   824
            }
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   825
        
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   826
        // now show the animating item, and start animation on it
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   827
        animationScreenShot->show();
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   828
        QString effectFile = getAnimationFile(effectEvent);
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   829
        HbEffect::add(animationScreenShot, effectFile, effectEvent);
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   830
        HbEffect::start(animationScreenShot, effectEvent, this,
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   831
                "onAnimationComplete");
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   832
        }
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   833
    }
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   834
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   835
//-----------------------------------------------------------------------------
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   836
//MsgServiceViewManager::resetAnimation
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   837
//@see header
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   838
//-----------------------------------------------------------------------------
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   839
void MsgServiceViewManager::resetAnimation(
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   840
        QString effectEvent,
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   841
        QGraphicsItem* item)
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   842
    {
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   843
    if (item) 
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   844
        {
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   845
        QString effectFile = getAnimationFile(effectEvent);
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   846
        HbEffect::remove(item, effectFile, effectEvent);
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   847
        mMainWindow->scene()->removeItem(item);
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   848
        delete item;
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   849
        item = NULL;
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   850
        }
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   851
    }
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   852
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   853
//-----------------------------------------------------------------------------
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   854
//MsgServiceViewManager::onAnimationComplete
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   855
//@see header
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   856
//-----------------------------------------------------------------------------
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   857
void MsgServiceViewManager::onAnimationComplete(
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   858
        const HbEffect::EffectStatus &status)
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   859
    {
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   860
    QGraphicsItem* item = status.item;
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   861
    QString effectEvent = status.effectEvent;
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   862
    resetAnimation(effectEvent, item);
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   863
    HbApplication::quit();
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   864
    }
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   865
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   866
//-----------------------------------------------------------------------------
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   867
//MsgServiceViewManager::screenShot
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   868
//@see header
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   869
//-----------------------------------------------------------------------------
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   870
QGraphicsPixmapItem* MsgServiceViewManager::screenShot()
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   871
    {
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   872
    // set fullscreen and hide unwanted items
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   873
    mMainWindow->currentView()->hideItems(Hb::ToolBarItem | Hb::DockWidgetItem | Hb::StatusBarItem);
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   874
    mMainWindow->currentView()->setContentFullScreen(true);
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   875
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   876
    // grab whole view into pixmap image
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   877
    QPixmap screenCapture = QPixmap::grabWindow(mMainWindow->internalWinId());
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   878
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   879
    // create an QGraphicsItem to do animation
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   880
    QGraphicsPixmapItem *ret(NULL);
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   881
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   882
    // for landscape, the screenshot must be rotated
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   883
    if(mMainWindow->orientation() == Qt::Horizontal)
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   884
        {
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   885
        QMatrix mat;
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   886
        mat.rotate(-90); // rotate 90 degrees counter-clockwise
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   887
        ret = new QGraphicsPixmapItem(screenCapture.transformed(mat));
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   888
        }
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   889
    else
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   890
        {
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   891
        ret = new QGraphicsPixmapItem(screenCapture);
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   892
        }
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   893
    return ret;
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   894
    }
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   895
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   896
//-----------------------------------------------------------------------------
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   897
//MsgServiceViewManager::getAnimationFile
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   898
//@see header
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   899
//-----------------------------------------------------------------------------
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   900
QString MsgServiceViewManager::getAnimationFile(QString effectEvent)
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   901
    {
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   902
    QString animFile;
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   903
    if(effectEvent == SEND_EFFECT)
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   904
        {
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   905
        animFile.append(SEND_EFFECT_FILE);
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   906
        }
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   907
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   908
    return animFile;
3507212d340e 201031_02
hgs
parents: 38
diff changeset
   909
    }
56
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   910
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   911
//-----------------------------------------------------------------------------
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   912
//MsgServiceViewManager::send
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   913
//@see header
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   914
//-----------------------------------------------------------------------------
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   915
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   916
void MsgServiceViewManager::send(ConvergedMessage message)
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   917
    {
67
fc91263aee62 201037_04
hgs
parents: 62
diff changeset
   918
    mMainWindow->show();    
56
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   919
    QVariantList param;
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   920
    QByteArray dataArray;
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   921
    QDataStream messageStream(&dataArray, QIODevice::WriteOnly | QIODevice::Append);
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   922
    message.serialize(messageStream);
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   923
    param << dataArray;
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   924
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   925
    // switch to editor
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   926
    switchToUniEditor(param);
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   927
    
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   928
    XQServiceUtil::toBackground(false);    
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   929
    }
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   930
	
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   931
	
f42d9a78f435 201033_02
hgs
parents: 51
diff changeset
   932