Removing extinct nsCalScheduler

Removing references to global mpCalendar in the shell (Now owned by nsILayer)
Have Canvas's ask the layer for events for painting
This commit is contained in:
spider%netscape.com 1998-10-02 19:40:44 +00:00
parent 128f141229
commit 95383219c1
13 changed files with 14 additions and 420 deletions

View File

@ -19,7 +19,6 @@ PRIVATE_EXPORTS = \
nsCalendarUser.h \
nsCalList.h \
nsCalLoggedInUser.h \
nsCalScheduler.h \
nsCalSession.h \
nsCalSessionMgr.h \
nsCalUser.h \

View File

@ -1,52 +0,0 @@
/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2
-*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/**
* nsCalScheduler
* Wraps all the capi and parsing code. A more convenient
* interface for performing scheduling tasks.
*
* sman
*/
#if !defined(AFX_NSCALSCHEDULER_H__A53027E1_42D1_11D2_8ED8_0060088A4B1D__INCLUDED_)
#define AFX_NSCALSCHEDULER_H__A53027E1_42D1_11D2_8ED8_0060088A4B1D__INCLUDED_
#include "nscore.h"
#include "nsError.h"
#include "nsCom.h"
#include "capi.h"
#include "julnstr.h"
#include "nsDateTime.h"
#include "nscalexport.h"
class nsCalendarShell;
class NS_CALENDAR nsCalScheduler
{
nsCalendarShell* mpShell;
public:
nsCalScheduler();
virtual ~nsCalScheduler();
nsresult InitialLoadData();
nsresult SetShell(nsCalendarShell* p) {mpShell = p; return NS_OK; }
};
#endif // !defined(AFX_NSCALSCHEDULER_H__A53027E1_42D1_11D2_8ED8_0060088A4B1D__INCLUDED_)

View File

@ -21,7 +21,6 @@ CPPSRCS = \
nsCalUserList.cpp \
nsCalList.cpp \
nsCalLoggedInUser.cpp \
nsCalScheduler.cpp \
nsCalSession.cpp \
nsCalSessionMgr.cpp \
nsCalUser.cpp \

View File

@ -1,316 +0,0 @@
/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2
-*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/**
* nsCalScheduler
* Wraps the functions that get and put events on a calendar store.
*
* sman
*/
#include "jdefines.h"
#include "julnstr.h"
#include "nsCalShellFactory.h"
#include "nsString.h"
#include "nsFont.h"
#include "nsCalShellCIID.h"
#include "nsXPFCObserverManager.h"
#include "nsCRT.h"
#include "plstr.h"
#include "prmem.h"
#include "prenv.h"
#include "julnstr.h"
#include "icalfrdr.h"
#include "nsIPref.h"
#include "nsCurlParser.h"
#include "nsCalUser.h"
#include "nsCalLoggedInUser.h"
#include "nsCalendarShell.h"
#include "nscalstrings.h"
#include "nsxpfcCIID.h"
#include "nsIAppShell.h"
#include "nsICommandServer.h"
#include "nsCalUICIID.h"
#include "nsCalCommandCanvas.h"
#include "nlsloc.h"
#include "nsCapiCIID.h"
#include "nspr.h"
#include "prcvar.h"
#include "nsCalStreamReader.h"
#include "nsCalScheduler.h"
#include "nsCalSessionMgr.h"
nsCalScheduler::nsCalScheduler()
{
mpShell = 0;
}
nsCalScheduler::~nsCalScheduler()
{
}
/*
* CAPI Callback used to fetch data from a general CAPI location
* Gets nsCalStreamReader object.
* If parse not started yet.
* Start the parser - the parser will block automatically when
* no more data to parse.
* When parse is blocked, set size handled
*/
static int RcvData(void * pData,
char * pBuf,
size_t iSize,
size_t * piTransferred)
{
nsCalStreamReader * pCalStreamReader = (nsCalStreamReader *) pData;
nsCapiCallbackReader * pCapiCallbackReader = pCalStreamReader->getReader();
if (!pCalStreamReader->isParseStarted())
{
PRMonitor * pMon = (PRMonitor*) pCalStreamReader->getCallerData();
pCalStreamReader->setParseStarted();
/*
* Start up the thread that will receive the ical data
*/
PR_ExitMonitor(pMon);
}
/*
* We're going to be adding a new buffer (unicode string) to the
* list of data. We don't want the other thread accessing the list
* while we're doing this. So, we enter the monitor...
*/
PR_EnterMonitor((PRMonitor *)pCapiCallbackReader->getMonitor());
/*
* if we're finished, set the CapiCallbackReader to finished.
*/
if (iSize == 0)
{
pCapiCallbackReader->setFinished();
}
else
{
/*
* XXX: may want to ensure that pBuf is 0 terminated.
*/
char * pBufCopy = new char[strlen(pBuf)];
strncpy(pBufCopy, pBuf, (size_t) strlen(pBuf));
nsCapiBufferStruct * capiBuffer = new nsCapiBufferStruct();
capiBuffer->m_pBuf = pBufCopy;
capiBuffer->m_pBufSize = iSize;
pCapiCallbackReader->AddBuffer(capiBuffer);
*piTransferred = iSize;
}
/*
* The parsing thread may be waiting on more data before it
* can continue. When this happens, it enters a PR_WAIT for
* this monitor. We've just finished adding more data, so we
* want to notify the other thread now if it's waiting.
*/
PR_Notify((PRMonitor *)pCapiCallbackReader->getMonitor());
PR_ExitMonitor((PRMonitor *)pCapiCallbackReader->getMonitor());
/*
* Now that another buffer is available for parsing, we want
* the parsing thread to take over. This will help keep the
* list of unparsed buffers to a minimum.
*/
// PR_Sleep(PR_INTERVAL_NO_WAIT);
return iSize > 0 ? 0 : -1;
}
/*
* required to set gasViewPropList and giViewPropListCount for now
* will need to change local CAPI so null gasViewPropList will return
* all properties.
*/
static char * gasViewPropList[10] = {
"ATTENDEE", "DTSTART", "DTEND", "UID", "RECURRENCE-ID",
"DTSTAMP", "SUMMARY", "DESCRIPTION", "ORGANIZER", "TRANSP"
};
static int giViewPropListCount = 10;
/**
* Given an nsICapi interface, log in and get some initial data.
* @return NS_OK on success.
*/
nsresult nsCalScheduler::InitialLoadData(/*nsIUser* pUser*/)
{
nsresult res;
ErrorCode status = ZERO_ERROR;
DateTime d;
char * psDTStart = 0;
char * psDTEnd = 0;
CAPIStream RcvStream = 0;
CAPIStatus capiStatus;
JulianPtrArray * pParsedCalList = new JulianPtrArray(); // destroyed
nsCalStreamReader * pCalStreamReader = 0; // destroyed
PRThread * parseThread = 0;
PRThread * mainThread = 0;
PRMonitor * pCBReaderMonitor = 0; /// destroyed
PRMonitor *pThreadMonitor = 0; /// destroyed
if (0 == mpShell)
return 1; // XXX fix this
/*
* Select the capi interface to use for this operation...
*/
nsICapi* pCapi = mpShell->mSessionMgr.GetAt(0L)->mCapi;
/*
* Set up the range of time for which we'll pull events...
*/
int iOffset = 30;
d.prevDay(iOffset);
psDTStart = d.toISO8601().toCString("");
d.nextDay(2 * iOffset);
psDTEnd = d.toISO8601().toCString("");
/*
* The data is actually read and parsed in another thread. Set it all
* up here...
*/
mainThread = PR_CurrentThread();
pCBReaderMonitor = PR_NewMonitor(); // destroyed
nsCapiCallbackReader * capiReader = new nsCapiCallbackReader(pCBReaderMonitor);
pThreadMonitor = ::PR_NewMonitor(); // destroyed
PR_EnterMonitor(pThreadMonitor);
pCalStreamReader = new nsCalStreamReader(capiReader, pParsedCalList, parseThread, pThreadMonitor);
parseThread = PR_CreateThread(PR_USER_THREAD,
main_CalStreamReader,
pCalStreamReader,
PR_PRIORITY_NORMAL,
PR_LOCAL_THREAD,
PR_UNJOINABLE_THREAD,
0);
capiStatus = pCapi->CAPI_SetStreamCallbacks(
mpShell->mCAPISession, &RcvStream, 0,0,RcvData, pCalStreamReader,0);
if (CAPI_ERR_OK != capiStatus)
return 1; /* XXX: really need to fix this up */
{
/* XXX: Get rid of the local variables as soon as
* local capi can take a null list or as soon as
* cs&t capi can take a list.
*/
nsCurlParser sessionURL(mpShell->msCalURL);
char** asList = gasViewPropList;
int iListSize = giViewPropListCount;
if (nsCurlParser::eCAPI == sessionURL.GetProtocol())
{
asList = 0;
iListSize = 0;
}
capiStatus = pCapi->CAPI_FetchEventsByRange(
mpShell->mCAPISession, &mpShell->mCAPIHandle, 1, 0,
psDTStart, psDTEnd,
asList, iListSize, RcvStream);
}
if (CAPI_ERR_OK != capiStatus)
return 1; /* XXX: really need to fix this up */
/*
* Wait here until we know the thread completed.
*/
if (!pCalStreamReader->isParseFinished() )
{
PR_EnterMonitor(pThreadMonitor);
PR_Wait(pThreadMonitor,PR_INTERVAL_NO_TIMEOUT);
PR_ExitMonitor(pThreadMonitor);
}
/*
* Load the retrieved events ito our calendar...
*/
int i,j;
NSCalendar* pCal;
JulianPtrArray* pEventList;
ICalComponent* pEvent;
for ( i = 0; i < pParsedCalList->GetSize(); i++)
{
pCal = (NSCalendar*)pParsedCalList->GetAt(i);
/**
* Change the ownership of the pCal's VEvents' vector
* from pCal to m_pCalendar
*/
pEventList = pCal->changeEventsOwnership();
if (0 != pEventList)
{
for (j = 0; j < pEventList->GetSize(); j++)
{
pEvent = (ICalComponent*)pEventList->GetAt(j);
if (0 != pEvent)
mpShell->mpCalendar->addEvent(pEvent);
}
}
/**
* delete pEventList since the vector is no longer needed
* (I only care about the VEvents inside the vector,
* not the vector itself)
*/
delete pEventList; pEventList = 0;
}
/**
* cleanup allocated memory
*/
/**
* Delete each calendar in pParsedCalList.
* I won't delete the events in them because there ownership
* has been changed.
*/
for (i = pParsedCalList->GetSize() - 1; i >= 0; i--)
{
pCal = (NSCalendar *)pParsedCalList->GetAt(i);
delete pCal; pCal = 0;
}
delete [] psDTStart; psDTStart = 0;
delete [] psDTEnd; psDTEnd = 0;
delete pCalStreamReader; pCalStreamReader = 0;
delete capiReader; capiReader = 0;
PR_DestroyMonitor(pThreadMonitor);
PR_DestroyMonitor(pCBReaderMonitor);
capiStatus = pCapi->CAPI_DestroyStreams(mpShell->mCAPISession, &RcvStream, 1, 0);
if (CAPI_ERR_OK != capiStatus)
return 1; /* XXX: really need to fix this up */
/*
* register the calendar...
*/
if (NS_OK != (res = mpShell->mCalList.Add(mpShell->mpCalendar)))
return res;
return NS_OK;
}

View File

@ -50,7 +50,6 @@
#include "nspr.h"
#include "prcvar.h"
#include "nsCalStreamReader.h"
#include "nsCalScheduler.h"
#include "nsCalSessionMgr.h"
static NS_DEFINE_IID(kILayerIID, NS_ILAYER_IID);
@ -68,10 +67,17 @@ NS_IMPL_RELEASE(nsLayer)
nsLayer::~nsLayer()
{
if (nsnull != mpCal)
{
delete mpCal;
mpCal = nsnull;
}
}
nsresult nsLayer::Init()
{
mpCal = new NSCalendar(0);
return (NS_OK);
}
@ -357,7 +363,7 @@ nsresult nsLayer::FetchEventsByRange(
delete psBuf;
#endif
anArray->Add(pEvent);
mpShell->mpCalendar->addEvent(pEvent);
mpCal->addEvent(pEvent);
}
}
}
@ -384,7 +390,7 @@ nsresult nsLayer::FetchEventsByRange(
/*
* register the calendar...
*/
if (NS_OK != (res = mpShell->mCalList.Add(mpShell->mpCalendar)))
if (NS_OK != (res = mpShell->mCalList.Add(mpCal)))
return res;
return NS_OK;

View File

@ -41,7 +41,6 @@
#include "nsCalUserList.h"
#include "nsCalSessionMgr.h"
#include "capi.h"
#include "nsCalScheduler.h"
/*
* CalendarShell Class Declaration
@ -75,9 +74,6 @@ public:
NS_IMETHOD SetCAPIPassword(char * aPassword) ;
NS_IMETHOD_(char *) GetCAPIPassword() ;
NS_IMETHOD SetNSCalendar(NSCalendar * aCalendar) ;
NS_IMETHOD_(NSCalendar *) GetNSCalendar() ;
// nsIAppShell interfaces
NS_IMETHOD Create(int* argc, char ** argv) ;
NS_IMETHOD SetDispatchListener(nsDispatchListener* aDispatchListener) ;
@ -106,7 +102,6 @@ public:
CAPISession mCAPISession;
CAPIHandle mCAPIHandle;
NSCalendar * mpCalendar;
nsICalendarUser* mpLoggedInUser;
JulianString msCalURL; /* the calendar associated with this user */
@ -115,7 +110,6 @@ public:
nsCalUserList mUserList;
nsCalList mCalList;
nsCalSessionMgr mSessionMgr;
nsCalScheduler mScheduler;
nsICommandServer * mCommandServer;
};

