emailuis/emailui/src/ncsaifeditor.cpp
branchRCL_3
changeset 29 6b8f3b30d0ec
parent 16 4ce476e64c59
child 52 efd4f1afd43e
equal deleted inserted replaced
26:67369d1b217f 29:6b8f3b30d0ec
    37 #include "FSEmail.pan"
    37 #include "FSEmail.pan"
    38 
    38 
    39 const TChar KCharAddressDelimeterSemiColon = ';';
    39 const TChar KCharAddressDelimeterSemiColon = ';';
    40 const TChar KCharAddressDelimeterComma = ',';
    40 const TChar KCharAddressDelimeterComma = ',';
    41 const TChar KCharSpace = ' ';
    41 const TChar KCharSpace = ' ';
       
    42 const TChar KCharAt = '@';
    42 
    43 
    43 // ---------------------------------------------------------------------------
    44 // ---------------------------------------------------------------------------
    44 // CNcsAifEntry::NewL
    45 // CNcsAifEntry::NewL
    45 // ---------------------------------------------------------------------------
    46 // ---------------------------------------------------------------------------
    46 //
    47 //
   347             CleanupStack::PopAndDestroy( text );            
   348             CleanupStack::PopAndDestroy( text );            
   348         	}
   349         	}
   349         iTextSelection = Selection();        
   350         iTextSelection = Selection();        
   350         ret = CNcsEditor::OfferKeyEventL( aKeyEvent, aType );
   351         ret = CNcsEditor::OfferKeyEventL( aKeyEvent, aType );
   351         }
   352         }
       
   353     
       
   354     if( ret == EKeyWasNotConsumed  && aType == EEventKeyDown )
       
   355         {
       
   356         HandleTextUpdateDeferred(); // update for lang that don't support CPS
       
   357         }
   352     return ret;
   358     return ret;
   353     }
   359     }
   354 
   360 
   355 // -----------------------------------------------------------------------------
   361 // -----------------------------------------------------------------------------
   356 // CNcsAifEditor::HandleEdwinEventL()
   362 // CNcsAifEditor::HandleEdwinEventL()
  1360     TBool entriesFound( EFalse );
  1366     TBool entriesFound( EFalse );
  1361     
  1367     
  1362     // start looking for entries separated with semicolon
  1368     // start looking for entries separated with semicolon
  1363     TInt start( 0 );
  1369     TInt start( 0 );
  1364     TInt end( ptr.Length() );
  1370     TInt end( ptr.Length() );
       
  1371     TInt lastSentinel = KErrNotFound;
  1365     
  1372     
  1366     for ( TInt ii = 0; ii < end; ++ii )
  1373     for ( TInt ii = 0; ii < end; ++ii )
  1367         {
  1374         {
  1368         TChar character = ptr[ii];
  1375         TChar character = ptr[ii];
       
  1376         TBool addAddress = EFalse;
  1369         
  1377         
  1370         if ( IsSentinel( character ) )
  1378         if ( IsSentinel( character ) )
  1371             {
  1379             {
  1372             if ( character == KCharAddressDelimeterComma )
  1380             if ( character == KCharSpace )
       
  1381                 {
       
  1382                 if ( ptr.Mid( start, ii-start ).Locate( KCharAt ) 
       
  1383                         != KErrNotFound )
       
  1384                     {
       
  1385                     ptr[ii] = KCharAddressDelimeterSemiColon;
       
  1386                     lastSentinel = ii;
       
  1387                     addAddress = ETrue;
       
  1388                     }
       
  1389                 }
       
  1390             else if ( character == KCharAddressDelimeterComma )
  1373                 {
  1391                 {
  1374                 // Replace comma with semicolon
  1392                 // Replace comma with semicolon
  1375                 ptr[ii] = KCharAddressDelimeterSemiColon;
  1393                 ptr[ii] = KCharAddressDelimeterSemiColon;
       
  1394                 lastSentinel = ii;
       
  1395                 addAddress = ETrue;
       
  1396                 }
       
  1397             else if ( character == KCharAddressDelimeterSemiColon )
       
  1398                 {
       
  1399                 lastSentinel = ii;
       
  1400                 addAddress = ETrue;
  1376                 }
  1401                 }
  1377 
  1402 
  1378             // Create new entry.
  1403             // Create new entry.
  1379             if ( start < end )
  1404             if ( addAddress && start < end )
  1380                 {
  1405                 {
  1381                 // only if longer than 0, if not we'll get 
  1406                 // only if longer than 0, if not we'll get 
  1382                 // "empty" email address
  1407                 // "empty" email address
  1383                 if ( ii-start )
  1408                 if ( ii-start )
  1384                     {
  1409                     {
  1385                     AddAddressL( KNullDesC(), ptr.Mid(start, ii-start) );
  1410                     AddAddressL( KNullDesC(), ptr.Mid(start, ii-start) );
  1386                     start = Min( ii + 1, end );
  1411                     start = Min( ii + 1, end );
  1387                     entriesFound = ETrue;
  1412                     entriesFound = ETrue;
  1388                     }
  1413                     }
  1389                 }
  1414                 addAddress = EFalse;
       
  1415                 }
       
  1416             }
       
  1417         }
       
  1418     
       
  1419     // add email that wasn't ended with semicolon
       
  1420     if ( lastSentinel != KErrNotFound )
       
  1421         {
       
  1422         if ( lastSentinel < end && start < end )
       
  1423             {
       
  1424             AddAddressL( KNullDesC(), ptr.Mid(start, end-start) );
  1390             }
  1425             }
  1391         }
  1426         }
  1392     
  1427     
  1393     CleanupStack::PopAndDestroy( text );
  1428     CleanupStack::PopAndDestroy( text );
  1394         
  1429         
  1503 //
  1538 //
  1504 TBool CNcsAifEditor::IsSentinel( TChar aCharacter ) const
  1539 TBool CNcsAifEditor::IsSentinel( TChar aCharacter ) const
  1505     {
  1540     {
  1506     FUNC_LOG;
  1541     FUNC_LOG;
  1507     return ( aCharacter == KCharAddressDelimeterSemiColon || 
  1542     return ( aCharacter == KCharAddressDelimeterSemiColon || 
  1508         aCharacter == KCharAddressDelimeterComma );
  1543         aCharacter == KCharAddressDelimeterComma || aCharacter == KCharSpace );
  1509     }
  1544     }
  1510 
  1545 
  1511 // ---------------------------------------------------------------------------
  1546 // ---------------------------------------------------------------------------
  1512 // Checks whether given character is considered as whitespace.
  1547 // Checks whether given character is considered as whitespace.
  1513 // ---------------------------------------------------------------------------
  1548 // ---------------------------------------------------------------------------