Checked in patch for bug 246115: Add support for launching calendar to xremote

r=shaver sr=shaver


git-svn-id: svn://10.0.0.236/trunk@168991 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
mostafah%oeone.com
2005-02-08 18:23:45 +00:00
parent beeae308b3
commit d6a3c1f7f6
2 changed files with 49 additions and 0 deletions

View File

@@ -699,6 +699,24 @@ XRemoteService::GetComposeLocation(const char **_retval)
return NS_OK;
}
nsresult
XRemoteService::GetCalendarLocation(char **_retval)
{
// get the calendar chrome URL
nsCOMPtr<nsIPref> prefs;
prefs = do_GetService(NS_PREF_CONTRACTID);
if (!prefs)
return NS_ERROR_FAILURE;
prefs->CopyCharPref("calendar.chromeURL", _retval);
// fallback
if (!*_retval)
*_retval = nsCRT::strdup("chrome://calendar/content/calendar.xul");
return NS_OK;
}
PRBool
XRemoteService::MayOpenURL(const nsCString &aURL)
{
@@ -1087,6 +1105,36 @@ XRemoteService::XfeDoCommand(nsCString &aArgument,
arg, getter_AddRefs(newWindow));
}
// open a new calendar window
else if (aArgument.LowerCaseEqualsLiteral("opencalendar")) {
// check to see if it's already running
nsCOMPtr<nsIDOMWindowInternal> domWindow;
rv = FindWindow(NS_LITERAL_STRING("calendarMainWindow").get(),
getter_AddRefs(domWindow));
if (NS_FAILED(rv))
return rv;
// focus the window if it was found
if (domWindow) {
domWindow->Focus();
}
// otherwise open a new calendar window
else {
nsXPIDLCString calendarChrome;
rv = GetCalendarLocation(getter_Copies(calendarChrome));
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIDOMWindow> newWindow;
rv = OpenChromeWindow(0, calendarChrome, "chrome,all,dialog=no",
arg, getter_AddRefs(newWindow));
}
}
return rv;
}

View File

@@ -87,6 +87,7 @@ class XRemoteService : public nsIXRemoteService, public nsIObserver {
nsresult GetBrowserLocation(char **_retval);
nsresult GetMailLocation(char **_retval);
nsresult GetComposeLocation(const char **_retval);
nsresult GetCalendarLocation(char **_retval);
// returns true if the URL may be loaded.
PRBool MayOpenURL(const nsCString &aURL);