Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions
nsMsgTagService Class Reference

#include <nsMsgTagService.h>

Inheritance diagram for nsMsgTagService:
Inheritance graph
[legend]
Collaboration diagram for nsMsgTagService:
Collaboration graph
[legend]

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS
NS_DECL_NSIMSGTAGSERVICE 
nsMsgTagService ()
void addTag (in AString tag, in ACString color, in ACString ordinal)
void addTagForKey (in ACString key, in AString tag, in ACString color, in ACString ordinal)
ACString getKeyForTag (in AString tag)
ACString getTopKey (in string keyList)
AString getTagForKey (in ACString key)
void setTagForKey (in ACString key, in AString tag)
ACString getColorForKey (in ACString key)
void setColorForKey (in ACString key, in ACString color)
ACString getOrdinalForKey (in ACString key)
void setOrdinalForKey (in ACString key, in ACString ordinal)
void deleteKey (in ACString key)
void getAllTags (out unsigned long count,[retval, array, size_is(count)] out nsIMsgTag tagArray)

Protected Member Functions

nsresult SetUnicharPref (const char *prefName, const nsAString &prefValue)
nsresult GetUnicharPref (const char *prefName, nsAString &prefValue)
nsresult MigrateLabelsToTags ()

Protected Attributes

nsCOMPtr< nsIPrefBranchm_tagPrefBranch

Private Member Functions

 ~nsMsgTagService ()

Detailed Description

Definition at line 65 of file nsMsgTagService.h.


Constructor & Destructor Documentation

Definition at line 154 of file nsMsgTagService.cpp.

{
  m_tagPrefBranch = nsnull;
  nsCOMPtr<nsIPrefService> prefService(do_GetService(NS_PREFSERVICE_CONTRACTID));
  if (prefService)
    prefService->GetBranch("mailnews.tags.", getter_AddRefs(m_tagPrefBranch));
  // need to figure out how to migrate the tags only once.
  MigrateLabelsToTags();
}

Here is the call graph for this function:

Definition at line 164 of file nsMsgTagService.cpp.

{
  /* destructor code */
}

Member Function Documentation

void nsIMsgTagService::addTag ( in AString  tag,
in ACString  color,
in ACString  ordinal 
) [inherited]
void nsIMsgTagService::addTagForKey ( in ACString  key,
in AString  tag,
in ACString  color,
in ACString  ordinal 
) [inherited]
void nsIMsgTagService::deleteKey ( in ACString  key) [inherited]
void nsIMsgTagService::getAllTags ( out unsigned long  count,
[retval, array, size_is(count)] out nsIMsgTag  tagArray 
) [inherited]
ACString nsIMsgTagService::getColorForKey ( in ACString  key) [inherited]
ACString nsIMsgTagService::getKeyForTag ( in AString  tag) [inherited]
ACString nsIMsgTagService::getOrdinalForKey ( in ACString  key) [inherited]
AString nsIMsgTagService::getTagForKey ( in ACString  key) [inherited]
ACString nsIMsgTagService::getTopKey ( in string  keyList) [inherited]
nsresult nsMsgTagService::GetUnicharPref ( const char *  prefName,
nsAString &  prefValue 
) [protected]

Definition at line 458 of file nsMsgTagService.cpp.

{
  nsresult rv;
  nsCOMPtr<nsISupportsString> supportsString =
    do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID, &rv);
  if (supportsString)
  {
    rv = m_tagPrefBranch->GetComplexValue(prefName,
                                          NS_GET_IID(nsISupportsString),
                                          getter_AddRefs(supportsString));
    if (supportsString)
      rv = supportsString->GetData(prefValue);
    else
      prefValue.Truncate();
  }
  return rv;
}

Here is the call graph for this function:

Definition at line 478 of file nsMsgTagService.cpp.

{
  nsCString prefString;

  PRInt32 prefVersion = 0;
  nsresult rv = m_tagPrefBranch->GetIntPref(TAG_PREF_VERSION, &prefVersion);
  if (NS_SUCCEEDED(rv) && prefVersion > 1)
    return rv;
  else if (prefVersion == 1)
  {
    gMigratingKeys = PR_TRUE;
  // need to convert the keys to lower case
    nsIMsgTag **tagArray;
    PRUint32 numTags;
    GetAllTags(&numTags, &tagArray);
    for (PRUint32 tagIndex = 0; tagIndex < numTags; tagIndex++)
    {
      nsCAutoString key, color, ordinal;
      nsAutoString tagStr;
      nsIMsgTag *tag = tagArray[tagIndex];
      tag->GetKey(key);
      tag->GetTag(tagStr);
      tag->GetOrdinal(ordinal);
      tag->GetColor(color);
      DeleteKey(key);
      ToLowerCase(key);
      AddTagForKey(key, tagStr, color, ordinal);
    }
    NS_Free(tagArray);
    gMigratingKeys = PR_FALSE;
  }
  else 
  {
    nsCOMPtr<nsIPrefBranch> prefRoot(do_GetService(NS_PREFSERVICE_CONTRACTID));
    nsCOMPtr<nsIPrefLocalizedString> pls;
    nsXPIDLString ucsval;
    nsCAutoString labelKey("$label1");
    for(PRInt32 i = 0; i < PREF_LABELS_MAX; )
    {
      prefString.Assign(PREF_LABELS_DESCRIPTION);
      prefString.AppendInt(i + 1);
      rv = prefRoot->GetComplexValue(prefString.get(),
                                     NS_GET_IID(nsIPrefLocalizedString),
                                     getter_AddRefs(pls));
      NS_ENSURE_SUCCESS(rv, rv);
      pls->ToString(getter_Copies(ucsval));

      prefString.Assign(PREF_LABELS_COLOR);
      prefString.AppendInt(i + 1);
      nsXPIDLCString csval;
      rv = prefRoot->GetCharPref(prefString.get(), getter_Copies(csval));
      NS_ENSURE_SUCCESS(rv, rv);

      rv = AddTagForKey(labelKey, ucsval, csval, EmptyCString());
      NS_ENSURE_SUCCESS(rv, rv);
      labelKey.SetCharAt(++i + '1', 6);
    }
  }
  m_tagPrefBranch->SetIntPref(TAG_PREF_VERSION, 2);
  return rv;
}

Here is the call graph for this function:

void nsIMsgTagService::setColorForKey ( in ACString  key,
in ACString  color 
) [inherited]
void nsIMsgTagService::setOrdinalForKey ( in ACString  key,
in ACString  ordinal 
) [inherited]
void nsIMsgTagService::setTagForKey ( in ACString  key,
in AString  tag 
) [inherited]
nsresult nsMsgTagService::SetUnicharPref ( const char *  prefName,
const nsAString &  prefValue 
) [protected]

Definition at line 435 of file nsMsgTagService.cpp.

{
  nsresult rv = NS_OK;
  if (!val.IsEmpty())
  {
    nsCOMPtr<nsISupportsString> supportsString =
      do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID, &rv);
    if (supportsString)
    {
      supportsString->SetData(val);
      rv = m_tagPrefBranch->SetComplexValue(prefName,
                                            NS_GET_IID(nsISupportsString),
                                            supportsString);
    }
  }
  else
  {
    m_tagPrefBranch->ClearUserPref(prefName);
  }
  return rv;
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 83 of file nsMsgTagService.h.


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