mobilemessaging/unieditor/smsplugin/src/UniSmsPlugin.cpp
changeset 2 0bf1d54f37d9
parent 0 72b543305e3a
child 9 1d7827e39b52
equal deleted inserted replaced
1:d09ac5c1e252 2:0bf1d54f37d9
   189         {
   189         {
   190         iNLTFeatureSupport = EFalse;
   190         iNLTFeatureSupport = EFalse;
   191         }
   191         }
   192     
   192     
   193     FeatureManager::UnInitializeLib();
   193     FeatureManager::UnInitializeLib();
       
   194     iStoreChanged = EFalse;
   194     
   195     
   195     UNILOGGER_LEAVEFN("CUniSmsPlugin::ConstructL");
   196     UNILOGGER_LEAVEFN("CUniSmsPlugin::ConstructL");
   196     }
   197     }
   197 
   198 
   198 // -----------------------------------------------------------------------------
   199 // -----------------------------------------------------------------------------
   338             CleanupStack::PopAndDestroy( bodyText );            
   339             CleanupStack::PopAndDestroy( bodyText );            
   339             }
   340             }
   340         }
   341         }
   341     
   342     
   342     SmsMtmL()->Body().Reset();
   343     SmsMtmL()->Body().Reset();
   343     
       
   344     SmsMtmL()->SaveMessageL();
   344     SmsMtmL()->SaveMessageL();
   345     TMsvEntry uniTEntry = iUniMtm.Entry().Entry();
   345     TMsvEntry uniTEntry = iUniMtm.Entry().Entry();
       
   346     CMsvStore* store = iUniMtm.Entry().EditStoreL();
       
   347     CleanupStack::PushL( store );
   346    
   348    
   347     iUniMtm.SaveMessageL();
   349     iUniMtm.SaveMessageL(*store, uniTEntry);
   348     
   350     
       
   351     store->CommitL();
       
   352     CleanupStack::PopAndDestroy(store);  
   349     // Lets convert the bits to Uni mode
   353     // Lets convert the bits to Uni mode
   350 	TUniMsvEntry::SetForwardedMessage( uniTEntry, aIsForward );
   354 	TUniMsvEntry::SetForwardedMessage( uniTEntry, aIsForward );
   351 	
   355 	
   352     uniTEntry.iMtm.iUid = KUidUniMtm;
   356     uniTEntry.iMtm.iUid = KUidUniMtm;
   353     iUniMtm.Entry().ChangeL( uniTEntry );
   357     iUniMtm.Entry().ChangeL( uniTEntry );
   354     UNILOGGER_LEAVEFN("CUniSmsPlugin::ConvertFromL");    
   358     UNILOGGER_LEAVEFN("CUniSmsPlugin::ConvertFromL");    
   355     UNILOGGER_WRITE_TIMESTAMP("CUniSmsPlugin::ConvertFromL end");
   359     UNILOGGER_WRITE_TIMESTAMP("CUniSmsPlugin::ConvertFromL end");
   356     return aId;
   360     return aId;
   357     }
   361     }
   358 
   362 
       
   363 TInt32 CUniSmsPlugin::AttachmentsSizeL( CMsvStore& aStore )
       
   364     {
       
   365     TInt32 size = 0;
       
   366 
       
   367     MMsvAttachmentManager& attachMan = aStore.AttachmentManagerL();
       
   368     TInt numAttachments = attachMan.AttachmentCount();
       
   369 
       
   370     for ( TInt i = 0; i < numAttachments; i++ )
       
   371         {
       
   372         CMsvAttachment* attachmentInfo = attachMan.GetAttachmentInfoL( i );
       
   373         CleanupStack::PushL( attachmentInfo );
       
   374         
       
   375         CMsvMimeHeaders* mimeHeaders = CMsvMimeHeaders::NewL();
       
   376         CleanupStack::PushL( mimeHeaders );
       
   377         
       
   378         mimeHeaders->RestoreL( *attachmentInfo );
       
   379         
       
   380         RFile attaFile = attachMan.GetAttachmentFileL( i );
       
   381         CleanupClosePushL( attaFile );
       
   382         TInt fileSize = 0;
       
   383         
       
   384         // If we cannot access the file, we are in trouble
       
   385         User::LeaveIfError( attaFile.Size( fileSize ) ); 
       
   386         
       
   387         // This adds up mime header size + actual attachment binary data
       
   388         size += mimeHeaders->Size() + fileSize;
       
   389 
       
   390         CleanupStack::PopAndDestroy( &attaFile );
       
   391         CleanupStack::PopAndDestroy( mimeHeaders );
       
   392         CleanupStack::PopAndDestroy( attachmentInfo );
       
   393         }
       
   394 
       
   395     return size;
       
   396     }
       
   397 	
   359 // -----------------------------------------------------------------------------
   398 // -----------------------------------------------------------------------------
   360 // ConvertToL
   399 // ConvertToL
   361 // -----------------------------------------------------------------------------
   400 // -----------------------------------------------------------------------------
   362 //
   401 //
   363 TMsvId CUniSmsPlugin::ConvertToL( TMsvId aId )
   402 TMsvId CUniSmsPlugin::ConvertToL( TMsvId aId )
   599         SmsMtmL()->SmsHeader().Message().SetAlternative7bitEncoding(currAlternateEncoding);       
   638         SmsMtmL()->SmsHeader().Message().SetAlternative7bitEncoding(currAlternateEncoding);       
   600         }
   639         }
   601 	
   640 	
   602     CleanupStack::PopAndDestroy( sendOptions ); 
   641     CleanupStack::PopAndDestroy( sendOptions ); 
   603 
   642 
       
   643     SmsMtmL()->SaveMessageL(*store, tEntry);
       
   644 
       
   645     store->CommitL();        
       
   646     tEntry.iSize = store->SizeL();
       
   647     if( AttachmentsSizeL( *store ) > 0 )
       
   648         {
       
   649         tEntry.SetAttachment( ETrue );
       
   650         }
       
   651     CleanupStack::PopAndDestroy( store );
       
   652     
   604     SmsMtmL()->Entry().ChangeL( tEntry );
   653     SmsMtmL()->Entry().ChangeL( tEntry );
   605 
       
   606     store->CommitL();        
       
   607     CleanupStack::PopAndDestroy( store );
       
   608     
       
   609     iUniMtm.SaveMessageL();
       
   610     SmsMtmL()->SaveMessageL();
       
   611     UNILOGGER_LEAVEFN("CUniSmsPlugin::ConvertToL");
   654     UNILOGGER_LEAVEFN("CUniSmsPlugin::ConvertToL");
   612     return aId;
   655     return aId;
   613     }
   656     }
   614 
   657 
   615 // -----------------------------------------------------------------------------
   658 // -----------------------------------------------------------------------------
   829 // ----------------------------------------------------------------------------
   872 // ----------------------------------------------------------------------------
   830 // MoveMessagesToOutboxL
   873 // MoveMessagesToOutboxL
   831 // ----------------------------------------------------------------------------
   874 // ----------------------------------------------------------------------------
   832 void CUniSmsPlugin::MoveMessagesToOutboxL()
   875 void CUniSmsPlugin::MoveMessagesToOutboxL()
   833     {
   876     {
       
   877     iStoreChanged = EFalse;
   834     if ( !iRecipients || !iRecipients->Count() )
   878     if ( !iRecipients || !iRecipients->Count() )
   835         {
   879         {
   836         User::Leave( KErrGeneral );
   880         User::Leave( KErrGeneral );
   837         }
   881         }
   838 
   882 
   913                     SmsMtmL( )->RemoveAddressee( 0 );	
   957                     SmsMtmL( )->RemoveAddressee( 0 );	
   914                 	}
   958                 	}
   915                 SmsMtmL()->AddAddresseeL( 
   959                 SmsMtmL()->AddAddresseeL( 
   916 	            iEmailOverSmsC->Address( ) ,
   960 	            iEmailOverSmsC->Address( ) ,
   917 		        KNullDesC( ) );
   961 		        KNullDesC( ) );
       
   962                 iStoreChanged = ETrue;
   918                 }
   963                 }
   919             else
   964             else
   920                 {                           
   965                 {                           
   921                 InsertSubjectL( header, SmsMtmL()->Body() );                                 
   966                 InsertSubjectL( header, SmsMtmL()->Body() );                                 
   922                 }
   967                 }
   923 
   968 
   924             entry.ChangeL( msvEntry );
   969             entry.ChangeL( msvEntry );
   925             SmsMtmL()->SaveMessageL();
   970             if( iStoreChanged )
       
   971                 {
       
   972             	SmsMtmL()->SaveMessageL();
       
   973                 }
   926             // Move it
   974             // Move it
   927             copyId = MoveMessageEntryL( KMsvGlobalOutBoxIndexEntryId );
   975             copyId = MoveMessageEntryL( KMsvGlobalOutBoxIndexEntryId );
   928             cantExit = EFalse;
   976             cantExit = EFalse;
   929             }
   977             }
   930         else 
   978         else 
   949                 
   997                 
   950                 copyId = CreateMessageInOutboxL(
   998                 copyId = CreateMessageInOutboxL(
   951                     msvEntry, *rcpt, SmsMtmL()->Body());
   999                     msvEntry, *rcpt, SmsMtmL()->Body());
   952  
  1000  
   953                 SmsMtmL()->RemoveAddressee( 0 );
  1001                 SmsMtmL()->RemoveAddressee( 0 );
       
  1002                 iStoreChanged = ETrue;
   954                 }
  1003                 }
   955             //If hundreds of recipient, make sure viewserver
  1004             //If hundreds of recipient, make sure viewserver
   956             //timers are reseted
  1005             //timers are reseted
   957             if ( iRecipients->Count() > 100 && ( iRecipients->Count() ) % 30 == 0 )
  1006             if ( iRecipients->Count() > 100 && ( iRecipients->Count() ) % 30 == 0 )
   958                 {
  1007                 {
  1378             {
  1427             {
  1379             aText.InsertL( 0, KUniSmsStartParenthesis );
  1428             aText.InsertL( 0, KUniSmsStartParenthesis );
  1380             aText.InsertL( 1, subject );
  1429             aText.InsertL( 1, subject );
  1381             aText.InsertL( writePosition-1, KUniSmsEndParenthesis );
  1430             aText.InsertL( writePosition-1, KUniSmsEndParenthesis );
  1382             }
  1431             }
       
  1432         iStoreChanged = ETrue;
  1383         }
  1433         }
  1384     
  1434     
  1385     // Clears the CSmsHeaders EmailFields for non Email addresses
  1435     // Clears the CSmsHeaders EmailFields for non Email addresses
  1386     CSmsEmailFields* emailFields = CSmsEmailFields::NewL();
  1436     CSmsEmailFields* emailFields = CSmsEmailFields::NewL();
  1387     CleanupStack::PushL( emailFields );
  1437     CleanupStack::PushL( emailFields );
  1388     aHeader.SetEmailFieldsL( *emailFields );
  1438     aHeader.SetEmailFieldsL( *emailFields );
  1389     CleanupStack::PopAndDestroy( emailFields );  
  1439     CleanupStack::PopAndDestroy( emailFields );  
       
  1440         iStoreChanged = ETrue;
  1390     }
  1441     }
  1391            
  1442            
  1392 // ----------------------------------------------------------------------------
  1443 // ----------------------------------------------------------------------------
  1393 // CreateVCardSMS
  1444 // CreateVCardSMS
  1394 // ----------------------------------------------------------------------------
  1445 // ----------------------------------------------------------------------------