зеркало из https://github.com/mozilla/gecko-dev.git
Layer updates
This commit is contained in:
Родитель
1d2955f5da
Коммит
0eba525234
|
@ -66,6 +66,14 @@ public:
|
|||
*/
|
||||
nsresult GetSession(CAPISession& s, const char* psPassword=0);
|
||||
|
||||
/**
|
||||
* Establish a CAPI session to the supplied curl. If a session already
|
||||
* exists, bump the reference count and return the existing session.
|
||||
* @return 0 on success
|
||||
* CAPI errors associated with not getting a session.
|
||||
*/
|
||||
nsresult EstablishSession(const char* psPassword=0);
|
||||
|
||||
/**
|
||||
* Release the session. That is, a consumer is indicating that they
|
||||
* are finished using the session. Decrement the usage count.
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include "jdefines.h"
|
||||
#include "ptrarray.h"
|
||||
#include "julnstr.h"
|
||||
#include "nsCalSession.h"
|
||||
#include "nscalexport.h"
|
||||
|
||||
|
@ -31,6 +32,15 @@ public:
|
|||
*/
|
||||
nsresult GetSession(const char* psCurl, long lFlags, const char* psPassword, CAPISession& s);
|
||||
|
||||
/**
|
||||
* Get a session to the supplied curl.
|
||||
* @param sCurl the curl to the calendar store
|
||||
* @param psPassword the password needed for logging in
|
||||
* @param s the session
|
||||
* @return 0 on success
|
||||
*/
|
||||
nsresult GetSession(const JulianString sCurl, long lFlags, const char* psPassword, nsCalSession* &pCalSession);
|
||||
|
||||
/**
|
||||
* Release a session
|
||||
* @param pUser pointer to the calendar to add
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
/**
|
||||
* nsCalUserList.cpp: implementation of the nsCalUserList class.
|
||||
* nsICalendarUserList.cpp: implementation of the nsICalendarUserList class.
|
||||
* This class manages the list of calendars currently in memory.
|
||||
* All calendars that are to be displayed should be registered
|
||||
* in this list.
|
||||
*/
|
||||
|
||||
#if !defined(AFX_NSCALUSERLIST_H__BC9A7773_3EF1_11D2_8ED1_000000000000__INCLUDED_)
|
||||
#define AFX_NSCALUSERLIST_H__BC9A7773_3EF1_11D2_8ED1_000000000000__INCLUDED_
|
||||
#if !defined(AFX_nsICalendarUserLIST_H__BC9A7773_3EF1_11D2_8ED1_000000000000__INCLUDED_)
|
||||
#define AFX_nsICalendarUserLIST_H__BC9A7773_3EF1_11D2_8ED1_000000000000__INCLUDED_
|
||||
|
||||
#include "jdefines.h"
|
||||
#include "ptrarray.h"
|
||||
#include "nscalexport.h"
|
||||
#include "nsCalUser.h"
|
||||
#include "nsICalendarUser.h"
|
||||
|
||||
class NS_CALENDAR nsCalUserList
|
||||
{
|
||||
|
@ -26,7 +26,7 @@ public:
|
|||
* @param pUser pointer to the user to add
|
||||
* @return 0 on success
|
||||
*/
|
||||
nsresult Add(nsCalUser* pUser);
|
||||
nsresult Add(nsICalendarUser* pUser);
|
||||
|
||||
/**
|
||||
* Delete the user matching the supplied pointer.
|
||||
|
@ -34,7 +34,7 @@ public:
|
|||
* @return 0 on success
|
||||
* 1 if not found
|
||||
*/
|
||||
nsresult Delete(nsCalUser* pUser);
|
||||
nsresult Delete(nsICalendarUser* pUser);
|
||||
|
||||
/**
|
||||
* Delete all users having the supplied cal url
|
||||
|
@ -66,10 +66,10 @@ public:
|
|||
* @return 0 if the index is bad, otherwise it is a pointer
|
||||
* to the calendar at index i in the list
|
||||
*/
|
||||
nsCalUser* GetAt(int i);
|
||||
nsICalendarUser* GetAt(int i);
|
||||
|
||||
};
|
||||
|
||||
#endif /* !defined(AFX_NSCALUSERLIST_H__BC9A7773_3EF1_11D2_8ED1_000000000000__INCLUDED_) */
|
||||
#endif /* !defined(AFX_nsICalendarUserLIST_H__BC9A7773_3EF1_11D2_8ED1_000000000000__INCLUDED_) */
|
||||
|
||||
|
||||
|
|
|
@ -38,10 +38,21 @@ public:
|
|||
NS_IMETHOD GetLayer(nsILayer *& aLayer);
|
||||
NS_IMETHOD SetLayer(nsILayer* aLayer);
|
||||
|
||||
/**
|
||||
* Check to see whether or not the user has a particular layer
|
||||
* in the list of layers that make up their calendar.
|
||||
* @param aCurl the curl containing the host and csid
|
||||
* @param aContains return value set to PR_TRUE if the user's
|
||||
* calendar list contains the specified curl
|
||||
* or PR_FALSE otherwise.
|
||||
* @return NS_OK on success.
|
||||
*/
|
||||
NS_IMETHOD HasLayer(const JulianString& aCurl,PRBool& aContains);
|
||||
|
||||
protected:
|
||||
nsISupports * mUserSupports;
|
||||
nsIUser * mUser;
|
||||
nsILayer * mLayer;
|
||||
nsISupports * mpUserSupports;
|
||||
nsIUser * mpUser;
|
||||
nsILayer * mpLayer;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -22,11 +22,14 @@
|
|||
#include "nscalexport.h"
|
||||
#include "nsILayer.h"
|
||||
|
||||
class nsCalendarShell;
|
||||
|
||||
class NS_CALENDAR nsLayer : public nsILayer
|
||||
{
|
||||
|
||||
JulianString msCurl;
|
||||
NSCalendar* mpCal;
|
||||
nsCalendarShell* mpShell;
|
||||
|
||||
public:
|
||||
nsLayer(nsISupports* outer);
|
||||
|
@ -37,13 +40,26 @@ public:
|
|||
NS_IMETHOD Init();
|
||||
NS_IMETHOD SetCurl(const JulianString& s);
|
||||
NS_IMETHOD GetCurl(JulianString& s);
|
||||
|
||||
/**
|
||||
* Check to see if the layer matches the supplied curl.
|
||||
* In this case, matching means that the host and CSID
|
||||
* values are equal.
|
||||
* @param s the curl
|
||||
* @return NS_OK on success
|
||||
*/
|
||||
NS_IMETHOD URLMatch(const JulianString& aCurl, PRBool& aMatch);
|
||||
|
||||
NS_IMETHOD SetCal(NSCalendar* aCal);
|
||||
NS_IMETHOD GetCal(NSCalendar*& aCal);
|
||||
NS_IMETHOD SetShell(nsCalendarShell* aShell) {mpShell = aShell; return NS_OK;}
|
||||
NS_IMETHOD FetchEventsByRange(
|
||||
const DateTime* aStart,
|
||||
const DateTime* aStop,
|
||||
JulianPtrArray* &anArray
|
||||
JulianPtrArray* anArray
|
||||
);
|
||||
private:
|
||||
nsresult FetchEventsByRange();
|
||||
};
|
||||
|
||||
#endif //nsLayer_h___
|
||||
|
|
|
@ -24,10 +24,11 @@
|
|||
#include "nsILayerCollection.h"
|
||||
#include "nsIVector.h"
|
||||
|
||||
|
||||
class NS_CALENDAR nsLayerCollection : public nsILayerCollection,
|
||||
nsILayer
|
||||
{
|
||||
|
||||
|
||||
public:
|
||||
nsLayerCollection(nsISupports* outer);
|
||||
~nsLayerCollection();
|
||||
|
@ -39,17 +40,28 @@ public:
|
|||
NS_IMETHOD AddLayer(nsILayer * aLayer);
|
||||
NS_IMETHOD RemoveLayer(nsILayer * aLayer);
|
||||
|
||||
NS_IMETHOD SetShell(nsCalendarShell* aShell) {mpShell = aShell; return NS_OK;}
|
||||
NS_IMETHOD SetCurl(const JulianString& s);
|
||||
NS_IMETHOD GetCurl(JulianString& s);
|
||||
|
||||
/**
|
||||
* Check to see if any layer matches the supplied curl.
|
||||
* In this case, matching means that the host and CSID
|
||||
* values are equal.
|
||||
* @param s the curl
|
||||
* @return NS_OK on success
|
||||
*/
|
||||
NS_IMETHOD URLMatch(const JulianString& aCurl, PRBool& aMatch);
|
||||
|
||||
NS_IMETHOD SetCal(NSCalendar* aCal);
|
||||
NS_IMETHOD GetCal(NSCalendar*& aCal);
|
||||
NS_IMETHOD FetchEventsByRange(
|
||||
const DateTime* aStart,
|
||||
const DateTime* aStop,
|
||||
JulianPtrArray* &anArray
|
||||
const DateTime* aStop, JulianPtrArray* aL
|
||||
);
|
||||
private:
|
||||
nsIVector * mLayers ;
|
||||
nsCalendarShell * mpShell;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ public:
|
|||
|
||||
NS_IMETHOD GetLayer(nsILayer *& aLayer) = 0;
|
||||
NS_IMETHOD SetLayer(nsILayer* aLayer) = 0;
|
||||
NS_IMETHOD HasLayer(const JulianString& aCurl,PRBool& aContains) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
class NSCalendar;
|
||||
class DateTime;
|
||||
class JulianPtrArray;
|
||||
class nsCalendarShell;
|
||||
|
||||
class nsILayer : public nsISupports
|
||||
{
|
||||
|
@ -37,14 +38,42 @@ class nsILayer : public nsISupports
|
|||
public:
|
||||
NS_IMETHOD Init() = 0;
|
||||
|
||||
/**
|
||||
* Set the curl that points to the cal store
|
||||
* @param s the curl
|
||||
* @return NS_OK on success
|
||||
*/
|
||||
NS_IMETHOD SetCurl(const JulianString& s) = 0;
|
||||
|
||||
/**
|
||||
* Set the shell pointer
|
||||
* @param s the curl
|
||||
* @return NS_OK on success
|
||||
*/
|
||||
NS_IMETHOD SetShell(nsCalendarShell* aShell) = 0;
|
||||
|
||||
/**
|
||||
* Get the curl that points to the cal store
|
||||
* @param s the curl
|
||||
* @return NS_OK on success
|
||||
*/
|
||||
NS_IMETHOD GetCurl(JulianString& s) = 0;
|
||||
|
||||
/**
|
||||
* Check to see if the layer matches the supplied curl.
|
||||
* In this case, matching means that the host and CSID
|
||||
* values are equal.
|
||||
* @param s the curl
|
||||
* @return NS_OK on success
|
||||
*/
|
||||
NS_IMETHOD URLMatch(const JulianString& aCurl, PRBool& aMatch) = 0;
|
||||
|
||||
NS_IMETHOD SetCal(NSCalendar* aCal) = 0;
|
||||
NS_IMETHOD GetCal(NSCalendar*& aCal) = 0;
|
||||
NS_IMETHOD FetchEventsByRange(
|
||||
const DateTime* aStart,
|
||||
const DateTime* aStop,
|
||||
JulianPtrArray* &anArray
|
||||
JulianPtrArray* anArray
|
||||
) = 0;
|
||||
};
|
||||
|
||||
|
|
|
@ -18,18 +18,18 @@ PRIVATE_EXPORTS = \
|
|||
MODULE = trex
|
||||
|
||||
CPPSRCS = \
|
||||
nsCalUserList.cpp \
|
||||
nsCalList.cpp \
|
||||
nsCalLoggedInUser.cpp \
|
||||
nsCalScheduler.cpp \
|
||||
nsCalSession.cpp \
|
||||
nsCalSessionMgr.cpp \
|
||||
nsCalUser.cpp \
|
||||
nsCalUserList.cpp \
|
||||
nsLayer.cpp \
|
||||
nsLayerCollection.cpp \
|
||||
nsCoreFactory.cpp \
|
||||
nsCalendarUser.cpp \
|
||||
nsCalendarModel.cpp \
|
||||
nsCalendarModel.cpp \
|
||||
$(NULL)
|
||||
|
||||
|
||||
|
|
|
@ -143,17 +143,17 @@ static int RcvData(void * pData,
|
|||
* will need to change local CAPI so null gasViewPropList will return
|
||||
* all properties.
|
||||
*/
|
||||
char * gasViewPropList[10] = {
|
||||
static char * gasViewPropList[10] = {
|
||||
"ATTENDEE", "DTSTART", "DTEND", "UID", "RECURRENCE-ID",
|
||||
"DTSTAMP", "SUMMARY", "DESCRIPTION", "ORGANIZER", "TRANSP"
|
||||
};
|
||||
int giViewPropListCount = 10;
|
||||
static int giViewPropListCount = 10;
|
||||
|
||||
/**
|
||||
* Given an nsICapi interface, log in and get some initial data.
|
||||
* @return NS_OK on success.
|
||||
*/
|
||||
nsresult nsCalScheduler::InitialLoadData()
|
||||
nsresult nsCalScheduler::InitialLoadData(/*nsIUser* pUser*/)
|
||||
{
|
||||
nsresult res;
|
||||
ErrorCode status = ZERO_ERROR;
|
||||
|
|
|
@ -95,12 +95,29 @@ nsCalSession::~nsCalSession()
|
|||
* CAPI errors associated with not getting a session.
|
||||
*/
|
||||
nsresult nsCalSession::GetSession(CAPISession& Session, const char* psPassword)
|
||||
{
|
||||
Session = 0;
|
||||
nsresult res = EstablishSession(psPassword);
|
||||
++m_iCount;
|
||||
Session = m_Session;
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Establish a CAPI session. If a session already
|
||||
* exists, bump the reference count and return the existing session.
|
||||
* If the value of s is 0 on return, there was a problem getting the
|
||||
* session.
|
||||
* @return 0 on success
|
||||
* 1 general failure
|
||||
* CAPI errors associated with not getting a session.
|
||||
*/
|
||||
nsresult nsCalSession::EstablishSession(const char* psPassword)
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
if (0 == m_Session)
|
||||
{
|
||||
CAPIStatus s;
|
||||
Session = 0;
|
||||
nsICapiLocal * capi_local = nsnull;
|
||||
|
||||
if ( m_sCurl == "")
|
||||
|
@ -172,11 +189,8 @@ nsresult nsCalSession::GetSession(CAPISession& Session, const char* psPassword)
|
|||
|
||||
if (CAPI_ERR_OK != s)
|
||||
return res;
|
||||
++m_iCount;
|
||||
}
|
||||
|
||||
Session = m_Session;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
@ -110,6 +110,48 @@ nsresult nsCalSessionMgr::GetSession(const char* psCurl, long lFlags, const char
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a session to the supplied curl.
|
||||
* @param sCurl the curl to the calendar store
|
||||
* @param psPassword the password needed for logging in
|
||||
* @param pCalSession the session object that was found or created
|
||||
* @return 0 on success (that is, the session was established with the
|
||||
* capi server) or the error that occurred while trying to
|
||||
* establish the session.
|
||||
*/
|
||||
nsresult nsCalSessionMgr::GetSession(const JulianString sCurl, long lFlags, const char* psPassword, nsCalSession* &pCalSession)
|
||||
{
|
||||
/*
|
||||
* First, search the current sessions and see if we already have a
|
||||
* session to the requested server...
|
||||
*/
|
||||
nsCurlParser Curl(sCurl);
|
||||
int iIndex;
|
||||
|
||||
pCalSession = 0;
|
||||
|
||||
if (0 == Find(Curl.GetCurl().GetBuffer(), 0, &iIndex))
|
||||
{
|
||||
/*
|
||||
* Found it
|
||||
*/
|
||||
pCalSession = GetAt(iIndex);
|
||||
if (0 == pCalSession)
|
||||
return 1;
|
||||
return pCalSession->EstablishSession(psPassword);
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* nothing found, have to create it.
|
||||
*/
|
||||
pCalSession = new nsCalSession(sCurl,lFlags);
|
||||
m_List.Add(pCalSession);
|
||||
return pCalSession->EstablishSession(psPassword ? psPassword : "");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Release a session
|
||||
* @param pUser pointer to the calendar to add
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "ptrarray.h"
|
||||
#include "nscal.h"
|
||||
#include "nspr.h"
|
||||
#include "nsICalendarUser.h"
|
||||
#include "nsCalUserList.h"
|
||||
|
||||
nsCalUserList::nsCalUserList()
|
||||
|
@ -45,7 +46,7 @@ nsCalUserList::~nsCalUserList()
|
|||
* @return 0 on success
|
||||
* 1 problems adding the calendar
|
||||
*/
|
||||
nsresult nsCalUserList::Add(nsCalUser* pUser)
|
||||
nsresult nsCalUserList::Add(nsICalendarUser* pUser)
|
||||
{
|
||||
if (0 > m_List.Add(pUser))
|
||||
return 1;
|
||||
|
@ -58,10 +59,9 @@ nsresult nsCalUserList::Add(nsCalUser* pUser)
|
|||
* @return 0 on success
|
||||
* 1 if not found
|
||||
*/
|
||||
nsresult nsCalUserList::Delete(nsCalUser* pUser)
|
||||
nsresult nsCalUserList::Delete(nsICalendarUser* pUser)
|
||||
{
|
||||
return (1 == m_List.Remove(pUser)) ? 0 : 1;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -94,7 +94,7 @@ nsresult nsCalUserList::Delete(char* psCurl)
|
|||
*/
|
||||
nsresult nsCalUserList::Find(char* p, int iStart, int* piFound)
|
||||
{
|
||||
nsCalUser* pUser;
|
||||
nsICalendarUser* pUser;
|
||||
JulianPtrArray* pList;
|
||||
JulianString* psCurl;
|
||||
int i,j;
|
||||
|
@ -106,9 +106,10 @@ nsresult nsCalUserList::Find(char* p, int iStart, int* piFound)
|
|||
iStart = m_List.GetSize() - 1;
|
||||
for (i = 0; i < m_List.GetSize(); i++)
|
||||
{
|
||||
pUser = (nsCalUser*) m_List.GetAt(i);
|
||||
pUser = (nsICalendarUser*) m_List.GetAt(i);
|
||||
if (0 != pUser)
|
||||
{
|
||||
#if 0
|
||||
pList = pUser->GetCalAddrList();
|
||||
for (j = 0; j < pList->GetSize(); j++)
|
||||
{
|
||||
|
@ -117,8 +118,9 @@ nsresult nsCalUserList::Find(char* p, int iStart, int* piFound)
|
|||
{
|
||||
*piFound = i;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -130,8 +132,8 @@ nsresult nsCalUserList::Find(char* p, int iStart, int* piFound)
|
|||
* @param i the index of the calendar to fetch
|
||||
* @return a pointer to the calendar at the supplied index.
|
||||
*/
|
||||
nsCalUser* nsCalUserList::GetAt(int i)
|
||||
nsICalendarUser* nsCalUserList::GetAt(int i)
|
||||
{
|
||||
return (nsCalUser*) m_List.GetAt(i);
|
||||
return (nsICalendarUser*) m_List.GetAt(i);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,12 +25,15 @@ static NS_DEFINE_IID(kICalendarUserIID, NS_ICALENDAR_USER_IID);
|
|||
static NS_DEFINE_IID(kIUserIID, NS_IUSER_IID);
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kCUserCID, NS_USER_CID);
|
||||
static NS_DEFINE_IID(kILayerIID, NS_ILAYER_IID);
|
||||
static NS_DEFINE_IID(kCLayerCollectionCID, NS_LAYER_COLLECTION_CID);
|
||||
|
||||
nsCalendarUser::nsCalendarUser(nsISupports* outer)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mUserSupports = nsnull;
|
||||
mUser = nsnull;
|
||||
mpUserSupports = nsnull;
|
||||
mpUser = nsnull;
|
||||
mpLayer = nsnull;
|
||||
}
|
||||
|
||||
nsresult nsCalendarUser::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
|
@ -52,8 +55,8 @@ nsresult nsCalendarUser::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
if (nsnull != mUserSupports)
|
||||
return mUserSupports->QueryInterface(aIID, aInstancePtr);
|
||||
if (nsnull != mpUserSupports)
|
||||
return mpUserSupports->QueryInterface(aIID, aInstancePtr);
|
||||
|
||||
return (NS_NOINTERFACE);
|
||||
|
||||
|
@ -65,18 +68,20 @@ NS_IMPL_RELEASE(nsCalendarUser)
|
|||
|
||||
nsCalendarUser::~nsCalendarUser()
|
||||
{
|
||||
NS_IF_RELEASE(mUserSupports);
|
||||
mUser = nsnull; // Do Not Release
|
||||
NS_IF_RELEASE(mpUserSupports);
|
||||
NS_IF_RELEASE(mpLayer);
|
||||
mpUser = nsnull; // Do Not Release
|
||||
}
|
||||
|
||||
nsresult nsCalendarUser::Init()
|
||||
{
|
||||
nsresult res;
|
||||
|
||||
/*
|
||||
* Aggregate in the XPFC User Implementation
|
||||
*/
|
||||
nsISupports * supports ;
|
||||
|
||||
res = QueryInterface(kISupportsIID, (void **) &supports);
|
||||
|
||||
if (NS_OK != res)
|
||||
return res;
|
||||
|
||||
|
@ -85,37 +90,52 @@ nsresult nsCalendarUser::Init()
|
|||
res = nsRepository::CreateInstance(kCUserCID,
|
||||
supports,
|
||||
kISupportsIID,
|
||||
(void**)&mUserSupports);
|
||||
(void**)&mpUserSupports);
|
||||
|
||||
if (NS_OK == res)
|
||||
{
|
||||
res = mUserSupports->QueryInterface(kIUserIID, (void**)&mUser);
|
||||
res = mpUserSupports->QueryInterface(kIUserIID, (void**)&mpUser);
|
||||
if (NS_OK != res)
|
||||
{
|
||||
mUserSupports->Release();
|
||||
mUserSupports = NULL;
|
||||
mpUserSupports->Release();
|
||||
mpUserSupports = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
mUser->Release();
|
||||
mpUser->Release();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Create a LayerCollection for this User, by default
|
||||
*/
|
||||
res = nsRepository::CreateInstance(
|
||||
kCLayerCollectionCID, // class id that we want to create
|
||||
nsnull, // not aggregating anything (this is the aggregatable interface)
|
||||
kILayerIID, // interface id of the object we want to get back
|
||||
(void**)&mpLayer); // pointer to the interface object
|
||||
|
||||
if (NS_OK == res)
|
||||
mpLayer->Init();
|
||||
|
||||
return res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsCalendarUser :: GetLayer(nsILayer *& aLayer)
|
||||
{
|
||||
aLayer = mLayer;
|
||||
aLayer = mpLayer;
|
||||
NS_ADDREF(mpLayer);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsCalendarUser :: SetLayer(nsILayer* aLayer)
|
||||
{
|
||||
mLayer = aLayer;
|
||||
mpLayer = aLayer;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsCalendarUser::HasLayer(const JulianString& aCurl, PRBool& aContains)
|
||||
{
|
||||
return mpLayer->URLMatch(aCurl,aContains);
|
||||
}
|
||||
|
|
|
@ -17,7 +17,41 @@
|
|||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "nscore.h"
|
||||
#include "nsError.h"
|
||||
#include "nsCom.h"
|
||||
#include "capi.h"
|
||||
#include "julnstr.h"
|
||||
#include "nsDateTime.h"
|
||||
#include "nscalexport.h"
|
||||
#include "nsLayer.h"
|
||||
#include "nsCurlParser.h"
|
||||
#include "nsCalendarShell.h"
|
||||
#include "jdefines.h"
|
||||
#include "nsCalShellFactory.h"
|
||||
#include "nsString.h"
|
||||
#include "nsFont.h"
|
||||
#include "nsCalShellCIID.h"
|
||||
#include "nsCRT.h"
|
||||
#include "plstr.h"
|
||||
#include "prmem.h"
|
||||
#include "prenv.h"
|
||||
#include "icalfrdr.h"
|
||||
#include "nsIPref.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"
|
||||
|
||||
static NS_DEFINE_IID(kILayerIID, NS_ILAYER_IID);
|
||||
|
||||
|
@ -25,6 +59,7 @@ nsLayer::nsLayer(nsISupports* outer)
|
|||
{
|
||||
NS_INIT_REFCNT();
|
||||
mpCal = 0;
|
||||
mpShell = 0;
|
||||
}
|
||||
|
||||
NS_IMPL_QUERY_INTERFACE(nsLayer, kILayerIID)
|
||||
|
@ -66,16 +101,277 @@ nsresult nsLayer::GetCal(NSCalendar*& aCal)
|
|||
return (NS_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if the layer matches the supplied curl.
|
||||
* In this case, matching means that the host and CSID
|
||||
* values are equal.
|
||||
* @param s the curl
|
||||
* @return NS_OK on success
|
||||
*/
|
||||
nsresult nsLayer::URLMatch(const JulianString& aCurl, PRBool& aMatch)
|
||||
{
|
||||
nsCurlParser curlA(msCurl);
|
||||
nsCurlParser curlB(aCurl);
|
||||
|
||||
aMatch = 0;
|
||||
|
||||
if ( ( curlA.GetHost() == curlB.GetHost() ) &&
|
||||
( curlA.GetCSID() == curlB.GetCSID() ) )
|
||||
aMatch = 1;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 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 nsLayer::FetchEventsByRange(
|
||||
const DateTime* aStart,
|
||||
const DateTime* aStop,
|
||||
JulianPtrArray*& anArray
|
||||
const DateTime* aStart,
|
||||
const DateTime* aStop,
|
||||
JulianPtrArray* anArray
|
||||
)
|
||||
{
|
||||
return (NS_OK);
|
||||
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
|
||||
|
||||
NS_ASSERTION(0 != mpShell, "null shell in fetchEventsByRange");
|
||||
if (0 == mpShell)
|
||||
return 1; // XXX fix this
|
||||
|
||||
/*
|
||||
* Select the capi interface to use for this operation...
|
||||
* Each layer stores its curl, ask for a session based on
|
||||
* the curl...
|
||||
*/
|
||||
nsICapi* pCapi = 0;
|
||||
nsCalSession *pSession;
|
||||
nsCurlParser curl(msCurl);
|
||||
if (NS_OK == (mpShell->mSessionMgr.GetSession(msCurl, 0, curl.GetPassword().GetBuffer(), pSession)))
|
||||
{
|
||||
if (0 != pSession)
|
||||
{
|
||||
pCapi = pSession->mCapi;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NS_ASSERTION(1,"Could not get a session");
|
||||
pCapi = mpShell->mSessionMgr.GetAt(0L)->mCapi; // should comment this
|
||||
}
|
||||
|
||||
/*
|
||||
* 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);
|
||||
pEventList = pCal->getEvents();
|
||||
if (0 != pEventList)
|
||||
{
|
||||
for (j = 0; j < pEventList->GetSize(); j++)
|
||||
{
|
||||
pEvent = (ICalComponent*)pEventList->GetAt(j);
|
||||
if (0 != pEvent)
|
||||
mpShell->mpCalendar->addEvent(pEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* cleanup allocated memory
|
||||
*/
|
||||
delete [] psDTStart; psDTStart = 0;
|
||||
delete [] psDTEnd; psDTEnd = 0;
|
||||
delete pCalStreamReader; pCalStreamReader = 0;
|
||||
delete capiReader; capiReader = 0;
|
||||
PR_DestroyMonitor(pThreadMonitor);
|
||||
PR_DestroyMonitor(pCBReaderMonitor);
|
||||
|
||||
/*
|
||||
* todo: need to delete calendars in pParsedCalList without
|
||||
* deleting events in it
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include "nscore.h"
|
||||
#include "jdefines.h"
|
||||
#include "ptrarray.h"
|
||||
#include "nsLayerCollection.h"
|
||||
#include "nsCoreCIID.h"
|
||||
#include "nsxpfcCIID.h"
|
||||
|
@ -137,11 +139,75 @@ nsresult nsLayerCollection::GetCal(NSCalendar*& aCal)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param aStart Starting time for fetch
|
||||
* @param aStart ending time for fetch
|
||||
* @param anArray Match a returned boolean value. If a match is found this value
|
||||
* is returned as PR_TRUE. Otherwise, the it is set to PR_FALSE.
|
||||
*
|
||||
* @return NS_OK on success
|
||||
*/
|
||||
nsresult nsLayerCollection::FetchEventsByRange(
|
||||
const DateTime* aStart,
|
||||
const DateTime* aStop,
|
||||
JulianPtrArray*& anArray
|
||||
JulianPtrArray* anArray
|
||||
)
|
||||
{
|
||||
return (NS_OK);
|
||||
PRInt32 i,j;
|
||||
PRInt32 iSize = mLayers->Count();
|
||||
PRInt32 iTmpSize;
|
||||
nsILayer *pLayer;
|
||||
JulianPtrArray TmpArray;
|
||||
|
||||
/*
|
||||
* XXX:
|
||||
* This should be made multi-threaded...
|
||||
*/
|
||||
for ( i = 0; i < iSize; i++)
|
||||
{
|
||||
pLayer = (nsILayer*)mLayers->ElementAt(i);
|
||||
if (NS_OK == (pLayer->FetchEventsByRange(aStart,aStop,&TmpArray)))
|
||||
{
|
||||
/*
|
||||
* copy the stuff in TmpArray into anArray...
|
||||
*/
|
||||
for (j = 0, iTmpSize = TmpArray.GetSize(); j < iTmpSize; j++)
|
||||
{
|
||||
/*
|
||||
* XXX: should sort these chronologically
|
||||
*/
|
||||
anArray->Add( TmpArray.GetAt(j) );
|
||||
}
|
||||
|
||||
TmpArray.RemoveAll();
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param aUrl the url for comparison. In this case, we check to see if
|
||||
* both the host and cal store id match on any layer in
|
||||
* the list.
|
||||
* @param aMatch a returned boolean value. If a match is found this value
|
||||
* is returned as PR_TRUE. Otherwise, the it is set to PR_FALSE.
|
||||
*
|
||||
* @return NS_OK on success
|
||||
*/
|
||||
nsresult nsLayerCollection::URLMatch(const JulianString& aUrl, PRBool& aMatch)
|
||||
{
|
||||
PRInt32 i;
|
||||
PRInt32 iSize = mLayers->Count();
|
||||
nsILayer *pLayer;
|
||||
aMatch = PR_FALSE;
|
||||
for ( i = 0; i < iSize; i++)
|
||||
{
|
||||
pLayer = (nsILayer*)mLayers->ElementAt(i);
|
||||
if (NS_OK == (pLayer->URLMatch(aUrl,aMatch)))
|
||||
{
|
||||
if (PR_TRUE == aMatch)
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -90,6 +90,7 @@ public:
|
|||
|
||||
NS_IMETHOD StartCommandServer();
|
||||
NS_IMETHOD ReceiveCommand(nsString& aCommand, nsString& aReply);
|
||||
NS_IMETHOD InitFactoryObjs();
|
||||
|
||||
private:
|
||||
NS_METHOD InitialLoadData();
|
||||
|
@ -106,7 +107,7 @@ public:
|
|||
CAPISession mCAPISession;
|
||||
CAPIHandle mCAPIHandle;
|
||||
NSCalendar * mpCalendar;
|
||||
nsCalLoggedInUser* mpLoggedInUser;
|
||||
nsICalendarUser* mpLoggedInUser;
|
||||
|
||||
JulianString msCalURL; /* the calendar associated with this user */
|
||||
char * mCAPIPassword; /* the password which must be entered by the user */
|
||||
|
|
|
@ -26,12 +26,11 @@
|
|||
#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 "nsCalUser.h"
|
||||
//#include "nsCalLoggedInUser.h"
|
||||
#include "nsCalendarShell.h"
|
||||
#include "nscalstrings.h"
|
||||
#include "nsxpfcCIID.h"
|
||||
|
@ -91,12 +90,17 @@ static NS_DEFINE_IID(kCXPFCObserverManagerCID, NS_XPFC_OBSERVERMANAGER_CID);
|
|||
#define CORE_DLL "libcalcore10.so"
|
||||
#endif
|
||||
|
||||
static NS_DEFINE_IID(kCCapiLocalCID, NS_CAPI_LOCAL_CID);
|
||||
static NS_DEFINE_IID(kCCapiCSTCID, NS_CAPI_CST_CID);
|
||||
static NS_DEFINE_IID(kCLayerCID, NS_LAYER_CID);
|
||||
static NS_DEFINE_IID(kCLayerCollectionCID, NS_LAYER_COLLECTION_CID);
|
||||
static NS_DEFINE_IID(kCCalendarUserCID, NS_CALENDAR_USER_CID);
|
||||
static NS_DEFINE_IID(kCCalendarModelCID, NS_CALENDAR_MODEL_CID);
|
||||
static NS_DEFINE_IID(kCCapiLocalCID, NS_CAPI_LOCAL_CID);
|
||||
static NS_DEFINE_IID(kCCapiCSTCID, NS_CAPI_CST_CID);
|
||||
static NS_DEFINE_IID(kCLayerCID, NS_LAYER_CID);
|
||||
static NS_DEFINE_IID(kILayerIID, NS_ILAYER_IID);
|
||||
static NS_DEFINE_IID(kCLayerCollectionCID, NS_LAYER_COLLECTION_CID);
|
||||
static NS_DEFINE_IID(kCCalendarModelCID, NS_CALENDAR_MODEL_CID);
|
||||
static NS_DEFINE_IID(kICalendarUserIID, NS_ICALENDAR_USER_IID);
|
||||
static NS_DEFINE_IID(kCCalendarUserCID, NS_CALENDAR_USER_CID);
|
||||
static NS_DEFINE_IID(kIUserIID, NS_IUSER_IID);
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kCUserCID, NS_USER_CID);
|
||||
|
||||
// All Application Must implement this function
|
||||
nsresult NS_RegisterApplicationShellFactory()
|
||||
|
@ -146,7 +150,6 @@ nsCalendarShell::~nsCalendarShell()
|
|||
NS_IF_RELEASE(mCommandServer);
|
||||
}
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIAppShellIID, NS_IAPPSHELL_IID);
|
||||
|
||||
|
||||
|
@ -179,12 +182,13 @@ NS_IMPL_RELEASE(nsCalendarShell)
|
|||
nsresult nsCalendarShell::Init()
|
||||
{
|
||||
mScheduler.SetShell(this);
|
||||
|
||||
/*
|
||||
* Register class factrories needed for application
|
||||
*/
|
||||
RegisterFactories() ;
|
||||
|
||||
InitFactoryObjs();
|
||||
|
||||
/*
|
||||
* Load Application Prefs
|
||||
*/
|
||||
|
@ -203,6 +207,27 @@ nsresult nsCalendarShell::Init()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create factory objects...
|
||||
* @return NS_OK on success
|
||||
*/
|
||||
nsresult nsCalendarShell::InitFactoryObjs()
|
||||
{
|
||||
nsresult res;
|
||||
|
||||
res = nsRepository::CreateInstance(kCCalendarUserCID, // class id that we want to create
|
||||
nsnull, // not aggregating anything (this is the aggregatable interface)
|
||||
kICalendarUserIID, // interface id of the object we want to get back
|
||||
(void**)&mpLoggedInUser);
|
||||
|
||||
if (NS_OK == res)
|
||||
{
|
||||
mpLoggedInUser->Init();
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method establishes a logged in user and opens a connection to
|
||||
* the calendar server (or local database file if they're working offline).
|
||||
|
@ -213,12 +238,22 @@ nsresult nsCalendarShell::Init()
|
|||
nsresult nsCalendarShell::Logon()
|
||||
{
|
||||
CAPIStatus s;
|
||||
nsIUser* pUser;
|
||||
nsresult res;
|
||||
|
||||
if (NS_OK != (res = mpLoggedInUser->QueryInterface(kIUserIID,(void**)&pUser)))
|
||||
return res ;
|
||||
|
||||
/*
|
||||
* Getting the first calendar by user name should be reviewed.
|
||||
*/
|
||||
nsCurlParser theURL(mpLoggedInUser->GetUserName());
|
||||
nsString nsstrUserName;
|
||||
pUser->GetUserName(nsstrUserName);
|
||||
JulianString sUserName(256);
|
||||
nsstrUserName.ToCString(sUserName.GetBuffer(),256);
|
||||
sUserName.DoneWithBuffer();
|
||||
|
||||
nsCurlParser theURL(sUserName);
|
||||
nsCurlParser sessionURL(msCalURL);
|
||||
theURL |= sessionURL;
|
||||
|
||||
|
@ -231,14 +266,20 @@ nsresult nsCalendarShell::Logon()
|
|||
GetCAPIPassword(),
|
||||
mCAPISession);
|
||||
|
||||
JulianString sHandle = mpLoggedInUser->GetUserName();
|
||||
pUser->GetUserName(nsstrUserName);
|
||||
JulianString sHandle(256);
|
||||
nsstrUserName.ToCString(sHandle.GetBuffer(),256);
|
||||
sHandle.DoneWithBuffer();
|
||||
|
||||
|
||||
NS_RELEASE(pUser);
|
||||
|
||||
if (nsCurlParser::eCAPI == theURL.GetProtocol())
|
||||
{
|
||||
nsX400Parser x(theURL.GetExtra());
|
||||
x.Delete("ND");
|
||||
x.GetValue(sHandle);
|
||||
sHandle.Prepend(":"); // this is disgusting. we must get cst to fix this
|
||||
sHandle.Prepend(":");
|
||||
}
|
||||
|
||||
s = mSessionMgr.GetAt(0L)->mCapi->CAPI_GetHandle(mCAPISession,sHandle.GetBuffer(),0,&mCAPIHandle);
|
||||
|
@ -257,7 +298,18 @@ nsresult nsCalendarShell::Logon()
|
|||
case nsCurlParser::eFILE:
|
||||
case nsCurlParser::eCAPI:
|
||||
{
|
||||
mScheduler.InitialLoadData();
|
||||
DateTime d;
|
||||
DateTime d1;
|
||||
JulianPtrArray EventList;
|
||||
nsILayer *pLayer;
|
||||
d.prevDay(14);
|
||||
d1.nextDay(14);
|
||||
//mScheduler.InitialLoadData();
|
||||
mpLoggedInUser->GetLayer(pLayer);
|
||||
NS_ASSERTION(0 != pLayer,"null pLayer");
|
||||
pLayer->SetShell(this);
|
||||
pLayer->FetchEventsByRange(&d,&d1,&EventList);
|
||||
mpCalendar->addEventList(&EventList);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -416,12 +468,9 @@ nsresult nsCalendarShell::LoadPreferences()
|
|||
|
||||
sBuf[0]=0;
|
||||
|
||||
mpLoggedInUser = new nsCalLoggedInUser();
|
||||
if (nsnull == mpLoggedInUser)
|
||||
{
|
||||
// XXX
|
||||
// return NOT OK
|
||||
}
|
||||
nsIUser* pUser;
|
||||
if (NS_OK != (res = mpLoggedInUser->QueryInterface(kIUserIID,(void**)&pUser)))
|
||||
return res ;
|
||||
|
||||
/*
|
||||
* fill in info for the user...
|
||||
|
@ -429,13 +478,22 @@ nsresult nsCalendarShell::LoadPreferences()
|
|||
mShellInstance->GetPreferences()->GetCharPref(CAL_STRING_PREF_USERNAME,sBuf, &iBufSize );
|
||||
s = sBuf;
|
||||
EnvVarsToValues(s);
|
||||
mpLoggedInUser->SetUserName(s.GetBuffer());
|
||||
nsString nsstrUserName = s.GetBuffer();
|
||||
pUser->SetUserName(nsstrUserName);
|
||||
|
||||
/*
|
||||
* Add the logged in user to the user list...
|
||||
*/
|
||||
mUserList.Add( mpLoggedInUser );
|
||||
|
||||
/*****************************************************************/
|
||||
|
||||
/*
|
||||
* This section of code needs to be revamped after a review.
|
||||
* Currently, it expects to load a local and preferred cal url.
|
||||
* We need to rethink this.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Get the local cal address.
|
||||
*/
|
||||
|
@ -444,8 +502,8 @@ nsresult nsCalendarShell::LoadPreferences()
|
|||
EnvVarsToValues(s);
|
||||
curl = s;
|
||||
curl.ResolveFileURL();
|
||||
mpLoggedInUser->SetLocalCapiUrl(curl.GetCSID().GetBuffer());
|
||||
|
||||
/* XXX for now, we're ignoring this value... */
|
||||
|
||||
/*
|
||||
* Load the preferred cal address. For now, the local cal address is the default too...
|
||||
|
@ -455,24 +513,43 @@ nsresult nsCalendarShell::LoadPreferences()
|
|||
EnvVarsToValues(s);
|
||||
curl = s;
|
||||
curl.ResolveFileURL();
|
||||
mpLoggedInUser->AddCalAddr(new JulianString(curl.GetCurl().GetBuffer()));
|
||||
// mpLoggedInUser->AddCalAddr(new JulianString(curl.GetCurl().GetBuffer()));
|
||||
|
||||
/*
|
||||
* create a layer for the preferred address
|
||||
*/
|
||||
nsILayer* pLayer;
|
||||
if (NS_OK != (res = nsRepository::CreateInstance(
|
||||
kCLayerCID, // class id that we want to create
|
||||
nsnull, // not aggregating anything (this is the aggregatable interface)
|
||||
kILayerIID, // interface id of the object we want to get back
|
||||
(void**)&pLayer)))
|
||||
return 1; // XXX fix this
|
||||
pLayer->Init();
|
||||
pLayer->SetCurl(curl.GetCurl());
|
||||
mpLoggedInUser->SetLayer(pLayer);
|
||||
|
||||
/*****************************************************************/
|
||||
|
||||
/*
|
||||
* Get the user's display name
|
||||
*/
|
||||
mShellInstance->GetPreferences()->GetCharPref(CAL_STRING_PREF_USER_DISPLAY_NAME,sBuf, &iBufSize );
|
||||
mpLoggedInUser->SetDisplayName(sBuf);
|
||||
// mpLoggedInUser->SetDisplayName(sBuf); // XXX fix this
|
||||
|
||||
/*
|
||||
* Set the curl to use for the logged in user's calendar...
|
||||
*/
|
||||
msCalURL = * mpLoggedInUser->GetPreferredCalAddr();
|
||||
// msCalURL = * mpLoggedInUser->GetPreferredCalAddr();
|
||||
msCalURL = curl.GetCurl();
|
||||
|
||||
/*
|
||||
* XXX: We gotta ask for this or save a secure password pref or something...
|
||||
*/
|
||||
SetCAPIPassword("HeyBaby");
|
||||
|
||||
NS_RELEASE(pUser);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ private:
|
|||
public:
|
||||
nsCurlParser();
|
||||
nsCurlParser(const char* psCurl);
|
||||
nsCurlParser(JulianString& sCurl);
|
||||
nsCurlParser(const JulianString& sCurl);
|
||||
nsCurlParser(const nsCurlParser& curl);
|
||||
virtual ~nsCurlParser();
|
||||
|
||||
|
|
|
@ -20,10 +20,10 @@ LIBRARY_NAME = util
|
|||
LIBRARY_VERSION = 10
|
||||
|
||||
LD_LIBS += \
|
||||
$(NATIVE_JULIAN_DLL) \
|
||||
$(NATIVE_LIBNLS_LIBS) \
|
||||
raptorbase \
|
||||
xpcom$(MOZ_BITS) \
|
||||
$(NATIVE_JULIAN_DLL) \
|
||||
$(NATIVE_LIBNLS_LIBS) \
|
||||
$(XP_REG_LIB)
|
||||
|
||||
EXTRA_LIBS += $(NSPR_LIBS)
|
||||
|
|
|
@ -89,7 +89,7 @@ nsCurlParser::nsCurlParser()
|
|||
Init();
|
||||
}
|
||||
|
||||
nsCurlParser::nsCurlParser(JulianString& sCurl)
|
||||
nsCurlParser::nsCurlParser(const JulianString& sCurl)
|
||||
{
|
||||
Init();
|
||||
SetCurl(sCurl);
|
||||
|
|
|
@ -20,6 +20,11 @@
|
|||
// John Sun
|
||||
// 1:35 PM Febuary 18 1998
|
||||
|
||||
/*
|
||||
* Updated 9/24/98 sman
|
||||
* We need to be able to append a list of events: AddEventList
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "jdefines.h"
|
||||
|
||||
|
@ -1200,6 +1205,21 @@ void NSCalendar::addEvent(ICalComponent * v)
|
|||
}
|
||||
}
|
||||
//---------------------------------------------------------------------
|
||||
void NSCalendar::addEventList(JulianPtrArray* pEventList)
|
||||
{
|
||||
int j;
|
||||
ICalComponent* pEvent;
|
||||
if (0 != pEventList)
|
||||
{
|
||||
for (j = 0; j < pEventList->GetSize(); j++)
|
||||
{
|
||||
pEvent = (ICalComponent*)pEventList->GetAt(j);
|
||||
if (0 != pEvent)
|
||||
addEvent(pEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------
|
||||
void NSCalendar::addTodo(ICalComponent * v)
|
||||
{
|
||||
if (m_VTodoVctr == 0)
|
||||
|
|
|
@ -21,6 +21,10 @@
|
|||
* John Sun
|
||||
* 2/18/98 1:35:06 PM
|
||||
*/
|
||||
/*
|
||||
* Updated 9/24/98 sman
|
||||
* We need to be able to append a list of events: AddEventList
|
||||
*/
|
||||
|
||||
#ifndef __NSCALENDAR_H_
|
||||
#define __NSCALENDAR_H_
|
||||
|
@ -349,6 +353,14 @@ public:
|
|||
*/
|
||||
void addEvent(ICalComponent * v);
|
||||
|
||||
/**
|
||||
* Append the supplied vector of events to this NSCalendar's
|
||||
* event list. Note that it does not clone the events. It simply
|
||||
* adds the pointer to the events to the event list.
|
||||
* @param pEventList the list of events to add...
|
||||
*/
|
||||
void addEventList(JulianPtrArray *pEventList);
|
||||
|
||||
/**
|
||||
* Add the ICalComponent to the vector of Todos.
|
||||
* NOTE: doesn't add clone of v, but actually ptr to v, so don't deallocate
|
||||
|
|
Загрузка…
Ссылка в новой задаче