LCOV - code coverage report
Current view: directory - extensions/spellcheck/hunspell/src - mozHunspellDirProvider.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 46 13 28.3 %
Date: 2012-06-02 Functions: 11 5 45.5 %

       1                 : /******* BEGIN LICENSE BLOCK *******
       2                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       3                 :  * 
       4                 :  * The contents of this file are subject to the Mozilla Public License Version
       5                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       6                 :  * the License. You may obtain a copy of the License at
       7                 :  * http://www.mozilla.org/MPL/
       8                 :  * 
       9                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      10                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      11                 :  * for the specific language governing rights and limitations under the
      12                 :  * License.
      13                 :  * 
      14                 :  * The Initial Developers of the Original Code are Kevin Hendricks (MySpell)
      15                 :  * and László Németh (Hunspell). Portions created by the Initial Developers
      16                 :  * are Copyright (C) 2002-2005 the Initial Developers. All Rights Reserved.
      17                 :  * 
      18                 :  * Contributor(s): Benjamin Smedberg (benjamin@smedbergs.us) (Original Code)
      19                 :  *                 László Németh (nemethl@gyorsposta.hu)
      20                 :  *                 Ryan VanderMeulen (ryanvm@gmail.com)
      21                 :  * 
      22                 :  * Alternatively, the contents of this file may be used under the terms of
      23                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
      24                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      25                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      26                 :  * of those above. If you wish to allow use of your version of this file only
      27                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      28                 :  * use your version of this file under the terms of the MPL, indicate your
      29                 :  * decision by deleting the provisions above and replace them with the notice
      30                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      31                 :  * the provisions above, a recipient may use your version of this file under
      32                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      33                 :  *
      34                 :  ******* END LICENSE BLOCK *******/
      35                 : 
      36                 : #include "mozHunspellDirProvider.h"
      37                 : #include "nsXULAppAPI.h"
      38                 : #include "nsString.h"
      39                 : 
      40                 : #include "mozISpellCheckingEngine.h"
      41                 : #include "nsICategoryManager.h"
      42                 : 
      43           51189 : NS_IMPL_ISUPPORTS2(mozHunspellDirProvider,
      44                 :                    nsIDirectoryServiceProvider,
      45                 :                    nsIDirectoryServiceProvider2)
      46                 : 
      47                 : NS_IMETHODIMP
      48            9787 : mozHunspellDirProvider::GetFile(const char *aKey, bool *aPersist,
      49                 :                                nsIFile* *aResult)
      50                 : {
      51            9787 :   return NS_ERROR_FAILURE;
      52                 : }
      53                 : 
      54                 : NS_IMETHODIMP
      55             181 : mozHunspellDirProvider::GetFiles(const char *aKey,
      56                 :                                 nsISimpleEnumerator* *aResult)
      57                 : {
      58             181 :   if (strcmp(aKey, DICTIONARY_SEARCH_DIRECTORY_LIST) != 0) {
      59             180 :     return NS_ERROR_FAILURE;
      60                 :   }
      61                 : 
      62                 :   nsCOMPtr<nsIProperties> dirSvc =
      63               2 :     do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID);
      64               1 :   if (!dirSvc)
      65               0 :     return NS_ERROR_FAILURE;
      66                 : 
      67               2 :   nsCOMPtr<nsISimpleEnumerator> list;
      68               1 :   nsresult rv = dirSvc->Get(XRE_EXTENSIONS_DIR_LIST,
      69                 :                             NS_GET_IID(nsISimpleEnumerator),
      70               1 :                             getter_AddRefs(list));
      71               1 :   if (NS_FAILED(rv))
      72               1 :     return rv;
      73                 : 
      74               0 :   nsCOMPtr<nsISimpleEnumerator> e = new AppendingEnumerator(list);
      75               0 :   if (!e)
      76               0 :     return NS_ERROR_OUT_OF_MEMORY;
      77                 : 
      78               0 :   *aResult = nsnull;
      79               0 :   e.swap(*aResult);
      80               0 :   return NS_SUCCESS_AGGREGATE_RESULT;
      81                 : }
      82                 : 
      83               0 : NS_IMPL_ISUPPORTS1(mozHunspellDirProvider::AppendingEnumerator,
      84                 :                    nsISimpleEnumerator)
      85                 : 
      86                 : NS_IMETHODIMP
      87               0 : mozHunspellDirProvider::AppendingEnumerator::HasMoreElements(bool *aResult)
      88                 : {
      89               0 :   *aResult = mNext ? true : false;
      90               0 :   return NS_OK;
      91                 : }
      92                 : 
      93                 : NS_IMETHODIMP
      94               0 : mozHunspellDirProvider::AppendingEnumerator::GetNext(nsISupports* *aResult)
      95                 : {
      96               0 :   if (aResult)
      97               0 :     NS_ADDREF(*aResult = mNext);
      98                 : 
      99               0 :   mNext = nsnull;
     100                 : 
     101                 :   nsresult rv;
     102                 : 
     103                 :   // Ignore all errors
     104                 : 
     105                 :   bool more;
     106               0 :   while (NS_SUCCEEDED(mBase->HasMoreElements(&more)) && more) {
     107               0 :     nsCOMPtr<nsISupports> nextbasesupp;
     108               0 :     mBase->GetNext(getter_AddRefs(nextbasesupp));
     109                 : 
     110               0 :     nsCOMPtr<nsIFile> nextbase(do_QueryInterface(nextbasesupp));
     111               0 :     if (!nextbase)
     112               0 :       continue;
     113                 : 
     114               0 :     nextbase->Clone(getter_AddRefs(mNext));
     115               0 :     if (!mNext)
     116               0 :       continue;
     117                 : 
     118               0 :     mNext->AppendNative(NS_LITERAL_CSTRING("dictionaries"));
     119                 : 
     120                 :     bool exists;
     121               0 :     rv = mNext->Exists(&exists);
     122               0 :     if (NS_SUCCEEDED(rv) && exists)
     123                 :       break;
     124                 : 
     125               0 :     mNext = nsnull;
     126                 :   }
     127                 : 
     128               0 :   return NS_OK;
     129                 : }
     130                 : 
     131               0 : mozHunspellDirProvider::AppendingEnumerator::AppendingEnumerator
     132                 :     (nsISimpleEnumerator* aBase) :
     133               0 :   mBase(aBase)
     134                 : {
     135                 :   // Initialize mNext to begin
     136               0 :   GetNext(nsnull);
     137               0 : }
     138                 : 
     139                 : char const *const
     140                 : mozHunspellDirProvider::kContractID = "@mozilla.org/spellcheck/dir-provider;1";

Generated by: LCOV version 1.7