16 */ |
16 */ |
17 |
17 |
18 |
18 |
19 #include <s32mem.h> // For RMemReadStream |
19 #include <s32mem.h> // For RMemReadStream |
20 #include <utf.h> |
20 #include <utf.h> |
|
21 #include <Etel3rdParty.h> |
|
22 #include <f32file.h> |
21 |
23 |
22 #include "sconpcconnclientserver.h" |
24 #include "sconpcconnclientserver.h" |
23 #include "sconpcconnserver.h" |
25 #include "sconpcconnserver.h" |
24 #include "sconpcd.h" |
26 #include "sconpcd.h" |
25 #include "sconcsc.h" |
27 #include "sconcsc.h" |
26 #include "sconconmlhandler.h" |
28 #include "sconconmlhandler.h" |
|
29 #include "sconimsireader.h" |
|
30 #include "sconoviaccounthandler.h" |
|
31 #include "sconfolderlister.h" |
|
32 #include "sconbtengine.h" |
27 #include "debug.h" |
33 #include "debug.h" |
28 |
34 |
29 #ifdef DEBUG_XML |
35 #ifdef DEBUG_XML |
30 #include <s32file.h> |
36 #include <s32file.h> |
31 _LIT8( KTimeFormat, "%02d:%02d:%02d.%03d" ); |
37 _LIT8( KTimeFormat, "%02d:%02d:%02d.%03d" ); |
32 _LIT8( KXmlBegin, "\nXML:\n" ); |
38 _LIT8( KXmlBegin, "\nXML:\n" ); |
33 #endif |
39 #endif |
34 |
40 |
35 _LIT( KSCONGetMetadataRequest, "METADATA:" ); |
41 _LIT( KSCONGetMetadataRequest, "METADATA:" ); |
|
42 _LIT8( KSCONSyncRequest, "SYNC:" ); |
|
43 _LIT( KSCONReadImsi, "READIMSI"); |
|
44 _LIT( KSCONReadNetworkInfo, "READNETWORKINFO"); |
|
45 _LIT( KSCONReadOviAccount, "READOVIACCOUNT"); |
|
46 _LIT( KSCONListPath, "LISTP:"); |
|
47 _LIT( KSCONReadBtInfo, "READBTINFO" ); |
|
48 _LIT( KSCONSetBtPower, "SETBTPOWER:" ); |
|
49 _LIT( KSCONSetBtName, "SETBTNAME:" ); |
|
50 _LIT( KSCONSetBtAuthorized, "SETBTAUTHORIZED:" ); |
36 |
51 |
37 //------------------------------------------------------------ |
52 //------------------------------------------------------------ |
38 // Global functions |
53 // Global functions |
39 //------------------------------------------------------------ |
54 //------------------------------------------------------------ |
40 |
55 |
505 TRAP_IGNORE( fws.CommitL() ); |
526 TRAP_IGNORE( fws.CommitL() ); |
506 fws.Close(); |
527 fws.Close(); |
507 |
528 |
508 CleanupStack::PopAndDestroy( &fws ); |
529 CleanupStack::PopAndDestroy( &fws ); |
509 } |
530 } |
510 file.Close(); |
531 file.Close(); |
511 CleanupStack::PopAndDestroy( &fs ); |
|
512 #endif |
532 #endif |
513 |
533 if ( ( ( typePtr.CompareC( KSConPCDWBXMLObjectType)== KErrNone ) || |
514 if ( ( typePtr.Compare( KSConPCDWBXMLObjectType ) == KErrNone) || |
534 ( typePtr.CompareC( KSConPCDWBXMLObjectType2 )== KErrNone ) ) |
|
535 && namePtr8.Find(KSCONSyncRequest) == 0 ) |
|
536 { |
|
537 LOGGER_WRITE_1("Sync request: %S", &namePtr); |
|
538 RBufReadStream stream( *iBuffer ); |
|
539 |
|
540 CleanupClosePushL( stream ); |
|
541 TRAP( ret, iPCDHandler->HandlePutSyncRequestL( namePtr8, stream )); |
|
542 if ( ret ) |
|
543 { |
|
544 LOGGER_WRITE_1("HandlePutSyncRequestL() Leaved with %d", ret); |
|
545 } |
|
546 |
|
547 CleanupStack::PopAndDestroy( &stream ); |
|
548 } |
|
549 else if ( ( typePtr.Compare( KSConPCDWBXMLObjectType ) == KErrNone) || |
515 ( typePtr.Compare( KSConPCDWBXMLObjectType2 )== KErrNone) ) |
550 ( typePtr.Compare( KSConPCDWBXMLObjectType2 )== KErrNone) ) |
516 { |
551 { |
517 LOGGER_WRITE( "CSConPCConnSession::HandlePutMessageL() : Object type PCD " ); |
552 LOGGER_WRITE( "CSConPCConnSession::HandlePutMessageL() : Object type PCD " ); |
518 TRAPD( err, ret = iConMLHandler->ParseDocumentL( *iBuffer, this ) ); |
553 TRAPD( err, ret = iConMLHandler->ParseDocumentL( *iBuffer, this ) ); |
519 if ( err != KErrNone ) |
554 if ( err != KErrNone ) |
614 fws.Close(); |
646 fws.Close(); |
615 |
647 |
616 CleanupStack::PopAndDestroy( &fws ); |
648 CleanupStack::PopAndDestroy( &fws ); |
617 } |
649 } |
618 file.Close(); |
650 file.Close(); |
619 CleanupStack::PopAndDestroy( &fs ); |
|
620 #endif |
651 #endif |
621 |
652 |
622 } |
653 } |
623 else if ( typePtr.CompareC( KSConPCDWBXMLObjectType) == KErrNone ) |
654 else if ( typePtr.CompareC( KSConPCDWBXMLObjectType) == KErrNone ) |
624 { |
655 { |
625 ret = HandleWBXMLGetRequestL( namePtr ); |
656 if ( namePtr8.Find(KSCONSyncRequest) == 0 ) // 8-bit search |
|
657 { |
|
658 LOGGER_WRITE("Sync request"); |
|
659 |
|
660 RBufWriteStream stream( *iBuffer ); |
|
661 |
|
662 CleanupClosePushL( stream ); |
|
663 |
|
664 TRAP( ret, iPCDHandler->HandleGetSyncRequestL( namePtr8, stream, iChunk.MaxSize() - sizeof(TInt32) )); |
|
665 if ( ret ) |
|
666 { |
|
667 LOGGER_WRITE_1("HandleGetSyncRequestL() Leaved with %d", ret); |
|
668 } |
|
669 stream.CommitL(); |
|
670 CleanupStack::PopAndDestroy( &stream ); |
|
671 |
|
672 LOGGER_WRITE_1("iBuffer size: %d", iBuffer->Size()); |
|
673 |
|
674 } |
|
675 else if ( namePtr.Find(KSCONReadImsi) == 0 ) // 16-bit search |
|
676 { |
|
677 LOGGER_WRITE("Read IMSI"); |
|
678 TBuf<CTelephony::KIMSISize> imsi; |
|
679 ret = CSconImsiReader::GetImsiL( imsi ); |
|
680 |
|
681 if ( ret == KErrNone ) |
|
682 { |
|
683 TBuf8<CTelephony::KIMSISize> imsi8; |
|
684 User::LeaveIfError( CnvUtfConverter::ConvertFromUnicodeToUtf8(imsi8,imsi) ); |
|
685 |
|
686 iBuffer->ResizeL( imsi8.Length() ); |
|
687 iBuffer->Write( 0, imsi8 ); |
|
688 } |
|
689 else |
|
690 { |
|
691 // Change error code more generic |
|
692 ret = KErrNotFound; |
|
693 } |
|
694 } |
|
695 else if ( namePtr.Find(KSCONReadNetworkInfo) == 0 ) // 16-bit search |
|
696 { |
|
697 LOGGER_WRITE("Read NetworkInfo"); |
|
698 CTelephony::TRegistrationStatus regStatus; |
|
699 ret = CSconImsiReader::GetNetworkStatusL( regStatus ); |
|
700 |
|
701 if ( ret == KErrNone ) |
|
702 { |
|
703 RBufWriteStream stream( *iBuffer ); |
|
704 CleanupClosePushL( stream ); |
|
705 stream.WriteInt8L( regStatus ); |
|
706 stream.CommitL(); |
|
707 CleanupStack::PopAndDestroy( &stream ); |
|
708 } |
|
709 else |
|
710 { |
|
711 // Change error code more generic |
|
712 ret = KErrNotFound; |
|
713 } |
|
714 } |
|
715 else if ( namePtr.Find(KSCONReadOviAccount) == 0 ) |
|
716 { |
|
717 LOGGER_WRITE("Read Ovi account"); |
|
718 RBufWriteStream stream( *iBuffer ); |
|
719 CleanupClosePushL( stream ); |
|
720 |
|
721 ret = ReadOviAccountInfoL( stream ); |
|
722 stream.CommitL(); |
|
723 CleanupStack::PopAndDestroy( &stream ); |
|
724 |
|
725 } |
|
726 else if ( namePtr.Find(KSCONListPath) == 0 ) |
|
727 { |
|
728 LOGGER_WRITE("List path"); |
|
729 // LISTP:0:pathname |
|
730 if ( namePtr.Length() > KSCONListPath().Length()+2) |
|
731 { |
|
732 TPtrC pathname = namePtr.Mid( KSCONListPath().Length()+2 ); |
|
733 |
|
734 const TUint16 levelsChar = namePtr[ KSCONListPath().Length() ]; |
|
735 TInt level(KErrNotFound); |
|
736 if ( levelsChar >= TChar('0') ) |
|
737 { |
|
738 level = levelsChar - TChar('0'); |
|
739 } |
|
740 |
|
741 RBufWriteStream stream( *iBuffer ); |
|
742 CleanupClosePushL( stream ); |
|
743 TRAP( ret, iFolderLister->GenerateFolderListL( stream, pathname, level )); |
|
744 LOGGER_WRITE_1("GenerateFolderListL leaved with err: %d", ret); |
|
745 stream.CommitL(); |
|
746 CleanupStack::PopAndDestroy( &stream ); |
|
747 } |
|
748 else |
|
749 { |
|
750 ret = KErrArgument; |
|
751 } |
|
752 |
|
753 } |
|
754 else if ( namePtr.Find(KSCONReadBtInfo) == 0 ) |
|
755 { |
|
756 LOGGER_WRITE( "Read BT info"); |
|
757 if ( !iBtEngine ) |
|
758 { |
|
759 iBtEngine = CSconBtEngine::NewL(); |
|
760 } |
|
761 RBufWriteStream stream( *iBuffer ); |
|
762 CleanupClosePushL( stream ); |
|
763 TRAP( ret, iBtEngine->ReadBTInfoL( stream ) ); |
|
764 LOGGER_WRITE_1("ReadBTInfoL leaved with err: %d", ret); |
|
765 stream.CommitL(); |
|
766 CleanupStack::PopAndDestroy( &stream ); |
|
767 } |
|
768 else if ( namePtr.Find(KSCONSetBtPower) == 0 ) |
|
769 { |
|
770 LOGGER_WRITE( "Change BT Power state"); |
|
771 if ( namePtr.Length() == KSCONSetBtPower().Length()+1 ) |
|
772 { |
|
773 const TUint16 lastChar = namePtr[ KSCONSetBtPower().Length() ]; |
|
774 TBool changeBtOn; |
|
775 if ( lastChar == TChar('0') ) |
|
776 { |
|
777 changeBtOn = EFalse; |
|
778 } |
|
779 else if ( lastChar == TChar('1') ) |
|
780 { |
|
781 changeBtOn = ETrue; |
|
782 } |
|
783 else |
|
784 { |
|
785 ret = KErrArgument; |
|
786 } |
|
787 |
|
788 if ( !ret ) |
|
789 { |
|
790 if ( !iBtEngine ) |
|
791 { |
|
792 iBtEngine = CSconBtEngine::NewL(); |
|
793 } |
|
794 TInt err = iBtEngine->SetBtPowerState( changeBtOn ); |
|
795 |
|
796 RBufWriteStream stream( *iBuffer ); |
|
797 CleanupClosePushL( stream ); |
|
798 stream.WriteInt32L( err ); |
|
799 stream.CommitL(); |
|
800 CleanupStack::PopAndDestroy( &stream ); |
|
801 } |
|
802 } |
|
803 else |
|
804 { |
|
805 ret = KErrArgument; |
|
806 } |
|
807 } |
|
808 else if ( namePtr.Find(KSCONSetBtName) == 0 ) |
|
809 { |
|
810 LOGGER_WRITE( "Set BT Name"); |
|
811 TPtrC btName = namePtr.Mid( KSCONSetBtName().Length() ); |
|
812 TInt err = iBtEngine->SetBtName( btName ); |
|
813 |
|
814 RBufWriteStream stream( *iBuffer ); |
|
815 CleanupClosePushL( stream ); |
|
816 stream.WriteInt32L( err ); |
|
817 stream.CommitL(); |
|
818 CleanupStack::PopAndDestroy( &stream ); |
|
819 } |
|
820 else if ( namePtr.Find(KSCONSetBtAuthorized) == 0 ) |
|
821 { |
|
822 LOGGER_WRITE( "Set BT Authorized"); |
|
823 ret = KErrArgument; |
|
824 // SETBTAUTHORIZED:0:00245f8d6a26 |
|
825 // 1. param = auth. state ("0"=off, "1"=true) |
|
826 // 2. param = bt address (hex string) |
|
827 |
|
828 if ( namePtr.Length() > KSCONSetBtAuthorized().Length()+2) |
|
829 { |
|
830 TPtrC btAddr = namePtr.Mid( KSCONSetBtAuthorized().Length()+2 ); |
|
831 |
|
832 const TUint16 authStateChar = namePtr[ KSCONSetBtAuthorized().Length() ]; |
|
833 TBool authorize(EFalse); |
|
834 if ( authStateChar == TChar('0') ) |
|
835 { |
|
836 authorize = EFalse; |
|
837 ret = KErrNone; |
|
838 } |
|
839 else if ( authStateChar == TChar('1') ) |
|
840 { |
|
841 authorize = ETrue; |
|
842 ret = KErrNone; |
|
843 } |
|
844 |
|
845 if ( !iBtEngine ) |
|
846 { |
|
847 iBtEngine = CSconBtEngine::NewL(); |
|
848 } |
|
849 TRAPD(err, iBtEngine->SetBtAuthorizedL( btAddr, authorize ) ); |
|
850 |
|
851 RBufWriteStream stream( *iBuffer ); |
|
852 CleanupClosePushL( stream ); |
|
853 stream.WriteInt32L( err ); |
|
854 stream.CommitL(); |
|
855 CleanupStack::PopAndDestroy( &stream ); |
|
856 } |
|
857 |
|
858 } |
|
859 else |
|
860 { |
|
861 ret = HandleWBXMLGetRequestL( namePtr ); |
|
862 } |
626 } |
863 } |
627 else |
864 else |
628 { |
865 { |
629 LOGGER_WRITE( "CSConPCConnSession::HandleGetMessageL() : Header type not regognized " ); |
866 LOGGER_WRITE( "CSConPCConnSession::HandleGetMessageL() : Header type not regognized " ); |
630 ret = KErrNotSupported; |
867 ret = KErrNotSupported; |
758 #endif |
995 #endif |
759 TRACE_FUNC_RET(ret); |
996 TRACE_FUNC_RET(ret); |
760 return ret; |
997 return ret; |
761 } |
998 } |
762 |
999 |
|
1000 |
|
1001 // ----------------------------------------------------------------------------- |
|
1002 // CSConPCConnSession::ReadOviAccountInfoL() |
|
1003 // Reads ovi account information to stream |
|
1004 // ----------------------------------------------------------------------------- |
|
1005 // |
|
1006 TInt CSConPCConnSession::ReadOviAccountInfoL( RWriteStream& aAccountInfoStream ) |
|
1007 { |
|
1008 TRACE_FUNC_ENTRY; |
|
1009 RLibrary oviaccounthandlerLib; |
|
1010 CleanupClosePushL( oviaccounthandlerLib ); |
|
1011 // Dynamically load DLL |
|
1012 TInt err = oviaccounthandlerLib.Load( KSconOviAccountHandlerDllName ); |
|
1013 if ( err ) |
|
1014 { |
|
1015 LOGGER_WRITE_1("oviaccounthandlerLib.Load err: %d", err); |
|
1016 err = KErrNotSupported; |
|
1017 } |
|
1018 else if( oviaccounthandlerLib.Type()[1] != KSconOviAccountHandlerDllUid ) |
|
1019 { |
|
1020 LOGGER_WRITE_1( "KSconOviAccountHandlerDllUid incorrect... (0x%08X)",oviaccounthandlerLib.Type()[1].iUid ); |
|
1021 err = KErrNotSupported; |
|
1022 } |
|
1023 |
|
1024 if ( err == KErrNone ) |
|
1025 { |
|
1026 TSConCreateCSconOviAccountHandlerFunc CreateCSconOviAccountHandlerL = |
|
1027 (TSConCreateCSconOviAccountHandlerFunc)oviaccounthandlerLib.Lookup(1); |
|
1028 |
|
1029 CSconOviAccountHandler* oviAccountHandler = (CSconOviAccountHandler*)CreateCSconOviAccountHandlerL(); |
|
1030 |
|
1031 TRAP(err, oviAccountHandler->GetOviAccountDetailsL( aAccountInfoStream ) ); |
|
1032 LOGGER_WRITE_1("GetOviAccountDetailsL err: %d", err); |
|
1033 |
|
1034 delete oviAccountHandler; |
|
1035 oviAccountHandler = NULL; |
|
1036 |
|
1037 if ( err ) |
|
1038 { |
|
1039 // change error code |
|
1040 err = KErrNotFound; |
|
1041 } |
|
1042 } |
|
1043 else |
|
1044 { |
|
1045 err = KErrNotSupported; |
|
1046 } |
|
1047 |
|
1048 CleanupStack::PopAndDestroy( &oviaccounthandlerLib ); |
|
1049 TRACE_FUNC_EXIT; |
|
1050 return err; |
|
1051 } |
|
1052 |
763 // ----------------------------------------------------------------------------- |
1053 // ----------------------------------------------------------------------------- |
764 // CSConPCConnSession::HandleResetMessage() |
1054 // CSConPCConnSession::HandleResetMessage() |
765 // Resets the PCCS service |
1055 // Resets the PCCS service |
766 // ----------------------------------------------------------------------------- |
1056 // ----------------------------------------------------------------------------- |
767 // |
1057 // |