22 #include <SyncMLNotifier.h> |
22 #include <SyncMLNotifier.h> |
23 #include <nsmlconstants.h> |
23 #include <nsmlconstants.h> |
24 #include <nsmldebug.h> |
24 #include <nsmldebug.h> |
25 #include <nsmlphoneinfo.h> |
25 #include <nsmlphoneinfo.h> |
26 #include <nsmlunicodeconverter.h> |
26 #include <nsmlunicodeconverter.h> |
|
27 #include <centralrepository.h> |
27 // common includes with DM |
28 // common includes with DM |
28 #include "nsmlcliagconstants.h" |
29 #include "nsmlcliagconstants.h" |
29 #include "NSmlCmdsBase.h" |
30 #include "NSmlCmdsBase.h" |
30 #include "NSmlAgentBase.h" |
31 #include "NSmlAgentBase.h" |
31 #include "NSmlStatusContainer.h" |
32 #include "NSmlStatusContainer.h" |
48 #include "nsmldserror.h" |
49 #include "nsmldserror.h" |
49 #include "nsmlfilter.h" |
50 #include "nsmlfilter.h" |
50 #include "nsmldssettings.h" |
51 #include "nsmldssettings.h" |
51 #include "nsmldsbatchbuffer.h" |
52 #include "nsmldsbatchbuffer.h" |
52 #include "nsmldshostclient.h" |
53 #include "nsmldshostclient.h" |
53 |
54 #include "nsmloperatordefines.h" |
54 |
55 |
55 #ifndef __WINS__ |
56 #ifndef __WINS__ |
56 // This lowers the unnecessary compiler warning (armv5) to remark. |
57 // This lowers the unnecessary compiler warning (armv5) to remark. |
57 // "Warning: #174-D: expression has no effect..." is caused by |
58 // "Warning: #174-D: expression has no effect..." is caused by |
58 // DBG_ARGS8 macro in no-debug builds. |
59 // DBG_ARGS8 macro in no-debug builds. |
4648 aNumericUid = KNullDataItemId; |
4654 aNumericUid = KNullDataItemId; |
4649 |
4655 |
4650 return lexer.Val( aNumericUid ); |
4656 return lexer.Val( aNumericUid ); |
4651 } |
4657 } |
4652 |
4658 |
|
4659 // ----------------------------------------------------------------------------- |
|
4660 // CNSmlDSCmds::InsertOperatorExtensionDevInfFieldsL |
|
4661 // Adds operator specific extension DevInf fields <XNam> and <XVal> |
|
4662 // Currently only one <XNam> and one corresponding <XVal> field is supported |
|
4663 // ----------------------------------------------------------------------------- |
|
4664 // |
|
4665 void CNSmlDSCmds::InsertOperatorExtensionDevInfFieldsL(SmlDevInfDevInfPtr_t& aDevInf) |
|
4666 { |
|
4667 TInt error = KErrNotFound; |
|
4668 CRepository *operatorSettingsCenrep = NULL; |
|
4669 |
|
4670 // TRAP the creation of operator cenrep handle, because we don't want to |
|
4671 // leave if the cenrep is not present |
|
4672 TRAP( error, operatorSettingsCenrep = CRepository::NewL( KNsmlOperatorCenrepUID )); |
|
4673 if( error != KErrNone ) |
|
4674 { |
|
4675 // operator cenrep not found |
|
4676 return; |
|
4677 } |
|
4678 else |
|
4679 { |
|
4680 CleanupStack::PushL( operatorSettingsCenrep ); |
|
4681 |
|
4682 // get the server id from the current profile |
|
4683 TInt profileId( iAgent->ProfileId() ); |
|
4684 CNSmlDSSettings* dsSettings = CNSmlDSSettings::NewLC(); |
|
4685 CNSmlDSProfile* profile = NULL; |
|
4686 TRAP( error, profile = dsSettings->ProfileL( profileId ) ); |
|
4687 |
|
4688 if( error != KErrNone || !profile ) |
|
4689 { |
|
4690 // if there was an error in reading profile from the profile ID |
|
4691 // return do not proceed to change the DevInf |
|
4692 CleanupStack::PopAndDestroy( dsSettings ); |
|
4693 CleanupStack::PopAndDestroy( operatorSettingsCenrep ); |
|
4694 return; |
|
4695 } |
|
4696 |
|
4697 HBufC* buffSerVerId = HBufC::NewLC( KMaxLength ); |
|
4698 TPtr ptrCurrentServerId = buffSerVerId->Des(); |
|
4699 ptrCurrentServerId.Copy( profile->StrValue( EDSProfileServerId ) ); |
|
4700 |
|
4701 // get the server id from operator cenrep |
|
4702 HBufC* buffCenrepServerId = HBufC::NewLC( KMaxLength ); |
|
4703 TPtr ptrCenrepServerId = buffCenrepServerId->Des(); |
|
4704 error = operatorSettingsCenrep->Get( KNsmlOperatorProfileServerId, ptrCenrepServerId); |
|
4705 |
|
4706 // if serverID read from operator cenrep and current profile match only then attempt to |
|
4707 // add devInf extension fields |
|
4708 if( error == KErrNone && ptrCenrepServerId.Compare( ptrCurrentServerId ) == 0 ) |
|
4709 { |
|
4710 // create 16-bit buffers to read XNam and XVal field values from cenrep |
|
4711 HBufC* buffXNamField = HBufC::NewLC( KMaxLength ); |
|
4712 HBufC* buffXValField = HBufC::NewLC( KMaxLength ); |
|
4713 TPtr xNamField = buffXNamField->Des(); |
|
4714 TPtr xValField = buffXValField->Des(); |
|
4715 |
|
4716 TInt keyErrorXNam = operatorSettingsCenrep->Get( KNsmlOperatorDevInfExtXNam, xNamField ); |
|
4717 TInt keyErrorXVal = operatorSettingsCenrep->Get( KNsmlOperatorDevInfExtXVal, xValField ); |
|
4718 |
|
4719 if( keyErrorXNam == KErrNone && keyErrorXVal == KErrNone && |
|
4720 xNamField.Length() > 0 && xValField.Length() > 0 ) |
|
4721 { |
|
4722 // create 8-bit buffers of exact necessary length |
|
4723 // to write extn. fields in dev-inf |
|
4724 HBufC8* buffXNam = HBufC8::NewLC( xNamField.Length() ); |
|
4725 HBufC8* buffXVal = HBufC8::NewLC( xValField.Length() ); |
|
4726 |
|
4727 TPtr8 xnam = buffXNam->Des(); |
|
4728 TPtr8 xval = buffXVal->Des(); |
|
4729 |
|
4730 // copy extn fields from 16-bit desc. to 8-bit desc. |
|
4731 xnam.Copy( xNamField ); |
|
4732 xval.Copy( xValField ); |
|
4733 |
|
4734 SmlPcdataPtr_t XNamData; |
|
4735 PcdataNewL( XNamData, xnam ); |
|
4736 |
|
4737 SmlPcdataPtr_t XValData; |
|
4738 PcdataNewL( XValData, xval ); |
|
4739 |
|
4740 SmlPcdataListPtr_t listPtr = new (ELeave) SmlPcdataList_t; |
|
4741 listPtr->data = XValData; |
|
4742 listPtr->next = NULL; |
|
4743 |
|
4744 SmlDevInfExtPtr_t extElementPtr = new (ELeave) SmlDevInfExt_t; |
|
4745 extElementPtr->xnam = XNamData; |
|
4746 extElementPtr->xval = listPtr; |
|
4747 |
|
4748 SmlDevInfExtListPtr_t extListPtr = new (ELeave) SmlDevInfExtList_t; |
|
4749 extListPtr->data = extElementPtr; |
|
4750 extListPtr->next = NULL; |
|
4751 |
|
4752 aDevInf->ext = extListPtr; |
|
4753 |
|
4754 CleanupStack::PopAndDestroy( buffXVal ); |
|
4755 CleanupStack::PopAndDestroy( buffXNam ); |
|
4756 } |
|
4757 CleanupStack::PopAndDestroy( buffXValField ); |
|
4758 CleanupStack::PopAndDestroy( buffXNamField ); |
|
4759 } |
|
4760 |
|
4761 CleanupStack::PopAndDestroy( buffCenrepServerId ); |
|
4762 CleanupStack::PopAndDestroy( buffSerVerId ); |
|
4763 CleanupStack::PopAndDestroy( dsSettings ); |
|
4764 CleanupStack::PopAndDestroy( operatorSettingsCenrep ); |
|
4765 } |
|
4766 } |
|
4767 |
4653 // End of File |
4768 // End of File |