Revision: 201017
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Fri, 14 May 2010 16:57:37 +0300
changeset 2 6c1a2771f4b7
parent 1 6f2c1c46032b
child 3 ae3f1779f6da
child 4 e0a44815fded
Revision: 201017 Kit: 201019
group/bld.inf
harvester/harvesterserver/inc/cindexingmanager.h
harvester/harvesterserver/src/cindexingmanager.cpp
qcpix/tsrc/orbitsearch/searchhelper.cpp
qcpix/tsrc/orbitsearch/uicontrols.h
rom/cpix_mw.iby
searchengine/cpix/cpix/inc/public/appclass-hierarchy.txt
searchengine/cpix/cpix/src/analyzer.cpp
searchengine/cpix/cpix/src/cpixanalyzer.cpp
searchengine/cpix/cpix/src/fileparser/pdffileparser.cpp
searchengine/cpix/cpix/src/idxdbdelta.cpp
searchengine/cpix/cpix/src/idxdbmgr.cpp
searchengine/cpix/cpix/src/qrytypes/addressqrytype.cpp
searchengine/cpix/cpixrotlog/src/cpixrotlog.cpp
searchengine/cpix/tsrc/cpixsample/data/cpixsample_reg.rss
searchengine/cpix/tsrc/cpixsample/group/bld.inf
searchengine/cpix/tsrc/cpixsample/group/cpixsample.mmp
searchengine/cpix/tsrc/cpixsample/sis/backup_registration.xml
searchengine/cpix/tsrc/cpixsample/sis/cpixsample_s60_3_x_v_1_0_0.pkg
searchengine/cpix/tsrc/cpixsample/src/cpixsample.cpp
searchengine/cpix/tsrc/cpixunittest/data/cpixunittestcorpus/query/query7.txt
searchengine/cpix/tsrc/cpixunittest/data/cpixunittestcorpus/query/query8.txt
searchengine/cpix/tsrc/cpixunittest/data/cpixunittestcorpus/query/query9.txt
searchengine/cpix/tsrc/cpixunittest/group/bld.inf
searchengine/cpix/tsrc/cpixunittest/inc/testutils.h
searchengine/cpix/tsrc/cpixunittest/src/negativetests.cpp
searchengine/cpix/tsrc/cpixunittest/src/querytest.cpp
searchengine/cpix/tsrc/cpixunittest/src/terms.cpp
searchengine/oss/cl/clucene/src/clucene/analysis/standard/standardtokenizer.cpp
searchengine/oss/cl/clucene/src/clucene/index/multireader.cpp
searchengine/oss/cl/clucene/src/clucene/index/terms.h
searchengine/oss/cl/clucene/src/clucene/search/filteredtermenum.cpp
searchengine/oss/cl/clucene/src/clucene/search/multisearcher.cpp
searchengine/oss/cl/clucene/src/clucene/search/phrasequery.cpp
searchengine/oss/cl/clucene/src/clucene/search/wildcardtermenum.cpp
searchengine/oss/cl/clucene/src/clucene/store/fsdirectory.cpp
searchengine/oss/cl/clucene/src/clucene/util/arrays.h
searchengine/oss/cl/clucene/src/clucene/util/fileinputstream.cpp
searchengine/oss/sb/snowball/libstemmer/libstemmer.c
searchengine/util/cpixtools/src/cpixfstools.cpp
searcher/searchserver/group/searchserver.mmp
searcher/searchserver/src/ccpixidxdb.cpp
searcher/searchserver/src/csearchserver.cpp
searcher/searchserver/src/searchservertesting.cpp
searchsrv_plat/cpix_framework_api/inc/mindexingpluginobserver.h
sis/cpixsearch_stub.pkg
sis/cpixsearch_stub.sis
sis/makestubsis.bat
--- a/group/bld.inf	Mon May 03 13:33:22 2010 +0300
+++ b/group/bld.inf	Fri May 14 16:57:37 2010 +0300
@@ -32,6 +32,7 @@
 
 PRJ_EXPORTS
 ../rom/CPix_mw.iby	CORE_MW_LAYER_IBY_EXPORT_PATH(CPix_mw.iby)
+../sis/cpixsearch_stub.sis        /epoc32/data/z/system/install/cpixsearch_stub.sis
 
 PRJ_TESTMMPFILES
 
--- a/harvester/harvesterserver/inc/cindexingmanager.h	Mon May 03 13:33:22 2010 +0300
+++ b/harvester/harvesterserver/inc/cindexingmanager.h	Fri May 14 16:57:37 2010 +0300
@@ -58,8 +58,9 @@
 	 *
      * @param aQualifiedBaseAppClass database to harvest
 	 * @param aMedia the media to be harvested
+	 * @param aRemovePersist if plugin wants to remove from harvesting queue as well as config to be saved
 	 */
-	void RemoveHarvestingQueue(CIndexingPlugin* aPlugin, const TDesC& aQualifiedBaseAppClass);
+	void RemoveHarvestingQueue(CIndexingPlugin* aPlugin, const TDesC& aQualifiedBaseAppClass,TBool aRemovePersist = EFalse);
 
 	/**
 	 * derived from MIndexingService
--- a/harvester/harvesterserver/src/cindexingmanager.cpp	Mon May 03 13:33:22 2010 +0300
+++ b/harvester/harvesterserver/src/cindexingmanager.cpp	Fri May 14 16:57:37 2010 +0300
@@ -445,7 +445,7 @@
 // CIndexingManager::RemoveHarvestingQueue()
 // -----------------------------------------------------------------------------
 //
-void CIndexingManager::RemoveHarvestingQueue(CIndexingPlugin* aPlugin, const TDesC& aQualifiedBaseAppClass)
+void CIndexingManager::RemoveHarvestingQueue(CIndexingPlugin* aPlugin, const TDesC& aQualifiedBaseAppClass,TBool aRemovePersist)
 	{
     OstTraceExt1( TRACE_NORMAL, CINDEXINGMANAGER_REMOVEHARVESTINGQUEUE, "CIndexingManager::RemoveHarvestingQueue;De-Queuing requested for <%S>", aQualifiedBaseAppClass );
     CPIXLOGSTRING2("CIndexingManager::RemoveHarvestingQueue(): De-queuing requested for <%S>.", &aQualifiedBaseAppClass);	
@@ -462,6 +462,13 @@
 				// No need to set iHarvesterArrayChanged when changing the status only (which is not saved)
 				iHarvesterArray[i].iStatus = EHarvesterStatusHibernate;
 				}
+			if(aRemovePersist) //Plugin want this to be removed from queue and saved to disk as well
+				{
+				CPIXLOGSTRING("CIndexingManager::RemoveHarvestingQueue(): aRemovePersist is true so removing");		
+				iHarvesterArray.Remove(i);
+				Externalize(); //Save to disk	
+				CPIXLOGSTRING("CIndexingManager::RemoveHarvestingQueue(): aRemovePersist Externalize successful");		
+				}
 			OstTrace0( TRACE_NORMAL, DUP1_CINDEXINGMANAGER_REMOVEHARVESTINGQUEUE, "CIndexingManager::RemoveHarvestingQueue(): Harvester de-queued successfully." );
 			CPIXLOGSTRING("CIndexingManager::RemoveHarvestingQueue(): Harvester de-queued successfully.");	
 			return;
--- a/qcpix/tsrc/orbitsearch/searchhelper.cpp	Mon May 03 13:33:22 2010 +0300
+++ b/qcpix/tsrc/orbitsearch/searchhelper.cpp	Fri May 14 16:57:37 2010 +0300
@@ -40,27 +40,24 @@
     QString resultString("");
     resultsBox->setPlainText( resultString );
     searchTime.restart();
-    QString searchString = searchBox->text();
+    QString searchString;
+    
+#if PREFIX_SEARCH
+    searchString = "$prefix(\""; 
+    searchString += searchBox->text();
+    searchString += "\")";
 
-#if STAR_SEARCH
+#elif STAR_SEARCH
+    searchString += searchBox->text();
     searchString += "*";
 #elif NO_STAR_SEARCH
         ;//do nothing
-#elif ESCAPE_SPECIAL_CHARS
-    //C-style array query - so that we dont have to hard code the length.
-    //Escape '\' first so that it does not re-escape all the other escapes.
-    QString escapeTheseCharacters [] = {"\\", "+", "-", "&&", "||", "!", 
-                                        "(", ")", "{", "}", "[", "]", "^", 
-                                        "~", "*", "?", ":", "\0"};
-    for( int i=0; escapeTheseCharacters[i] != "\0"; i++ ){
-        QString escapedCharacter = "\\" + escapeTheseCharacters[i];
-        searchString.replace( escapeTheseCharacters[i], escapedCharacter );
-    }
 #endif
     
     hits = searcher->search( searchString );
-    
-    resultString = "SearchTime: " + QString().setNum( searchTime.elapsed() ) + " ms \r\n";
+
+    if (searchTime.elapsed() >= 0)
+        resultString = "SearchTime: " + QString().setNum( searchTime.elapsed() ) + " ms \r\n";
     resultString += "Hits: " + QString().setNum( hits ) + "\r\n";
     resultsBox->setPlainText( resultString );
 
--- a/qcpix/tsrc/orbitsearch/uicontrols.h	Mon May 03 13:33:22 2010 +0300
+++ b/qcpix/tsrc/orbitsearch/uicontrols.h	Fri May 14 16:57:37 2010 +0300
@@ -30,14 +30,15 @@
 //in the order below.
 //i.e., STAR_SEARCH over-rides NO_STAR_SEARCH which overrides 
 //ESCAPE_SPECIAL_CHARS.
-#define STAR_SEARCH 1
+#define STAR_SEARCH 0
 
 //Vanilla search. Send search string to engine "as-is". 
 #define NO_STAR_SEARCH 0
 
-//Will escape the following characters:
-//+,-,&&,||,!,(,),{,},[,],^,",~,*,?,:and '\'
-#define ESCAPE_SPECIAL_CHARS 0
+//Enable the prefix_search macro to enable Prefix query feature. This will add $prefix to the query 
+//string.
+
+#define PREFIX_SEARCH 1
 
 //If you dont want to see results, define this flag.
 #define DONT_SHOW_RESULTS 0
--- a/rom/cpix_mw.iby	Mon May 03 13:33:22 2010 +0300
+++ b/rom/cpix_mw.iby	Fri May 14 16:57:37 2010 +0300
@@ -50,6 +50,9 @@
 // must be hardcoded 'c' drive for this file
 
 data=DATAZ_\PRIVATE\101f875a\import\20029ab8.rsc  private\101f875a\import\20029ab8.rsc
+
+data=ZSYSTEM\install\cpixsearch_stub.sis    System\Install\cpixsearch_stub.sis
+
 #endif //FF_SEARCH_SW
 
 #endif // __CPIXENGINE_IBY__
--- a/searchengine/cpix/cpix/inc/public/appclass-hierarchy.txt	Mon May 03 13:33:22 2010 +0300
+++ b/searchengine/cpix/cpix/inc/public/appclass-hierarchy.txt	Fri May 14 16:57:37 2010 +0300
@@ -19,11 +19,14 @@
     +-- file
     |     |
     | 		|
-    |     +-- Content
-    |			|	[ Contents 	]	    {EStoreYes | EIndexTokenized}
+    |     +-- content
+    |			|	[ Contents 	]			{EStoreYes | EIndexTokenized}
+    |			| [ Name      ]     {EStoreNo  | EIndexTokenized}
+    |			| [ BaseName  ]     {EStoreNo  | EIndexTokenized}
+    |     | [ Extension ]     {EStoreNo  | EIndexTokenized}
     |			|
-    |			+-- folder     
-    |       [ Name  		]     {EStoreYes | EIndexTokenized}
+    |			+-- folder
+    |			  [ Name  	  ]     {EStoreYes | EIndexTokenized}
     |			  [ Extension ]     {EStoreYes | EIndexUnTokenized}
     |
     |      
--- a/searchengine/cpix/cpix/src/analyzer.cpp	Mon May 03 13:33:22 2010 +0300
+++ b/searchengine/cpix/cpix/src/analyzer.cpp	Fri May 14 16:57:37 2010 +0300
@@ -457,13 +457,15 @@
                       auto_ptr<TokenStreamFactory> factory) 
             : factory_(factory) {
             using namespace Cpt::Parser;
-            if (invokation.params().size() != 2 || 
-                !dynamic_cast<IntegerLit*>(invokation.params()[0]) || 
-                !dynamic_cast<IntegerLit*>(invokation.params()[1])) {
-                THROW_CPIXEXC("Length filter takes exactly two integer parameters");
+            if (!(invokation.params().empty())) {
+                if (invokation.params().size() != 2 || 
+                        !dynamic_cast<IntegerLit*>(invokation.params()[0]) || 
+                        !dynamic_cast<IntegerLit*>(invokation.params()[1])) {
+                    THROW_CPIXEXC("Length filter takes exactly two integer parameters");
+                }
+                min_ = dynamic_cast<IntegerLit*>(invokation.params()[0])->value();
+                max_ = dynamic_cast<IntegerLit*>(invokation.params()[1])->value();
             }
-            min_ = dynamic_cast<IntegerLit*>(invokation.params()[0])->value();
-            max_ = dynamic_cast<IntegerLit*>(invokation.params()[1])->value();
         }
         virtual lucene::analysis::TokenStream* tokenStream(const TCHAR          * fieldName, 
                                                            lucene::util::Reader * reader) {
@@ -486,11 +488,13 @@
                       auto_ptr<TokenStreamFactory> factory) 
             : factory_(factory) {
             using namespace Cpt::Parser;
-            if (invokation.params().size() != 1 || 
-                !dynamic_cast<IntegerLit*>(invokation.params()[0])) {
-                THROW_CPIXEXC("Prefix generator takes exactly one integer parameter");
+            if (invokation.params().empty()) {
+                if (invokation.params().size() != 1 || 
+                    !dynamic_cast<IntegerLit*>(invokation.params()[0])) {
+                    THROW_CPIXEXC("Prefix generator takes exactly one integer parameter");
+                }            
+                maxPrefixLength_ = dynamic_cast<IntegerLit*>(invokation.params()[0])->value();
             }
-            maxPrefixLength_ = dynamic_cast<IntegerLit*>(invokation.params()[0])->value();
         }
         virtual lucene::analysis::TokenStream* tokenStream(const TCHAR          * fieldName, 
                                                            lucene::util::Reader * reader) {
--- a/searchengine/cpix/cpix/src/cpixanalyzer.cpp	Mon May 03 13:33:22 2010 +0300
+++ b/searchengine/cpix/cpix/src/cpixanalyzer.cpp	Fri May 14 16:57:37 2010 +0300
@@ -141,9 +141,9 @@
 
             // the wrapper custom must be released in any case, as
             // it was just a first step in the construction
-            // sequence
-            cpix_Analyzer_destroy(custom);
+            // sequence            
         }
+    cpix_Analyzer_destroy(custom);
 
     return system;
 }
--- a/searchengine/cpix/cpix/src/fileparser/pdffileparser.cpp	Mon May 03 13:33:22 2010 +0300
+++ b/searchengine/cpix/cpix/src/fileparser/pdffileparser.cpp	Fri May 14 16:57:37 2010 +0300
@@ -48,69 +48,43 @@
 
 namespace
 {
-    const char EXTENSION[]       = ".txt";
-    const char EXTENSION_UPPER[] = ".TXT";
-
-    const char DEFAULT_ENCODING[] = "UTF-8";
-    
     /**
      * Returns 1 on success, 0 on eof. 
      */
