simpleengine/presencedm/src/presencedmadapter.cpp
branchRCL_3
changeset 34 2669f8761a99
parent 0 c8caa15ef882
child 35 fbd2e7cec7ef
equal deleted inserted replaced
31:2580314736af 34:2669f8761a99
     1 /*
     1 /*
     2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2006 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".
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:    OMA Presence Settings Device Management Adapter's source file 
    14 * Description:    OMA Presence Settings Device Management Adapter's source file 
    15 *
    15 *
    16 */
    16 */
       
    17 
       
    18 
       
    19 
    17  
    20  
    18 #include <implementationproxy.h>
    21 #include <implementationproxy.h>
    19 #include <nsmldmuri.h>
    22 #include <nsmldmuri.h>
    20 #include <utf.h>
    23 #include <utf.h>
    21 #include <badesca.h>
    24 #include <badesca.h>
   357    
   360    
   358     TPresSettingsSet tempSet;
   361     TPresSettingsSet tempSet;
   359     TPresSettingsProperty property;
   362     TPresSettingsProperty property;
   360 
   363 
   361     HBufC8* luid = Callback().GetLuidAllocL( aUri );
   364     HBufC8* luid = Callback().GetLuidAllocL( aUri );
   362     PRES_DM_LOG(LOG_LIT8("   GetLuidAllocL() => '%S'"), luid );
       
   363     TInt settingsId = DesToInt( *luid );
   365     TInt settingsId = DesToInt( *luid );
   364     
   366     
   365     PRES_DM_LOG(LOG_LIT("   settingsId after callback:%d"), settingsId);
   367     PRES_DM_LOG(LOG_LIT("   settingsId after callback:%d"), settingsId);
   366     
   368     
   367     // check whether above found id is valid or not
   369     // check whether above found id is valid or not
   368     if (!IsPresIDValidL(settingsId))
   370     if (!IsPresIDValidL(settingsId))
   369         {
   371         {
   370         //try to find it another way
   372         //try to find it another way
   371         if( NSmlDmURI::NumOfURISegs( aUri ) > 1 )
   373         TPtrC8 removedLastSeg = NSmlDmURI::RemoveLastSeg(aUri);
   372             {
   374         TPtrC8 idSegment = NSmlDmURI::LastURISeg(removedLastSeg);
   373             TPtrC8 idSegment = NSmlDmURI::URISeg( aUri, 2 );
   375         TInt settingsId = DesToInt(idSegment);
   374             settingsId = DesToInt(idSegment);
   376         if (!IsPresIDValidL(settingsId))
   375             if(!IsPresIDValidL(settingsId))
   377             status = CSmlDmAdapter::ENotFound;
   376                 {
   378         PRES_DM_LOG(LOG_LIT("   settingsId found local way:%d"), settingsId);
   377                 status = CSmlDmAdapter::ENotFound;
       
   378                 }
       
   379             PRES_DM_LOG(LOG_LIT("   settingsId found local way:%d"), settingsId);
       
   380             }
       
   381         }
   379         }
   382     
   380     
   383     // if previous settings id processing was ok
   381     // if previous settings id processing was ok
   384     if (status == CSmlDmAdapter::EOk)
   382     if (status == CSmlDmAdapter::EOk)
   385         {
   383         {
   519     
   517     
   520     // check whether above found id is valid or not
   518     // check whether above found id is valid or not
   521     if (!IsPresIDValidL(settingsId))
   519     if (!IsPresIDValidL(settingsId))
   522         {
   520         {
   523         //try to find it another way
   521         //try to find it another way
   524         if( NSmlDmURI::NumOfURISegs( aUri ) > 1 )
   522         TPtrC8 removedLastSeg = NSmlDmURI::RemoveLastSeg(aUri);
   525             {
   523         TPtrC8 idSegment = NSmlDmURI::LastURISeg(removedLastSeg);
   526             TPtrC8 idSegment = NSmlDmURI::URISeg( aUri, 2 );
   524         TInt settingsId = DesToInt(idSegment);
   527             settingsId = DesToInt(idSegment);
   525         if (!IsPresIDValidL(settingsId))
   528             if (!IsPresIDValidL(settingsId))
   526             status = CSmlDmAdapter::ENotFound; 
   529                 {
   527         PRES_DM_LOG(LOG_LIT("   settingsId found local way:%d"), settingsId);
   530                 status = CSmlDmAdapter::ENotFound;
       
   531                 }
       
   532             PRES_DM_LOG(LOG_LIT("   settingsId found local way:%d"), settingsId);
       
   533             }
       
   534         }
   528         }
   535     
   529     
   536     // if previous settings id processing was ok
   530     // if previous settings id processing was ok
   537     if (status == CSmlDmAdapter::EOk)
   531     if (status == CSmlDmAdapter::EOk)
   538         {
   532         {
   726                                          const TDesC8& /*aArgument*/, 
   720                                          const TDesC8& /*aArgument*/, 
   727                                          const TDesC8& /*aType*/, 
   721                                          const TDesC8& /*aType*/, 
   728                                          const TInt aStatusRef )
   722                                          const TInt aStatusRef )
   729     {
   723     {
   730     // Not supported 
   724     // Not supported 
   731     PRES_DM_LOG(LOG_LIT("ExecuteCommandL"));    
       
   732     Callback().SetStatusL( aStatusRef, CSmlDmAdapter::EError );
   725     Callback().SetStatusL( aStatusRef, CSmlDmAdapter::EError );
   733     }
   726     }
   734 
   727 
   735 // -----------------------------------------------------------------------------
   728 // -----------------------------------------------------------------------------
   736 // CPresenceDMAdapter::ExecuteCommandL()
   729 // CPresenceDMAdapter::ExecuteCommandL()
   741                                          RWriteStream*& /*aStream*/, 
   734                                          RWriteStream*& /*aStream*/, 
   742                                          const TDesC8& /*aType*/, 
   735                                          const TDesC8& /*aType*/, 
   743                                          const TInt aStatusRef )
   736                                          const TInt aStatusRef )
   744     {
   737     {
   745     // Not supported
   738     // Not supported
   746     PRES_DM_LOG(LOG_LIT("ExecuteCommandL"));
       
   747     Callback().SetStatusL( aStatusRef, CSmlDmAdapter::EError );
   739     Callback().SetStatusL( aStatusRef, CSmlDmAdapter::EError );
   748     }
   740     }
   749 
   741 
   750 // -----------------------------------------------------------------------------
   742 // -----------------------------------------------------------------------------
   751 // CPresenceDMAdapter::CopyCommandL()
   743 // CPresenceDMAdapter::CopyCommandL()
   757                                       const TDesC8& /*aSourceLUID*/, 
   749                                       const TDesC8& /*aSourceLUID*/, 
   758                                       const TDesC8& /*aType*/, 
   750                                       const TDesC8& /*aType*/, 
   759                                       TInt aStatusRef )
   751                                       TInt aStatusRef )
   760     {
   752     {
   761     // Not supported
   753     // Not supported
   762     PRES_DM_LOG(LOG_LIT("CopyCommandL"));    
       
   763     Callback().SetStatusL( aStatusRef, CSmlDmAdapter::EError );
   754     Callback().SetStatusL( aStatusRef, CSmlDmAdapter::EError );
   764     }
   755     }
   765 
   756 
   766 // -----------------------------------------------------------------------------
   757 // -----------------------------------------------------------------------------
   767 // CPresenceDMAdapter::StartAtomicL()
   758 // CPresenceDMAdapter::StartAtomicL()
   768 // -----------------------------------------------------------------------------
   759 // -----------------------------------------------------------------------------
   769 //
   760 //
   770 void CPresenceDMAdapter::StartAtomicL()
   761 void CPresenceDMAdapter::StartAtomicL()
   771     {
   762     {
   772     PRES_DM_LOG(LOG_LIT("StartAtomicL"));
       
   773     // Not supported
   763     // Not supported
   774     }
   764     }
   775 
   765 
   776 // -----------------------------------------------------------------------------
   766 // -----------------------------------------------------------------------------
   777 // CPresenceDMAdapter::CommitAtomicL()
   767 // CPresenceDMAdapter::CommitAtomicL()
   778 // -----------------------------------------------------------------------------
   768 // -----------------------------------------------------------------------------
   779 //
   769 //
   780 void CPresenceDMAdapter::CommitAtomicL()
   770 void CPresenceDMAdapter::CommitAtomicL()
   781     {
   771     {
   782     PRES_DM_LOG(LOG_LIT("CommitAtomicL"));
       
   783     // Not supported
   772     // Not supported
   784     }
   773     }
   785 
   774 
   786 // -----------------------------------------------------------------------------
   775 // -----------------------------------------------------------------------------
   787 // CPresenceDMAdapter::RollbackAtomicL()
   776 // CPresenceDMAdapter::RollbackAtomicL()
   788 // -----------------------------------------------------------------------------
   777 // -----------------------------------------------------------------------------
   789 //
   778 //
   790 void CPresenceDMAdapter::RollbackAtomicL()
   779 void CPresenceDMAdapter::RollbackAtomicL()
   791     {
   780     {
   792     PRES_DM_LOG(LOG_LIT("RollbackAtomicL"));
       
   793     // Not supported
   781     // Not supported
   794     }
   782     }
   795 
   783 
   796 // -----------------------------------------------------------------------------
   784 // -----------------------------------------------------------------------------
   797 // CPresenceDMAdapter::StreamingSupport()
   785 // CPresenceDMAdapter::StreamingSupport()
   798 // -----------------------------------------------------------------------------
   786 // -----------------------------------------------------------------------------
   799 //
   787 //
   800 TBool CPresenceDMAdapter::StreamingSupport( TInt& /*aItemSize*/ )
   788 TBool CPresenceDMAdapter::StreamingSupport( TInt& /*aItemSize*/ )
   801     {
   789     {
   802     PRES_DM_LOG(LOG_LIT("StreamingSupport"));    
       
   803     return EFalse;
   790     return EFalse;
   804     }
   791     }
   805 
   792 
   806 // -----------------------------------------------------------------------------
   793 // -----------------------------------------------------------------------------
   807 // CPresenceDMAdapter::StreamCommittedL()
   794 // CPresenceDMAdapter::StreamCommittedL()
   808 // -----------------------------------------------------------------------------
   795 // -----------------------------------------------------------------------------
   809 //
   796 //
   810 void CPresenceDMAdapter::StreamCommittedL()
   797 void CPresenceDMAdapter::StreamCommittedL()
   811     {
   798     {
   812     PRES_DM_LOG(LOG_LIT("StreamCommittedL"));    
       
   813     // Not supported
   799     // Not supported
   814     }
   800     }
   815     
   801     
   816 // -----------------------------------------------------------------------------
   802 // -----------------------------------------------------------------------------
   817 // CPresenceDMAdapter::CompleteOutstandingCmdsL()
   803 // CPresenceDMAdapter::CompleteOutstandingCmdsL()
   889         {
   875         {
   890         HBufC8* utfValue = ConvertLC( *value ); // << utfValue
   876         HBufC8* utfValue = ConvertLC( *value ); // << utfValue
   891         aObject.InsertL( 0, *utfValue );
   877         aObject.InsertL( 0, *utfValue );
   892         CleanupStack::PopAndDestroy(utfValue);  // >>> utfValue
   878         CleanupStack::PopAndDestroy(utfValue);  // >>> utfValue
   893         CleanupStack::PopAndDestroy(value);  // >>> value
   879         CleanupStack::PopAndDestroy(value);  // >>> value
   894         PRES_DM_LOG(LOG_LIT(" return( EOk )"));  
   880         PRES_DM_LOG(LOG_LIT(" return(%d)"),CSmlDmAdapter::EOk);  
   895         return CSmlDmAdapter::EOk;
   881         return CSmlDmAdapter::EOk;
   896         }
   882         }
   897     PRES_DM_LOG(LOG_LIT(" return( ENotFound )"));      
   883     PRES_DM_LOG(LOG_LIT(" return(%d)"),CSmlDmAdapter::ENotFound);      
   898     return CSmlDmAdapter::ENotFound;
   884     return CSmlDmAdapter::ENotFound;
   899     }
   885     }
   900     
   886     
   901 
   887 
   902 // -----------------------------------------------------------------------------
   888 // -----------------------------------------------------------------------------
  1068 // -----------------------------------------------------------------------------
  1054 // -----------------------------------------------------------------------------
  1069 //
  1055 //
  1070 CSmlDmAdapter::TError CPresenceDMAdapter::GetConRefFromSipIDL( TInt aSipID,
  1056 CSmlDmAdapter::TError CPresenceDMAdapter::GetConRefFromSipIDL( TInt aSipID,
  1071                                                       CBufBase& aObject)
  1057                                                       CBufBase& aObject)
  1072     {
  1058     {
  1073     PRES_DM_LOG(LOG_LIT(" GetConRefFromSipIDL(aSipId:%d)"),aSipID);
  1059     PRES_DM_LOG(LOG_LIT(" GetConRefFromSipIDL(%d)"),aSipID);
  1074 
  1060 
  1075     CSmlDmAdapter::TError status = CSmlDmAdapter::EOk;
  1061     CSmlDmAdapter::TError status = CSmlDmAdapter::EOk;
  1076     
  1062     
  1077     TBool found(EFalse);
  1063     TBool found(EFalse);
  1078     
  1064     
  1081         CBufBase* result = CBufFlat::NewL(1);
  1067         CBufBase* result = CBufFlat::NewL(1);
  1082         CleanupStack::PushL(result);    // << result
  1068         CleanupStack::PushL(result);    // << result
  1083         
  1069         
  1084         // Request all the sip settings identifiers 
  1070         // Request all the sip settings identifiers 
  1085         Callback().FetchLinkL( KPresDMSipDMNode, *result, status);
  1071         Callback().FetchLinkL( KPresDMSipDMNode, *result, status);
  1086         PRES_DM_LOG(LOG_LIT("   FetchLinkL(SIP) status : %d"), status );
       
  1087         
  1072         
  1088         if( status == EOk )
  1073         if( status == EOk )
  1089             {
  1074             {
  1090             TPtr8 uriSeg8Ptr = result->Ptr(0);
  1075             TPtr8 uriSeg8Ptr = result->Ptr(0);
  1091             
  1076             
  1092             HBufC8* uriSegBuffer = uriSeg8Ptr.AllocLC(); // << uriSegBuffer
  1077             HBufC8* uriSegBuffer = uriSeg8Ptr.AllocLC();
  1093             PRES_DM_LOG(LOG_LIT8("   uri : '%S'"), uriSegBuffer );
       
  1094             
  1078             
  1095             TPtr8 uriSegBufferPtr = uriSegBuffer->Des();
  1079             TPtr8 uriSegBufferPtr = uriSegBuffer->Des();
  1096             
  1080             
  1097             TInt numOfUriSegs = NSmlDmURI::NumOfURISegs(uriSeg8Ptr);
  1081             TInt numOfUriSegs = NSmlDmURI::NumOfURISegs(uriSeg8Ptr);
  1098             
  1082             
  1101             TInt foundId(KErrNotFound);
  1085             TInt foundId(KErrNotFound);
  1102             
  1086             
  1103                      
  1087                      
  1104             // Check if given SIP set id match with any of found
  1088             // Check if given SIP set id match with any of found
  1105             // SIP settings identifiers
  1089             // SIP settings identifiers
  1106             while( numOfUriSegs > 0 )
  1090             while( numOfUriSegs > 1)
  1107                 {
  1091                 {
  1108                 idLinkBuffer = NSmlDmURI::LastURISeg(uriSegBufferPtr);
  1092                 idLinkBuffer = NSmlDmURI::LastURISeg(uriSegBufferPtr);
  1109                 uriSegBufferPtr = NSmlDmURI::RemoveLastSeg(uriSegBufferPtr);
  1093                 uriSegBufferPtr = NSmlDmURI::RemoveLastSeg(uriSegBufferPtr);
  1110                 
  1094                 
  1111                 idLinkBuffer.Insert(0, KPresDMSipDMNode);
  1095                 idLinkBuffer.Insert(0, KPresDMSipDMNode);
  1116                 TPtrC8 finalLink = idLinkBuffer;
  1100                 TPtrC8 finalLink = idLinkBuffer;
  1117                         
  1101                         
  1118                 //Reqest the ID
  1102                 //Reqest the ID
  1119                 result->Reset();
  1103                 result->Reset();
  1120                 Callback().FetchLinkL( finalLink, *result, status);
  1104                 Callback().FetchLinkL( finalLink, *result, status);
  1121                 PRES_DM_LOG(LOG_LIT8("   FetchLinkL(%S) status : %d"), &idLinkBuffer, status );                        
  1105                         
  1122                 if( status == EOk )
  1106                 foundId = DesToInt(result->Ptr(0));
       
  1107                         
       
  1108                 if (foundId == aSipID)
  1123                     {
  1109                     {
  1124                     foundId = DesToInt(result->Ptr(0));
  1110                     found = ETrue;
  1125                     PRES_DM_LOG(LOG_LIT("   foundId : %d"), foundId );                        
  1111                     aObject.InsertL(0, NSmlDmURI::RemoveLastSeg(finalLink));
  1126                     if (foundId == aSipID)
       
  1127                         {
       
  1128                         found = ETrue;
       
  1129                         aObject.InsertL(0, NSmlDmURI::RemoveLastSeg(finalLink));
       
  1130                         break;
  1112                         break;
  1131                         }
  1113                         }
  1132                     }
       
  1133                 
  1114                 
  1134                 numOfUriSegs--;  
  1115                 numOfUriSegs -= 1;  
  1135                 }
  1116                 }
  1136             CleanupStack::PopAndDestroy( uriSegBuffer );    // >>> uriSegBuffer
  1117             CleanupStack::PopAndDestroy( uriSegBuffer );    // >>> uriSegBuffer
  1137             }
  1118             }
  1138         
  1119         
  1139         CleanupStack::PopAndDestroy( result );    // >>> result
  1120         CleanupStack::PopAndDestroy( result );    // >>> result
  1154 // -----------------------------------------------------------------------------
  1135 // -----------------------------------------------------------------------------
  1155 //
  1136 //
  1156 CSmlDmAdapter::TError CPresenceDMAdapter::GetConRefFromXdmIDL( TInt aXdmID,
  1137 CSmlDmAdapter::TError CPresenceDMAdapter::GetConRefFromXdmIDL( TInt aXdmID,
  1157                                                       CBufBase& aObject)
  1138                                                       CBufBase& aObject)
  1158     {
  1139     {
  1159     PRES_DM_LOG(LOG_LIT(" GetConRefFromXdmIDL(aXdmId:%d)"),aXdmID);
  1140     PRES_DM_LOG(LOG_LIT(" GetConRefFromXdmIDL(%d)"),aXdmID);
  1160 
  1141 
  1161     CSmlDmAdapter::TError status = CSmlDmAdapter::ENotFound;
  1142     CSmlDmAdapter::TError status = CSmlDmAdapter::ENotFound;
  1162     
  1143     
  1163     if( aXdmID != KErrNotFound )
  1144     if( aXdmID != KErrNotFound )
  1164         {
  1145         {
  1165         CBufBase* result = CBufFlat::NewL(1);
  1146         CBufBase* result = CBufFlat::NewL(1);
  1166         CleanupStack::PushL(result);    // << result
  1147         CleanupStack::PushL(result);    // << result
  1167         
  1148         
  1168         // Request all the XDM settings identifiers 
  1149         // Request all the XDM settings identifiers 
  1169         Callback().FetchLinkL( KPresDMXdmDMNode, *result, status);
  1150         Callback().FetchLinkL( KPresDMXdmDMNode, *result, status);
  1170         PRES_DM_LOG(LOG_LIT("   FetchLinkL(XDM) status : %d"), status );
       
  1171         TInt id(KErrNotFound);
  1151         TInt id(KErrNotFound);
  1172         
  1152         
  1173         TPtrC8 lastUriSegXdm;
  1153         TPtrC8 lastUriSegXdm;
  1174         
  1154         
  1175         if( status == EOk )
  1155         if( status == EOk )
  1229 TBool CPresenceDMAdapter::IsPresIDValidL(TInt aSetId)
  1209 TBool CPresenceDMAdapter::IsPresIDValidL(TInt aSetId)
  1230     {
  1210     {
  1231     TPresSettingsSet tempSet;
  1211     TPresSettingsSet tempSet;
  1232     if ((PresSettingsApi::SettingsSetL(aSetId,tempSet)) == KErrNone)
  1212     if ((PresSettingsApi::SettingsSetL(aSetId,tempSet)) == KErrNone)
  1233         return ETrue;
  1213         return ETrue;
  1234     PRES_DM_LOG(LOG_LIT8(" IsPresIDValidL - Invalid settings : %d"), aSetId );
       
  1235     return EFalse;   
  1214     return EFalse;   
  1236     }
  1215     }
  1237     
  1216     
  1238 // -----------------------------------------------------------------------------
  1217 // -----------------------------------------------------------------------------
  1239 // CPresenceDMAdapter::GetSipIdFromConRefL
  1218 // CPresenceDMAdapter::GetSipIdFromConRefL
  1267     //resultBuf.Zero();
  1246     //resultBuf.Zero();
  1268     //result->Read(0, resultBuf,result->Size());
  1247     //result->Read(0, resultBuf,result->Size());
  1269         
  1248         
  1270     if( status == EOk )
  1249     if( status == EOk )
  1271         {
  1250         {
  1272         TUint32 id = DesToInt( result->Ptr( 0 ) );
  1251         TUint32 id(NULL);
       
  1252         id = DesToInt( result->Ptr( 0 ) );
  1273         returnId = (TInt)id;       
  1253         returnId = (TInt)id;       
  1274         }
  1254         }
  1275     CleanupStack::PopAndDestroy( result );   // >>> result   
  1255     CleanupStack::PopAndDestroy( result );   // >>> result   
  1276     
  1256     
  1277     PRES_DM_LOG(LOG_LIT("   status(%d), returnId(%d): end"), status, returnId);
  1257     PRES_DM_LOG(LOG_LIT("   status(%d), returnId(%d): end"), status, returnId);