зеркало из https://github.com/mozilla/pjs.git
changes for make the subscribe dialog i18n friendly. now, imap folders with
japanese names work. thanks to ji@netscape.com for the help in getting a japanese folder name. remove the old news/tests. they are old and not used anymore.
This commit is contained in:
Родитель
4ca4d3fb2a
Коммит
3c77570a67
|
@ -41,9 +41,9 @@ interface nsISubscribableServer : nsISupports {
|
|||
void startPopulatingSubscribeDS();
|
||||
void stopPopulatingSubscribeDS();
|
||||
void findAndAddParentToSubscribeDS(in string uri, in string serverUri, in string aName, in nsIRDFResource aChildResource);
|
||||
void setPropertiesInSubscribeDS(in string uri, in string aName, in nsIRDFResource aResource);
|
||||
void setPropertiesInSubscribeDS(in string uri, in wstring aName, in nsIRDFResource aResource);
|
||||
void addToSubscribeDS(in string aName);
|
||||
void setAsSubscribedInSubscribeDS(in string aName);
|
||||
void setAsSubscribedInSubscribeDS(in string aURI);
|
||||
void updateSubscribedInSubscribeDS();
|
||||
void subscribe(in string name);
|
||||
void unsubscribe(in string name);
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "nsIFolder.h"
|
||||
|
||||
#include "rdf.h"
|
||||
#include "nsMsgUtils.h"
|
||||
|
||||
#if defined(DEBUG_sspitzer_) || defined(DEBUG_seth_)
|
||||
#define DEBUG_SUBSCRIBE 1
|
||||
|
@ -68,25 +69,15 @@ nsSubscribableServer::SetDelimiter(char aDelimiter)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSubscribableServer::SetAsSubscribedInSubscribeDS(const char *aName)
|
||||
nsSubscribableServer::SetAsSubscribedInSubscribeDS(const char *aURI)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
NS_ASSERTION(aName,"no name");
|
||||
if (!aName) return NS_ERROR_FAILURE;
|
||||
|
||||
nsXPIDLCString serverUri;
|
||||
|
||||
rv = mIncomingServer->GetServerURI(getter_Copies(serverUri));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCAutoString uri;
|
||||
uri = (const char *)serverUri;
|
||||
uri += "/";
|
||||
uri += aName;
|
||||
NS_ASSERTION(aURI,"no URI");
|
||||
if (!aURI) return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIRDFResource> resource;
|
||||
rv = mRDFService->GetResource((const char *) uri, getter_AddRefs(resource));
|
||||
rv = mRDFService->GetResource(aURI, getter_AddRefs(resource));
|
||||
|
||||
nsCOMPtr<nsIRDFDataSource> ds;
|
||||
rv = mRDFService->GetDataSource("rdf:subscribe",getter_AddRefs(mSubscribeDatasource));
|
||||
|
@ -132,11 +123,10 @@ nsSubscribableServer::UpdateSubscribedInSubscribeDS()
|
|||
if (NS_SUCCEEDED(rv) && child) {
|
||||
currFolder = do_QueryInterface(child, &rv);
|
||||
if (NS_SUCCEEDED(rv) && currFolder) {
|
||||
nsXPIDLString name;
|
||||
rv = currFolder->GetName(getter_Copies(name));
|
||||
if (NS_SUCCEEDED(rv) && name) {
|
||||
nsCAutoString asciiName; asciiName.AssignWithConversion(name);
|
||||
rv = SetAsSubscribedInSubscribeDS((const char *)asciiName);
|
||||
nsXPIDLCString uri;
|
||||
rv = currFolder->GetURI(getter_Copies(uri));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = SetAsSubscribedInSubscribeDS((const char *)uri);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -170,8 +160,12 @@ nsSubscribableServer::AddToSubscribeDS(const char *aName)
|
|||
nsCOMPtr<nsIRDFResource> resource;
|
||||
rv = mRDFService->GetResource((const char *) uri, getter_AddRefs(resource));
|
||||
if(NS_FAILED(rv)) return rv;
|
||||
|
||||
nsXPIDLString unicodeName;
|
||||
rv = ConvertNameToUnichar(aName, getter_Copies(unicodeName));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = SetPropertiesInSubscribeDS((const char *) uri, aName, resource);
|
||||
rv = SetPropertiesInSubscribeDS((const char *) uri, (const PRUnichar *)unicodeName, resource);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = FindAndAddParentToSubscribeDS((const char *) uri, (const char *)serverUri, aName, resource);
|
||||
|
@ -181,18 +175,16 @@ nsSubscribableServer::AddToSubscribeDS(const char *aName)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSubscribableServer::SetPropertiesInSubscribeDS(const char *uri, const char *aName, nsIRDFResource *aResource)
|
||||
nsSubscribableServer::SetPropertiesInSubscribeDS(const char *uri, const PRUnichar *aName, nsIRDFResource *aResource)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
#ifdef DEBUG_SUBSCRIBE
|
||||
printf("SetPropertiesInSubscribeDS(%s,%s,??)\n",uri,aName);
|
||||
printf("SetPropertiesInSubscribeDS(%s,??,??)\n",uri);
|
||||
#endif
|
||||
|
||||
nsCOMPtr<nsIRDFLiteral> nameLiteral;
|
||||
nsAutoString nameString;
|
||||
nameString.AssignWithConversion(aName);
|
||||
rv = mRDFService->GetLiteral(nameString.GetUnicode(), getter_AddRefs(nameLiteral));
|
||||
rv = mRDFService->GetLiteral(aName, getter_AddRefs(nameLiteral));
|
||||
if(NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = mSubscribeDatasource->Assert(aResource, kNC_Name, nameLiteral, PR_TRUE);
|
||||
|
@ -251,7 +243,11 @@ nsSubscribableServer::FindAndAddParentToSubscribeDS(const char *uri, const char
|
|||
}
|
||||
|
||||
if (!parentExists) {
|
||||
rv = SetPropertiesInSubscribeDS((const char *)uriCStr, (const char *)nameCStr, parentResource);
|
||||
nsXPIDLString unicodeName;
|
||||
rv = ConvertNameToUnichar((const char *)nameCStr, getter_Copies(unicodeName));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = SetPropertiesInSubscribeDS((const char *)uriCStr, (const PRUnichar *)unicodeName, parentResource);
|
||||
if(NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@ class nsSubscribableServer : public nsISubscribableServer
|
|||
NS_DECL_NSISUBSCRIBABLESERVER
|
||||
|
||||
private:
|
||||
nsresult ConvertNameToUnichar(const char *inStr, PRUnichar **outStr);
|
||||
nsCOMPtr <nsISubscribeListener> mSubscribeListener;
|
||||
nsCOMPtr <nsIRDFDataSource> mSubscribeDatasource;
|
||||
nsCOMPtr <nsIRDFService> mRDFService;
|
||||
|
|
|
@ -36,10 +36,12 @@
|
|||
#include "nsMsgLocalCID.h"
|
||||
#include "nsMsgBaseCID.h"
|
||||
#include "nsMsgImapCID.h"
|
||||
#include "nsICharsetConverterManager.h"
|
||||
|
||||
static NS_DEFINE_CID(kImapUrlCID, NS_IMAPURL_CID);
|
||||
static NS_DEFINE_CID(kCMailboxUrl, NS_MAILBOXURL_CID);
|
||||
static NS_DEFINE_CID(kCNntpUrlCID, NS_NNTPURL_CID);
|
||||
static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID);
|
||||
|
||||
#if defined(DEBUG_sspitzer_) || defined(DEBUG_seth_)
|
||||
#define DEBUG_NS_MsgHashIfNecessary 1
|
||||
|
@ -376,3 +378,47 @@ nsresult NS_MsgCreatePathStringFromFolderURI(const char *folderURI, nsCString& p
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult CreateUnicodeStringFromUtf7(const char *aSourceString, PRUnichar **aUnicodeStr)
|
||||
{
|
||||
if (!aUnicodeStr)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
PRUnichar *convertedString = NULL;
|
||||
nsresult res;
|
||||
NS_WITH_SERVICE(nsICharsetConverterManager, ccm, kCharsetConverterManagerCID, &res);
|
||||
|
||||
if(NS_SUCCEEDED(res) && (nsnull != ccm))
|
||||
{
|
||||
nsString aCharset; aCharset.AssignWithConversion("x-imap4-modified-utf7");
|
||||
PRUnichar *unichars = nsnull;
|
||||
PRInt32 unicharLength;
|
||||
|
||||
// convert utf7 to unicode
|
||||
nsIUnicodeDecoder* decoder = nsnull;
|
||||
|
||||
res = ccm->GetUnicodeDecoder(&aCharset, &decoder);
|
||||
if(NS_SUCCEEDED(res) && (nsnull != decoder))
|
||||
{
|
||||
PRInt32 srcLen = PL_strlen(aSourceString);
|
||||
res = decoder->GetMaxLength(aSourceString, srcLen, &unicharLength);
|
||||
// temporary buffer to hold unicode string
|
||||
unichars = new PRUnichar[unicharLength + 1];
|
||||
if (unichars == nsnull)
|
||||
{
|
||||
res = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
else
|
||||
{
|
||||
res = decoder->Convert(aSourceString, &srcLen, unichars, &unicharLength);
|
||||
unichars[unicharLength] = 0;
|
||||
}
|
||||
NS_IF_RELEASE(decoder);
|
||||
nsString unicodeStr(unichars);
|
||||
convertedString = unicodeStr.ToNewUnicode();
|
||||
delete [] unichars;
|
||||
}
|
||||
}
|
||||
*aUnicodeStr = convertedString;
|
||||
return (convertedString) ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
|
|
@ -69,5 +69,7 @@ NS_MSG_BASE nsresult NS_MsgHashIfNecessary(nsCAutoString &name);
|
|||
|
||||
NS_MSG_BASE nsresult NS_MsgCreatePathStringFromFolderURI(const char *folderURI, nsCString& pathString);
|
||||
|
||||
nsresult CreateUnicodeStringFromUtf7(const char *aSourceString, PRUnichar **result);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -58,6 +58,7 @@
|
|||
#include "nsIEventQueueService.h"
|
||||
#include "nsIMsgMailNewsUrl.h"
|
||||
#include "nsIImapService.h"
|
||||
#include "nsMsgUtils.h"
|
||||
|
||||
#include "nsITimer.h"
|
||||
static NS_DEFINE_CID(kCImapHostSessionList, NS_IIMAPHOSTSESSIONLIST_CID);
|
||||
|
@ -186,6 +187,7 @@ nsImapIncomingServer::SetServerDirectory(const char *serverDirectory)
|
|||
return SetCharValue("server_sub_directory", dirString.GetBuffer());
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImapIncomingServer::GetOverrideNamespaces(PRBool *bVal)
|
||||
{
|
||||
|
@ -1887,11 +1889,11 @@ nsImapIncomingServer::SetDelimiter(char aDelimiter)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImapIncomingServer::SetAsSubscribedInSubscribeDS(const char *aName)
|
||||
nsImapIncomingServer::SetAsSubscribedInSubscribeDS(const char *aURI)
|
||||
{
|
||||
NS_ASSERTION(mInner,"not initialized");
|
||||
if (!mInner) return NS_ERROR_FAILURE;
|
||||
return mInner->SetAsSubscribedInSubscribeDS(aName);
|
||||
return mInner->SetAsSubscribedInSubscribeDS(aURI);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -1910,8 +1912,9 @@ nsImapIncomingServer::AddToSubscribeDS(const char *aName)
|
|||
return mInner->AddToSubscribeDS(aName);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImapIncomingServer::SetPropertiesInSubscribeDS(const char *uri, const char *aName, nsIRDFResource *aResource)
|
||||
nsImapIncomingServer::SetPropertiesInSubscribeDS(const char *uri, const PRUnichar *aName, nsIRDFResource *aResource)
|
||||
{
|
||||
NS_ASSERTION(mInner,"not initialized");
|
||||
if (!mInner) return NS_ERROR_FAILURE;
|
||||
|
|
|
@ -531,49 +531,3 @@ CreateUtf7ConvertedStringFromUnicode(const PRUnichar * aSourceString)
|
|||
}
|
||||
return dstPtr;
|
||||
}
|
||||
|
||||
|
||||
nsresult CreateUnicodeStringFromUtf7(const char *aSourceString, PRUnichar **aUnicodeStr)
|
||||
{
|
||||
if (!aUnicodeStr)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
PRUnichar *convertedString = NULL;
|
||||
nsresult res;
|
||||
NS_WITH_SERVICE(nsICharsetConverterManager, ccm, kCharsetConverterManagerCID, &res);
|
||||
|
||||
if(NS_SUCCEEDED(res) && (nsnull != ccm))
|
||||
{
|
||||
nsString aCharset; aCharset.AssignWithConversion("x-imap4-modified-utf7");
|
||||
PRUnichar *unichars = nsnull;
|
||||
PRInt32 unicharLength;
|
||||
|
||||
// convert utf7 to unicode
|
||||
nsIUnicodeDecoder* decoder = nsnull;
|
||||
|
||||
res = ccm->GetUnicodeDecoder(&aCharset, &decoder);
|
||||
if(NS_SUCCEEDED(res) && (nsnull != decoder))
|
||||
{
|
||||
PRInt32 srcLen = PL_strlen(aSourceString);
|
||||
res = decoder->GetMaxLength(aSourceString, srcLen, &unicharLength);
|
||||
// temporary buffer to hold unicode string
|
||||
unichars = new PRUnichar[unicharLength + 1];
|
||||
if (unichars == nsnull)
|
||||
{
|
||||
res = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
else
|
||||
{
|
||||
res = decoder->Convert(aSourceString, &srcLen, unichars, &unicharLength);
|
||||
unichars[unicharLength] = 0;
|
||||
}
|
||||
NS_IF_RELEASE(decoder);
|
||||
nsString unicodeStr(unichars);
|
||||
convertedString = unicodeStr.ToNewUnicode();
|
||||
delete [] unichars;
|
||||
}
|
||||
}
|
||||
*aUnicodeStr = convertedString;
|
||||
return (convertedString) ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
|
|
|
@ -53,8 +53,6 @@ char*
|
|||
CreateUtf7ConvertedString(const char * aSourceString,
|
||||
PRBool aConvertToUtf7Imap);
|
||||
|
||||
nsresult CreateUnicodeStringFromUtf7(const char *aSourceString, PRUnichar **result);
|
||||
|
||||
char *
|
||||
CreateUtf7ConvertedStringFromUnicode(const PRUnichar *aSourceString);
|
||||
|
||||
|
|
|
@ -76,9 +76,6 @@ mailnews/news/resources/Makefile
|
|||
mailnews/news/resources/content/Makefile
|
||||
mailnews/news/resources/locale/Makefile
|
||||
mailnews/news/resources/locale/en-US/Makefile
|
||||
mailnews/news/tests/Makefile
|
||||
mailnews/news/tests/nntp/Makefile
|
||||
mailnews/news/tests/newsParser/Makefile
|
||||
mailnews/mime/Makefile
|
||||
mailnews/mime/cthandlers/Makefile
|
||||
mailnews/mime/cthandlers/resources/Makefile
|
||||
|
|
|
@ -28,9 +28,5 @@ include $(DEPTH)/config/autoconf.mk
|
|||
|
||||
DIRS = public src build resources
|
||||
|
||||
#ifdef ENABLE_TESTS
|
||||
#DIRS += tests
|
||||
#endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
|
|
|
@ -882,11 +882,11 @@ nsNntpIncomingServer::SetDelimiter(char aDelimiter)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNntpIncomingServer::SetAsSubscribedInSubscribeDS(const char *aName)
|
||||
nsNntpIncomingServer::SetAsSubscribedInSubscribeDS(const char *aURI)
|
||||
{
|
||||
NS_ASSERTION(mInner,"not initialized");
|
||||
if (!mInner) return NS_ERROR_FAILURE;
|
||||
return mInner->SetAsSubscribedInSubscribeDS(aName);
|
||||
return mInner->SetAsSubscribedInSubscribeDS(aURI);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -906,7 +906,7 @@ nsNntpIncomingServer::AddToSubscribeDS(const char *aName)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNntpIncomingServer::SetPropertiesInSubscribeDS(const char *uri, const char *aName, nsIRDFResource *aResource)
|
||||
nsNntpIncomingServer::SetPropertiesInSubscribeDS(const char *uri, const PRUnichar *aName, nsIRDFResource *aResource)
|
||||
{
|
||||
NS_ASSERTION(mInner,"not initialized");
|
||||
if (!mInner) return NS_ERROR_FAILURE;
|
||||
|
|
Загрузка…
Ссылка в новой задаче