-    int clgetline(lucene::util::Reader& reader, std::wstring& line) 
+    int getPDFExcerpt(const char* filePath,std::wstring& line) 
         {
-        line = L""; 
+        line = L"";
+        int wordCount = 0;
         
         // read line 
+        FILE *fp = fopen(filePath,"rb");
         while (true) 
             {
-                int c = reader.read(); 
+                int c = fgetc(fp); 
                 switch (c) {
                     case -1: // EOF
+                        fclose(fp);
                         return line.length() > 0; 
                     case '\n': // line break
                     case '\r': // line break
+                        fclose(fp);
                         return 1;
                     default:
                         line += static_cast<wchar_t>(c);
-                        if  (line.length() > 500)
-                            return 1;
+                        if ( c == ' ')
+                            wordCount ++;
+                        
+                        if  ((line.length() > MAX_EXCERPT_LENGTH) ||  wordCount == 10 )
+                            {
+                                fclose(fp);
+                                return 1;
+                            }
                 }
             }
         }
 
-    void getExcerptOfFile(wchar_t       * dst,
-                          const char    * path,
-                          size_t          maxWords,
-                          size_t          bufSize)
-    {
-        using namespace std;
-        using namespace lucene::util;
-                
-        // Lucene reader can do UTF-8 magic, so let's use it
-        FileReader file( path, DEFAULT_ENCODING ); 
-        
-        if ( file.reader->getStatus() == jstreams::Ok ) 
-            {
-                cpix_EPIState
-                    epiState;
-                cpix_init_EPIState(&epiState);
-        
-                wstring
-                    line;
-        
-                while (bufSize > 0 && maxWords > 0 && clgetline(file, line))
-                    {
-                        dst = cpix_getExcerptOfWText(dst,
-                                                     line.c_str(),
-                                                     &maxWords,
-                                                     &bufSize,
-                                                     &epiState);
-                    }
-            }
     }
 
-}
-
 using namespace std;
 using namespace Cpt;
 
@@ -139,7 +113,7 @@
                             }
                         if (fnd) return buffer - buffer0;
                         buffer = buffer + 1;
-                        if (buffer - buffer0 + len >= buffersize) return -1;
+                        if (buffer - buffer0 + len > buffersize) return -1;
                         }
                     return -1;
                     }
@@ -441,6 +415,7 @@
         bool hasStreamData = true;
         bool hasStreamStarted = false;
 
+
         char* writePointer;
         int bytesToWrite = 0;
         FILE* pdfReaderI;
@@ -451,7 +426,7 @@
             free (buffer);
             return -1;
             }
-        
+
         getTempFileName(path,tempFile);
         strcat(tempFile,"_compressedbin.data");
 
@@ -468,7 +443,7 @@
                  * Chances are there half of the word "stream" may get read to the buffer.
                  * if it happens, that particular two stream wont get index.
                  * Didnt implement it as of now. Because the logic requires lot of file pointer movement
-				 * and character comparison.
+				 * and character comparison.0
                  */
 
               
@@ -489,7 +464,7 @@
 
                     {
                     if ((streamStart - streamEnd) == 3)
-                    streamStart = -1;
+                        streamStart = -1;
                     }
 
                 if ((streamStart> 0) && (hasStreamStarted == false ))
@@ -525,7 +500,9 @@
                         }
                     else
                     bytesToWrite = actualRead-streamStart;
-                    fwrite(writePointer, 1,bytesToWrite, pdfReaderI);
+                    
+                    if(bytesToWrite >  0)
+                        fwrite(writePointer, 1,bytesToWrite, pdfReaderI);
 
                     }
                 else if (hasStreamStarted)
@@ -543,14 +520,16 @@
                         }
                     else
                     bytesToWrite = actualRead;
-
-                    fwrite(buffer, 1,bytesToWrite, pdfReaderI);
+                    
+                    if(bytesToWrite >  0)
+                        fwrite(buffer, 1,bytesToWrite, pdfReaderI);
 
                     }
 
                 }
             }
-        fclose(pdfReaderI);
+        if (pdfReaderI)
+            fclose(pdfReaderI); // coverty 121614
 
         free (buffer);
         return 1;
@@ -584,8 +563,10 @@
         else
             retf = -1;
         
-        fclose(UncompressedFile);
-        fclose(CompressedFile);
+        if (UncompressedFile) // coverty 
+            fclose(UncompressedFile);
+        if  (CompressedFile)
+            fclose(CompressedFile); // coverty
         remove(tempFile);
         return retf;
 
@@ -611,8 +592,8 @@
                 // memset(start,0,space);
                  if (file == 0)
                      {
-                         fclose(file);
-                         file = 0;
+
+                         free(outBuf);
                          return -1;
                      }
                  
@@ -635,10 +616,12 @@
                          if(ret == -1)
                              {
                              fclose(file);
-                             fclose(unCompressedFp);
-                             fclose(fileO);
                              free(outBuf);
                              file = 0;
+                             if (unCompressedFp)
+                                 fclose( unCompressedFp );
+                             if(fileO)
+                                 fclose( fileO );
                              remove(tempFile);
                              getTempFileName(path,tempFile);
                              strcat(tempFile,"_compressedbin.data");
@@ -657,7 +640,8 @@
                                  }
                              }
                          retVal = 0;
-                         fclose(unCompressedFp);
+                         if(unCompressedFp)
+                             fclose(unCompressedFp);
                    }
                  fclose(fileO);
                  remove(tempFile);
@@ -698,8 +682,8 @@
         const char DEFAULT_ENCODING[] = "UTF-8";
         char tempFile[254];
         FILE *fp;
