messagingapp/msgui/msguiutils/src/msgimagefetcherutil.cpp
changeset 25 84d9eb65b26f
parent 23 238255e8b033
child 27 e4592d119491
child 37 518b245aa84c
child 79 2981cb3aa489
equal deleted inserted replaced
23:238255e8b033 25:84d9eb65b26f
     1 /*
       
     2  * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3  * All rights reserved.
       
     4  * This component and the accompanying materials are made available
       
     5  * under the terms of "Eclipse Public License v1.0"
       
     6  * which accompanies this distribution, and is available
       
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8  *
       
     9  * Initial Contributors:
       
    10  * Nokia Corporation - initial contribution.
       
    11  *
       
    12  * Contributors:
       
    13  *
       
    14  * Description:
       
    15  *
       
    16  */
       
    17  
       
    18  // USER INCLUDES
       
    19 #include "msgimagefetcherutil.h"
       
    20 
       
    21 // INCLUDES
       
    22 #include <QDebug>
       
    23 #include <QStringList>
       
    24 #include <xqappmgr.h>
       
    25 #include <xqaiwrequest.h>
       
    26 
       
    27 // Constants
       
    28 
       
    29 //---------------------------------------------------------------
       
    30 // MsgImageFetcherUtil::MsgImageFetcherUtil
       
    31 // @see header file
       
    32 //---------------------------------------------------------------
       
    33 MsgImageFetcherUtil::MsgImageFetcherUtil(QObject* parent):
       
    34 QObject(parent),
       
    35 mRequest(NULL)
       
    36 {
       
    37     mAppMgr = new XQApplicationManager;
       
    38 }
       
    39 
       
    40 //---------------------------------------------------------------
       
    41 // MsgImageFetcherUtil::~MsgImageFetcherUtil
       
    42 // @see header file
       
    43 //---------------------------------------------------------------
       
    44 MsgImageFetcherUtil::~MsgImageFetcherUtil()
       
    45 {
       
    46     if(mAppMgr)
       
    47     {
       
    48         delete mAppMgr;
       
    49         mAppMgr = NULL;
       
    50     }
       
    51 }
       
    52 
       
    53 //---------------------------------------------------------------
       
    54 // MsgImageFetcherUtil::fetchImages
       
    55 // @see header file
       
    56 //---------------------------------------------------------------
       
    57 void MsgImageFetcherUtil::fetchImages()
       
    58 {
       
    59 
       
    60     QString interface("Image");
       
    61     QString operation("fetch(QVariantMap,QVariant)");
       
    62     
       
    63     mRequest = mAppMgr->create(interface, operation, false);
       
    64     if(!mRequest)
       
    65     {
       
    66         qDebug() << "AIW-ERROR: NULL request";
       
    67         return;
       
    68     }
       
    69 
       
    70     connect(mRequest, SIGNAL(requestOk(const QVariant&)),
       
    71             parent(), SIGNAL(imagesFetched(const QVariant&)));
       
    72     connect(mRequest, SIGNAL(requestError(int,const QString&)),
       
    73             this, SLOT(onRequestError(int,const QString&)));
       
    74     connect(this, SIGNAL(serviceError(const QString&)),
       
    75             parent(), SIGNAL(serviceError(const QString&)));
       
    76     
       
    77     // Make the request
       
    78     if (!mRequest->send())
       
    79     {
       
    80         qDebug() << "AIW-ERROR: Send failed" << mRequest->lastError();
       
    81     }    
       
    82 }
       
    83 
       
    84 //---------------------------------------------------------------
       
    85 // MsgImageFetcherUtil::onRequestError
       
    86 // @see header file
       
    87 //---------------------------------------------------------------
       
    88 void MsgImageFetcherUtil::onRequestError(int errorCode,
       
    89                                      const QString& errorMessage)
       
    90 {
       
    91     //TODO: handle error here
       
    92     Q_UNUSED(errorCode);
       
    93     Q_UNUSED(errorMessage);  
       
    94     // emit utils mgr signal
       
    95     emit serviceError(errorMessage);
       
    96 }
       
    97 
       
    98 //EOF