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