552 } |
516 } |
553 CleanupStack::PopAndDestroy(); // policyData |
517 CleanupStack::PopAndDestroy(); // policyData |
554 |
518 |
555 aMessage.Complete(KErrNone); |
519 aMessage.Complete(KErrNone); |
556 } |
520 } |
557 |
|
558 void CVpnApiServant::CreateProvisionServerL( const RMessage2& aMessage ) |
|
559 { |
|
560 TAgileProvisionApiServerSettings* serverCreate = new (ELeave) TAgileProvisionApiServerSettings(); |
|
561 CleanupStack::PushL(serverCreate); |
|
562 TPckg<TAgileProvisionApiServerSettings> pckgServerCreate(*serverCreate); |
|
563 aMessage.ReadL(0, pckgServerCreate); |
|
564 TAgileProvisionServerLocals* serverAccountLocalData = new (ELeave) TAgileProvisionServerLocals(); |
|
565 CleanupStack::PushL(serverAccountLocalData); |
|
566 serverAccountLocalData->iSelection = serverCreate->iSelection; |
|
567 serverAccountLocalData->iServerAddress.Copy(serverCreate->iServerUrl); |
|
568 serverAccountLocalData->iServerNameLocal.Copy(serverCreate->iServerNameLocal); |
|
569 |
|
570 TFileName serverFilePath; |
|
571 User::LeaveIfError(iFs.PrivatePath(serverFilePath)); |
|
572 serverFilePath.Append(KProvisionServerSettings); |
|
573 |
|
574 /* Check if file allready exists and copy policy and vpn iap id to a new file */ |
|
575 TFileName policyFileName; |
|
576 TUint32 agileProvisionAPId=0; |
|
577 |
|
578 HBufC* serverUrlBuf=NULL; |
|
579 |
|
580 HBufC* serverNameBuf=NULL; |
|
581 |
|
582 TBuf<KMaxIapLength> iapIdBuf; |
|
583 |
|
584 TBool serverFileExist=EFalse; |
|
585 |
|
586 if ( iFileUtil.FileExists(serverFilePath) ) |
|
587 { |
|
588 RFile serverFile; |
|
589 User::LeaveIfError(serverFile.Open(iFs,serverFilePath, EFileRead)); |
|
590 |
|
591 |
|
592 TFileText tx; |
|
593 tx.Set(serverFile); |
|
594 |
|
595 TInt fileSize; |
|
596 User::LeaveIfError(serverFile.Size(fileSize)); |
|
597 |
|
598 serverUrlBuf = HBufC::NewLC(fileSize); |
|
599 |
|
600 TPtr serverUrlPtr=serverUrlBuf->Des(); |
|
601 |
|
602 User::LeaveIfError(tx.Read(serverUrlPtr)); |
|
603 |
|
604 serverNameBuf = HBufC::NewLC(fileSize); |
|
605 TPtr serverNamePtr=serverNameBuf->Des(); |
|
606 |
|
607 User::LeaveIfError(tx.Read(serverNamePtr)); |
|
608 |
|
609 TBuf<KMaxIapLength> iapIdData; |
|
610 User::LeaveIfError(tx.Read(iapIdData)); |
|
611 |
|
612 TBuf<KMaxIapLength> iapModeData; |
|
613 User::LeaveIfError(tx.Read(iapModeData)); |
|
614 |
|
615 HBufC* policyFileNameBuf = HBufC::NewLC(fileSize); |
|
616 TPtr policyFileNamePtr = policyFileNameBuf->Des(); |
|
617 |
|
618 if ( tx.Read(policyFileNamePtr) == KErrNone ) |
|
619 { |
|
620 tx.Read(iapIdBuf); |
|
621 |
|
622 TLex iapIdConverter(iapIdBuf); |
|
623 iapIdConverter.Val(agileProvisionAPId,EDecimal); |
|
624 policyFileName = *policyFileNameBuf; |
|
625 } |
|
626 CleanupStack::PopAndDestroy(policyFileNameBuf); |
|
627 serverFile.Close(); |
|
628 serverFileExist = ETrue; |
|
629 } |
|
630 /* end of saving old values */ |
|
631 |
|
632 //IAP data Max value 255 |
|
633 TBuf<KMaxIapLength> iapIdStr; |
|
634 TBuf<KMaxIapLength> iapModeStr; |
|
635 TBuf<KMaxIapLength> iapAgileIdStr; |
|
636 |
|
637 iapIdStr.Num(serverAccountLocalData->iSelection.iId); |
|
638 iapModeStr.Num(serverAccountLocalData->iSelection.iResult); |
|
639 HBufC* serverSettingsDataBuf; |
|
640 _LIT(KCRLF, "\n"); |
|
641 if ( agileProvisionAPId >0 ) |
|
642 { |
|
643 |
|
644 serverSettingsDataBuf = HBufC::NewL(serverAccountLocalData->iServerNameLocal.Length() + serverAccountLocalData->iServerAddress.Length() + |
|
645 iapIdStr.Length() + iapModeStr.Length() + policyFileName.Length() + iapIdBuf.Length() + 5*(KCRLF().Length()) ); |
|
646 } |
|
647 else |
|
648 { |
|
649 serverSettingsDataBuf = HBufC::NewL(serverAccountLocalData->iServerNameLocal.Length() + serverAccountLocalData->iServerAddress.Length() + |
|
650 iapIdStr.Length() + iapModeStr.Length() + 3*(KCRLF().Length()) ); |
|
651 } |
|
652 CleanupStack::PushL(serverSettingsDataBuf); |
|
653 TPtr tPtr(serverSettingsDataBuf->Des()); |
|
654 tPtr.Copy(serverAccountLocalData->iServerAddress); |
|
655 |
|
656 tPtr.Append(KCRLF); |
|
657 tPtr.Append(serverAccountLocalData->iServerNameLocal); |
|
658 tPtr.Append(KCRLF); |
|
659 tPtr.Append(iapIdStr); |
|
660 tPtr.Append(KCRLF); |
|
661 tPtr.Append(iapModeStr); |
|
662 if ( agileProvisionAPId >0 ) |
|
663 { |
|
664 tPtr.Append(KCRLF); |
|
665 tPtr.Append(policyFileName); |
|
666 tPtr.Append(KCRLF); |
|
667 tPtr.Append(iapIdBuf); |
|
668 } |
|
669 |
|
670 RFile file; |
|
671 CleanupClosePushL(file); |
|
672 |
|
673 User::LeaveIfError(file.Replace(iFs, serverFilePath, EFileWrite)); |
|
674 |
|
675 TPtrC8 ptr8 ( (TUint8*) tPtr.Ptr(), tPtr.Size() ); |
|
676 file.Write ( ptr8 ); |
|
677 file.Close(); |
|
678 CleanupStack::PopAndDestroy(1); //file |
|
679 CleanupStack::PopAndDestroy(serverSettingsDataBuf); |
|
680 |
|
681 if ( serverFileExist != EFalse ) |
|
682 { |
|
683 CleanupStack::PopAndDestroy(serverNameBuf); |
|
684 CleanupStack::PopAndDestroy(serverUrlBuf); |
|
685 } |
|
686 |
|
687 CleanupStack::PopAndDestroy(serverAccountLocalData); |
|
688 CleanupStack::PopAndDestroy(serverCreate); |
|
689 |
|
690 aMessage.Complete(KErrNone); |
|
691 } |
|
692 |
|
693 void CVpnApiServant::ListProvisionServerL( const RMessage2& aMessage ) |
|
694 { |
|
695 |
|
696 TAgileProvisionApiServerListElem* serverList = new (ELeave) TAgileProvisionApiServerListElem(); |
|
697 CleanupStack::PushL(serverList); |
|
698 TPckg<TAgileProvisionApiServerListElem> serverPckg(*serverList); |
|
699 |
|
700 TFileName serverFilePath; |
|
701 User::LeaveIfError(iFs.PrivatePath(serverFilePath)); |
|
702 serverFilePath.Append(KProvisionServerSettings); |
|
703 |
|
704 if ( iFileUtil.FileExists(serverFilePath) ) |
|
705 { |
|
706 |
|
707 RFile serverFile; |
|
708 User::LeaveIfError(serverFile.Open(iFs,serverFilePath, EFileRead)); |
|
709 |
|
710 |
|
711 TFileText tx; |
|
712 tx.Set(serverFile); |
|
713 |
|
714 TInt fileSize; |
|
715 User::LeaveIfError(serverFile.Size(fileSize)); |
|
716 |
|
717 HBufC* serverUrlBuf = HBufC::NewLC(fileSize); |
|
718 |
|
719 TPtr serverUrlPtr=serverUrlBuf->Des(); |
|
720 |
|
721 User::LeaveIfError(tx.Read(serverUrlPtr)); |
|
722 |
|
723 HBufC8* serverUrl=iFileUtil.To8BitL(serverUrlPtr); |
|
724 serverList->iServerUrl=*serverUrl; |
|
725 |
|
726 delete serverUrl; |
|
727 serverUrl=NULL; |
|
728 |
|
729 CleanupStack::PopAndDestroy(serverUrlBuf); |
|
730 |
|
731 HBufC* serverNameBuf = HBufC::NewLC(fileSize); |
|
732 TPtr serverNamePtr=serverNameBuf->Des(); |
|
733 |
|
734 User::LeaveIfError(tx.Read(serverNamePtr)); |
|
735 |
|
736 serverList->iServerNameLocal=serverNamePtr; |
|
737 |
|
738 CleanupStack::PopAndDestroy(serverNameBuf); |
|
739 |
|
740 serverFile.Close(); |
|
741 } |
|
742 |
|
743 aMessage.WriteL(0, serverPckg); |
|
744 |
|
745 CleanupStack::PopAndDestroy(serverList); |
|
746 aMessage.Complete(KErrNone); |
|
747 } |
|
748 |
|
749 void CVpnApiServant::GetProvisionServerDetailsL( const RMessage2& aMessage ) |
|
750 { |
|
751 |
|
752 TAgileProvisionApiServerSettings* serverList = new (ELeave) TAgileProvisionApiServerSettings(); |
|
753 CleanupStack::PushL(serverList); |
|
754 TPckg<TAgileProvisionApiServerSettings> serverPckg(*serverList); |
|
755 |
|
756 TFileName serverFilePath; |
|
757 User::LeaveIfError(iFs.PrivatePath(serverFilePath)); |
|
758 serverFilePath.Append(KProvisionServerSettings); |
|
759 |
|
760 if ( iFileUtil.FileExists(serverFilePath) ) |
|
761 { |
|
762 RFile serverFile; |
|
763 User::LeaveIfError(serverFile.Open(iFs,serverFilePath, EFileRead)); |
|
764 |
|
765 TFileText tx; |
|
766 tx.Set(serverFile); |
|
767 |
|
768 TInt fileSize; |
|
769 User::LeaveIfError(serverFile.Size(fileSize)); |
|
770 |
|
771 HBufC* serverUrlBuf = HBufC::NewLC(fileSize); |
|
772 |
|
773 TPtr serverUrlPtr=serverUrlBuf->Des(); |
|
774 |
|
775 User::LeaveIfError(tx.Read(serverUrlPtr)); |
|
776 |
|
777 HBufC8* serverUrl=iFileUtil.To8BitL(serverUrlPtr); |
|
778 serverList->iServerUrl=*serverUrl; |
|
779 |
|
780 delete serverUrl; |
|
781 serverUrl=NULL; |
|
782 |
|
783 CleanupStack::PopAndDestroy(serverUrlBuf); |
|
784 |
|
785 HBufC* serverNameBuf = HBufC::NewLC(fileSize); |
|
786 TPtr serverNamePtr=serverNameBuf->Des(); |
|
787 |
|
788 User::LeaveIfError(tx.Read(serverNamePtr)); |
|
789 |
|
790 serverList->iServerNameLocal=serverNamePtr; |
|
791 |
|
792 CleanupStack::PopAndDestroy(serverNameBuf); |
|
793 |
|
794 TBuf<KMaxIapLength> iapIdData; |
|
795 User::LeaveIfError(tx.Read(iapIdData)); |
|
796 |
|
797 TLex iapIdConverter(iapIdData); |
|
798 TUint idInt; |
|
799 iapIdConverter.Val(idInt); |
|
800 serverList->iSelection.iId = idInt; |
|
801 |
|
802 TBuf<KMaxIapLength> iapModeData; |
|
803 User::LeaveIfError(tx.Read(iapModeData)); |
|
804 |
|
805 TLex iapModeConverter = iapModeData; |
|
806 iapModeConverter.Val(idInt); |
|
807 |
|
808 CMManager::TCmSettingSelectionMode selectionMode = (CMManager::TCmSettingSelectionMode) idInt; |
|
809 serverList->iSelection.iResult = selectionMode; |
|
810 |
|
811 serverFile.Close(); |
|
812 } |
|
813 aMessage.WriteL(0, serverPckg); |
|
814 |
|
815 CleanupStack::PopAndDestroy(serverList); |
|
816 |
|
817 aMessage.Complete(KErrNone); |
|
818 } |
|
819 |
|
820 void CVpnApiServant::SynchronizeVPNPolicyServerL( const RMessage2& aMessage ) |
|
821 { |
|
822 iPolicyImporter = CPolicyImporter::NewL(aMessage, *this, *iPolicyStore, iFs); |
|
823 |
|
824 //Asynchronous call |
|
825 iPolicyImporter->SynchronizeVpnPolicyServerL(); |
|
826 } |
|
827 |
|
828 void CVpnApiServant::DeleteVPNPolicyServerL( const RMessage2& aMessage ) |
|
829 { |
|
830 TFileName serverFilePath; |
|
831 User::LeaveIfError(iFs.PrivatePath(serverFilePath)); |
|
832 serverFilePath.Append(KProvisionServerSettings); |
|
833 iFileUtil.DeleteFileL(serverFilePath); |
|
834 aMessage.Complete(KErrNone); |
|
835 } |
|
836 |
|
837 void CVpnApiServant::CancelSynchronize( const RMessage2& aMessage ) |
|
838 { |
|
839 if (iPolicyImporter) |
|
840 { |
|
841 if ( iPolicyImporter->iAgileProvisionWs != NULL ) |
|
842 { |
|
843 CAgileProvisionWs* ws = iPolicyImporter->iAgileProvisionWs; |
|
844 ws->CancelGetPolicy(); |
|
845 } |
|
846 iPolicyImporter->Cancel(); |
|
847 delete iPolicyImporter; |
|
848 iPolicyImporter = NULL; |
|
849 } |
|
850 aMessage.Complete(KErrCancel); |
|
851 } |
|
852 |
|
853 void CVpnApiServant::GetVPNPolicyNameL( const RMessage2& aMessage ) |
|
854 { |
|
855 TAgileProvisionPolicy* policy = new (ELeave) TAgileProvisionPolicy(); |
|
856 CleanupStack::PushL(policy); |
|
857 TPckg<TAgileProvisionPolicy> serverPckg(*policy); |
|
858 |
|
859 TFileName serverFilePath; |
|
860 User::LeaveIfError(iFs.PrivatePath(serverFilePath)); |
|
861 serverFilePath.Append(KProvisionServerSettings); |
|
862 |
|
863 if ( iFileUtil.FileExists(serverFilePath) ) |
|
864 { |
|
865 RFile serverFile; |
|
866 User::LeaveIfError(serverFile.Open(iFs,serverFilePath, EFileRead)); |
|
867 |
|
868 TFileText tx; |
|
869 tx.Set(serverFile); |
|
870 |
|
871 TInt fileSize; |
|
872 User::LeaveIfError(serverFile.Size(fileSize)); |
|
873 |
|
874 HBufC* serverUrlBuf = HBufC::NewLC(fileSize); |
|
875 |
|
876 TPtr serverUrlPtr=serverUrlBuf->Des(); |
|
877 |
|
878 User::LeaveIfError(tx.Read(serverUrlPtr)); |
|
879 |
|
880 HBufC* serverNameBuf = HBufC::NewLC(fileSize); |
|
881 TPtr serverNamePtr=serverNameBuf->Des(); |
|
882 |
|
883 User::LeaveIfError(tx.Read(serverNamePtr)); |
|
884 |
|
885 TBuf<KMaxIapLength> iapIdData; |
|
886 User::LeaveIfError(tx.Read(iapIdData)); |
|
887 |
|
888 TBuf<KMaxIapLength> iapModeData; |
|
889 User::LeaveIfError(tx.Read(iapModeData)); |
|
890 |
|
891 TBuf<KMaxIapLength> iapIdBuf; |
|
892 |
|
893 HBufC* policyFileNameBuf = HBufC::NewLC(fileSize); |
|
894 TPtr policyFileNamePtr = policyFileNameBuf->Des(); |
|
895 |
|
896 User::LeaveIfError(tx.Read(policyFileNamePtr)); |
|
897 policy->iPolicyName = policyFileNamePtr; |
|
898 CleanupStack::PopAndDestroy(policyFileNameBuf); |
|
899 serverFile.Close(); |
|
900 |
|
901 CleanupStack::PopAndDestroy(serverNameBuf); |
|
902 CleanupStack::PopAndDestroy(serverUrlBuf); |
|
903 } |
|
904 |
|
905 aMessage.WriteL(0, serverPckg); |
|
906 |
|
907 CleanupStack::PopAndDestroy(policy); |
|
908 |
|
909 aMessage.Complete(KErrNone); |
|
910 } |
|