messagingapp/msgnotifications/msgnotifier/src/msgstorehandler.cpp
changeset 34 84197e66a4bd
parent 25 84d9eb65b26f
child 43 35b64624a9e7
equal deleted inserted replaced
31:ebfee66fde93 34:84197e66a4bd
    61     if (iFailedMessages) {
    61     if (iFailedMessages) {
    62         delete iFailedMessages;
    62         delete iFailedMessages;
    63         iFailedMessages = NULL;
    63         iFailedMessages = NULL;
    64     }
    64     }
    65 
    65 
    66     if (iFailedNotes) {
       
    67         delete iFailedNotes;
       
    68         iFailedNotes = NULL;
       
    69     }
       
    70 }
    66 }
    71 
    67 
    72 // ---------------------------------------------------------
    68 // ---------------------------------------------------------
    73 // InitL( )
    69 // InitL( )
    74 // Initialize the Store handler.
    70 // Initialize the Store handler.
    78     iMsvSession = CMsvSession::OpenSyncL(*this);
    74     iMsvSession = CMsvSession::OpenSyncL(*this);
    79     iMsvEntry = iMsvSession->GetEntryL(KMsvGlobalOutBoxIndexEntryId);
    75     iMsvEntry = iMsvSession->GetEntryL(KMsvGlobalOutBoxIndexEntryId);
    80     iMsvEntry->AddObserverL(*this);
    76     iMsvEntry->AddObserverL(*this);
    81 
    77 
    82     iFailedMessages = new (ELeave) CMsvEntrySelection;
    78     iFailedMessages = new (ELeave) CMsvEntrySelection;
    83     iFailedNotes = new (ELeave) CMsvEntrySelection;
       
    84 }
    79 }
    85 
    80 
    86 // ---------------------------------------------------------
    81 // ---------------------------------------------------------
    87 // MsgStoreHandler::HandleSessionEventL()
    82 // MsgStoreHandler::HandleSessionEventL()
    88 // ---------------------------------------------------------
    83 // ---------------------------------------------------------
   106         && aEvent != EMsvEntriesChanged) {
   101         && aEvent != EMsvEntriesChanged) {
   107         return;
   102         return;
   108     }
   103     }
   109 
   104 
   110     //Handling for outbox entries
   105     //Handling for outbox entries
   111     if( parent == KMsvGlobalOutBoxIndexEntryIdValue )
   106     if (parent == KMsvGlobalOutBoxIndexEntryIdValue) {
   112     {
       
   113         CMsvEntry* rootEntry = iMsvSession->GetEntryL(KMsvGlobalOutBoxIndexEntryId);
   107         CMsvEntry* rootEntry = iMsvSession->GetEntryL(KMsvGlobalOutBoxIndexEntryId);
   114 
   108 
   115         for (TInt i = 0; i < selection->Count(); ++i) {
   109         for (TInt i = 0; i < selection->Count(); ++i) {
   116             TMsvEntry entry = rootEntry->ChildDataL(selection->At(i));
   110             TMsvEntry entry = rootEntry->ChildDataL(selection->At(i));
   117 
   111 
   118             if ((entry.iMtm == KSenduiMtmSmsUid) || (entry.iMtm == KSenduiMtmMmsUid)) {
   112             if ((entry.iMtm == KSenduiMtmSmsUid) || (entry.iMtm == KSenduiMtmMmsUid)) {
   119                 TUint sendingState = entry.SendingState();
   113                 TUint sendingState = entry.SendingState();
   120                 TInt index = iFailedMessages->Find(entry.Id());
   114                 TInt index = iFailedMessages->Find(entry.Id());
   121 
   115 
   122                 if (sendingState == KMsvSendStateFailed && KErrNotFound == index) {
   116                 if (sendingState == KMsvSendStateFailed && KErrNotFound == index) {
       
   117 
   123                     iFailedMessages->AppendL(entry.Id());
   118                     iFailedMessages->AppendL(entry.Id());
   124                     iFailedNotes->AppendL(entry.Id());
   119                     MsgInfo aInfo;
       
   120                     ProcessIndicatorDataL(entry.Id(), aInfo);
       
   121                     iNotifier->displayFailedNote(aInfo);
   125                 }
   122                 }
   126                 else if (sendingState != KMsvSendStateFailed && KErrNotFound != index) {
   123                 else if (sendingState != KMsvSendStateFailed && KErrNotFound != index) {
   127                     iFailedMessages->Delete(index);
   124                     iFailedMessages->Delete(index);
   128                     iFailedMessages->Compress();
   125                     iFailedMessages->Compress();
   129                 }
   126                 }
   130                 if (iFailedNotes->Count()) {
   127 
   131                     MsgInfo aInfo;
       
   132                     ProcessIndicatorDataL(iFailedNotes->At(0), aInfo);
       
   133                     iNotifier->displayFailedNote(aInfo);
       
   134                     iFailedNotes->Delete(0);
       
   135                     iFailedNotes->Compress();
       
   136                 }
       
   137             }
   128             }
   138         }//end for
   129         }//end for
   139     }
   130     }
   140     else
   131     else {
   141     {
       
   142         TMsvEntry entry;
   132         TMsvEntry entry;
   143         TMsvId service;
   133         TMsvId service;
   144         TInt error= KErrNone;
   134         TInt error = KErrNone;
   145         for (TInt i = 0; i < selection->Count(); ++i)
   135         for (TInt i = 0; i < selection->Count(); ++i) {
   146         {
       
   147             error = iMsvSession->GetEntry(selection->At(i), service, entry);
   136             error = iMsvSession->GetEntry(selection->At(i), service, entry);
   148 
   137 
   149             if (error == KErrNone && entry.iMtm == KUidMsgMMSNotification && MmsNotificationStatus(
   138             if (error == KErrNone && entry.iMtm == KUidMsgMMSNotification && 
   150                 entry) == EMsgStatusFailed)
   139                 MmsNotificationStatus(entry) == EMsgStatusFailed) {
   151             {
   140 
   152                 MsgInfo aInfo;
   141                 TInt index = iFailedMessages->Find(entry.Id());
   153                                 
   142 
   154                 //Fill aInfo with appropriate data
   143                 if (KErrNotFound == index) {
   155                 aInfo.mMessageType = ECsMmsNotification;
   144                     iFailedMessages->AppendL(entry.Id());
   156 
   145                     MsgInfo aInfo;
   157                 ProcessIndicatorDataL(entry.Id(),aInfo);
   146                     //Fill aInfo with appropriate data
   158                 iNotifier->displayFailedNote(aInfo);
   147                     aInfo.mMessageType = ECsMmsNotification;
   159             }
   148                     ProcessIndicatorDataL(entry.Id(), aInfo);
   160         }
   149                     iNotifier->displayFailedNote(aInfo);
   161     }
   150 
       
   151                 }// end of if
       
   152             }
       
   153             else if (error == KErrNone && entry.iMtm == KUidMsgMMSNotification
       
   154                 && MmsNotificationStatus(entry) == EMsgStatusRetrieving) {
       
   155                 
       
   156                 TInt index = iFailedMessages->Find(entry.Id());
       
   157                 if (KErrNotFound != index) {
       
   158                     iFailedMessages->Delete(index);
       
   159                     iFailedMessages->Compress();
       
   160                 }// end of KErrNotFound != index if block
       
   161 
       
   162             } // end of 2nd if  
       
   163         } // for loop
       
   164     }
       
   165 
   162 }
   166 }
   163 
   167 
   164 // ---------------------------------------------------------
   168 // ---------------------------------------------------------
   165 // MsgStoreHandler::HandleEntryEventL()
   169 // MsgStoreHandler::HandleEntryEventL()
   166 // ---------------------------------------------------------
   170 // ---------------------------------------------------------