-		wchar_t* excerpt = new wchar_t[MAX_EXCERPT_LENGTH];
-        
+		//wchar_t excerpt [MAX_EXCERPT_LENGTH];
+        wstring excerpt;
         convertPDFToText(path);
 
         // remove these fields before creating new values for them.
@@ -724,12 +708,8 @@
         
                 doc->add(newField.get());
                 newField.release();
-				        getExcerptOfFile(excerpt,
-                        tempFile,
-                        10, // max words
-                        sizeof(excerpt) / sizeof(wchar_t));
-						doc->setExcerpt(excerpt);
-						
+                getPDFExcerpt(tempFile,excerpt);
+                doc->setExcerpt(excerpt.c_str());
             }
         else
            {
@@ -744,7 +724,6 @@
 
         doc->setAppClass(CONTENTAPPCLASS);
         doc->setMimeType(LPDFFILE_MIMETYPE);
-        delete excerpt;
         GenericFileProcessor(doc,path);
         }
 
--- a/searchengine/cpix/cpix/src/idxdbdelta.cpp	Mon May 03 13:33:22 2010 +0300
+++ b/searchengine/cpix/cpix/src/idxdbdelta.cpp	Fri May 14 16:57:37 2010 +0300
@@ -153,6 +153,7 @@
                     rv = visitFile(path);
                 }
 
+            if (startPath_) {
             if (rv
                 && strcmp(path, startPath_) == 0
                 && newerMarkerFile_.length() > 0)
@@ -162,6 +163,7 @@
                     removePath(newerMarkerFile_.c_str());
                     rv = success_ == 0;
                 }
+            }
 
             return rv;
         }
--- a/searchengine/cpix/cpix/src/idxdbmgr.cpp	Mon May 03 13:33:22 2010 +0300
+++ b/searchengine/cpix/cpix/src/idxdbmgr.cpp	Fri May 14 16:57:37 2010 +0300
@@ -731,19 +731,22 @@
                                            newHandle);
                 storeReg();
 
-                std::vector<IIdxDbInfo>::iterator
-                    i = multiIdxDbs_.begin(),
-                    end = multiIdxDbs_.end();
-                for (; i!= end; ++i)
-                    {
-                        if (i->ptr() != NULL)
-                            {
-                                MultiIdxDb
-                                    * m = dynamic_cast<MultiIdxDb*>(i->ptr());
-                                m->suggestHndl(newHandle,
-                                               qualBaseAppClass);
-                            }
-                    }
+                std::vector<IIdxDbInfo>::iterator i, end;
+                    if (!(multiIdxDbs_.empty())) {
+	                    i = multiIdxDbs_.begin();
+	                    end = multiIdxDbs_.end();
+		                for (; i!= end; ++i)
+		                    {
+		                        if (i->ptr() != NULL)
+		                            {
+		                                MultiIdxDb
+		                                    * m = dynamic_cast<MultiIdxDb*>(i->ptr());
+		                                if ( m )
+		                                m->suggestHndl(newHandle,
+		                                               qualBaseAppClass);
+		                            }
+		                    }
+					}
             }
     }
 
@@ -786,8 +789,9 @@
 
                     storeReg();
 
-                    vector<IIdxDbInfo>::iterator
-                        i = multiIdxDbs_.begin(),
+                    vector<IIdxDbInfo>::iterator i, end;
+                    if (!(multiIdxDbs_.empty())) {
+                        i = multiIdxDbs_.begin(); //coverty 121612 121611
                         end = multiIdxDbs_.end();
                     for (; i != end; ++i)
                         {
@@ -795,6 +799,7 @@
                                 {
                                     MultiIdxDb
                                         * m = dynamic_cast<MultiIdxDb*>(i->ptr());
+                                    if ( m ){
                                     bool
                                         used = m->removeHndl(hndl);
 
@@ -802,8 +807,10 @@
                                         {
                                             idxDbs_[hndl].decRefCount();
                                         }
+                                    }
                                 }
                         }
+                    }
 
                     // At this point, all multiidx-es have lost their
                     // reference to the index in question
--- a/searchengine/cpix/cpix/src/qrytypes/addressqrytype.cpp	Mon May 03 13:33:22 2010 +0300
+++ b/searchengine/cpix/cpix/src/qrytypes/addressqrytype.cpp	Fri May 14 16:57:37 2010 +0300
@@ -199,6 +199,7 @@
                             else
                                 {
                                     idxSearcher->err_ = result.err_;
+                                    cpix_Hits_destroy(sorted);
                                 }
                         }
                     catch (...)
@@ -329,19 +330,17 @@
                                 {
                                     moveErrorCode(idxSearcher_,
                                                   qp);
-                                }
-                        
-                            cpix_QueryParser_destroy(qp);
+                                }                        
+                            
                         }
                     else
                         {
                             moveErrorCode(idxSearcher_,
                                           &result);
                         }
-
-                    cpix_BoostMap_destroy(boosts);
+                    cpix_QueryParser_destroy(qp);                    
                 }
-
+            cpix_BoostMap_destroy(boosts);
             return rv;
         }
 
@@ -378,16 +377,14 @@
                         {
                             moveErrorCode(idxSearcher_,
                                           qp);
-                        }
-
-                    cpix_QueryParser_destroy(qp);
+                        }                    
                 }
             else
                 {
                     moveErrorCode(idxSearcher_,
                                   &result);
                 }
-
+            cpix_QueryParser_destroy(qp);
             return rv;
         }
 
--- a/searchengine/cpix/cpixrotlog/src/cpixrotlog.cpp	Mon May 03 13:33:22 2010 +0300
+++ b/searchengine/cpix/cpixrotlog/src/cpixrotlog.cpp	Fri May 14 16:57:37 2010 +0300
@@ -257,14 +257,14 @@
                                      L"Failed to create-db IdxDb: %S\n",
                                      report);
                             cpix_ClearError(&result);
-                        }
-                    cpix_Analyzer_destroy(analyzer);
+                        }                    
                 }
             else
                 {
                     printf("Could not define volume %s\n",
                            SMS_QBASEAPPCLASS);
                 }
+            cpix_Analyzer_destroy(analyzer);
         }
     else
         {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/searchengine/cpix/tsrc/cpixsample/data/cpixsample_reg.rss	Fri May 14 16:57:37 2010 +0300
@@ -0,0 +1,21 @@
+/*
+============================================================================
+ Name        : cpixsample_reg.rss
+ Author      : Shankar
+ Copyright   : Your copyright notice
+ Description : This file contains all the resources for the cpixsample.
+============================================================================
+*/
+
+#include <appinfo.rh>
+
+UID2 KUidAppRegistrationResourceFile
+UID3 0xE46C866B
+
+RESOURCE APP_REGISTRATION_INFO
+    {
+    app_file = "cpixsample";
+    embeddability = KAppNotEmbeddable;
+    newfile = KAppDoesNotSupportNewFile;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/searchengine/cpix/tsrc/cpixsample/group/bld.inf	Fri May 14 16:57:37 2010 +0300
@@ -0,0 +1,12 @@
+/*
+============================================================================
+ Name        : bld.inf
+ Author      : Shankar
+ Copyright   : Your copyright notice
+ Description : This file provides the information required for building the
+               whole of a CPiXSample.
+============================================================================
+*/
+
+PRJ_MMPFILES
+cpixsample.mmp
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/searchengine/cpix/tsrc/cpixsample/group/cpixsample.mmp	Fri May 14 16:57:37 2010 +0300
@@ -0,0 +1,85 @@
+/*
+============================================================================
+ Name        : cpixsample.mmp
+ Author      : Shankar
+ Copyright   : Your copyright notice
+ Description : This is the project specification file for cpixsample.
+============================================================================
+*/
+
+TARGET          cpixsample.exe
+TARGETTYPE      exe
+UID             0x100039CE 0xE46C866B
+EPOCSTACKSIZE   0x10000         
+EPOCHEAPSIZE    0x50000 0xa00000 // From about 65KB to about 10 MB
+VENDORID        0
+
+SOURCEPATH      ..\data
+START RESOURCE  CPiXSample_reg.rss
+#ifdef WINSCW
+TARGETPATH      \private\10003a3f\apps
+#else
+TARGETPATH      \private\10003a3f\import\apps
+#endif
+END //RESOURCE
+
+SOURCEPATH      ..\src
+SOURCE          CPiXSample.cpp
+
+
+USERINCLUDE     ../../../../../searchsrv_plat/cpix_utility_api/inc
+USERINCLUDE     ../inc
+USERINCLUDE     ../../../cpix/inc/public
+// for white box tests
+USERINCLUDE     ../../../cpix/inc/private
+USERINCLUDE     ../../../../util/tsrc/itk/inc/public
+USERINCLUDE     ../../../../util/cpixtools/inc/public
+USERINCLUDE     ../../../../oss/cl/CLucene/src
+
+
+SYSTEMINCLUDE   \epoc32\include
+SYSTEMINCLUDE   \epoc32\include\stdapis
+
+SYSTEMINCLUDE   \epoc32\include\osextensions\stdapis
+SYSTEMINCLUDE   \epoc32\include\osextensions\stdapis\stlport
+SYSTEMINCLUDE   \epoc32\include\stdapis\stlport
+SYSTEMINCLUDE   \epoc32\include\osextensions\stdapis\glib-2.0
+
+// Using main() as entry point
+STATICLIBRARY   libcrt0.lib
+STATICLIBRARY   libcpix.lib
+STATICLIBRARY   libclucene.lib
+STATICLIBRARY   libstemmer.lib
+//STATICLIBRARY   libitk.lib
+STATICLIBRARY   libcpixtools.lib
+//STATICLIBRARY   libcpixxf.lib
+//STATICLIBRARY   libexif.lib
+//STATICLIBRARY   libid3.lib
+
+LIBRARY   		libpthread.lib
+LIBRARY         libz.lib // for libid3
+
+// libc and euser are always needed when using main() entry point
+LIBRARY           libc.lib
+LIBRARY           libglib.lib
+LIBRARY           libstdcpp.lib
+LIBRARY           libm.lib
+LIBRARY           euser.lib
+
+// For SPI 
+LIBRARY   efsrv.lib
+LIBRARY   exiflib.lib
+LIBRARY   MetaDataUtility.lib
+
+
+// No capabilities needed by this application
+CAPABILITY      AllFiles CommDD DiskAdmin DRM LocalServices Location MultimediaDD NetworkControl NetworkServices PowerMgmt ProtServ ReadDeviceData ReadUserData SurroundingsDD SwEvent TrustedUI UserEnvironment WriteDeviceData WriteUserData
+
+OPTION CW -wchar_t on
+OPTION GCCE -finput-charset=ISO-8859-1
+
+MACRO _WCHAR_T_DECLARED RVCT22_STATICS_WORKAROUND 
+
+#ifdef ENABLE_ABIV2_MODE
+DEBUGGABLE_UDEBONLY
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/searchengine/cpix/tsrc/cpixsample/sis/backup_registration.xml	Fri May 14 16:57:37 2010 +0300
@@ -0,0 +1,5 @@
+<?xml version="1.0" standalone="yes"?>
+<backup_registration>
+  <system_backup/>
+  <restore requires_reboot = "no"/>
+</backup_registration>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/searchengine/cpix/tsrc/cpixsample/sis/cpixsample_s60_3_x_v_1_0_0.pkg	Fri May 14 16:57:37 2010 +0300
@@ -0,0 +1,47 @@
+;
+; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description: 
+;
+; Installation file for cpixsample application
+;
+; This is an auto-generated PKG file by Carbide.
+; This file uses variables specific to Carbide builds that will not work
+; on command-line builds. If you want to use this generated PKG file from the
+; command-line tools you will need to modify the variables with the appropriate
+; values: $(EPOCROOT), $(PLATFORM), $(TARGET)
+;
+;Languages
+&EN
+
+;
+; UID is the app's UID
+;
+#{"cpixsample"},(0xE46C866B),1,0,0
+
+;Localised Vendor name
+%{"Vendor-EN"}
+
+;Unique Vendor name
+:"Vendor"
+
+; Supports Series 60 v 3.0
+[0x101F7961], 0, 0, 0, {"S60ProductID"}
+
+; Files to install
+; Symbols set up for the source location are Carbide.c++ specific symbols
+"$(EPOCROOT)epoc32\release\$(PLATFORM)\$(TARGET)\cpixsample.exe"             -"!:\sys\bin\cpixsample.exe"
+"$(EPOCROOT)epoc32\data\z\private\10003a3f\import\apps\cpixsample_reg.rsc"   -"!:\private\10003a3f\import\apps\cpixsample_reg.rsc"
+
+; required for application to be covered by backup/restore facility 
+"..\sis\backup_registration.xml"    -"!:\private\E46C866B\backup_registration.xml"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/searchengine/cpix/tsrc/cpixsample/src/cpixsample.cpp	Fri May 14 16:57:37 2010 +0300
@@ -0,0 +1,239 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+// INCLUDE FILES
+#include <stdio.h>
+#include <iostream.h>
+
+// This is a GCCE toolchain workaround needed when compiling with GCCE
+// and using main() entry point
+#ifdef __GCCE__
+#include <staticlibinit_gcce.h>
+#endif
+
+#include "cpixidxdb.h"
+#include "cpixdoc.h"
+#include "cpixsearch.h"
+#include "cpixidxdb.h"
+#include "rotlogger.h"
+#include "common/cpixlog.h"
+
+
+#define TEST_DOCUMENT_QBASEAPPCLASS "@0:root test document"
+#define TEST_DOCUMENT_INDEXDB_PATH "c:\\Data\\indexing\\test\\"
+
+#define LDOCUID1 L"document1"
+#define LDOCUID2 L"document2"
+
+
+#define FIELD_ALPHA L"Alpha"
+
+
+#define DOC1CONTENT L"mary had a little lamb its fleece was black as coal"
+#define DOC2CONTENT L"sri rama jeyam shankar.rajendran@yahoo.co.in www.google.com U.S.A. file.txt"
+
+
+// The term that will be present in multiple documents.
+#define SEARCH_TERM L"$prefix(\"yahoo\")"
+
+
+int testInit(cpix_Analyzer **analyzer_, cpix_IdxDb **idxDb_)
+    {
+    
+    cpix_Result result;
+    cpix_InitParams
+    * initParams = cpix_InitParams_create(&result);
+    
+    
+    if (cpix_Failed(&result))
+        {
+        printf("Failed to initialize Cpix\n");
+        return 0;
+        }
+
+    if (cpix_Failed(initParams))
+        {
+        printf("Failed to set max idle sec\n");
+        return 0;
+        }
+
+    cpix_init(&result,
+            initParams);
+
+    if ( !( *analyzer_ = cpix_Analyzer_create(&result,L"standard") ) )
+        {
+        printf("Analyzer could not be created \n");
+        return 0;
+        }
+    cpix_IdxDb_defineVolume(&result, 
+            TEST_DOCUMENT_QBASEAPPCLASS, 
+            TEST_DOCUMENT_INDEXDB_PATH);
+    if (cpix_Failed(&result))
+        {
+        printf("Failed to define test index db\n");
+        return 0;
+        }
+
+    *idxDb_ = cpix_IdxDb_openDb(&result,
+            TEST_DOCUMENT_QBASEAPPCLASS,
+            cpix_IDX_CREATE);
+    if (cpix_Failed(&result))
+        {
+        printf("Failed to open indexDb\n");
+        return 0;
+        }
+    return 1;
+    }
+
+int createDocument(const wchar_t* docUid, const wchar_t* data,cpix_Analyzer **analyzer_, cpix_IdxDb **idxDb_)
+    {
+    cpix_Document *doc;
+    cpix_Field field;
+    cpix_Result result;
+    
+    doc = cpix_Document_create(&result,docUid,NULL,      // app class
+            NULL,      // excerpt
+            NULL);     // mime type
+    if (cpix_Failed(&result))
+        {
+        printf("Failed to create a document\n");
+        return 0;
+        }
+
+    cpix_Field_initialize(&field,
+            FIELD_ALPHA,
+            data, 
+            cpix_STORE_YES |cpix_INDEX_TOKENIZED);
+
+    if (cpix_Failed(&field))
+        {
+        cpix_Document_destroy(doc);
+        printf("Failed to initialize the field \n");
+        return 0;
+        }
+    cpix_Document_add(doc,&field);
+    cpix_IdxDb_add(*idxDb_,doc,*analyzer_);
+
+    cpix_Document_destroy(doc);
+    cpix_IdxDb_flush(*idxDb_);
+    return 1;
+    }
+void cleanUp(cpix_Analyzer ** analyzer_, cpix_QueryParser ** queryParser_, cpix_Query ** query_ , cpix_IdxDb ** idxDb_ , cpix_Hits ** hits_)
+    {
+    cpix_Analyzer_destroy(*analyzer_);
+    analyzer_ = NULL;
+
+    cpix_QueryParser_destroy(*queryParser_);
+    queryParser_ = NULL;
+
+    cpix_Query_destroy(*query_);
+    query_ = NULL;
+
+    cpix_IdxDb_releaseDb(*idxDb_);
+    idxDb_ = NULL;
+
+    cpix_Hits_destroy(*hits_);
+    hits_ = NULL;
+
+    }
+
+void printHit(cpix_Document * doc)
+{
+    using namespace std;
+       
+    const wchar_t 
+        * value = cpix_Document_getFieldValue(doc,FIELD_ALPHA);
+    
+       
+    fprintf(stdout, 
+            "%S\n",
+            value);
+}
+
+void printHits(cpix_Hits    * hits)
+{
+    using namespace std;
+
+    int32_t
+        hitCount = cpix_Hits_length(hits);
+
+    if (cpix_Failed(hits))
+        {
+            printf("Hits failed\n");
+            return;
+        }
+
+    cout << "Number of hits: " << hitCount << endl;
+
+    cpix_Document
+        doc;
+
+    for (int32_t i = 0; i < hitCount; ++i)
+        {
+            cpix_Hits_doc(hits,
+                          i,
+                          &doc);
+
+            printHit(&doc);
+        }
+    logDbgMsg("Shankar Ha hahah");
+}
+
+int main(void)
+    {
+    
+        cpix_Result result;
+        cpix_Analyzer * analyzer_ = NULL ;
+        cpix_QueryParser * queryParser_;
+        cpix_Query * query_;
+        cpix_IdxDb * idxDb_ = NULL;
+        cpix_Hits * hits_;
+
+        printf("Press a character to exit!\n");
+
+        testInit(&analyzer_,&idxDb_);    
+        createDocument(LDOCUID1,DOC1CONTENT, &analyzer_,&idxDb_);
+        createDocument(LDOCUID2,DOC2CONTENT, &analyzer_,&idxDb_);
+                
+                        
+        queryParser_ = cpix_QueryParser_create(&result,
+                L"_aggregate",
+                analyzer_);
+        if (queryParser_ == NULL)
+            {
+            printf("Could not create query parser\n");
+            }                
+
+        query_ = cpix_QueryParser_parse(queryParser_, SEARCH_TERM);
+
+        if (cpix_Failed(queryParser_))
+            {
+            printf("Could not create query parser \n");
+            }
+
+        hits_ = cpix_IdxDb_search(idxDb_, query_);
+        printHits( hits_); 
+
+
+        int32_t hits_len = cpix_Hits_length(hits_); 
+        
+        cleanUp(&analyzer_, &queryParser_,&query_,&idxDb_,&hits_);
+
+        printf("Press a character to exit!\n");
+        int c = getchar();
+        return 0;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/searchengine/cpix/tsrc/cpixunittest/data/cpixunittestcorpus/query/query7.txt	Fri May 14 16:57:37 2010 +0300
@@ -0,0 +1,9 @@
+Infact 
+ 
+
+d decoration 
+lonely located
+
+work woried pride.
+
+race rice 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/searchengine/cpix/tsrc/cpixunittest/data/cpixunittestcorpus/query/query8.txt	Fri May 14 16:57:37 2010 +0300
@@ -0,0 +1,6 @@
+count c.
+detonate donate dosti dokha 
+love.
+rich rupees 
+intensions is idiot 
+culprit
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/searchengine/cpix/tsrc/cpixunittest/data/cpixunittestcorpus/query/query9.txt	Fri May 14 16:57:37 2010 +0300
@@ -0,0 +1,6 @@
+country coin consumer  culture 
+disko dk
+ line liver linear 
+rupa racet
+
+id idz 
\ No newline at end of file
--- a/searchengine/cpix/tsrc/cpixunittest/group/bld.inf	Mon May 03 13:33:22 2010 +0300
+++ b/searchengine/cpix/tsrc/cpixunittest/group/bld.inf	Fri May 14 16:57:37 2010 +0300
@@ -356,7 +356,9 @@
 "../data/cpixunittestcorpus/stem/fi/3.txt"                            "/epoc32/winscw/c/Data/cpixunittestcorpus/stem/fi/3.txt"
 "../data/cpixunittestcorpus/stem/fi/4.txt"                            "/epoc32/winscw/c/Data/cpixunittestcorpus/stem/fi/4.txt"
 
-
+"../data/cpixunittestcorpus/query/query7.txt"                            "/epoc32/winscw/c/Data/cpixunittestcorpus/query/query7.txt"
+"../data/cpixunittestcorpus/query/query8.txt"                            "/epoc32/winscw/c/Data/cpixunittestcorpus/query/query8.txt"
+"../data/cpixunittestcorpus/query/query9.txt"                            "/epoc32/winscw/c/Data/cpixunittestcorpus/query/query9.txt"
 
 PRJ_TESTMMPFILES
 cpixunittest.mmp
--- a/searchengine/cpix/tsrc/cpixunittest/inc/testutils.h	Mon May 03 13:33:22 2010 +0300
+++ b/searchengine/cpix/tsrc/cpixunittest/inc/testutils.h	Fri May 14 16:57:37 2010 +0300
@@ -27,6 +27,26 @@
 #include "cpixidxdb.h"
 #include "itk.h"
 
+
+/** 
+ * 
+ *Enum for the Kind of Field to be feteched
+ */
+
+enum Efield_type{
+    LCPIX_DOCUID,
+    LCPIX_APPCLASS,
+    LCPIX_UNTOKENIZED_APPCLASS,
+    LCPIX_EXCERPT,
+    LCPIX_MIMETYPE,
+    LCPIX_DEFAULT,
+    LCPIX_DEFAULT_PREFIX,
+    LCPIX_FILTERID,
+    LCPIX_QUADFILTER,
+    LCPIX_FILEPARSER,
+    LTERM_TEXT,
+    LTERM_DOCFREQ
+};
 /**
 
  * To be able to search for docuids, we need to process them (from
--- a/searchengine/cpix/tsrc/cpixunittest/src/negativetests.cpp	Mon May 03 13:33:22 2010 +0300
+++ b/searchengine/cpix/tsrc/cpixunittest/src/negativetests.cpp	Fri May 14 16:57:37 2010 +0300
@@ -213,7 +213,7 @@
     cpix_Query * query_;
     cpix_Hits * hits_;
     cpix_Result result;
-    int32_t hits_len;
+    int32_t hits_len=0;
     
     queryParser_ = cpix_QueryParser_create(&result,
                     L"_aggregate",
@@ -366,7 +366,7 @@
      
      testInit(&iCrptDb2_, cpix_IDX_OPEN, TEST_CORRUPTTEST2_QBASEAPPCLASS,
                  TEST_CORRUPTTEST2_INDEXDB_PATH);
-     int hit_search2;
+     int hit_search2=0;
      if(iCrptDb2_)
          hit_search2= search(&analyzer_,&iCrptDb2_, SEARCH_TERM);
      else
--- a/searchengine/cpix/tsrc/cpixunittest/src/querytest.cpp	Mon May 03 13:33:22 2010 +0300
+++ b/searchengine/cpix/tsrc/cpixunittest/src/querytest.cpp	Fri May 14 16:57:37 2010 +0300
@@ -84,7 +84,34 @@
         cpix_Analyzer_destroy(analyzer);
     }
 
-void testQuery(Itk::TestMgr * testMgr, const wchar_t *qryStr, int hitLen)
+void setupPrefixOptimiseQuery(Itk::TestMgr * testMgr)
+    {
+    cpix_Result
+            result;
+
+        cpix_IdxDb_dbgScrapAll(&result);
+        ITK_ASSERT(testMgr,
+                       cpix_Succeeded(&result),
+                       "Could not get rid of all test qbac-idx pairs");
+        std::auto_ptr<FileIdxUtil> util( new FileIdxUtil ); 
+        util->init(true); 
+        cpix_Analyzer* analyzer = cpix_Analyzer_create(&result, L"standard"); 
+        if ( cpix_Failed( &result) ) ITK_PANIC("Analyzer could not be created");
+       
+        util->indexFile( CORPUS_PATH "\\query\\query7.txt", analyzer, testMgr );
+               
+        util->flush();
+        util->indexFile( CORPUS_PATH "\\query\\query8.txt", analyzer, testMgr );
+               
+        util->flush();
+        util->indexFile( CORPUS_PATH "\\query\\query9.txt", analyzer, testMgr );
+               
+        util->flush();
+        cpix_Analyzer_destroy(analyzer);
+    
+    }
+
+void testQuery(Itk::TestMgr * testMgr, const wchar_t *qryStr, int hitLen, Efield_type ftype = LCPIX_DEFAULT)
 {
 cpix_Result
         result;
@@ -96,9 +123,16 @@
     cpix_Analyzer* analyzer = cpix_Analyzer_create(&result, L"standard"); 
     if ( cpix_Failed( &result) ) ITK_PANIC("Analyzer could not be created");
         cpix_QueryParser
-            * queryParser = cpix_QueryParser_create(&result,
-                                                    LCPIX_DEFAULT_FIELD,
-                                                    analyzer );
+            * queryParser = NULL;
+        switch(ftype)
+        {
+            case LCPIX_DEFAULT_PREFIX:
+                queryParser = cpix_QueryParser_create(&result,LCPIX_DEFAULT_PREFIX_FIELD,analyzer );
+                break;
+            case LCPIX_DEFAULT:
+                queryParser = cpix_QueryParser_create(&result,LCPIX_DEFAULT_FIELD,analyzer );
+                break;
+        }
         if (queryParser == NULL)
             {
                 cpix_Analyzer_destroy( analyzer );
@@ -148,7 +182,6 @@
 
 void CreatePlainQueryTest(Itk::TestMgr * testMgr) 
 {
-    bool val = true;
     setupPlainQuery(testMgr);
     testQuery(testMgr,L"Nokia", 2);
     testQuery(testMgr,L"iNdia", 1);
@@ -187,7 +220,6 @@
 
 void CreatePrefixQueryTest(Itk::TestMgr * testMgr) 
 {
-    bool val = true;
     setupPrefixQuery(testMgr);
     testQuery(testMgr,L"$prefix(\"new-notes\")", 1);
     testQuery(testMgr,L"$prefix(\"notes\")", 1);
@@ -232,6 +264,31 @@
     
 }
 
+void CreatePrefixOptimiseQueryTest(Itk::TestMgr * testMgr)
+    {
+    setupPrefixOptimiseQuery(testMgr);
+    testQuery(testMgr,L"i*", 3,LCPIX_DEFAULT_PREFIX );
+    testQuery(testMgr,L"in*", 2,LCPIX_DEFAULT_PREFIX );
+    testQuery(testMgr,L"i?", 3,LCPIX_DEFAULT_PREFIX );
+    testQuery(testMgr,L"id*", 2,LCPIX_DEFAULT_PREFIX );
+    testQuery(testMgr,L"c*", 2,LCPIX_DEFAULT_PREFIX );
+    testQuery(testMgr,L"c?", 2,LCPIX_DEFAULT_PREFIX );
+    testQuery(testMgr,L"cu*", 2,LCPIX_DEFAULT_PREFIX );
+    testQuery(testMgr,L"co*", 2,LCPIX_DEFAULT_PREFIX );
+    testQuery(testMgr,L"d*", 3,LCPIX_DEFAULT_PREFIX );
+    testQuery(testMgr,L"d?", 3,LCPIX_DEFAULT_PREFIX );
+    testQuery(testMgr,L"de*", 2,LCPIX_DEFAULT_PREFIX );
+    testQuery(testMgr,L"do*", 1,LCPIX_DEFAULT_PREFIX );
+    testQuery(testMgr,L"l*", 3,LCPIX_DEFAULT_PREFIX );
+    testQuery(testMgr,L"lo*", 2,LCPIX_DEFAULT_PREFIX );
+    testQuery(testMgr,L"li*", 1,LCPIX_DEFAULT_PREFIX );
+    testQuery(testMgr,L"wo*", 1,LCPIX_DEFAULT_PREFIX );
+    testQuery(testMgr,L"pr*", 1,LCPIX_DEFAULT_PREFIX );
+    testQuery(testMgr,L"r*", 3,LCPIX_DEFAULT_PREFIX );
+    testQuery(testMgr,L"ru*", 2,LCPIX_DEFAULT_PREFIX );
+    testQuery(testMgr,L"ra*", 2,LCPIX_DEFAULT_PREFIX );
+    testQuery(testMgr,L"ri*", 2,LCPIX_DEFAULT_PREFIX );
+    }
 Itk::TesterBase * CreateQueryTests()
 {
     using namespace Itk;
@@ -241,6 +298,7 @@
 
     qryTests->add("PlainQueryTest", &CreatePlainQueryTest);
     qryTests->add("PrefixQueryTest", &CreatePrefixQueryTest);
+    qryTests->add("PrefixOptimiseQueryTest", &CreatePrefixOptimiseQueryTest);
     
     return qryTests;
 }
--- a/searchengine/cpix/tsrc/cpixunittest/src/terms.cpp	Mon May 03 13:33:22 2010 +0300
+++ b/searchengine/cpix/tsrc/cpixunittest/src/terms.cpp	Fri May 14 16:57:37 2010 +0300
@@ -63,7 +63,7 @@
 	cpix_Result
 		result;
 	
-	int32_t hits_len;
+	int32_t hits_len=0;
 
 	cpix_IdxDb_dbgScrapAll(&result);
 
--- a/searchengine/oss/cl/clucene/src/clucene/analysis/standard/standardtokenizer.cpp	Mon May 03 13:33:22 2010 +0300
+++ b/searchengine/oss/cl/clucene/src/clucene/analysis/standard/standardtokenizer.cpp	Fri May 14 16:57:37 2010 +0300
@@ -255,9 +255,9 @@
 				case '\'':
 					str.appendChar('\'');
 					return ReadApostrophe(&str,t);
-				case '@':
-					str.appendChar('@');
-					return ReadAt(&str,t);
+//				case '@':
+//					str.appendChar('@');
+//					return ReadAt(&str,t);
 				case '&':
 					str.appendChar('&');
 					return ReadCompany(&str,t);
@@ -304,6 +304,7 @@
         ch = readChar();
         const bool dot = ch == '.';
         const bool dash = ch == '-';
+        //const bool at = ch == '@';
 
         if (!(ALNUM || UNDERSCORE || dot || dash)) {
           break;
@@ -322,8 +323,11 @@
           }
           break;
         }
+        
 
         str.appendChar(ch);
+            
+    
 
         prevWasDot = dot;
         prevWasDash = dash;
@@ -379,17 +383,25 @@
     }
     } /* End block-guard of strBuf */
 
-    if (!EOS) {
-      if (ch == '@' && str.len < LUCENE_MAX_WORD_LEN-1) {
-        str.appendChar('@');
-        return ReadAt(&str,t);
-      } else {
-        unReadChar();
-      }
-    }
+
 
-	return setToken(t,&str,CL_NS2(analysis,standard)::UNKNOWN
-			? forcedType : CL_NS2(analysis,standard)::HOST);
+//    if (!EOS) {
+//      if (ch == '@' && str.len < LUCENE_MAX_WORD_LEN-1) {
+//        str.appendChar('@');
+//        return ReadAt(&str,t);
+//      } else {
+//        unReadChar();
+//      } 
+    
+      if (!EOS) {
+            unReadChar();
+          }
+
+     
+    
+  return setToken(t,&str,CL_NS2(analysis,standard)::ALPHANUM);
+//	return setToken(t,&str,CL_NS2(analysis,standard)::UNKNOWN
+//			? forcedType : CL_NS2(analysis,standard)::HOST);
   }
 
   bool StandardTokenizer::ReadApostrophe(StringBuffer* _str, Token* t) {
--- a/searchengine/oss/cl/clucene/src/clucene/index/multireader.cpp	Mon May 03 13:33:22 2010 +0300
+++ b/searchengine/oss/cl/clucene/src/clucene/index/multireader.cpp	Fri May 14 16:57:37 2010 +0300
@@ -545,7 +545,7 @@
 	
 	//Check if the queue has elements
 	if (t != NULL && queue->size() > 0) {
-		next();
+		(void)next();
 	}
 }
 
--- a/searchengine/oss/cl/clucene/src/clucene/index/terms.h	Mon May 03 13:33:22 2010 +0300
+++ b/searchengine/oss/cl/clucene/src/clucene/index/terms.h	Fri May 14 16:57:37 2010 +0300
@@ -101,7 +101,7 @@
 	virtual Term* term(bool pointer){
 		Term* ret = term();
 		if ( !pointer )
-			ret->__cl_decref();
+			(void)ret->__cl_decref();
 		return ret;
 	}
 
--- a/searchengine/oss/cl/clucene/src/clucene/search/filteredtermenum.cpp	Mon May 03 13:33:22 2010 +0300
+++ b/searchengine/oss/cl/clucene/src/clucene/search/filteredtermenum.cpp	Fri May 14 16:57:37 2010 +0300
@@ -129,7 +129,7 @@
             _CLDECDELETE(currentTerm);
             currentTerm = _CL_POINTER(term);
         }else{
-            next();
+            (void)next();
 		}
     }
 
--- a/searchengine/oss/cl/clucene/src/clucene/search/multisearcher.cpp	Mon May 03 13:33:22 2010 +0300
+++ b/searchengine/oss/cl/clucene/src/clucene/search/multisearcher.cpp	Fri May 14 16:57:37 2010 +0300
@@ -190,6 +190,7 @@
 	  _CLDELETE(docs);
     }
 
+	if (hq) {
     int32_t hqlen = hq->size();
 	fieldDocs = _CL_NEWARRAY(FieldDoc*,hqlen);
 	for (j = hqlen - 1; j >= 0; j--)	  // put docs in array
@@ -200,6 +201,9 @@
     _CLDELETE(hq);
 
     return _CLNEW TopFieldDocs (totalHits, fieldDocs, hqlen, hqFields);
+	} else  {
+	   return _CLNEW TopFieldDocs(0, NULL, 0, NULL );
+	}
   }
 
   Query* MultiSearcher::rewrite(Query* original) {
--- a/searchengine/oss/cl/clucene/src/clucene/search/phrasequery.cpp	Mon May 03 13:33:22 2010 +0300
+++ b/searchengine/oss/cl/clucene/src/clucene/search/phrasequery.cpp	Fri May 14 16:57:37 2010 +0300
@@ -428,7 +428,7 @@
 
    
    Explanation* tfExpl = _CLNEW Explanation;
-   scorer(reader)->explain(doc, tfExpl);
+   (void)scorer(reader)->explain(doc, tfExpl);
    fieldExpl->addDetail(tfExpl);
    fieldExpl->addDetail(idfExpl);
 
--- a/searchengine/oss/cl/clucene/src/clucene/search/wildcardtermenum.cpp	Mon May 03 13:33:22 2010 +0300
+++ b/searchengine/oss/cl/clucene/src/clucene/search/wildcardtermenum.cpp	Fri May 14 16:57:37 2010 +0300
@@ -29,8 +29,8 @@
 		fieldMatch(false),
 		_endEnum(false)
     {
-       
-		pre = stringDuplicate(term->text());
+        if ( term )
+            pre = stringDuplicate(term->text());
 
 		const TCHAR* sidx = _tcschr( pre, LUCENE_WILDCARDTERMENUM_WILDCARD_STRING );
 		const TCHAR* cidx = _tcschr( pre, LUCENE_WILDCARDTERMENUM_WILDCARD_CHAR );
@@ -42,7 +42,8 @@
 		CND_PRECONDITION(tidx != NULL, "tidx==NULL");
 		int32_t idx = (int32_t)(tidx - pre);
 		preLen = idx;
-		CND_PRECONDITION(preLen<term->textLength(), "preLen >= term->textLength()");
+		if ( term )
+		    CND_PRECONDITION(preLen<term->textLength(), "preLen >= term->textLength()");
 		pre[preLen]=0; //trim end
 
 		Term* t = _CLNEW Term(__term, pre);
--- a/searchengine/oss/cl/clucene/src/clucene/store/fsdirectory.cpp	Mon May 03 13:33:22 2010 +0300
+++ b/searchengine/oss/cl/clucene/src/clucene/store/fsdirectory.cpp	Fri May 14 16:57:37 2010 +0300
@@ -87,7 +87,8 @@
 	  }
 
 	  //Store the file length
-	  handle->_length = fileSize(handle->fhandle);
+	  if ( handle->fhandle > 0 )
+	      handle->_length = fileSize(handle->fhandle);
 	  handle->_fpos = 0;
 	  this->_pos = 0;
   }
