diff -r bd83ceabce89 -r 5a1685599b76 fep/aknfep/src/aknfepuiinputminiqwertystrokephrasebase.cpp --- a/fep/aknfep/src/aknfepuiinputminiqwertystrokephrasebase.cpp Tue Sep 14 21:59:06 2010 +0300 +++ b/fep/aknfep/src/aknfepuiinputminiqwertystrokephrasebase.cpp Wed Sep 15 12:34:44 2010 +0300 @@ -55,6 +55,8 @@ const TInt16 KKey1 = 0x31; const TInt16 KKey6 = 0x36; +const TUid KPtiSogouCoreUid = { 0x20031DD6 }; + _LIT( KMaxPhraseNote,"\x8BCD\x7EC4\x6700\x957F\x4E3A\x4E03\x5B57" ); // --------------------------------------------------------------------------- @@ -229,6 +231,8 @@ ptiengine->GetPhoneticSpelling(1).Length(); stringAfterLength = ptiengine->AppendKeyPress((TPtiKey)keyCode).Length(); + stringAfterLength = ptiengine->GetPhoneticSpelling(1).Length(); + //the keystroke is invalid. if ( stringBeforeLength == stringAfterLength ) { @@ -264,7 +268,7 @@ if ( cdtCount > 0 ) { UIContainer()->EditPaneWindow()->SetChangeState( ETrue ); - iOwner->ChangeState( ECandidate ); + iOwner->ChangeState( EEntry ); return; } @@ -467,17 +471,50 @@ TInt index = editPane->GetCursorIndexOfKeystroke(); TBuf showInfo; + // Get the current core id + TInt coreID = 0; + TRAP_IGNORE( coreID = iOwner->PtiEngine()->HandleCommandL( EPtiCommandGetCoreID )); + TInt phraseCount = 0; + for ( TInt i = 0; i < phrase->Count(); ++i ) { - showInfo.Append( phrase->MdcaPoint( i ) ); + // If this method is called in construction of the state machine, + // the plugin is not set. If sogou core is in use now, we should append + // each characters to showInfo. + // For Sogou core, maybe one element of PhraseArray() contains two or more characters. + if ( TUid::Uid( coreID ) == KPtiSogouCoreUid ) + { + for ( TInt k = 0; k < phrase->MdcaPoint(i).Length(); k++ ) + { + showInfo.Append( phrase->MdcaPoint(i)[k] ); + } + phraseCount += phrase->MdcaPoint(i).Length(); + } + else + { + // If cpicore is in use, just append the element of phrase + showInfo.Append(phrase->MdcaPoint(i) ); + } } for ( TInt ii = 0; ii < keystroke->Count(); ++ii ) { showInfo.Append( keystroke->MdcaPoint( ii ) ); } - - editPane->SetText( showInfo, index + phrase->Count() ); + + // If this method is called in construction of the state machine, + // the plugin is not set. If sogou core is in use now, the phraseCount + // should be the same as the phrase characters count. + // For Sogou core, maybe one element of PhraseArray() contains two or more characters. + if ( TUid::Uid( coreID ) == KPtiSogouCoreUid ) + { + editPane->SetText( showInfo, index + phraseCount ); + } + else + { + // If cpicore is in use, phraseCount is the same as phrase->Count() + editPane->SetText( showInfo, index + phrase->Count() ); + } switch ( iState ) { @@ -702,6 +739,12 @@ void TAknFepInputMiniQwertyStrokePhraseBase::AddPhraseToDB( const TDesC& aPhraseAdd ) { + // If sogou core is actived, use the plugin. + if ( iStrokePlugin.IsEnable()) + { + iStrokePlugin.AddPhrasePinyinToPti(); + return; + } TPtiUserDictionaryEntry addUdbEntry( aPhraseAdd ); //Add the phrase to the DB by PTI Engine iOwner->PtiEngine()->AddUserDictionaryEntry( addUdbEntry ); @@ -752,6 +795,11 @@ // TBool TAknFepInputMiniQwertyStrokePhraseBase::CommitInlineEEPL( const TDesC& aDes ) { + // If sogou core is actived, use the plugin. + if ( iStrokePlugin.IsEnable()) + { + return iStrokePlugin.CommitInlineEEPL( aDes ); + } TInt charCount = aDes.Length(); MAknFepManagerUIInterface* fepMan = iOwner->FepMan(); MAknFepUICtrlEditPane* editpane = UIContainer()->EditPaneWindow(); @@ -846,7 +894,21 @@ TInt phraseCount = editPane->PhraseArray()->Count(); TInt keystrokeCount = keystrokeArray->Count(); TInt index = editPane->GetCursorIndexOfKeystroke(); + + // Get the current core id + TInt coreID = 0; + TRAP_IGNORE( coreID = iOwner->PtiEngine()->HandleCommandL( EPtiCommandGetCoreID )); + if ( TUid::Uid( coreID ) == KPtiSogouCoreUid ) + { + CDesCArrayFlat* phrase = editPane->PhraseArray(); + phraseCount = 0; + for ( TInt j = 0; j < phrase->Count(); j++ ) + { + phraseCount += phrase->MdcaPoint(j).Length();; + } + } + if ( phraseCount + keystrokeCount >= KMaxKeystrokeCount ) { return EFalse; @@ -917,7 +979,17 @@ ) { CPtiEngine* ptiEngine = iOwner->PtiEngine(); - TBuf lowerdata; + TBuf lowerdata; + + // If the key is EPtiKeyQwertySpace, just append a KStrokeDelimiter. + if ( aKey == EPtiKeyQwertySpace ) + { + TBuf<1> strokeDLT; + strokeDLT.Append( KStrokeDelimiter ); + aKeystroke.Copy( strokeDLT ); + return; + } + ptiEngine->MappingDataForKey((TPtiKey)aKey, lowerdata, EPtiCaseLower); TInt StrokeUnicodePosition =0; @@ -990,6 +1062,13 @@ keystrokeArray->Compress(); phrase->Compress(); phraseStroke->Compress(); + + TInt coreID = iOwner->PtiEngine()->HandleCommandL( EPtiCommandGetCoreID ); + if ( TUid::Uid( coreID ) == KPtiSogouCoreUid ) + { + // Notify sogoucore that last phrase is cancelled + iOwner->PtiEngine()->HandleCommandL( EPtiCommandCancelSelectElement ); + } } // --------------------------------------------------------- @@ -1015,6 +1094,20 @@ TBuf<1> delimiter; delimiter.Append( KStrokeDelimiter ); + // Get the current core id + TInt coreID = 0; + TRAP_IGNORE( coreID = iOwner->PtiEngine()->HandleCommandL( EPtiCommandGetCoreID )); + + if ( TUid::Uid( coreID ) == KPtiSogouCoreUid ) + { + CDesCArrayFlat* phrase = editPane->PhraseArray(); + phraseCount = 0; + for ( TInt j = 0; j < phrase->Count(); j++ ) + { + phraseCount += phrase->MdcaPoint(j).Length();; + } + } + //set warning color stroke after 7th group when it's more than 7 groups. if ( 0 == keystrokeCount ) { @@ -1038,22 +1131,29 @@ if ( EPtiKeyQwertySpace == keyCode ) { delimiterCount = delimiterCount + 1; - if ( delimiterCount == KMaxPhraseCreationCount ) + + // For Sogou core, there is no need to limit characters count to + // KMaxPhraseCreationCount. + if ( TUid::Uid( coreID ) != KPtiSogouCoreUid ) { - if ( !valid ) + if ( delimiterCount == KMaxPhraseCreationCount ) { - editPane->SetHighlight( - phraseCount + index, - phraseCount + keystrokeCount - 1 ); + if ( !valid ) + { + editPane->SetHighlight( + phraseCount + index, + phraseCount + keystrokeCount - 1 ); + } + else + { + editPane->SetHighlight( + phraseCount + i, + phraseCount + keystrokeCount - 1 ); + } + break; } - else - { - editPane->SetHighlight( - phraseCount + i, - phraseCount + keystrokeCount - 1 ); - } - break; } + if ( ( !valid ) || ( 0 == i ) ) { editPane->SetHighlight( @@ -1079,6 +1179,8 @@ stringBeforeLength = ptiengine->GetPhoneticSpelling(1).Length(); stringAfterLength = ptiengine->AppendKeyPress((TPtiKey)keyCode).Length(); + stringAfterLength = ptiengine->GetPhoneticSpelling(1).Length(); + if ( stringBeforeLength == stringAfterLength ) { valid = EFalse; @@ -1360,6 +1462,8 @@ stringBeforeLength = ptiengine->GetPhoneticSpelling(1).Length(); stringAfterLength = ptiengine->AppendKeyPress((TPtiKey)keyCode).Length(); + stringAfterLength = ptiengine->GetPhoneticSpelling(1).Length(); + if ( stringBeforeLength == stringAfterLength ) { editPane->SetAllValidFlag( EFalse ); @@ -1412,7 +1516,26 @@ { #ifdef RD_INTELLIGENT_TEXT_INPUT TBool isEditorFull = iOwner->FepMan()->IsFlagSet(CAknFepManager::EFlagEditorFull); - if ( !isEditorFull ) + + // For sogou core, the predictive is not endless, so when there + // is no predictive candidates, we should call TryCloseUiL(). + TBool noCandidates = EFalse; + + TInt coreID = iOwner->PtiEngine()->HandleCommandL( EPtiCommandGetCoreID ); + if ( TUid::Uid( coreID ) == KPtiSogouCoreUid ) + { + // Get the predictive candidates. + CDesCArrayFlat* phraseCandidates = new(ELeave) CDesCArrayFlat( 1 ); + CleanupStack::PushL ( phraseCandidates ); + phraseCandidates->Reset(); + iOwner->PtiEngine()->GetChinesePhraseCandidatesL( *phraseCandidates ); + if ( phraseCandidates->Count() == 0 ) + { + noCandidates = ETrue; + } + CleanupStack::PopAndDestroy( phraseCandidates ); + } + if ( !isEditorFull && !noCandidates ) { iOwner->ChangeState( EPredictiveCandidate ); UIContainer()->EditPaneWindow()->SetChangeState(ETrue);