Back to index

lightning-sunbird  0.9+nobinonly
Public Types | Public Member Functions | Protected Attributes
CMostRecentUrls Class Reference

#include <MostRecentUrls.h>

Collaboration diagram for CMostRecentUrls:
Collaboration graph
[legend]

List of all members.

Public Types

enum  _maxUrls { MAX_URLS = 16, MAX_URLS = 16 }
enum  _maxUrls { MAX_URLS = 16, MAX_URLS = 16 }

Public Member Functions

 CMostRecentUrls ()
virtual ~CMostRecentUrls ()
char * GetURL (int aInx)
void AddURL (const char *aURL)
int GetNumURLs ()
FILEGetFD (const char *aMode)
 CMostRecentUrls ()
virtual ~CMostRecentUrls ()
char * GetURL (int aInx)
void AddURL (const char *aURL)
int GetNumURLs ()
FILEGetFD (const char *aMode)

Protected Attributes

char * mURLs [MAX_URLS]
int mNumURLs

Detailed Description

Definition at line 39 of file MostRecentUrls.h.


Member Enumeration Documentation

Enumerator:
MAX_URLS 
MAX_URLS 

Definition at line 34 of file MostRecentUrls.h.

                  {
        MAX_URLS = 16
    };
Enumerator:
MAX_URLS 
MAX_URLS 

Definition at line 41 of file MostRecentUrls.h.

                  {
        MAX_URLS = 16
    };

Constructor & Destructor Documentation

Definition at line 57 of file MostRecentUrls.cpp.

                                 :
        mNumURLs(0)
{
       for (int i=0;i<MAX_URLS;i++) {
              mURLs[i] = NULL;
       }

       FILE * fd = GetFD("r");
       if (fd) {
              char line[512];
              while (fgets(line, 512, fd)) {
                     if (strlen(line) > 1) {
                            line[strlen(line)-1] = 0;
                            mURLs[mNumURLs++] = _strdup(line);
                     }
              }
              fclose(fd);
       }

}

Here is the call graph for this function:

Definition at line 92 of file MostRecentUrls.cpp.

{
    FILE * fd = GetFD("w");
    if (fd) {
        for (int i=0;i<MAX_URLS;i++) {
            if(mURLs[i])
                fprintf(fd, "%s\n", mURLs[i]);
        }
    fclose(fd);
    }

    for (int i=0;i<MAX_URLS;i++) {
        if(mURLs[i])
          free(mURLs[i]);
    }
}

Here is the call graph for this function:

virtual CMostRecentUrls::~CMostRecentUrls ( ) [virtual]

Member Function Documentation

Definition at line 118 of file MostRecentUrls.cpp.

{
       TCHAR szTemp[512];
       strcpy(szTemp, aURL);

       // check to see if an existing url matches the one passed in
       int i = 0;
       for (; i<MAX_URLS-1; i++)
       {
        if(mURLs[i])
        {
            if(strcmpi(mURLs[i], szTemp) == 0)
                break; 
        }
       }

    // if there was a match "i" will point to matching url entry
    // if not i will be MAX_URLS-1

    // move all url entries before this one down
       for (; i>0; i--)
       {
        if(mURLs[i])
          free(mURLs[i]);

        if(mURLs[i-1])  
            mURLs[i] = _strdup(mURLs[i-1]);
       }

       // place this url at the top
    if(mURLs[0])
        free(mURLs[0]);
    mURLs[0] = _strdup(szTemp);
}

Here is the caller graph for this function:

FILE* CMostRecentUrls::GetFD ( const char *  aMode)
FILE * CMostRecentUrls::GetFD ( const char *  aMode)

Definition at line 78 of file MostRecentUrls.cpp.

{
    FILE * fd = nsnull;
    nsCOMPtr<nsIFile> file;
    nsresult rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(file));
    if (NS_SUCCEEDED(rv)) {
        nsCOMPtr<nsILocalFile> local_file(do_QueryInterface(file));
        local_file->AppendNative(NS_LITERAL_CSTRING("urls.txt"));
        local_file->OpenANSIFileDesc(aMode, &fd);
    }

    return fd;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 43 of file MostRecentUrls.h.

{ return mNumURLs; }

Definition at line 50 of file MostRecentUrls.h.

{ return mNumURLs; }

Here is the caller graph for this function:

char* CMostRecentUrls::GetURL ( int  aInx)
char * CMostRecentUrls::GetURL ( int  aInx)

Definition at line 109 of file MostRecentUrls.cpp.

{
    if (aInx < mNumURLs) {
        return mURLs[aInx];
    }

    return NULL;
}

Here is the caller graph for this function:


Member Data Documentation

Definition at line 55 of file MostRecentUrls.h.

char * CMostRecentUrls::mURLs [protected]

Definition at line 54 of file MostRecentUrls.h.


The documentation for this class was generated from the following files: