зеркало из https://github.com/mozilla/gecko-dev.git
Made progress on bug 134969: Add alarms to nsnotify/Alarm as well if Calendar is not running
by changing calendar icon in taskbar when alarm goes off.
This commit is contained in:
Родитель
f939dab6e1
Коммит
7148814fee
|
@ -53,6 +53,7 @@ REQUIRES = xpcom \
|
|||
necko \
|
||||
msgcompose \
|
||||
addrbook \
|
||||
dom \
|
||||
ical \
|
||||
icalss \
|
||||
$(NULL)
|
||||
|
|
|
@ -229,7 +229,17 @@ oeICalContainerImpl::AddCalendar( const char *server ) {
|
|||
#endif
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<oeIICal> calendar = do_CreateInstance(OE_ICAL_CONTRACTID, &rv);
|
||||
|
||||
nsCOMPtr<oeIICal> calendar;
|
||||
GetCalendar( server , getter_AddRefs(calendar) );
|
||||
if( calendar ) {
|
||||
#ifdef ICAL_DEBUG_ALL
|
||||
printf( "oeICalContainerImpl::AddCalendar()-Warning: Calendar already exists\n" );
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
calendar = do_CreateInstance(OE_ICAL_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -252,6 +262,8 @@ oeICalContainerImpl::AddCalendar( const char *server ) {
|
|||
calendar->AddTodoObserver( tmpobserver );
|
||||
}
|
||||
|
||||
calendar->SetBatchMode( m_batchMode ); //Make sure the current batchmode value is inherited
|
||||
|
||||
calendar->SetServer( server );
|
||||
|
||||
return NS_OK;
|
||||
|
|
|
@ -53,6 +53,12 @@
|
|||
#include "nsISupportsArray.h"
|
||||
#include "nsXPCOM.h"
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsIWindowMediator.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMElement.h"
|
||||
|
||||
|
||||
extern "C" {
|
||||
#include "icalss.h"
|
||||
|
@ -1668,6 +1674,57 @@ void AlarmTimerCallback(nsITimer *aTimer, void *aClosure)
|
|||
icallib->SetupAlarmManager();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP UpdateCalendarIcon( PRBool hasAlarm )
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIWindowMediator> windowMediator =
|
||||
do_GetService(NS_WINDOWMEDIATOR_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
static PRBool lastTimeHadAlarm = false;
|
||||
|
||||
if( lastTimeHadAlarm == hasAlarm )
|
||||
return NS_OK;
|
||||
|
||||
lastTimeHadAlarm = hasAlarm;
|
||||
nsCOMPtr<nsISimpleEnumerator> windowEnumerator;
|
||||
|
||||
// why use DOM window enumerator instead of XUL window...????
|
||||
if (NS_SUCCEEDED(windowMediator->GetEnumerator(nsnull, getter_AddRefs(windowEnumerator))))
|
||||
{
|
||||
PRBool more;
|
||||
|
||||
windowEnumerator->HasMoreElements(&more);
|
||||
|
||||
while(more)
|
||||
{
|
||||
nsCOMPtr<nsISupports> nextWindow = nsnull;
|
||||
windowEnumerator->GetNext(getter_AddRefs(nextWindow));
|
||||
nsCOMPtr<nsIDOMWindowInternal> domWindow(do_QueryInterface(nextWindow));
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> domDocument;
|
||||
domWindow->GetDocument(getter_AddRefs(domDocument));
|
||||
|
||||
if(domDocument)
|
||||
{
|
||||
nsCOMPtr<nsIDOMElement> domElement;
|
||||
domDocument->GetElementById(NS_LITERAL_STRING("mini-cal"), getter_AddRefs(domElement));
|
||||
|
||||
if (domElement) {
|
||||
if ( hasAlarm ) {
|
||||
domElement->SetAttribute(NS_LITERAL_STRING("BiffState"), NS_LITERAL_STRING("Alarm"));
|
||||
}
|
||||
else {
|
||||
domElement->RemoveAttribute(NS_LITERAL_STRING("BiffState"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
windowEnumerator->HasMoreElements(&more);
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void oeICalImpl::SetupAlarmManager() {
|
||||
#ifdef ICAL_DEBUG
|
||||
printf( "oeICalImpl::SetupAlarmManager()\n" );
|
||||
|
@ -1682,6 +1739,8 @@ void oeICalImpl::SetupAlarmManager() {
|
|||
return;
|
||||
}
|
||||
|
||||
UpdateCalendarIcon( false );
|
||||
|
||||
PRTime todayinms = PR_Now();
|
||||
PRInt64 usecpermsec;
|
||||
LL_I2L( usecpermsec, PR_USEC_PER_MSEC );
|
||||
|
@ -1706,6 +1765,8 @@ void oeICalImpl::SetupAlarmManager() {
|
|||
printf( "ALARM WENT OFF: %s\n", icaltime_as_ical_string( alarmtime ) );
|
||||
#endif
|
||||
|
||||
UpdateCalendarIcon( true );
|
||||
|
||||
nsresult rv;
|
||||
oeIICalEventDisplay* eventDisplay;
|
||||
rv = NS_NewICalEventDisplay( event, &eventDisplay );
|
||||
|
|
|
@ -127,6 +127,9 @@ function calendarInit()
|
|||
// get the Ical Library
|
||||
gICalLib = gEventSource.getICalLib();
|
||||
|
||||
// this suspends feedbacks to observers until all is settled
|
||||
gICalLib.batchMode = true;
|
||||
|
||||
// set up the CalendarWindow instance
|
||||
|
||||
gCalendarWindow = new CalendarWindow();
|
||||
|
@ -196,6 +199,9 @@ function calendarInit()
|
|||
document.getElementById( 'event-filter-menulist' ).selectedItem = document.getElementById( 'event-filter-'+value );
|
||||
|
||||
gEventSource.alarmObserver.firePendingAlarms();
|
||||
|
||||
//All is settled, enable feedbacks to observers
|
||||
gICalLib.batchMode = false;
|
||||
}
|
||||
|
||||
// Set the date and time on the clock and set up a timeout to refresh the clock when the
|
||||
|
|
|
@ -101,7 +101,7 @@
|
|||
function CalendarEventDataSource( )
|
||||
{
|
||||
try {
|
||||
var iCalLibComponent = Components.classes["@mozilla.org/ical-container;1"].createInstance();
|
||||
var iCalLibComponent = Components.classes["@mozilla.org/ical-container;1"].getService();
|
||||
} catch ( e ) {
|
||||
alert(
|
||||
"The calendar cannot run due to the following error:\n"+
|
||||
|
|
|
@ -115,6 +115,8 @@ calendar.jar:
|
|||
skin/classic/calendar/synch_animated.gif (skin/classic/synch_animated.gif)
|
||||
skin/classic/calendar/taskbar-cal.gif (skin/classic/taskbar-cal.gif)
|
||||
skin/classic/calendar/taskbar-cal-act.gif (skin/classic/taskbar-cal-act.gif)
|
||||
skin/classic/calendar/taskbar-calalarm.gif (skin/classic/taskbar-calalarm.gif)
|
||||
skin/classic/calendar/taskbar-calalarm-act.gif (skin/classic/taskbar-calalarm-act.gif)
|
||||
skin/classic/calendar/week-view-corner.png (skin/classic/week-view-corner.png)
|
||||
skin/classic/calendar/ca-event-dialog/calendar_disabled.gif (skin/classic/ca-event-dialog/calendar_disabled.gif)
|
||||
skin/classic/calendar/ca-event-dialog/calendar_down.gif (skin/classic/ca-event-dialog/calendar_down.gif)
|
||||
|
@ -158,6 +160,8 @@ calendar.jar:
|
|||
skin/modern/calendar/synch_animated.gif (skin/modern/synch_animated.gif)
|
||||
skin/modern/calendar/taskbar-cal.gif (skin/modern/taskbar-cal.gif)
|
||||
skin/modern/calendar/taskbar-cal-act.gif (skin/modern/taskbar-cal-act.gif)
|
||||
skin/modern/calendar/taskbar-calalarm.gif (skin/modern/taskbar-calalarm.gif)
|
||||
skin/modern/calendar/taskbar-calalarm-act.gif (skin/modern/taskbar-calalarm-act.gif)
|
||||
skin/modern/calendar/week-view-corner.png (skin/modern/week-view-corner.png)
|
||||
skin/modern/calendar/ca-event-dialog/calendar_disabled.gif (skin/modern/ca-event-dialog/calendar_disabled.gif)
|
||||
skin/modern/calendar/ca-event-dialog/calendar_down.png (skin/modern/ca-event-dialog/calendar_down.png)
|
||||
|
|
|
@ -45,6 +45,14 @@
|
|||
list-style-image: url("chrome://calendar/skin/taskbar-cal-act.gif");
|
||||
}
|
||||
|
||||
#mini-cal[BiffState="Alarm"] {
|
||||
list-style-image: url("chrome://calendar/skin/taskbar-calalarm.gif");
|
||||
}
|
||||
|
||||
#mini-cal[BiffState="Alarm"]:hover:active {
|
||||
list-style-image: url("chrome://calendar/skin/taskbar-calalarm-act.gif");
|
||||
}
|
||||
|
||||
.icon-calendar16 {
|
||||
list-style-image: url("chrome://calendar/skin/calendar-16.gif");
|
||||
}
|
||||
|
|
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 210 B |
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 204 B |
|
@ -45,6 +45,14 @@
|
|||
list-style-image: url("chrome://calendar/skin/taskbar-cal-act.gif");
|
||||
}
|
||||
|
||||
#mini-cal[BiffState="Alarm"] {
|
||||
list-style-image: url("chrome://calendar/skin/taskbar-calalarm.gif");
|
||||
}
|
||||
|
||||
#mini-cal[BiffState="Alarm"]:hover:active {
|
||||
list-style-image: url("chrome://calendar/skin/taskbar-calalarm-act.gif");
|
||||
}
|
||||
|
||||
.icon-calendar16 {
|
||||
list-style-image: url("chrome://calendar/skin/calendar-16.gif");
|
||||
}
|
||||
|
|
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 210 B |
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 204 B |
Загрузка…
Ссылка в новой задаче