Bug 793118 - Do not send network shared file as normal attachment when already uploded to filelink. r=mkmelin,jorgk a=wsmwk
--- a/mailnews/compose/src/nsMsgCompUtils.cpp
+++ b/mailnews/compose/src/nsMsgCompUtils.cpp
@@ -1302,29 +1302,16 @@ nsresult nsMsgNewURL(nsIURI** aInstanceP
nsAutoCString uri(NS_LITERAL_CSTRING("http://"));
uri.Append(aSpec);
rv = pNetService->NewURI(uri, nullptr, nullptr, aInstancePtrResult);
} else
rv = pNetService->NewURI(aSpec, nullptr, nullptr, aInstancePtrResult);
return rv;
}
-bool nsMsgIsLocalFile(const char* url) {
- // A url is considered as a local file if it's start with file://
- // But on Window, we need to filter UNC file url because there
- // are not really local file. Those start with file:////
- if (PL_strncasecmp(url, "file://", 7) == 0) {
-#ifdef XP_WIN
- if (PL_strncasecmp(url, "file:////", 9) == 0) return false;
-#endif
- return true;
- } else
- return false;
-}
-
char* nsMsgGetLocalFileFromURL(const char* url) {
char* finalPath;
NS_ASSERTION(PL_strncasecmp(url, "file://", 7) == 0, "invalid url");
finalPath = (char*)PR_Malloc(strlen(url));
if (finalPath == NULL) return NULL;
strcpy(finalPath, url + 6 + 1);
return finalPath;
}
--- a/mailnews/compose/src/nsMsgCompUtils.h
+++ b/mailnews/compose/src/nsMsgCompUtils.h
@@ -102,17 +102,16 @@ void msg_pick_real_name(nsMsgAttachmentH
//
void nsMsgMIMESetConformToStandard(bool conform_p);
bool nsMsgMIMEGetConformToStandard(void);
//
// network service type calls...
//
nsresult nsMsgNewURL(nsIURI** aInstancePtrResult, const nsCString& aSpec);
-bool nsMsgIsLocalFile(const char* url);
char* nsMsgGetLocalFileFromURL(const char* url);
char* nsMsgParseURLHost(const char* url);
char* GenerateFileNameFromURI(nsIURI* aURL);
//
// Folder calls...
--- a/mailnews/compose/src/nsMsgSend.cpp
+++ b/mailnews/compose/src/nsMsgSend.cpp
@@ -1687,17 +1687,17 @@ nsresult nsMsgComposeAndSend::CountCompF
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIMsgAttachment> attachment = do_QueryInterface(element, &rv);
if (NS_SUCCEEDED(rv) && attachment) {
attachment->GetUrl(url);
if (!url.IsEmpty()) {
// Check to see if this is a file URL, if so, don't retrieve
// like a remote URL...
- if (nsMsgIsLocalFile(url.get()))
+ if (PL_strncasecmp(url.get(), "file://", 7) == 0)
mCompFieldLocalAttachments++;
else // This is a remote URL...
mCompFieldRemoteAttachments++;
}
}
}
return NS_OK;
@@ -1743,17 +1743,17 @@ nsresult nsMsgComposeAndSend::AddCompFie
// m_attachments[newLoc]->m_done = true;
attachment->GetHtmlAnnotation(m_attachments[newLoc]->mHtmlAnnotation);
m_attachments[newLoc]->m_type.AssignLiteral("text/html");
attachment->GetCloudFileAccountKey(
m_attachments[newLoc]->mCloudFileAccountKey);
attachment->GetContentLocation(m_attachments[newLoc]->mCloudUrl);
}
// Just look for local file:// attachments and do the right thing.
- if (nsMsgIsLocalFile(url.get())) {
+ if (PL_strncasecmp(url.get(), "file://", 7) == 0) {
//
// Now we have to setup the m_attachments entry for the file://
// URL that is passed in...
//
m_attachments[newLoc]->mDeleteFile = false;
nsMsgNewURL(getter_AddRefs(m_attachments[newLoc]->mURL), url);
@@ -1913,17 +1913,17 @@ nsresult nsMsgComposeAndSend::AddCompFie
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIMsgAttachment> attachment = do_QueryInterface(element, &rv);
if (NS_SUCCEEDED(rv) && attachment) {
attachment->GetUrl(url);
if (!url.IsEmpty()) {
// Just look for files that are NOT local file attachments and do
// the right thing.
- if (!nsMsgIsLocalFile(url.get())) {
+ if (PL_strncasecmp(url.get(), "file://", 7) != 0) {
// Check for message attachment, see
// nsMsgMailNewsUrl::GetIsMessageUri.
nsCOMPtr<nsIURI> nsiuri;
rv = NS_MutateURI(NS_STANDARDURLMUTATOR_CONTRACTID)
.SetSpec(url)
.Finalize(nsiuri);
NS_ENSURE_SUCCESS(rv, rv);