View File

@ -56,9 +56,6 @@ public:
NS_IMETHOD SetCAPIPassword(char * aPassword) = 0;
NS_IMETHOD_(char *) GetCAPIPassword() = 0;
NS_IMETHOD SetNSCalendar(NSCalendar * aCalendar) = 0;
NS_IMETHOD_(NSCalendar *) GetNSCalendar() = 0;
NS_IMETHOD_(nsEventStatus) HandleEvent(nsGUIEvent *aEvent) = 0 ;
};

View File

@ -126,7 +126,6 @@ nsCalendarShell::nsCalendarShell()
mDocumentContainer = nsnull ;
mObserverManager = nsnull;
mCAPIPassword = nsnull;
mpCalendar = nsnull;
mpLoggedInUser = nsnull;
mCommandServer = nsnull;
mCAPISession = nsnull;
@ -142,8 +141,6 @@ nsCalendarShell::~nsCalendarShell()
if (mCAPIPassword)
PR_Free(mCAPIPassword);
if (mpCalendar)
delete mpCalendar;
if (mpLoggedInUser)
delete mpLoggedInUser;
@ -183,7 +180,6 @@ NS_IMPL_RELEASE(nsCalendarShell)
nsresult nsCalendarShell::Init()
{
mScheduler.SetShell(this);
/*
* Register class factrories needed for application
*/
@ -299,8 +295,6 @@ nsresult nsCalendarShell::Logon()
/*
* Begin a calendar for the logged in user...
*/
mpCalendar = new NSCalendar(0);
SetNSCalendar(mpCalendar);
switch(theURL.GetProtocol())
{
@ -313,7 +307,6 @@ nsresult nsCalendarShell::Logon()
nsILayer *pLayer;
d.prevDay(14);
d1.nextDay(14);
//mScheduler.InitialLoadData();
mpLoggedInUser->GetLayer(pLayer);
NS_ASSERTION(0 != pLayer,"null pLayer");
{
@ -327,8 +320,6 @@ nsresult nsCalendarShell::Logon()
}
pLayer->SetShell(this);
pLayer->FetchEventsByRange(&d,&d1,&EventList);
pLayer->SetCal(mpCalendar);
mpCalendar->addEventList(&EventList);
}
break;
@ -626,7 +617,6 @@ nsresult nsCalendarShell::LoadUI()
return res ;
mDocumentContainer->SetApplicationShell((nsIApplicationShell*)this);
//((nsCalendarContainer *)mDocumentContainer)->mpCalendarShell = this;
mDocumentContainer->SetToolbarManager(mShellInstance->GetToolbarManager());
@ -704,18 +694,6 @@ CAPISession nsCalendarShell::GetCAPISession()
return (mCAPISession);
}
nsresult nsCalendarShell::SetNSCalendar(NSCalendar * aNSCalendar)
{
mpCalendar = aNSCalendar;
return NS_OK;
}
NSCalendar * nsCalendarShell::GetNSCalendar()
{
return (mpCalendar);
}
nsresult nsCalendarShell::Create(int* argc, char ** argv)
{
return NS_OK;

View File

@ -237,16 +237,7 @@ nsEventStatus nsCalDayViewCanvas :: PaintForeground(nsIRenderingContext& aRender
user->GetLayer(layer);
NSCalendar * nscal;
layer->GetCal(nscal);
if (0)
{
gCalToolkit->GetNSCalendar()->getEventsByRange(evtVctr, *dStart, *dEnd);
}
nscal->getEventsByRange(evtVctr, *dStart, *dEnd);
layer->FetchEventsByRange(dStart, dEnd, evtVctr);
PRUint32 vis_start_min = GetTimeContext()->GetFirstVisibleTime(nsCalPeriodFormat_kHour) * 60 + GetTimeContext()->GetFirstVisibleTime(nsCalPeriodFormat_kMinute);
PRUint32 vis_end_min = GetTimeContext()->GetLastVisibleTime(nsCalPeriodFormat_kHour) * 60 + GetTimeContext()->GetLastVisibleTime(nsCalPeriodFormat_kMinute);

View File

@ -179,6 +179,7 @@ nsEventStatus nsCalMonthViewCanvas :: PaintForeground(nsIRenderingContext& aRend
user->GetLayer(layer);
#if 0
NSCalendar * nscal;
layer->GetCal(nscal);
@ -186,6 +187,9 @@ nsEventStatus nsCalMonthViewCanvas :: PaintForeground(nsIRenderingContext& aRend
nscal->sortComponentsByDTStart(ICalComponent::ICAL_COMPONENT::ICAL_COMPONENT_VEVENT);
nscal->getEventsByRange(evtVctr, *dStart, *dEnd);
#endif
layer->FetchEventsByRange(dStart, dEnd, evtVctr);
for (j = 0; j < evtVctr->GetSize(); j++)
{

View File

@ -38,7 +38,6 @@ public:
NS_IMETHOD_(CAPIHandle) GetCAPIHandle();
NS_IMETHOD_(char *) GetCAPIPassword() ;
NS_IMETHOD_(NSCalendar *) GetNSCalendar();
protected:
~nsCalToolkit();

View File

@ -40,7 +40,6 @@ public:
NS_IMETHOD_(CAPISession) GetCAPISession() = 0;
NS_IMETHOD_(CAPIHandle) GetCAPIHandle() = 0;
NS_IMETHOD_(char *) GetCAPIPassword() = 0 ;
NS_IMETHOD_(NSCalendar *) GetNSCalendar() = 0;
};

View File

@ -105,7 +105,3 @@ char * nsCalToolkit::GetCAPIPassword()
return (mCalendarShell->GetCAPIPassword());
}
NSCalendar * nsCalToolkit::GetNSCalendar()
{
return (mCalendarShell->GetNSCalendar());
}