diff -r aecbbf00d063 -r d48ab3b357f1 uifw/EikStd/coctlsrc/smileymodel.cpp --- a/uifw/EikStd/coctlsrc/smileymodel.cpp Tue Aug 31 15:28:30 2010 +0300 +++ b/uifw/EikStd/coctlsrc/smileymodel.cpp Wed Sep 01 12:16:19 2010 +0100 @@ -390,3 +390,89 @@ aText[i + aDocPos] = CSmileyManager::KPlaceHolder; } } + + +///////////////////////////////////////////////////////////////////////////////////////// + +const char KStartSymbol[] = {'(', '<', '[', '{'}; +const char KEndSymbol[] = {')', '>', ']', '}'}; + +TInt IndexFrom(const char* const aPtr, TInt aLength, TInt aChar) + { + for(TInt i=0; i=0; i--) + { + TInt index = IndexFrom(KEndSymbol, sizeof(KEndSymbol), aText[i]); // detect end symbol + if(KErrNotFound != index) // push + { + stack[pos++] = KStartSymbol[index]; + } + else if(pos) // detect start symbol + { + if(stack[pos-1] == aText[i]) // meet a start symbol + { + pos--; + if(!pos) return (smileyPos > i); + } + } + + if(smileyPos == i) // smiley combination finished + { + if(!pos) return EFalse; + } + } + + return EFalse; + } + +TBool IsPartOfUrl(const TDesC& aText) + { + const TInt end = aText.Length() - 1; + TInt pos = end; + while(pos > 0) + { + const TUint16 word = aText[--pos]; + if(word == ' ' || word == 0x2029) + { + break; + } + } + + TInt length = end - pos; + if(length > 5) + { + TPtrC field(aText.Mid(pos,length)); + pos = field.Find(_L(":\\\\")); + if(KErrNotFound == pos) pos = field.Find(_L("://")); + if(KErrNotFound != pos) + { + return ETrue; + } + } + + return EFalse; + } + +TBool CSmileyModel::IsSmileyBySemanticAnalysis(const TDesC& aText, TInt aSmileyLength) + { + if(HavePairedSymbol(aText, aSmileyLength)) return EFalse; + + if(IsPartOfUrl(aText)) return EFalse; + + return ETrue; + }