simpledatamodeladapter/src/presenceplugindata.cpp
changeset 12 e6a66db4e9d0
parent 0 c8caa15ef882
equal deleted inserted replaced
0:c8caa15ef882 12:e6a66db4e9d0
     1 /*
     1 /*
     2 * Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    38 #include <msimpleelement.h>
    38 #include <msimpleelement.h>
    39 #include <msimplepresencelist.h>
    39 #include <msimplepresencelist.h>
    40 #include <msimplemeta.h>
    40 #include <msimplemeta.h>
    41 #include <simpleutils.h>
    41 #include <simpleutils.h>
    42 #include <presencecachewriter2.h>
    42 #include <presencecachewriter2.h>
    43 #include <presencecachereader2.h>
       
    44 #include <presencebuddyinfo.h>
    43 #include <presencebuddyinfo.h>
    45 #include <spsettings.h>
    44 #include <spsettings.h>
    46 #include <spentry.h>
    45 #include <spentry.h>
    47 #include <spproperty.h>
    46 #include <spproperty.h>
    48 #include <spdefinitions.h>
    47 #include <spdefinitions.h>
    49 #include <avabilitytext.h>
    48 #include <avabilitytext.h>
    50 #include <cvimpstsettingsstore.h>
    49 #include <cvimpstsettingsstore.h>
    51 
    50 
    52 
       
    53 #include "presenceplugindata.h"
    51 #include "presenceplugindata.h"
    54 #include "presenceplugincommon.h"
    52 #include "presenceplugincommon.h"
    55 #include "presencepluginvirtualgroup.h"
    53 #include "presencepluginvirtualgroup.h"
    56 #include "presencepluginlanguagecodes.h"
       
    57 
    54 
    58 // ---------------------------------------------------------------------------
    55 // ---------------------------------------------------------------------------
    59 // CPresencePluginData::CPresencePluginData
    56 // CPresencePluginData::CPresencePluginData
    60 // ---------------------------------------------------------------------------
    57 // ---------------------------------------------------------------------------
    61 //
    58 //
    62 CPresencePluginData::CPresencePluginData( 
    59 CPresencePluginData::CPresencePluginData( 
    63 	MPresencePluginConnectionObs& aObs,
    60 	MPresencePluginConnectionObs& aObs,
    64 	TInt aServiceId ):
    61 	TInt aServiceId ):
    65 	iConnObs( aObs ), 
    62 	iConnObs( aObs ), 
    66 	iServiceId( aServiceId ),
    63 	iServiceId( aServiceId ),
    67 	iPresenceCacheWriter( NULL ),
    64 	iPresenceCacheWriter( NULL )
    68 	iPresenceCacheReader( NULL )
       
    69     {
    65     {
    70     }
    66     }
    71 
    67 
    72 // ---------------------------------------------------------------------------
    68 // ---------------------------------------------------------------------------
    73 // CPresencePluginData::~CPresencePluginData
    69 // CPresencePluginData::~CPresencePluginData
    75 //
    71 //
    76 CPresencePluginData::~CPresencePluginData()
    72 CPresencePluginData::~CPresencePluginData()
    77     {
    73     {
    78     DP_SDA("CPresencePluginData::~CPresencePluginData");
    74     DP_SDA("CPresencePluginData::~CPresencePluginData");
    79     delete iPresenceCacheWriter;
    75     delete iPresenceCacheWriter;
    80     delete iPresenceCacheReader;
       
    81     }
    76     }
    82 
    77 
    83 // ---------------------------------------------------------------------------
    78 // ---------------------------------------------------------------------------
    84 // CPresencePluginData::NewL
    79 // CPresencePluginData::NewL
    85 // ---------------------------------------------------------------------------
    80 // ---------------------------------------------------------------------------
   101 //
    96 //
   102 void CPresencePluginData::ConstructL()
    97 void CPresencePluginData::ConstructL()
   103     {
    98     {
   104     DP_SDA("CPresencePluginData::ConstructL");
    99     DP_SDA("CPresencePluginData::ConstructL");
   105     iPresenceCacheWriter =  MPresenceCacheWriter2::CreateWriterL();
   100     iPresenceCacheWriter =  MPresenceCacheWriter2::CreateWriterL();
   106     iPresenceCacheReader = MPresenceCacheReader2::CreateReaderL();
       
   107     }
   101     }
   108 
   102 
   109 // ---------------------------------------------------------------------------
   103 // ---------------------------------------------------------------------------
   110 // CPresencePluginData::NewLC
   104 // CPresencePluginData::NewLC
   111 // ---------------------------------------------------------------------------
   105 // ---------------------------------------------------------------------------
   421 			                    }
   415 			                    }
   422 			                } 
   416 			                } 
   423              	        }
   417              	        }
   424              	    
   418              	    
   425                     //FIND ACTIVITIES ELEMENT
   419                     //FIND ACTIVITIES ELEMENT
   426              	    if ( basicElementFound && !activitiesElementFound &&
   420              	    if ( basicElementFound  && 
   427              	        !elem2->LocalName().CompareF( KPresenceActivities8 ) )
   421              	        !elem2->LocalName().CompareF( KPresenceActivities8 ) )
   428              	        {
   422              	        {
   429              	        DP_SDA("NotifyToPrInfoL activities found outside basic");
   423              	        DP_SDA("NotifyToPrInfoL activities found outside basic");
   430 			            elem2->SimpleElementsL( activitiesElems );
   424 			            elem2->SimpleElementsL( activitiesElems );
   431 			            TInt count4 = activitiesElems.Count();
   425 			            TInt count4 = activitiesElems.Count();
   434 			                activitiesSimpleElem = activitiesElems[l];
   428 			                activitiesSimpleElem = activitiesElems[l];
   435 			                activitiesElementFound = ETrue;
   429 			                activitiesElementFound = ETrue;
   436 			                DP_SDA("CPresencePluginData::NotifyToPrInfoL 6");
   430 			                DP_SDA("CPresencePluginData::NotifyToPrInfoL 6");
   437 			                }
   431 			                }
   438              	        }
   432              	        }
   439                     }
   433              	    // Check note field    
   440                 
   434              	    if ( basicElementFound  && 
   441                 if ( basicElementFound && !noteSimpleElem )
   435              	        !elem2->LocalName().CompareF( KPresenceNote8 ) )
   442                     {
   436              	        {
   443                     noteSimpleElem = ResolveNoteElementL( elems2 );
   437              	        DP_SDA("NotifyToPrInfoL note field found inside tuple");
   444                     }
   438 			            noteSimpleElem = elem2;
   445                 
   439              	        }             	    
       
   440                     }   
   446                 DP_SDA("NotifyToPrInfoL ALL DONE"); 
   441                 DP_SDA("NotifyToPrInfoL ALL DONE"); 
   447                 CleanupStack::PopAndDestroy( &elems2 );
   442                 CleanupStack::PopAndDestroy( &elems2 );
   448                 
   443                 
   449                 if ( basicElementFound && activitiesElementFound && noteElemFound )
   444                 if( basicElementFound && activitiesElementFound && noteElemFound )
   450                     {
   445                     {
   451                     DP_SDA("NotifyToPrInfoL ALL DONE break out"); 
   446                     DP_SDA("NotifyToPrInfoL ALL DONE break out"); 
   452                     //Just handle first status information from document
   447                     //Just handle first status information from document
   453                     // In future server should support <timestamp>
   448                     // In future server should support <timestamp>
   454                     //Also client should be can handle timestaps if there are present
   449                     //Also client should be can handle timestaps if there are present
   484     aPrInfo.AddDevicePresenceL ( NULL );
   479     aPrInfo.AddDevicePresenceL ( NULL );
   485     aPrInfo.AddServicePresenceL( NULL );
   480     aPrInfo.AddServicePresenceL( NULL );
   486     */
   481     */
   487     DP_SDA("CPresencePluginData::NotifyToPrInfoL end");        
   482     DP_SDA("CPresencePluginData::NotifyToPrInfoL end");        
   488     }
   483     }
   489 
       
   490 
   484 
   491 // ---------------------------------------------------------------------------
   485 // ---------------------------------------------------------------------------
   492 // CPresencePluginData::CacheEntriesFromPrInfo
   486 // CPresencePluginData::CacheEntriesFromPrInfo
   493 // ---------------------------------------------------------------------------
   487 // ---------------------------------------------------------------------------
   494 //
   488 //
   712                 DP_SDA(" CPresencePluginData::SingleUserStatusToXIMPL else closed");
   706                 DP_SDA(" CPresencePluginData::SingleUserStatusToXIMPL else closed");
   713                 enumField->SetValueL( NPresenceInfo::ENotAvailable );
   707                 enumField->SetValueL( NPresenceInfo::ENotAvailable );
   714                 }
   708                 }
   715             }
   709             }
   716         
   710         
   717         field->SetFieldValue( enumField );
   711         field->SetFieldValue( enumField );        
   718         aCollection.AddOrReplaceFieldL( field );
   712         aCollection.AddOrReplaceFieldL( field );
   719         
   713         
   720         CleanupStack::Pop( 2 );            // >> field, enumField
   714         CleanupStack::Pop( 2 );            // >> field, enumField      
   721         
   715         
   722         DP_SDA(" CPresencePluginData::SingleUserStatusToXIMPL check for note");
   716         DP_SDA(" CPresencePluginData::SingleUserStatusToXIMPL check for note");
   723         
   717         // Handle notes field if found
   724         // Handle note field if found and buddy is "available".
   718         if ( aNoteElement )
   725         if ( aNoteElement && 
       
   726              NPresenceInfo::EOffline != enumField->Value() &&
       
   727              NPresenceInfo::ENotAvailable != enumField->Value() )
       
   728             {
   719             {
   729             DP_SDA(" CPresencePluginData::SingleUserStatusToXIMPL note elems found");
   720             DP_SDA(" CPresencePluginData::SingleUserStatusToXIMPL note elems found");
   730             // consider mapping note text to enum value if value not mapped
   721             // consider mapping note text to enum value if value not mapped
   731             UserNoteToXIMPL( aPresenceFactory, aNoteElement, aCollection );
   722             UserNoteToXIMPL( aPresenceFactory, aNoteElement, 
       
   723                 aCollection );
   732             }
   724             }
   733         }
   725         }
   734     CleanupStack::PopAndDestroy( nodeContent );
   726     CleanupStack::PopAndDestroy( nodeContent );
   735     DP_SDA(" CPresencePluginData::SingleUserStatusToXIMPL end");
   727     DP_SDA(" CPresencePluginData::SingleUserStatusToXIMPL end");
   736     }
   728     }
   983         // Maybe should check which prefix to use,
   975         // Maybe should check which prefix to use,
   984         // but assume that no secure is used if prefix missing
   976         // but assume that no secure is used if prefix missing
   985         TInt len = aPresentityUri.Length() + KMyLenSipPrefix;
   977         TInt len = aPresentityUri.Length() + KMyLenSipPrefix;
   986         buf = buf->ReAllocL( len );
   978         buf = buf->ReAllocL( len );
   987         //update pointer after realloc
   979         //update pointer after realloc
   988         CleanupStack::Pop( 1 );
   980         CleanupStack::Pop( buf );
   989         CleanupStack::PushL( buf );
   981         CleanupStack::PushL( buf );
   990         // Since realloc may have changed the location in memory
   982         // Since realloc may have changed the location in memory
   991         // we must also reset ptr
   983         // we must also reset ptr
   992         pBuf.Set( buf->Des() );
   984         pBuf.Set( buf->Des() );
   993         pBuf.Append( KMySip8 );
   985         pBuf.Append( KMySip8 );
  1386 //
  1378 //
  1387 TInt CPresencePluginData::ServiceId()
  1379 TInt CPresencePluginData::ServiceId()
  1388     {
  1380     {
  1389     return iServiceId;
  1381     return iServiceId;
  1390     }
  1382     }
  1391 
  1383     
  1392 // ---------------------------------------------------------------------------
       
  1393 // CPresencePluginData::ServiceNameLC()
       
  1394 // ---------------------------------------------------------------------------
       
  1395 //
       
  1396 HBufC* CPresencePluginData::ServiceNameLC( TInt aServiceId ) const
       
  1397     {
       
  1398     CSPSettings* spSettings = CSPSettings::NewLC();
       
  1399     CSPEntry* entry = CSPEntry::NewLC();
       
  1400     HBufC* serviceName = NULL;
       
  1401     
       
  1402     User::LeaveIfError( spSettings->FindEntryL( aServiceId, *entry ) );
       
  1403     
       
  1404     serviceName = entry->GetServiceName().AllocL();
       
  1405     
       
  1406     CleanupStack::PopAndDestroy( entry );
       
  1407     CleanupStack::PopAndDestroy( spSettings );
       
  1408     CleanupStack::PushL( serviceName );
       
  1409     return serviceName;
       
  1410     }
       
  1411 
       
  1412 // ---------------------------------------------------------------------------
       
  1413 // CPresencePluginData::ResolveCacheXspIdentifierL()
       
  1414 // ---------------------------------------------------------------------------
       
  1415 //
       
  1416 HBufC* CPresencePluginData::ResolveCacheXspIdentifierL(
       
  1417     const TDesC& aIdentity ) const
       
  1418     {
       
  1419     DP_SDA( "CPresencePluginData::ResolveCacheXspIdentifierL" ); 
       
  1420     
       
  1421     CSPSettings* spSettings = CSPSettings::NewLC();
       
  1422     CSPEntry* entry = CSPEntry::NewLC();
       
  1423     
       
  1424     User::LeaveIfError( spSettings->FindEntryL( iServiceId, *entry ) );
       
  1425 
       
  1426     TInt cacheUriLength = ( entry->GetServiceName().Length() + 
       
  1427             aIdentity.Length() + 1 );
       
  1428     
       
  1429     HBufC* cacheUri = HBufC::NewL( cacheUriLength );
       
  1430     TPtr cacheUriPtr( cacheUri->Des() );
       
  1431     
       
  1432     cacheUriPtr.Append( entry->GetServiceName() );
       
  1433     cacheUriPtr.Append( ':' );
       
  1434     cacheUriPtr.Append( aIdentity );
       
  1435     
       
  1436     CleanupStack::PopAndDestroy( entry );
       
  1437     CleanupStack::PopAndDestroy( spSettings );
       
  1438     
       
  1439     DP_SDA2( "CPresencePluginData::ResolveCacheXspIdentifierL returns: %S", cacheUri );
       
  1440     return cacheUri;
       
  1441     }
       
  1442 
       
  1443 // ---------------------------------------------------------------------------
  1384 // ---------------------------------------------------------------------------
  1444 // CPresencePluginData::WriteBlockItemsToCacheL()
  1385 // CPresencePluginData::WriteBlockItemsToCacheL()
  1445 // ---------------------------------------------------------------------------
  1386 // ---------------------------------------------------------------------------
  1446 //    
  1387 //    
  1447 void CPresencePluginData::WriteStatusToCacheL(
  1388 void CPresencePluginData::WriteStatusToCacheL(
  1455         aAvailability );
  1396         aAvailability );
  1456     DP_SDA2( "CPresencePluginData::WriteStatusToCacheL, availabilityText: %S", 
  1397     DP_SDA2( "CPresencePluginData::WriteStatusToCacheL, availabilityText: %S", 
  1457         &aAvailabilityText );
  1398         &aAvailabilityText );
  1458     DP_SDA2( "CPresencePluginData::WriteStatusToCacheL, statusMessage: %S", 
  1399     DP_SDA2( "CPresencePluginData::WriteStatusToCacheL, statusMessage: %S", 
  1459         &aStatusMessage );
  1400         &aStatusMessage );
  1460 
  1401     
  1461     TBool updateCache( ETrue );
  1402     CSPSettings* spSettings = CSPSettings::NewL();
  1462     
  1403     CleanupStack::PushL( spSettings );
  1463     HBufC* cacheUri = ResolveCacheXspIdentifierL( aPresentityId );
  1404     // Resolve service name (cache xsp identifier)
  1464     CleanupStack::PushL( cacheUri );
  1405     CSPEntry* entry = CSPEntry::NewLC();
  1465     
  1406     spSettings->FindEntryL( ServiceId(), *entry );
  1466     DP_SDA(" -> WriteStatusToCacheL - read previous values from cache"); 
  1407 
  1467     
  1408     TInt cacheUriLength = ( entry->GetServiceName().Length() + 
  1468     // Read previous values from cache
  1409         aPresentityId.Length() + 1 );
  1469     MPresenceBuddyInfo2* previousPresInfo = 
  1410     
  1470         iPresenceCacheReader->PresenceInfoLC( *cacheUri );
  1411     DP_SDA2(" -> cache uri length: %d", cacheUriLength );    
  1471     
  1412     
  1472     if ( previousPresInfo )
  1413     HBufC* cacheUri = HBufC::NewLC( cacheUriLength );
  1473         {
  1414     TPtr cacheUriPtr( cacheUri->Des() );
  1474         DP_SDA(" -> WriteStatusToCacheL - get availability value"); 
  1415     
  1475         
  1416     DP_SDA(" -> WriteStatusToCacheL - form cache entry");
  1476         MPresenceBuddyInfo2::TAvailabilityValues availability = 
  1417     cacheUriPtr.Append( entry->GetServiceName() );
  1477             previousPresInfo->Availability();
  1418     cacheUriPtr.Append( ':' );
  1478         
  1419     cacheUriPtr.Append( aPresentityId );
  1479         DP_SDA(" -> WriteStatusToCacheL - get availability text"); 
  1420     
  1480         
  1421     MPresenceBuddyInfo2* buddyPresInfo = MPresenceBuddyInfo2::NewLC();
  1481         TPtrC availabilityText = previousPresInfo->AvailabilityText();
  1422     buddyPresInfo->SetIdentityL( cacheUriPtr );
  1482         
  1423 
  1483         DP_SDA(" -> WriteStatusToCacheL - get status message"); 
  1424     TBuf<20> buf;
  1484         
  1425     TBool handled = EFalse;
  1485         TPtrC statusMessage = previousPresInfo->StatusMessage();
  1426     
  1486         CleanupStack::PopAndDestroy(); //previousPresInfo 
  1427     buf.Copy( KBlockedExtensionValue );
  1487         
  1428    
  1488         DP_SDA2( "CPresencePluginData::WriteStatusToCacheL, OLD STATUS: %d", 
  1429     if( aAvailabilityText.Compare( buf ) == 0 )
  1489                 availability );
  1430         {
  1490         DP_SDA2( "CPresencePluginData::WriteStatusToCacheL, OLD AVAILABILITY TEXT: %S", 
  1431         DP_SDA( " -> WriteStatusToCacheL - set Blocked" );
  1491             &availabilityText );
  1432         buddyPresInfo->SetAnyFieldL( KExtensionKey, KBlockedExtensionValue );
  1492         DP_SDA2( "CPresencePluginData::WriteStatusToCacheL, OLD STATUS MESSAGE: %S", 
  1433         handled = ETrue;
  1493             &statusMessage );
  1434         }
  1494         
  1435     
  1495         if ( ( aAvailability == availability ) && 
  1436     buf.Copy( KPendingRequestExtensionValue );
  1496             ( aAvailabilityText.Compare( availabilityText ) == 0 ) &&
  1437     
  1497             ( aStatusMessage.Compare( statusMessage ) == 0 ))
  1438     if ( aAvailabilityText.Compare( buf ) == 0 )
  1498             {
  1439         {
  1499             DP_SDA(" -> WriteStatusToCacheL - no need to update cache");    
  1440         DP_SDA( " -> WriteStatusToCacheL - set Pending request" );
  1500             updateCache = EFalse;
  1441         buddyPresInfo->SetAnyFieldL( KExtensionKey, KPendingRequestExtensionValue );
  1501             } 
  1442         handled = ETrue;
  1502         }
  1443         }
  1503         
  1444     
  1504     if ( updateCache )
  1445     if ( !handled )
  1505         {
  1446         {
  1506         MPresenceBuddyInfo2* newPresInfo = MPresenceBuddyInfo2::NewLC();
  1447         DP_SDA( " -> WriteStatusToCacheL - set availability text" );
  1507         newPresInfo->SetIdentityL( *cacheUri );
  1448             buddyPresInfo->SetAvailabilityL( aAvailability, aAvailabilityText );
  1508         
  1449         }
  1509         DP_SDA(" -> WriteStatusToCacheL - update cache");
  1450     
  1510         
  1451     if ( aStatusMessage.Length() )
  1511         TBuf<KBufSize20> buf;
  1452         {
  1512         TBool handled = EFalse;
  1453         DP_SDA( " -> WriteStatusToCacheL - set status message" ); 
  1513            
  1454         buddyPresInfo->SetStatusMessageL( aStatusMessage );
  1514         buf.Copy( KBlockedExtensionValue );
  1455         }
  1515           
  1456 
  1516         if( aAvailabilityText.Compare( buf ) == 0 )
  1457     DP_SDA( " -> WriteStatusToCacheL - write presence to cache" );    
  1517             {
  1458     TInt cacheError = iPresenceCacheWriter->WritePresenceL( buddyPresInfo );
  1518             DP_SDA( " -> WriteStatusToCacheL - set Blocked" );
  1459     DP_SDA2( "CPresencePluginEntityWatcher::WriteStatusToCacheL error: %d", 
  1519             newPresInfo->SetAnyFieldL( KExtensionKey, KBlockedExtensionValue );
  1460         cacheError );
  1520             handled = ETrue;
  1461     
  1521             }
  1462     DP_SDA( " -> destroy buddy info" );    
  1522            
  1463     CleanupStack::PopAndDestroy(); // buddyPresInfo
  1523         buf.Copy( KPendingRequestExtensionValue );
       
  1524            
       
  1525         if ( aAvailabilityText.Compare( buf ) == 0 )
       
  1526             {
       
  1527             DP_SDA( " -> WriteStatusToCacheL - set Pending request" );
       
  1528             newPresInfo->SetAnyFieldL( KExtensionKey, KPendingRequestExtensionValue );
       
  1529             handled = ETrue;
       
  1530             }
       
  1531            
       
  1532         if ( !handled )
       
  1533             {
       
  1534             DP_SDA2( " -> WriteStatusToCacheL - set availability text: %S", &aAvailabilityText );
       
  1535             newPresInfo->SetAvailabilityL( aAvailability, aAvailabilityText );
       
  1536             }
       
  1537            
       
  1538         if ( aStatusMessage.Length() )
       
  1539             {
       
  1540             DP_SDA2( " -> WriteStatusToCacheL - set status message: %S", &aStatusMessage ); 
       
  1541             newPresInfo->SetStatusMessageL( aStatusMessage );
       
  1542             }
       
  1543 
       
  1544         DP_SDA( " -> WriteStatusToCacheL - write presence to cache" );    
       
  1545         TInt cacheError = iPresenceCacheWriter->WritePresenceL( newPresInfo );
       
  1546         DP_SDA2( "CPresencePluginEntityWatcher::WriteStatusToCacheL error: %d", 
       
  1547             cacheError );
       
  1548            
       
  1549         DP_SDA( " -> destroy buddy info" );    
       
  1550         CleanupStack::PopAndDestroy(); // newPresInfo            
       
  1551         }
       
  1552     
       
  1553     DP_SDA(" -> destroy uri");    
  1464     DP_SDA(" -> destroy uri");    
  1554     CleanupStack::PopAndDestroy( cacheUri );
  1465     CleanupStack::PopAndDestroy( cacheUri );
  1555 
  1466 
       
  1467     DP_SDA(" -> destroy sp entry");        
       
  1468     CleanupStack::PopAndDestroy( entry );        
       
  1469     DP_SDA(" -> destroy sp");        
       
  1470     CleanupStack::PopAndDestroy( spSettings );
  1556     DP_SDA("CPresencePluginData::WriteStatusToCacheL end");
  1471     DP_SDA("CPresencePluginData::WriteStatusToCacheL end");
  1557     }     
  1472     }     
  1558     
  1473     
  1559 // ---------------------------------------------------------------------------
  1474 // ---------------------------------------------------------------------------
  1560 // CPresencePluginData::RemoveCacheL()
  1475 // CPresencePluginData::RemoveCacheL()
  1565     DP_SDA("CPresencePluginData::RemoveCacheL");
  1480     DP_SDA("CPresencePluginData::RemoveCacheL");
  1566     
  1481     
  1567     // Resolve service name (cache xsp identifier)
  1482     // Resolve service name (cache xsp identifier)
  1568     CSPSettings* spSettings = CSPSettings::NewL();
  1483     CSPSettings* spSettings = CSPSettings::NewL();
  1569     CleanupStack::PushL( spSettings );
  1484     CleanupStack::PushL( spSettings );
  1570     
       
  1571     CSPEntry* entry = CSPEntry::NewLC();
  1485     CSPEntry* entry = CSPEntry::NewLC();
  1572     DP_SDA2(" -> RemoveCacheL look for service: %d", ServiceId() );
  1486     DP_SDA2(" -> RemoveCacheL look for service: %d", ServiceId() );
  1573     spSettings->FindEntryL( ServiceId(), *entry );
  1487     spSettings->FindEntryL( ServiceId(), *entry );
  1574 
  1488 
  1575     DP_SDA(" -> RemoveCacheL cache xsp identifier found");
  1489     DP_SDA(" -> RemoveCacheL cache xsp identifier found");
  1628     CleanupStack::PopAndDestroy( entry ); 
  1542     CleanupStack::PopAndDestroy( entry ); 
  1629     DP_SDA(" -> destroy sp");        
  1543     DP_SDA(" -> destroy sp");        
  1630     CleanupStack::PopAndDestroy( spSettings );
  1544     CleanupStack::PopAndDestroy( spSettings );
  1631     DP_SDA("CPresencePluginData::DeletePresenceL out");
  1545     DP_SDA("CPresencePluginData::DeletePresenceL out");
  1632     }    
  1546     }    
  1633 
       
  1634     
  1547     
  1635 // ---------------------------------------------------------------------------
  1548 // ---------------------------------------------------------------------------
  1636 // CPresencePluginData::StorePresenceOwnPresenceL()
  1549 // CPresencePluginData::StorePresenceOwnPresenceL()
  1637 // ---------------------------------------------------------------------------
  1550 // ---------------------------------------------------------------------------
  1638 //    
  1551 //    
  1644     DP_SDA("CPresencePluginData::StorePresenceOwnPresenceL IN");
  1557     DP_SDA("CPresencePluginData::StorePresenceOwnPresenceL IN");
  1645     DP_SDA2(" -> aServiceId: %d", aServiceId );
  1558     DP_SDA2(" -> aServiceId: %d", aServiceId );
  1646         
  1559         
  1647     DP_SDA2(" -> SAVE AVAILABILITY VALUE: %d", aAvailability );
  1560     DP_SDA2(" -> SAVE AVAILABILITY VALUE: %d", aAvailability );
  1648     DP_SDA2(" -> SAVE STATUS MESSAGE: %S", &aStatusMessage );
  1561     DP_SDA2(" -> SAVE STATUS MESSAGE: %S", &aStatusMessage );
  1649         
  1562        
  1650     MVIMPSTSettingsStore* settings = CVIMPSTSettingsStore::NewLC();
  1563     MVIMPSTSettingsStore* settings = CVIMPSTSettingsStore::NewLC();
  1651     
  1564     
  1652     DP_SDA("CPresencePluginData::StorePresenceOwnPresenceL 1");
  1565     DP_SDA("CPresencePluginData::StorePresenceOwnPresenceL 1");
  1653     
  1566     
  1654     // Store availability value to uiservicetabsettings
  1567     // Store availability value to uiservicetabsettings
  1674 void CPresencePluginData::ReadDocumentIdL(
  1587 void CPresencePluginData::ReadDocumentIdL(
  1675     const TInt aServiceId, 
  1588     const TInt aServiceId, 
  1676     TDes8& aDocumentId )
  1589     TDes8& aDocumentId )
  1677     {  
  1590     {  
  1678     DP_SDA("CPresencePluginData::ReadDocumentIdL IN");
  1591     DP_SDA("CPresencePluginData::ReadDocumentIdL IN");
  1679         
  1592     
  1680     DP_SDA2(" -> aServiceId: %d", aServiceId );
  1593     DP_SDA2(" -> aServiceId: %d", aServiceId );
  1681     
  1594     
  1682     MVIMPSTSettingsStore* settings = CVIMPSTSettingsStore::NewLC();
  1595     MVIMPSTSettingsStore* settings = CVIMPSTSettingsStore::NewLC();
  1683     
  1596     
  1684     RBuf8 documentId;
  1597     RBuf8 documentId;
  1743     
  1656     
  1744     CleanupStack::PopAndDestroy(); // settings
  1657     CleanupStack::PopAndDestroy(); // settings
  1745     
  1658     
  1746     DP_SDA("CPresencePluginData::DeletePresenceVariablesL OUT");
  1659     DP_SDA("CPresencePluginData::DeletePresenceVariablesL OUT");
  1747     }   
  1660     }   
  1748 
  1661         
  1749 
       
  1750 // ---------------------------------------------------------------------------
       
  1751 // CPresencePluginData::ResolveNoteElementL
       
  1752 // Returns <note> element corresponding current locale or first <note> 
       
  1753 // element if better match is not found.
       
  1754 // ---------------------------------------------------------------------------
       
  1755 //
       
  1756 MSimpleElement* CPresencePluginData::ResolveNoteElementL( 
       
  1757         const RPointerArray<MSimpleElement>& aElements ) const
       
  1758     {
       
  1759     DP_SDA("CPresencePluginData::ResolveNoteElementL" )
       
  1760     
       
  1761     MSimpleElement* bestMatch = NULL;
       
  1762     MSimpleElement* secondBestMatch = NULL;
       
  1763     
       
  1764     for ( TInt i = aElements.Count() - 1; i >= 0 && NULL == bestMatch; i-- )
       
  1765         {
       
  1766         MSimpleElement* element = aElements[i];
       
  1767         
       
  1768         using namespace NPresencePlugin::NPresence;
       
  1769         if ( 0 == element->LocalName().CompareF( KPresenceNote8 ) )
       
  1770             {
       
  1771             if ( IsElementLanguageValidForCurrentLocaleL( *element ) )
       
  1772                 {
       
  1773                 DP_SDA("CPresencePluginData::ResolveNoteElementL, BEST MATCH.")
       
  1774                 bestMatch = element;
       
  1775                 }
       
  1776             else
       
  1777                 {
       
  1778                 secondBestMatch = element;
       
  1779                 }
       
  1780             }
       
  1781         }
       
  1782     
       
  1783     return ( bestMatch ? bestMatch : secondBestMatch );
       
  1784     }
       
  1785 
       
  1786 
       
  1787 // ---------------------------------------------------------------------------
       
  1788 // CPresencePluginData::IsElementLanguageValidForCurrentLocaleL
       
  1789 // ---------------------------------------------------------------------------
       
  1790 //
       
  1791 TBool CPresencePluginData::IsElementLanguageValidForCurrentLocaleL( 
       
  1792         MSimpleElement& aElement ) const
       
  1793     {
       
  1794     DP_SDA( "CPresencePluginData::IsElementLanguageValidForCurrentLocaleL" )
       
  1795     
       
  1796     TBool isLanguageResolved = EFalse;
       
  1797     _LIT8( KLanguageAttribute, "xml:lang" );
       
  1798     
       
  1799     TLanguage language = User::Language();
       
  1800     RPointerArray<MSimpleAttribute> attributes;
       
  1801     CleanupClosePushL( attributes );
       
  1802     aElement.SimpleAttributesL( attributes );
       
  1803     for ( TInt i = attributes.Count() - 1; i >= 0 && !isLanguageResolved; i-- )
       
  1804         {
       
  1805         if ( 0 == KLanguageAttribute().CompareF( attributes[i]->Name() ) )
       
  1806             {
       
  1807             const TDesC8& attributeValue = attributes[i]->Value();
       
  1808             for ( TInt index = 0; index < KLanguageCodeMappingsCount; index++ )
       
  1809                 {
       
  1810                 if ( language == KLanguageCodeMappings[index].SymbianLanguageCode() &&
       
  1811                      0 == attributeValue.CompareF( 
       
  1812                          KLanguageCodeMappings[index].IsoLanguageCode() ) )
       
  1813                     {
       
  1814                     isLanguageResolved = ETrue;
       
  1815                     }
       
  1816                 }
       
  1817             }
       
  1818         }
       
  1819     CleanupStack::Pop( &attributes );
       
  1820     
       
  1821     return isLanguageResolved;
       
  1822     }
       
  1823 
       
  1824 // End of file
  1662 // End of file