@@ -275,7 +276,8 @@
    useMMap(false)
   {
   	_realpath(path,directory);//set a realpath so that if we change directory, we can still function
-  	if ( !directory || !*directory ){
+  	//if ( !directory || !*directory ){
+  	if ( !*directory ){
   		strcpy(directory,path);	
   	}
     
@@ -287,8 +289,8 @@
     }
     
     // Ensure that lockDir exists and is a directory.
-		struct fileStat fstat;
-	  if ( fileStat(tmplockdir,&fstat) != 0 ) {
+		struct fileStat fstat = { 0 };
+	  if ( (tmplockdir) && (fileStat(tmplockdir,&fstat) != 0)  ) {
 			//todo: should construct directory using _mkdirs... have to write replacement
 			if ( _mkdir(lockDir) == -1 ){
 				_CLTHROWA(CL_ERR_IO,"Cannot create temp directory"); //todo: make richer error
@@ -401,8 +403,8 @@
 
     while ( fl != NULL ){
       strcpy(pathP,fl->d_name);
-      fileStat(path,&buf);
-      if ( !(buf.st_mode & S_IFDIR) ) {
+      //fileStat(path,&buf);
+      if ( (fileStat(path,&buf) == 0) && (!(buf.st_mode & S_IFDIR)) ) {
         names->push_back( fl->d_name );
       }
       fl = readdir(dir);
@@ -464,7 +466,7 @@
     struct fileStat buf;
     char buffer[CL_MAX_DIR];
 	_snprintf(buffer,CL_MAX_DIR,"%s%s%s",dir,PATH_DELIMITERA,name);
-    fileStat( buffer, &buf );
+    (void)fileStat( buffer, &buf );
     return buf.st_mtime;
   }
 
@@ -476,7 +478,7 @@
     int32_t r = _open(buffer, O_RDWR, _S_IWRITE);
 	if ( r < 0 )
 		_CLTHROWA(CL_ERR_IO,"IO Error while touching file");
-	_close(r);
+	(void)_close(r);
   }
 
   int64_t FSDirectory::fileLength(const char* name) const {
@@ -689,7 +691,7 @@
 	if ( r < 0 )
 	  return false;
 	else{
-	  _close(r);
+	  (void)_close(r);
 	  return true;
 	}
 
@@ -703,7 +705,7 @@
   void FSDirectory::FSLock::release() {
     if (disableLocks)
           return;
-    _unlink( lockFile );
+    (void)_unlink( lockFile );
   }
 
   TCHAR* FSDirectory::toString() const{
--- a/searchengine/oss/cl/clucene/src/clucene/util/arrays.h	Mon May 03 13:33:22 2010 +0300
+++ b/searchengine/oss/cl/clucene/src/clucene/util/arrays.h	Fri May 14 16:57:37 2010 +0300
@@ -156,7 +156,8 @@
 
 			_itr1 itr1 = val1->begin();
 			_itr2 itr2 = val2->begin();
-			while ( --size >= 0 ){
+			//while ( --size >= 0 ){
+			for(int i=0; i< size; i++){
 				if ( !comp(*itr1,*itr2) )
 					return false;
 				itr1++;
--- a/searchengine/oss/cl/clucene/src/clucene/util/fileinputstream.cpp	Mon May 03 13:33:22 2010 +0300
+++ b/searchengine/oss/cl/clucene/src/clucene/util/fileinputstream.cpp	Fri May 14 16:57:37 2010 +0300
@@ -134,6 +134,7 @@
             FileInputStream::~FileInputStream()
                 {
                 char tempFile[252];
+                char tempFile1[252];
                 
                 if (file)
                     {
@@ -149,15 +150,24 @@
                     {
                         strcpy(tempFile,temp);
                         strcat(tempFile,"_lock");
-                        if(access(tempFile,F_OK) == 0)
+                        strcpy(tempFile1,tempFile);
+                        strcat(tempFile1,"_1");
+                        
+                        if((access(tempFile,F_OK) != 0) && (access(tempFile1,F_OK) != 0))
                             {
-                                remove(temp);
+                            FILE *fp = fopen(tempFile,"w");
+                            fclose(fp);
+                            }
+                        else if(access(tempFile,F_OK) == 0)
+                            {
                                 remove(tempFile);
+                                FILE *fp = fopen(tempFile1,"w");
+                                fclose(fp);
                             }
                         else
                             {
-                                FILE *fp = fopen(tempFile,"w");
-                                fclose(fp);
+                                remove(temp);
+                                remove(tempFile1);
                             }
                     }
 
@@ -189,9 +199,7 @@
 
                 if (file == 0  )
                     {
-                        fclose(file);
-                        file = 0;
-                        return -1;
+                     return -1;
                     }
                 // read into the buffer
                 int32_t nwritten = fread(start, 1, space, file);
--- a/searchengine/oss/sb/snowball/libstemmer/libstemmer.c	Mon May 03 13:33:22 2010 +0300
+++ b/searchengine/oss/sb/snowball/libstemmer/libstemmer.c	Fri May 14 16:57:37 2010 +0300
@@ -77,12 +77,20 @@
 	    (struct sb_stemmer *) malloc(sizeof(struct sb_stemmer));
     if (stemmer == NULL) return NULL;
     enc = sb_getenc(charenc);
-    if (enc == ENC_UNKNOWN) return NULL;
+    if (enc == ENC_UNKNOWN) 
+        {
+        sb_stemmer_delete(stemmer);
+        return NULL;
+        }
 
     for (module = modules; module->name != 0; module++) {
 	if (strcmp(module->name, algorithm) == 0 && module->enc == enc) break;
     }
-    if (module->name == NULL) return NULL;
+    if (module->name == NULL) 
+        {
+        sb_stemmer_delete(stemmer);
+        return NULL;
+        }
     
     stemmer->create = module->create;
     stemmer->close = module->close;
--- a/searchengine/util/cpixtools/src/cpixfstools.cpp	Mon May 03 13:33:22 2010 +0300
+++ b/searchengine/util/cpixtools/src/cpixfstools.cpp	Fri May 14 16:57:37 2010 +0300
@@ -205,7 +205,7 @@
 
         if (getparent(parent, sizeof(parent), path) >= 0) {
             // make the parent
-            mkdirs(parent, mod); 
+            (void)mkdirs(parent, mod); 
         } 
         
         return mkdir(path, mod);
--- a/searcher/searchserver/group/searchserver.mmp	Mon May 03 13:33:22 2010 +0300
+++ b/searcher/searchserver/group/searchserver.mmp	Fri May 14 16:57:37 2010 +0300
@@ -48,7 +48,6 @@
 SOURCE            CSearchServerSession.cpp
 SOURCE            CCPixIdxDb.cpp
 SOURCE            CCPixSearch.cpp
-SOURCE            SearchServerTesting.cpp
 SOURCE			  CSearchServerSubSession.cpp
 SOURCE			  CHeartBeatTimer.cpp
 SOURCE			  CCPixAsyncronizer.cpp
--- a/searcher/searchserver/src/ccpixidxdb.cpp	Mon May 03 13:33:22 2010 +0300
+++ b/searcher/searchserver/src/ccpixidxdb.cpp	Fri May 14 16:57:37 2010 +0300
@@ -478,7 +478,6 @@
 	if (!doc)
 		{
 		SearchServerHelper::LogErrorL(*result.err_);
-		cpix_ClearError(doc);
 		User::Leave(KErrCannotCreateDocument);
 		}
 	// document created, push to cleanup stack.
--- a/searcher/searchserver/src/csearchserver.cpp	Mon May 03 13:33:22 2010 +0300
+++ b/searcher/searchserver/src/csearchserver.cpp	Fri May 14 16:57:37 2010 +0300
@@ -24,7 +24,6 @@
 #include "SearchServerCommon.h"
 #include "CSearchServerSession.h"
 #include "CCPixIdxDb.h"
-#include "SearchServerTesting.h"
 #include "CHouseKeepingHandler.h"
 #include "SearchServerLogger.h"
 #include "OstTraceDefinitions.h"
@@ -306,21 +305,10 @@
 
 	// Install active scheduler
 	CActiveScheduler::Install(activeScheduler);
-	
-#ifdef PROVIDE_TESTING_UTILITY
-	CSearchServerTesting* testing = new ( ELeave ) CSearchServerTesting; \
-	CleanupStack::PushL( testing ); \
-	testing->ConstructL();
-	testing->StartL();
-#endif
 
 	// Construct server
 	CSearchServer* server = CSearchServer::NewLC();
 	
-#ifdef PROVIDE_TESTING_UTILITY
-	testing->SetServer( server ); 
-#endif 
-	
     // Rename the thread.
     User::RenameThread(KSearchServerName);        
     RProcess::Rendezvous(KErrNone);           
@@ -352,11 +340,6 @@
 	
 	// Cleanup
 	CleanupStack::PopAndDestroy( server );
-	
-#ifdef PROVIDE_TESTING_UTILITY
-	CleanupStack::PopAndDestroy( testing ); 
-#endif // PROVIDE_TESTING_UTILITY
-
 	CleanupStack::PopAndDestroy( activeScheduler );
 	}
 
--- a/searcher/searchserver/src/searchservertesting.cpp	Mon May 03 13:33:22 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,473 +0,0 @@
-/*
-* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: 
-*
-*/
-
-#include "SearchServerConfiguration.h"
-
-#include "SearchServerTesting.h"
-#include "SearchServerLogger.h"
-
-#include "CSearchServer.h"
-
-#ifdef PROVIDE_TESTING_UTILITY
-
-
-#include <e32math.h>
-
-TPerformanceRecord::TPerformanceRecord() 
-: iMinimum(0x7fffffff), 
-  iAverage(0),
-  iVarEst(0),
-  iPeak(0),  
-  iSampleCount(0) 
-	{
-
-	}
-
-void TPerformanceRecord::Record( TInt aValue )
-	{
-	iAverage = ( iAverage ) * ( (double)iSampleCount / (double)( iSampleCount + 1. ) ) 
-					   + ( ( double ) aValue ) / ( iSampleCount + 1. );
-	iVarEst = ( iVarEst ) * ( (double)iSampleCount / (double)( iSampleCount + 1. ) ) 
-					   + ( ( aValue - iAverage ) * ( aValue - iAverage ) ) / ( iSampleCount + 1. );
-	iPeak = Max( iPeak, aValue );
-	iMinimum = Min( iMinimum, aValue );
-	iSampleCount++; 
-	}
-
-void TPerformanceRecord::Record( TPerformanceRecord& aRecord )
-	{
-	iAverage = ((iAverage*iSampleCount) + (aRecord.iAverage*aRecord.iSampleCount)) / (iSampleCount+aRecord.iSampleCount); 
-	iVarEst = ((iVarEst*iSampleCount) + (aRecord.iVarEst*aRecord.iSampleCount)) / (iSampleCount+aRecord.iSampleCount); 
-	iPeak = Max( iPeak, aRecord.iPeak ); 
-	iMinimum = Min( iPeak, aRecord.iPeak ); 
-	iSampleCount += aRecord.iSampleCount; 
-	}
-
-void TPerformanceRecord::ToStringL( TDes& aString, const TDesC& aUnit, TInt aScale )
-	{
-	TReal sd;
-	Math::Sqrt( sd, iVarEst );
-	aString.AppendNum( iMinimum / aScale );
-	aString.Append( _L( " " ) ); 
-	aString.Append( aUnit );
-	aString.Append( _L( " > ~") );
-	aString.AppendNum( (TInt)(iAverage / aScale) );
-	aString.Append( _L( "+-" ) ); 
-	aString.AppendNum( (TInt)(sd / aScale) ); 
-	aString.Append( _L( " " ) ); 
-	aString.Append( aUnit ); 
-	aString.Append( _L( " < ") );
-	aString.AppendNum( iPeak / aScale );
-	aString.Append( _L( " " ) ); 
-	aString.Append( aUnit ); 
-	aString.Append( _L( " (n=") );
-	aString.AppendNum( iSampleCount );
-	aString.Append( _L( ")") );
-	}
-
-int MemoryRecorder::iInstances = 0; 
-
-MemoryRecorder* MemoryRecorder::NewL()
-	{
-	MemoryRecorder* self = new ( ELeave ) MemoryRecorder(); 	
-	CleanupStack::PushL( self ); 
-	self->ConstructL();
-	CleanupStack::Pop( self ); 
-	return self; 
-	}
-
-MemoryRecorder::MemoryRecorder()
-:  	iSemaphore(), 
-	iWorkerThread(),
- 	iAbandon( EFalse  ), 
- 	iRecord( NULL )
- 	{
-	}
-
-void MemoryRecorder::ConstructL()
-	{
-	TThreadFunction function = MemoryRecorder::ThreadFunction; 
-	User::LeaveIfError( iSemaphore.CreateLocal( 0 ) ); 
-	TBuf<64> buf; 
-	buf.Append( _L( "MemUsgRecord" ) ); 
-	buf.AppendNum( iInstances++ ); 
-	User::LeaveIfError( iWorkerThread.Create( buf, function, 2048, NULL, this ) ); 
-	// Ownerhips is safely transferred to the worker thread
-	// Go thread go. It will get stuck in the semaphore
-	iWorkerThread.Resume(); 
-	}
-
-MemoryRecorder::~MemoryRecorder()
-	{
-	if ( iRecord ) 
-		{
-		// We are still recording!
-		iSemaphore.Wait(); // need to do this to access the iRecord
-		delete iRecord; 
-		// And the thread is stuck 
-		// Semaphore is in 0
-		}
-	
-	iAbandon = ETrue; // Thread, let's go and die
-	iSemaphore.Signal(); // Release thread and kill semaphore
-
-	TRequestStatus status; 
-	iWorkerThread.Logon( status );
-	User::WaitForRequest( status ); 
-
-	iWorkerThread.Close(); 
-	iSemaphore.Close(); 
-	}
-
-void MemoryRecorder::StartL( TInt aRecordingIntervalMs ) 
-	{
-	if ( iRecord ) 
-		{
-		User::Leave( KErrNotReady ); 
-		}
-	
-	iIntervalMs = aRecordingIntervalMs;
-	iRecord = new TPerformanceRecord(); 
-	Record(); 
-	iSemaphore.Signal(); // Go thread go 
-	
-	// Must not touch record from this thread anymore
-	}
-
-TBool MemoryRecorder::IsActive() 
-	{
-	return iRecord != 0; 
-	}
-
-TPerformanceRecord* MemoryRecorder::Finish()
-	{
-	if ( !iRecord ) 
-		{
-		User::Panic( _L( "MemUsageRecord" ), 1 ); 
-		}
-	iSemaphore.Wait(); // Thread, stop
-	// Can touch record from this thread now 
-	Record(); 
-	TPerformanceRecord* ret = iRecord;
-	iRecord = NULL; 
-	return ret; 
-	}
-
-void MemoryRecorder::Record()
-	{
-    TInt 
-        largestBlock;
-    TInt 
-        mem = User::Heap().Size() - User::Heap().Available(largestBlock);
-    
-    iRecord->Record( mem ); 
-	}
-
-void MemoryRecorder::Work()
-	{
-	while (true) 
-		{
-		iSemaphore.Wait();
-		// Condition: iAbandon == ETrue || iRecord != NULL 
-		if ( iAbandon ) {
-			break; // Quit execution
-		}
-		Record(); 
-		iSemaphore.Signal();
-
-		User::After( iIntervalMs * 1000 );
-		}
-	}
-
-	
-TInt MemoryRecorder::ThreadFunction(void *aThis)
-	{	
-	(reinterpret_cast<MemoryRecorder*>(aThis))->Work();
-	return KErrNone;
-	}
-
-#endif // 
-
-
-#ifdef LOG_PERIODIC_MEMORY_USAGE
-
-CMemoryLogger::CMemoryLogger() 
-	{
-	}
-
-CMemoryLogger::~CMemoryLogger() 
-	{
-	//iPeriodic->Cancel(); 
-	delete iPeriodic;
-	if ( iRecorder ) 
-		{
-		iRecorder->Close();
-		}
-	}
-
-	
-void CMemoryLogger::StartL()
-	{
-	TCallBack callback(CMemoryLogger::RunThisL, this);
-	iPeriodic = CPeriodic::NewL( CActive::EPriorityNormal ); 
-	iPeriodic->Start( TTimeIntervalMicroSeconds32( KMemoryLoggingIntervalMs*1000 ), 
-					  TTimeIntervalMicroSeconds32( KMemoryLoggingIntervalMs*1000 ), 
-					  callback ); 
-
-	iRecorder = RMemoryRecorder::NewL(); 
-	iRecorder->StartL( KMemoryRecordingIntervalMs );
-	}
-	
-void CMemoryLogger::Stop()
-	{
-	iPeriodic->Cancel(); 
-	delete iPeriodic; 
-	iPeriodic = NULL; 
-	iRecorder->Close(); 
-	iRecorder = NULL; 
-	}
-	
-void CMemoryLogger::RunL()
-	{
-	TPerformanceRecord* record = iRecorder->Finish(); 
-
-	CleanupStack::PushL( record ); 
-	
-	TBuf<256> buf; 
-	buf.Append( _L("SearchServer ") );
-	record->ToStringL( buf ); 
-	PERFORMANCE_LOG( buf );
-	
-	CleanupStack::PopAndDestroy( record ); 				
-	
-	iRecorder->StartL( KMemoryRecordingIntervalMs );
-	}
-	
-TInt CMemoryLogger::RunThisL(void *aThis)
-	{
-	(reinterpret_cast<CMemoryLogger*>(aThis))->RunL(); 
-	return KErrNone; 
-	}
-
-#endif
-
-#ifdef PROVIDE_TESTING_UTILITY
-
-
-TFunctionPerformanceEntry::TFunctionPerformanceEntry( const TDesC& aId )
-	{
-	iId = aId; 
-	}
-
-CSearchServerTesting* CSearchServerTesting::iInstance = NULL;
-
-CSearchServerTesting* CSearchServerTesting::Instance()
-	{
-	return iInstance; 
-	}
-	
-CSearchServerTesting::CSearchServerTesting()
-:	iRecorder( 0 ),
-	iServer( 0 ),
-	iPeriodic( 0 ),
-	iEntries()
-	{
-	iInstance = this;
-	}
-
-void CSearchServerTesting::ConstructL()
-	{
-	User::LeaveIfError( iFs.Connect() ); 
-	iPeriodic = CPeriodic::NewL( CActive::EPriorityLow ); 
-	iRecorder = MemoryRecorder::NewL();
-	}
-
-CSearchServerTesting::~CSearchServerTesting()
-	{
-	Stop(); 
-	
-	delete iRecorder;
-	
-	iEntries.Reset(); 
-	iEntries.Close(); 
-	
-	iInstance = NULL;
-	delete iPeriodic;
-	
-	iPeriodic = NULL; 
-	iFs.Close(); 
-	}
-	
-void CSearchServerTesting::SetServer( CSearchServer* aServer )
-	{
-	iServer = aServer; 
-	}
-
-void CSearchServerTesting::Reset()
-	{
-	iEntries.Reset(); 
-	}
-
-TFunctionPerformanceEntry& CSearchServerTesting::FunctionEntry( const TDesC& aFunctionId )
-	{
-	for ( TInt i = 0; i < iEntries.Count(); i++ ) 
-		{
-		if ( iEntries[i].iId == aFunctionId )
-			{
-			return iEntries[i]; 
-			}
-		}
-	
-	TFunctionPerformanceEntry entry( aFunctionId );
-	TRAP_IGNORE(iEntries.AppendL( entry )); 
-	
-	return iEntries[iEntries.Count()-1]; 
-	}
-
-void CSearchServerTesting::StartL()
-	{
-	User::LeaveIfError( iFs.Connect() ); 
-	TCallBack callback( CSearchServerTesting::RunThisL, this );
-	iPeriodic->Start( TTimeIntervalMicroSeconds32( TSignalCheckIntervalMs*1000 ), 
-					  TTimeIntervalMicroSeconds32( TSignalCheckIntervalMs*1000 ), 
-					  callback ); 
-}
-
-void CSearchServerTesting::Stop()
-	{
-	iPeriodic->Cancel(); 
-	}
-
-void CSearchServerTesting::RunL()
-	{
-	TEntry entry; 
-
-	if ( iFs.Entry( KStartRecordingSignalFile, entry ) == KErrNone  ) 
-		{
-		iFs.Delete( KStartRecordingSignalFile );
-		StartRecordingL(); 
-		}
-
-	if ( iFs.Entry( KStopRecordingSignalFile, entry ) == KErrNone  ) 
-		{
-		iFs.Delete( KStopRecordingSignalFile );
-		StopRecording(); 
-		}
-
-	if ( iFs.Entry( KDumpRecordSignalFile, entry ) == KErrNone  ) 
-		{
-		iFs.Delete( KDumpRecordSignalFile );
-		DumpRecordL(); 
-		}
-
-	if ( iFs.Entry( KShutdownSignalFile, entry ) == KErrNone ) 
-		{
-		iFs.Delete( KShutdownSignalFile );
-		ShutdownL(); 
-		}
-	}
-
-TInt CSearchServerTesting::RunThisL(void *aThis)
-	{
-	(reinterpret_cast<CSearchServerTesting*>(aThis))->RunL(); 
-	return KErrNone; 
-	}
-
-void CSearchServerTesting::ShutdownL()
-	{
-	if ( iServer ) 
-		{
-		iServer->ShutDown();
-		}
-	}
-	
-void CSearchServerTesting::StartRecordingL()
-	{
-	if ( !iRecorder->IsActive() )
-		{
-		iRecorder->StartL( KMemoryRecordingIntervalMs ); 
-		}
-	}
-
-void CSearchServerTesting::StopRecording()
-	{
-	if ( iRecorder->IsActive() )
-		{
-        TPerformanceRecord* record;
-        record = iRecorder->Finish();
-		delete record; 
-		}
-	}
-	
-
-void CSearchServerTesting::DumpRecordL()
-	{
-	if ( !iRecorder->IsActive() ) return; // not active
-
-	TPerformanceRecord* record = iRecorder->Finish();
-	CleanupStack::PushL( record ); 
-
-	HBufC8* buf = HBufC8::NewLC( 2048 ); 
-	
-	RFile file;
-	TBool created = EFalse; 
-	if ( file.Open( iFs, KServerRecordFile, EFileWrite ) == KErrNotFound ) 
-		{
-		User::LeaveIfError( file.Create( iFs, KServerRecordFile, EFileWrite ) );
-		created = ETrue; 
-		}
-	CleanupClosePushL( file ); 
-
-	TInt end = 0;
-	file.Seek( ESeekEnd, end );
-	
-	if ( created ) 
-		{
-		buf->Des().Append( _L8("heap min ; heap aver; heap peak\n" ) );
-		file.Write( *buf ); 
-		buf->Des().Zero();
-		}
-	
-	buf->Des().AppendNum( record->iMinimum ); 
-	
-	TInt spaces = Max( 0, 9 - buf->Length() );
-	if ( spaces ) buf->Des().AppendFill( ' ', spaces );
-	buf->Des().Append( _L8("; " ) );
-	buf->Des().AppendNum( record->iAverage ); 
-	
-	spaces = Max( 0, 20 - buf->Length() );
-	if ( spaces ) buf->Des().AppendFill( ' ', spaces );
-	buf->Des().Append( _L8("; " ) );
-	buf->Des().AppendNum( record->iPeak ); 
-	
-	buf->Des().Append( _L8("\n" ) );
-	file.Write( *buf ); 
-	file.Flush();
-	
-	CleanupStack::PopAndDestroy(); // file
-	CleanupStack::PopAndDestroy( buf ); 
-	CleanupStack::PopAndDestroy( record ); 
-	
-	Reset(); 
-	StartRecordingL(); 
-	}
-
-
-	
-#endif  // PROVIDE_TESTING_UTILITY
-
-
--- a/searchsrv_plat/cpix_framework_api/inc/mindexingpluginobserver.h	Mon May 03 13:33:22 2010 +0300
+++ b/searchsrv_plat/cpix_framework_api/inc/mindexingpluginobserver.h	Fri May 14 16:57:37 2010 +0300
@@ -55,8 +55,9 @@
 	 *
 	 * @param aPlugin the plugin object that calls this function 
 	 * @param aQualifiedBaseAppClass database to harvest
+	 * @param aRemovePersist if plugin wants to remove from harvesting queue as well as config to be saved
 	 */
-	virtual void RemoveHarvestingQueue(CIndexingPlugin* aPlugin, const TDesC& aQualifiedBaseAppClass) = 0;
+	virtual void RemoveHarvestingQueue(CIndexingPlugin* aPlugin, const TDesC& aQualifiedBaseAppClass,TBool aRemovePersist = EFalse) = 0;
 
 	/**
 	 * A pure virtual method which is called by the plug-in when it has ended harvesting
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sis/cpixsearch_stub.pkg	Fri May 14 16:57:37 2010 +0300
@@ -0,0 +1,29 @@
+;
+; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description: 
+;
+
+
+
+;Languages
+&EN
+
+#{"CPix Search"},(0x2001F6FB),1,0,0, TYPE=SA
+
+; Supports Series 60 v 3.0
+[0x101F7961], 0, 0, 0, {"S60ProductID"}
+
+; Vendor names
+%{"Nokia"}
+:"Nokia"
Binary file sis/cpixsearch_stub.sis has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sis/makestubsis.bat	Fri May 14 16:57:37 2010 +0300
@@ -0,0 +1,16 @@
+@rem
+@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description: 
+@rem
+makesis -s cpixsearch_stub.pkg cpixsearch_stub.sis
\ No newline at end of file