diff --git a/mozilla/xpfe/components/xremote/src/XRemoteService.cpp b/mozilla/xpfe/components/xremote/src/XRemoteService.cpp index 1da2b5697b2..481b8faca6d 100644 --- a/mozilla/xpfe/components/xremote/src/XRemoteService.cpp +++ b/mozilla/xpfe/components/xremote/src/XRemoteService.cpp @@ -498,6 +498,38 @@ XRemoteService::BuildResponse(const char *aError, const char *aMessage) return retval; } +void +XRemoteService::FindRestInList(nsCString &aString, nsCString &retString, + PRUint32 *aIndexRet) +{ + // init our return + *aIndexRet = 0; + nsCString tempString; + PRInt32 strIndex; + // find out if there's a comma from the start of the string + strIndex = aString.FindChar(','); + + // give up now if you can + if (strIndex == kNotFound) + return; + + // cut the string down to the first , + tempString = Substring(aString, strIndex+1, aString.Length()); + + // strip off leading + trailing whitespace + tempString.Trim(" ", PR_TRUE, PR_TRUE); + + // see if we've reduced it to nothing + if (tempString.IsEmpty()) + return; + + *aIndexRet = strIndex; + + // otherwise, return it as a new C string + retString = tempString; + +} + void XRemoteService::FindLastInList(nsCString &aString, nsCString &retString, PRUint32 *aIndexRet) @@ -589,6 +621,15 @@ XRemoteService::GetMailLocation(char **_retval) } +nsresult +XRemoteService::GetComposeLocation(const char **_retval) +{ + // get the Compose chrome URL + *_retval = "chrome://messenger/content/messengercompose/messengercompose.xul"; + + return NS_OK; +} + nsresult XRemoteService::OpenURL(nsCString &aArgument, nsIDOMWindowInternal *aParent, @@ -810,6 +851,22 @@ XRemoteService::XfeDoCommand(nsCString &aArgument, nsIDOMWindowInternal *aParent) { nsresult rv = NS_OK; + + // see if there are any arguments on the end + nsCString restArgument; + PRUint32 index; + FindRestInList(aArgument, restArgument, &index); + + if (!restArgument.IsEmpty()) + aArgument.Truncate(index); + nsCOMPtr arg; + arg = do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID, &rv); + + if (NS_FAILED(rv)) + return rv; + + // pass the second argument as parameter + arg->SetData(NS_ConvertUTF8toUCS2(restArgument)); // someone requested opening mail/news if (aArgument.EqualsIgnoreCase("openinbox")) { @@ -838,7 +895,7 @@ XRemoteService::XfeDoCommand(nsCString &aArgument, nsCOMPtr newWindow; rv = OpenChromeWindow(0, mailLocation, "chrome,all,dialog=no", - nsnull, getter_AddRefs(newWindow)); + arg, getter_AddRefs(newWindow)); } } @@ -851,13 +908,23 @@ XRemoteService::XfeDoCommand(nsCString &aArgument, nsCOMPtr newWindow; rv = OpenChromeWindow(0, browserLocation, "chrome,all,dialog=no", - nsnull, getter_AddRefs(newWindow)); + arg, getter_AddRefs(newWindow)); } // open a new compose window else if (aArgument.EqualsIgnoreCase("composemessage")) { - nsCString tempString("mailto:"); - rv = OpenURL(tempString, nsnull, PR_FALSE); + /* + * Here we change to OpenChromeWindow instead of OpenURL so as to + * pass argument values to the compose window, especially attachments + */ + const char * composeLocation; + rv = GetComposeLocation(&composeLocation); + if (rv != NS_OK) + return NS_ERROR_FAILURE; + + nsCOMPtr newWindow; + rv = OpenChromeWindow(0, composeLocation, "chrome,all,dialog=no", + arg, getter_AddRefs(newWindow)); } return rv; diff --git a/mozilla/xpfe/components/xremote/src/XRemoteService.h b/mozilla/xpfe/components/xremote/src/XRemoteService.h index 7d549b55928..38eb1bbab6c 100644 --- a/mozilla/xpfe/components/xremote/src/XRemoteService.h +++ b/mozilla/xpfe/components/xremote/src/XRemoteService.h @@ -52,6 +52,10 @@ class XRemoteService : public nsIXRemoteService { // find the last argument in an argument string void FindLastInList(nsCString &aString, nsCString &retString, + PRUint32 *aIndexRet); + + // find the second argument through the last argument in the string + void FindRestInList(nsCString &aString, nsCString &retString, PRUint32 *aIndexRet); // short cut for opening chrome windows @@ -64,6 +68,7 @@ class XRemoteService : public nsIXRemoteService { // get the primary browser chrome location nsresult GetBrowserLocation(char **_retval); nsresult GetMailLocation(char **_retval); + nsresult GetComposeLocation(const char **_retval); // remote command handlers nsresult OpenURL(nsCString &aArgument,