emailuis/nmhswidget/src/nmhswidgetemailengine.cpp
changeset 54 997a02608b3a
parent 53 bf7eb7911fc5
child 72 64e38f08e49c
equal deleted inserted replaced
53:bf7eb7911fc5 54:997a02608b3a
    41     mEmailInterface(0), 
    41     mEmailInterface(0), 
    42     mFactory(0), 
    42     mFactory(0), 
    43     mAccountEventReceivedWhenSuspended(false),
    43     mAccountEventReceivedWhenSuspended(false),
    44     mMessageEventReceivedWhenSuspended(false), 
    44     mMessageEventReceivedWhenSuspended(false), 
    45     mSuspended(false),
    45     mSuspended(false),
    46     mUpdateTimer(0)
    46     mUpdateTimer(0),
       
    47     mAiwRequest(0)
    47 {
    48 {
    48     NM_FUNCTION;
    49     NM_FUNCTION;
    49 }
    50 }
    50 
    51 
    51 /*!
    52 /*!
   178 {
   179 {
   179     NM_FUNCTION;
   180     NM_FUNCTION;
   180     list.clear(); //Reset the parameter list to avoid side effects
   181     list.clear(); //Reset the parameter list to avoid side effects
   181     int i = 0;
   182     int i = 0;
   182     for (; i < mEnvelopeList.count() && i < maxEnvelopeAmount; i++) {
   183     for (; i < mEnvelopeList.count() && i < maxEnvelopeAmount; i++) {
   183         NmMessageEnvelope env(*mEnvelopeList[i]);
   184         NmMessageEnvelope env(*mEnvelopeList.at(i));
   184         list.append(env);
   185         list.append(env);
   185     }
   186     }
   186     return i;
   187     return i;
   187 }
   188 }
   188 
   189 
   406  */
   407  */
   407 void NmHsWidgetEmailEngine::launchMailAppInboxView()
   408 void NmHsWidgetEmailEngine::launchMailAppInboxView()
   408 {
   409 {
   409     NM_FUNCTION;
   410     NM_FUNCTION;
   410     
   411     
   411     XQApplicationManager appManager;
   412     QT_TRY{ 
   412     XQAiwRequest* request = appManager.create(
   413         if (!mAiwRequest) {
   413             XQI_EMAIL_INBOX_VIEW, XQOP_EMAIL_INBOX_VIEW,
   414             XQApplicationManager appManager;
   414             false);
   415             mAiwRequest = appManager.create(
   415     
   416                     XQI_EMAIL_INBOX_VIEW, XQOP_EMAIL_INBOX_VIEW,
   416     if (request) {
   417                     false);
   417         QList<QVariant> list;
   418             
   418         list.append(QVariant(mMailboxId.id()));
   419             if (mAiwRequest) {
   419     
   420                 connect(mAiwRequest, SIGNAL( requestError(int, const QString&) ), 
   420         request->setArguments(list);
   421                         this, SLOT( aiwRequestError(int, const QString&) ));
   421         request->send();
   422                 connect(mAiwRequest, SIGNAL( requestOk(const QVariant&) ), 
       
   423                         this, SLOT( aiwRequestOk(const QVariant&) ));
       
   424                 QList<QVariant> list;
       
   425                 list.append(QVariant(mMailboxId.id()));
       
   426             
       
   427                 mAiwRequest->setSynchronous(false);
       
   428                 mAiwRequest->setArguments(list);
       
   429                 mAiwRequest->send();
       
   430             }
       
   431         }
       
   432     }
       
   433     QT_CATCH(...){
       
   434         // no actions taken.
       
   435         // try-catch mechanism added to avoid crashing widget, in case XQAiwRequest
       
   436         // creation raise exception.
   422     }
   437     }
   423 }
   438 }
   424 
   439 
   425 /*!
   440 /*!
   426  launchMailAppMailViewer slot.
   441  launchMailAppMailViewer slot.
   429  */
   444  */
   430 void NmHsWidgetEmailEngine::launchMailAppMailViewer(const NmId &messageId)
   445 void NmHsWidgetEmailEngine::launchMailAppMailViewer(const NmId &messageId)
   431 {
   446 {
   432     NM_FUNCTION;
   447     NM_FUNCTION;
   433 
   448 
   434     XQApplicationManager appManager;
   449     QT_TRY{
   435     XQAiwRequest* request = appManager.create(
   450         if (!mAiwRequest) {
   436             XQI_EMAIL_MESSAGE_VIEW, XQOP_EMAIL_MESSAGE_VIEW,
   451             XQApplicationManager appManager;
   437             false);
   452             mAiwRequest = appManager.create(
   438     
   453                     XQI_EMAIL_MESSAGE_VIEW, XQOP_EMAIL_MESSAGE_VIEW,
   439     if (request) {
   454                     false);
   440         QList<QVariant> list;
   455             
   441         list.append(QVariant(mMailboxId.id()));
   456             if (mAiwRequest) {
   442         list.append(QVariant(mFolderId.id()));
   457                 connect(mAiwRequest, SIGNAL( requestError(int, const QString&) ), 
   443         list.append(QVariant(messageId.id()));
   458                         this, SLOT( aiwRequestError(int, const QString&) ));
   444     
   459                 connect(mAiwRequest, SIGNAL( requestOk(const QVariant&) ), 
   445         request->setArguments(list);
   460                         this, SLOT( aiwRequestOk(const QVariant&) ));
   446         request->send();
   461                 QList<QVariant> list;
   447     }
   462                 list.append(QVariant(mMailboxId.id()));
   448 }
   463                 list.append(QVariant(mFolderId.id()));
       
   464                 list.append(QVariant(messageId.id()));
       
   465             
       
   466                 mAiwRequest->setSynchronous(false);
       
   467                 mAiwRequest->setArguments(list);
       
   468                 mAiwRequest->send();
       
   469             }
       
   470         }
       
   471     }
       
   472     QT_CATCH(...){
       
   473         // no actions taken.
       
   474         // try-catch mechanism added to avoid crashing widget, in case XQAiwRequest
       
   475         // creation raise exception.
       
   476     }
       
   477 }
       
   478 
       
   479 /*!
       
   480  aiwRequestOk slot.
       
   481  */
       
   482 void NmHsWidgetEmailEngine::aiwRequestOk(const QVariant& result)
       
   483 {
       
   484     NM_FUNCTION;
       
   485 
       
   486     Q_UNUSED(result);
       
   487     
       
   488     deleteAiwRequest();
       
   489 }
       
   490 
       
   491 /*!
       
   492  aiwRequestError slot.
       
   493  */
       
   494 void NmHsWidgetEmailEngine::aiwRequestError(int errorCode, const QString& errorMessage)
       
   495 {
       
   496     NM_FUNCTION;
       
   497 
       
   498     Q_UNUSED(errorCode);
       
   499     Q_UNUSED(errorMessage);
       
   500     
       
   501     deleteAiwRequest();
       
   502 }
       
   503 
       
   504 /*!
       
   505  deleteAiwRequest function.
       
   506  */
       
   507 void NmHsWidgetEmailEngine::deleteAiwRequest()
       
   508 {
       
   509     NM_FUNCTION;
       
   510 
       
   511     delete mAiwRequest;
       
   512     mAiwRequest = NULL;    
       
   513 }
       
   514