Esempio n. 1
0
    def OnEditCalendarEvent(self, eventID, ownerID, oldEventDateTime, eventDateTime, eventDuration, eventTitle, importance, autoEventType = None):
        """
            This event is fired when the character is invited to a new calendar event.
            If the month/year of the event already exists in the eventList, then this
            event should be added. Otherwise, this event can be ignored.
        """
        oldYear, oldMonth = util.GetYearMonthFromTime(oldEventDateTime)
        if eventID in self.nextEvents:
            self.nextEvents.pop(eventID)
        if eventID in self.eventDetails:
            self.eventDetails.pop(eventID)
        if oldEventDateTime != eventDateTime:
            if self.eventResponses is None:
                self.GetEventResponses()
            if ownerID != session.charid:
                oldReply = self.eventResponses.get(eventID, const.eventResponseUndecided)
                if oldReply in (const.eventResponseUndecided, const.eventResponseAccepted, const.eventResponseMaybe):
                    self.eventResponses[eventID] = const.eventResponseUndecided
                    year, month = util.GetYearMonthFromTime(eventDateTime)
                    if eventDateTime > blue.os.GetWallclockTime() and self.IsInNextEventsWindow(year, month):
                        sm.GetService('neocom').Blink('calendar')
            self.objectCaching.InvalidateCachedMethodCall('calendarMgr', 'GetResponsesToEvent', eventID, ownerID)
        eventList = self.events.get((oldMonth, oldYear))
        if eventList is not None:
            for evt in eventList:
                if eventID == evt.eventID:
                    eventList.remove(evt)

            self.events[oldMonth, oldYear] = eventList
        self.OnNewCalendarEvent(eventID, ownerID, eventDateTime, eventDuration, eventTitle, importance, autoEventType, doBlink=False)
Esempio n. 2
0
 def OnNewCalendarEvent(self,
                        eventID,
                        ownerID,
                        eventDateTime,
                        eventDuration,
                        eventTitle,
                        importance,
                        autoEventType=None,
                        doBlink=True):
     year, month = util.GetYearMonthFromTime(eventDateTime)
     now = blue.os.GetWallclockTime()
     eventList = self.events.get((month, year))
     if eventList is not None:
         if eventID not in [x.eventID for x in eventList]:
             eventKV = util.KeyVal(eventID=eventID,
                                   ownerID=ownerID,
                                   eventDateTime=eventDateTime,
                                   eventDuration=eventDuration,
                                   eventTitle=eventTitle,
                                   importance=importance,
                                   flag=self.GetEventFlag(
                                       ownerID, autoEventType))
             eventKV.isDeleted = False
             eventKV.dateModified = blue.os.GetWallclockTime()
             eventList.append(eventKV)
             self.events[month, year] = eventList
             if eventDateTime > now and self.IsInNextEventsWindow(
                     year, month):
                 self.nextEvents[eventID] = eventKV
     if doBlink and ownerID != session.charid and eventDateTime > now and self.IsInNextEventsWindow(
             year, month):
         sm.GetService('neocom').Blink('calendar')
     sm.ScatterEvent('OnReloadCalendar')
     sm.ScatterEvent('OnReloadToDo')
Esempio n. 3
0
 def IsInNextEventsWindow(self, eventYear, eventMonth):
     now = blue.os.GetWallclockTime(
     ) + eveLocalization.GetTimeDelta() * const.SEC
     nowYear, nowMonth = util.GetYearMonthFromTime(now)
     if eventYear == nowYear:
         return eventMonth in (nowMonth, nowMonth + 1)
     if eventYear == nowYear + 1:
         return nowMonth == const.calendarDecember and eventMonth == const.calendarJanuary
     return False
Esempio n. 4
0
 def IsInNextEventsWindow(self, eventYear, eventMonth):
     """
         Determines if the event datetime is in the current month or next month.
         If so, then the event should be shown in Latest Update / Upcoming Events
         lists.
     """
     now = blue.os.GetWallclockTime() + eveLocalization.GetTimeDelta() * const.SEC
     nowYear, nowMonth = util.GetYearMonthFromTime(now)
     if eventYear == nowYear:
         return eventMonth in (nowMonth, nowMonth + 1)
     if eventYear == nowYear + 1:
         return nowMonth == const.calendarDecember and eventMonth == const.calendarJanuary
     return False
Esempio n. 5
0
 def OnNewCalendarEvent(self, eventID, ownerID, eventDateTime, eventDuration, eventTitle, importance, autoEventType = None, doBlink = True):
     """
         This event is fired when the character is invited to a new calendar event.
         If the month/year of the event already exists in the eventList, then this
         event should be added. Otherwise, this event can be ignored.
     """
     year, month = util.GetYearMonthFromTime(eventDateTime)
     now = blue.os.GetWallclockTime()
     eventList = self.events.get((month, year))
     if eventList is not None:
         if eventID not in [ x.eventID for x in eventList ]:
             eventKV = util.KeyVal(eventID=eventID, ownerID=ownerID, eventDateTime=eventDateTime, eventDuration=eventDuration, eventTitle=eventTitle, importance=importance, flag=self.GetEventFlag(ownerID, autoEventType))
             eventKV.isDeleted = False
             eventKV.dateModified = blue.os.GetWallclockTime()
             eventList.append(eventKV)
             self.events[month, year] = eventList
             if eventDateTime > now and self.IsInNextEventsWindow(year, month):
                 self.nextEvents[eventID] = eventKV
     if doBlink and ownerID != session.charid and eventDateTime > now and self.IsInNextEventsWindow(year, month):
         sm.GetService('neocom').Blink('calendar')
     sm.ScatterEvent('OnReloadCalendar')
     sm.ScatterEvent('OnReloadToDo')