зеркало из https://github.com/mozilla/gecko-dev.git
Fix for 17556. Reviewed by alecf. Newsgroups show abbreviated name in folder pane.
This commit is contained in:
Родитель
bed851411e
Коммит
7d2a82beee
|
@ -25,6 +25,7 @@ interface nsIFolder : nsICollection {
|
|||
readonly attribute string URI;
|
||||
attribute wstring name;
|
||||
attribute wstring prettyName;
|
||||
readonly attribute wstring abbreviatedName;
|
||||
|
||||
nsISupports GetChildNamed(in string name);
|
||||
attribute nsIFolder parent;
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
IsServer="rdf:http://home.netscape.com/NC-rdf#IsServer"
|
||||
ServerType="rdf:http://home.netscape.com/NC-rdf#ServerType">
|
||||
<treerow >
|
||||
<treecell indent="true" value="rdf:http://home.netscape.com/NC-rdf#Name"/>
|
||||
<treecell indent="true" value="rdf:http://home.netscape.com/NC-rdf#FolderTreeName"/>
|
||||
<treecell value="rdf:http://home.netscape.com/NC-rdf#TotalUnreadMessages"/>
|
||||
<treecell value="rdf:http://home.netscape.com/NC-rdf#TotalMessages"/>
|
||||
</treerow>
|
||||
|
@ -50,7 +50,7 @@
|
|||
</rule>
|
||||
</template>
|
||||
|
||||
<treecol persist="width" width="3*" id="FolderColumn" rdf:resource="http://home.netscape.com/NC-rdf#Name"/>
|
||||
<treecol persist="width" width="3*" id="FolderColumn" rdf:resource="http://home.netscape.com/NC-rdf#FolderTreeName"/>
|
||||
<treecol persist="width" width="1*" id="TotalUnreadCol" rdf:resource="http://home.netscape.com/NC-rdf#TotalUnreadMessages"/>
|
||||
<treecol persist="width" width="1*" id="TotalMsgCol" rdf:resource="http://home.netscape.com/NC-rdf#TotalMessages"/>
|
||||
|
||||
|
|
|
@ -288,7 +288,7 @@ function OnLoadFolderPane(folderTree)
|
|||
{
|
||||
dump('In onLoadfolderPane\n');
|
||||
gFolderTree = folderTree;
|
||||
SortFolderPane('FolderColumn', 'http://home.netscape.com/NC-rdf#Name');
|
||||
SortFolderPane('FolderColumn', 'http://home.netscape.com/NC-rdf#FolderTreeName');
|
||||
//Add folderDataSource and accountManagerDataSource to folderPane
|
||||
accountManagerDataSource = accountManagerDataSource.QueryInterface(Components.interfaces.nsIRDFDataSource);
|
||||
folderDataSource = folderDataSource.QueryInterface(Components.interfaces.nsIRDFDataSource);
|
||||
|
|
|
@ -59,7 +59,9 @@ typedef struct _serverCreationParams {
|
|||
// static members
|
||||
nsIRDFResource* nsMsgAccountManagerDataSource::kNC_Child=nsnull;
|
||||
nsIRDFResource* nsMsgAccountManagerDataSource::kNC_Name=nsnull;
|
||||
nsIRDFResource* nsMsgAccountManagerDataSource::kNC_FolderTreeName=nsnull;
|
||||
nsIRDFResource* nsMsgAccountManagerDataSource::kNC_NameSort=nsnull;
|
||||
nsIRDFResource* nsMsgAccountManagerDataSource::kNC_FolderTreeNameSort=nsnull;
|
||||
nsIRDFResource* nsMsgAccountManagerDataSource::kNC_PageTag=nsnull;
|
||||
nsIRDFResource* nsMsgAccountManagerDataSource::kNC_Settings=nsnull;
|
||||
nsIRDFResource* nsMsgAccountManagerDataSource::kNC_AccountRoot=nsnull;
|
||||
|
@ -110,7 +112,9 @@ nsMsgAccountManagerDataSource::~nsMsgAccountManagerDataSource()
|
|||
{
|
||||
NS_IF_RELEASE(kNC_Child);
|
||||
NS_IF_RELEASE(kNC_Name);
|
||||
NS_IF_RELEASE(kNC_FolderTreeName);
|
||||
NS_IF_RELEASE(kNC_NameSort);
|
||||
NS_IF_RELEASE(kNC_FolderTreeNameSort);
|
||||
NS_IF_RELEASE(kNC_PageTag);
|
||||
NS_IF_RELEASE(kNC_Account);
|
||||
NS_IF_RELEASE(kNC_Server);
|
||||
|
@ -148,7 +152,9 @@ nsMsgAccountManagerDataSource::Init()
|
|||
if (gAccountManagerResourceRefCnt++ == 0) {
|
||||
getRDFService()->GetResource(NC_RDF_CHILD, &kNC_Child);
|
||||
getRDFService()->GetResource(NC_RDF_NAME, &kNC_Name);
|
||||
getRDFService()->GetResource(NC_RDF_FOLDERTREENAME, &kNC_FolderTreeName);
|
||||
getRDFService()->GetResource(NC_RDF_NAME_SORT, &kNC_NameSort);
|
||||
getRDFService()->GetResource(NC_RDF_FOLDERTREENAME_SORT, &kNC_FolderTreeNameSort);
|
||||
getRDFService()->GetResource(NC_RDF_PAGETAG, &kNC_PageTag);
|
||||
getRDFService()->GetResource(NC_RDF_ACCOUNT, &kNC_Account);
|
||||
getRDFService()->GetResource(NC_RDF_SERVER, &kNC_Server);
|
||||
|
@ -187,7 +193,7 @@ nsMsgAccountManagerDataSource::GetTarget(nsIRDFResource *source,
|
|||
rv = NS_RDF_NO_VALUE;
|
||||
|
||||
nsString str="";
|
||||
if (property == kNC_Name) {
|
||||
if (property == kNC_Name || property == kNC_FolderTreeName) {
|
||||
|
||||
// XXX these should be localized
|
||||
if (source == kNC_PageTitleMain)
|
||||
|
@ -220,7 +226,6 @@ nsMsgAccountManagerDataSource::GetTarget(nsIRDFResource *source,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if (property == kNC_PageTag) {
|
||||
// do NOT localize these strings. these are the urls of the XUL files
|
||||
if (source == kNC_PageTitleServer)
|
||||
|
@ -236,7 +241,7 @@ nsMsgAccountManagerDataSource::GetTarget(nsIRDFResource *source,
|
|||
}
|
||||
|
||||
// handle sorting of servers
|
||||
else if (property == kNC_NameSort) {
|
||||
else if ((property == kNC_NameSort) || (property == kNC_FolderTreeNameSort)) {
|
||||
// make sure we're handling a root folder that is a server
|
||||
nsCOMPtr<nsIMsgFolder> folder = do_QueryInterface(source,&rv);
|
||||
if (NS_FAILED(rv))
|
||||
|
@ -436,7 +441,9 @@ nsMsgAccountManagerDataSource::ArcLabelsOut(nsIRDFResource *source,
|
|||
|
||||
arcs->AppendElement(kNC_Settings);
|
||||
arcs->AppendElement(kNC_Name);
|
||||
arcs->AppendElement(kNC_FolderTreeName);
|
||||
arcs->AppendElement(kNC_NameSort);
|
||||
arcs->AppendElement(kNC_FolderTreeNameSort);
|
||||
arcs->AppendElement(kNC_PageTag);
|
||||
|
||||
#ifdef DEBUG_amds_
|
||||
|
|
|
@ -62,7 +62,9 @@ public:
|
|||
protected:
|
||||
|
||||
static nsIRDFResource* kNC_Name;
|
||||
static nsIRDFResource* kNC_FolderTreeName;
|
||||
static nsIRDFResource* kNC_NameSort;
|
||||
static nsIRDFResource* kNC_FolderTreeNameSort;
|
||||
static nsIRDFResource* kNC_PageTag;
|
||||
static nsIRDFResource* kNC_Child;
|
||||
static nsIRDFResource* kNC_AccountRoot;
|
||||
|
|
|
@ -52,7 +52,9 @@ nsIRDFResource* nsMsgFolderDataSource::kNC_Child = nsnull;
|
|||
nsIRDFResource* nsMsgFolderDataSource::kNC_MessageChild = nsnull;
|
||||
nsIRDFResource* nsMsgFolderDataSource::kNC_Folder= nsnull;
|
||||
nsIRDFResource* nsMsgFolderDataSource::kNC_Name= nsnull;
|
||||
nsIRDFResource* nsMsgFolderDataSource::kNC_FolderTreeName= nsnull;
|
||||
nsIRDFResource* nsMsgFolderDataSource::kNC_NameSort= nsnull;
|
||||
nsIRDFResource* nsMsgFolderDataSource::kNC_FolderTreeNameSort= nsnull;
|
||||
nsIRDFResource* nsMsgFolderDataSource::kNC_SpecialFolder= nsnull;
|
||||
nsIRDFResource* nsMsgFolderDataSource::kNC_ServerType = nsnull;
|
||||
nsIRDFResource* nsMsgFolderDataSource::kNC_IsServer = nsnull;
|
||||
|
@ -97,7 +99,9 @@ nsMsgFolderDataSource::~nsMsgFolderDataSource (void)
|
|||
NS_RELEASE2(kNC_MessageChild, refcnt);
|
||||
NS_RELEASE2(kNC_Folder, refcnt);
|
||||
NS_RELEASE2(kNC_Name, refcnt);
|
||||
NS_RELEASE2(kNC_FolderTreeName, refcnt);
|
||||
NS_RELEASE2(kNC_NameSort, refcnt);
|
||||
NS_RELEASE2(kNC_FolderTreeNameSort, refcnt);
|
||||
NS_RELEASE2(kNC_SpecialFolder, refcnt);
|
||||
NS_RELEASE2(kNC_ServerType, refcnt);
|
||||
NS_RELEASE2(kNC_IsServer, refcnt);
|
||||
|
@ -138,7 +142,9 @@ nsresult nsMsgFolderDataSource::Init()
|
|||
rdf->GetResource(NC_RDF_MESSAGECHILD, &kNC_MessageChild);
|
||||
rdf->GetResource(NC_RDF_FOLDER, &kNC_Folder);
|
||||
rdf->GetResource(NC_RDF_NAME, &kNC_Name);
|
||||
rdf->GetResource(NC_RDF_FOLDERTREENAME, &kNC_FolderTreeName);
|
||||
rdf->GetResource(NC_RDF_NAME_SORT, &kNC_NameSort);
|
||||
rdf->GetResource(NC_RDF_FOLDERTREENAME_SORT, &kNC_FolderTreeNameSort);
|
||||
rdf->GetResource(NC_RDF_SPECIALFOLDER, &kNC_SpecialFolder);
|
||||
rdf->GetResource(NC_RDF_SERVERTYPE, &kNC_ServerType);
|
||||
rdf->GetResource(NC_RDF_ISSERVER, &kNC_IsServer);
|
||||
|
@ -356,6 +362,7 @@ NS_IMETHODIMP nsMsgFolderDataSource::GetTargets(nsIRDFResource* source,
|
|||
}
|
||||
}
|
||||
else if ((kNC_Name == property) ||
|
||||
(kNC_FolderTreeName == property) ||
|
||||
(kNC_SpecialFolder == property) ||
|
||||
(kNC_IsServer == property) ||
|
||||
(kNC_ServerType == property))
|
||||
|
@ -469,6 +476,7 @@ nsMsgFolderDataSource::getFolderArcLabelsOut(nsISupportsArray **arcs)
|
|||
return rv;
|
||||
|
||||
(*arcs)->AppendElement(kNC_Name);
|
||||
(*arcs)->AppendElement(kNC_FolderTreeName);
|
||||
(*arcs)->AppendElement(kNC_SpecialFolder);
|
||||
(*arcs)->AppendElement(kNC_ServerType);
|
||||
(*arcs)->AppendElement(kNC_IsServer);
|
||||
|
@ -789,8 +797,12 @@ nsresult nsMsgFolderDataSource::createFolderNode(nsIMsgFolder* folder,
|
|||
|
||||
if (kNC_NameSort == property)
|
||||
rv = createFolderNameNode(folder, target, PR_TRUE);
|
||||
else if(kNC_FolderTreeNameSort == property)
|
||||
rv = createFolderTreeNameNode(folder, target, PR_TRUE);
|
||||
else if (kNC_Name == property)
|
||||
rv = createFolderNameNode(folder, target, PR_FALSE);
|
||||
else if (kNC_FolderTreeName == property)
|
||||
rv = createFolderTreeNameNode(folder, target, PR_FALSE);
|
||||
else if ((kNC_SpecialFolder == property))
|
||||
rv = createFolderSpecialNode(folder,target);
|
||||
else if ((kNC_ServerType == property))
|
||||
|
@ -824,19 +836,43 @@ nsresult nsMsgFolderDataSource::createFolderNameNode(nsIMsgFolder *folder,
|
|||
if (NS_FAILED(rv)) return rv;
|
||||
nsString nameString(name);
|
||||
if(sort)
|
||||
{
|
||||
CreateNameSortString(folder, nameString);
|
||||
}
|
||||
createNode(nameString, target, getRDFService());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult nsMsgFolderDataSource::createFolderTreeNameNode(nsIMsgFolder *folder,
|
||||
nsIRDFNode **target, PRBool sort)
|
||||
{
|
||||
|
||||
nsXPIDLString name;
|
||||
nsresult rv = folder->GetAbbreviatedName(getter_Copies(name));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsString nameString(name);
|
||||
if(sort)
|
||||
{
|
||||
CreateNameSortString(folder, nameString);
|
||||
}
|
||||
createNode(nameString, target, getRDFService());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsMsgFolderDataSource::CreateNameSortString(nsIMsgFolder *folder, nsString &name)
|
||||
{
|
||||
PRInt32 order;
|
||||
rv = GetFolderSortOrder(folder, &order);
|
||||
nsresult rv = GetFolderSortOrder(folder, &order);
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
char * orderString = PR_smprintf("%d", order);
|
||||
if(!orderString)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nameString.Insert(orderString, 0);
|
||||
name.Insert(orderString, 0);
|
||||
PR_smprintf_free(orderString);
|
||||
}
|
||||
createNode(nameString, target, getRDFService());
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1226,6 +1262,7 @@ nsresult nsMsgFolderDataSource::DoFolderHasAssertion(nsIMsgFolder *folder,
|
|||
rv = folder->HasMessage(message, hasAssertion);
|
||||
}
|
||||
else if ((kNC_Name == property) ||
|
||||
(kNC_FolderTreeName == property) ||
|
||||
(kNC_SpecialFolder == property) ||
|
||||
(kNC_ServerType == property) ||
|
||||
(kNC_IsServer == property) ||
|
||||
|
|
|
@ -113,6 +113,7 @@ protected:
|
|||
nsresult createFolderNode(nsIMsgFolder *folder, nsIRDFResource* property,
|
||||
nsIRDFNode **target);
|
||||
nsresult createFolderNameNode(nsIMsgFolder *folder, nsIRDFNode **target, PRBool sort);
|
||||
nsresult createFolderTreeNameNode(nsIMsgFolder *folder, nsIRDFNode **target, PRBool sort);
|
||||
nsresult createFolderSpecialNode(nsIMsgFolder *folder, nsIRDFNode **target);
|
||||
nsresult createFolderServerTypeNode(nsIMsgFolder *folder,
|
||||
nsIRDFNode **target);
|
||||
|
@ -147,6 +148,7 @@ protected:
|
|||
|
||||
nsresult GetBiffStateString(PRUint32 biffState, nsCAutoString & biffStateStr);
|
||||
|
||||
nsresult CreateNameSortString(nsIMsgFolder *folder, nsString &name);
|
||||
nsresult GetFolderSortOrder(nsIMsgFolder *folder, PRInt32* order);
|
||||
|
||||
nsresult CreateArcsOutEnumerator();
|
||||
|
@ -155,7 +157,9 @@ protected:
|
|||
static nsIRDFResource* kNC_MessageChild;
|
||||
static nsIRDFResource* kNC_Folder;
|
||||
static nsIRDFResource* kNC_Name;
|
||||
static nsIRDFResource* kNC_FolderTreeName;
|
||||
static nsIRDFResource* kNC_NameSort;
|
||||
static nsIRDFResource* kNC_FolderTreeNameSort;
|
||||
static nsIRDFResource* kNC_Columns;
|
||||
static nsIRDFResource* kNC_MSGFolderRoot;
|
||||
static nsIRDFResource* kNC_SpecialFolder;
|
||||
|
|
|
@ -45,6 +45,7 @@ typedef struct _nsMsgRDFNotification {
|
|||
#define NC_RDF_CHILD NC_NAMESPACE_URI "child"
|
||||
#define NC_RDF_MESSAGECHILD NC_NAMESPACE_URI "MessageChild"
|
||||
#define NC_RDF_NAME NC_NAMESPACE_URI "Name"
|
||||
#define NC_RDF_FOLDERTREENAME NC_NAMESPACE_URI "FolderTreeName"
|
||||
#define NC_RDF_FOLDER NC_NAMESPACE_URI "Folder"
|
||||
#define NC_RDF_SPECIALFOLDER NC_NAMESPACE_URI "SpecialFolder"
|
||||
#define NC_RDF_SERVERTYPE NC_NAMESPACE_URI "ServerType"
|
||||
|
@ -59,6 +60,7 @@ typedef struct _nsMsgRDFNotification {
|
|||
#define NC_RDF_SENDER_COLLATION_SORT NC_NAMESPACE_URI "Sender?collation=true"
|
||||
|
||||
#define NC_RDF_NAME_SORT NC_NAMESPACE_URI "Name?sort=true"
|
||||
#define NC_RDF_FOLDERTREENAME_SORT NC_NAMESPACE_URI "FolderTreeName?sort=true"
|
||||
|
||||
//Folder Commands
|
||||
#define NC_RDF_DELETE NC_NAMESPACE_URI "Delete"
|
||||
|
|
|
@ -481,6 +481,12 @@ NS_IMETHODIMP nsMsgFolder::SetName(const PRUnichar * name)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
//For default, just return name
|
||||
NS_IMETHODIMP nsMsgFolder::GetAbbreviatedName(PRUnichar * *aAbbreviatedName)
|
||||
{
|
||||
return GetName(aAbbreviatedName);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgFolder::GetChildNamed(const char *name, nsISupports ** aChild)
|
||||
{
|
||||
NS_ASSERTION(aChild, "NULL child");
|
||||
|
|
|
@ -544,17 +544,16 @@ nsMsgNewsFolder::GetChildNamed(const char *name, nsISupports ** aChild)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgNewsFolder::GetPrettyName(PRUnichar ** prettyName)
|
||||
NS_IMETHODIMP nsMsgNewsFolder::GetAbbreviatedName(PRUnichar * *aAbbreviatedName)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (!prettyName)
|
||||
if (!aAbbreviatedName)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
rv = nsMsgFolder::GetPrettyName(prettyName);
|
||||
rv = nsMsgFolder::GetPrettyName(aAbbreviatedName);
|
||||
if(NS_FAILED(rv)) return rv;
|
||||
|
||||
//not ready for prime time yet, as I don't know how to test this yet.
|
||||
#ifdef NOT_READY_FOR_PRIME_TIME
|
||||
// only do this for newsgroup names, not for newsgroup hosts.
|
||||
PRBool isNewsServer = PR_FALSE;
|
||||
rv = GetIsServer(&isNewsServer);
|
||||
|
@ -566,16 +565,18 @@ NS_IMETHODIMP nsMsgNewsFolder::GetPrettyName(PRUnichar ** prettyName)
|
|||
|
||||
PRInt32 numFullWords;
|
||||
rv = prefs->GetIntPref(PREF_NEWS_ABBREVIATE_PRETTY_NAMES, &numFullWords);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (NS_FAILED(rv))
|
||||
numFullWords = 1;
|
||||
|
||||
if (numFullWords != 0) {
|
||||
rv = AbbreviatePrettyName(prettyName, numFullWords);
|
||||
rv = AbbreviatePrettyName(aAbbreviatedName, numFullWords);
|
||||
}
|
||||
}
|
||||
#endif /* NOT_READY_FOR_PRIME_TIME */
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
// original code from Oleg Rekutin
|
||||
// rekusha@asan.com
|
||||
// Public domain, created by Oleg Rekutin
|
||||
|
@ -597,10 +598,21 @@ nsresult nsMsgNewsFolder::AbbreviatePrettyName(PRUnichar ** prettyName, PRInt32
|
|||
PRInt32 totalwords = 0; // total no. of words
|
||||
|
||||
// get the total no. of words
|
||||
for (PRInt32 pos = 0;
|
||||
(pos++) != name.Length();
|
||||
pos = name.FindChar('.', PR_FALSE,pos))
|
||||
PRInt32 pos = 0;
|
||||
while(1)
|
||||
{
|
||||
pos = name.FindChar('.', PR_FALSE, pos);
|
||||
if(pos == -1)
|
||||
{
|
||||
totalwords++;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
totalwords++;
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
|
||||
// get the no. of words to abbreviate
|
||||
PRInt32 abbrevnum = totalwords - fullwords;
|
||||
|
|
|
@ -64,8 +64,7 @@ public:
|
|||
NS_IMETHOD Adopt(nsIMsgFolder *srcFolder, PRUint32 *outPos);
|
||||
|
||||
NS_IMETHOD GetChildNamed(const char* name, nsISupports ** aChild);
|
||||
|
||||
NS_IMETHOD GetPrettyName(PRUnichar ** prettyName); // Override of the base, for top-level news folder
|
||||
NS_IMETHODIMP GetAbbreviatedName(PRUnichar * *aAbbreviatedName);
|
||||
|
||||
NS_IMETHOD GetFolderURL(char **url);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче