mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
updates to support layers
This commit is contained in:
parent
990efcfe1d
commit
65ecbcc677
@ -40,7 +40,7 @@ public:
|
||||
NS_IMETHOD AddLayer(nsILayer * aLayer);
|
||||
NS_IMETHOD RemoveLayer(nsILayer * aLayer);
|
||||
|
||||
NS_IMETHOD SetShell(nsCalendarShell* aShell) {mpShell = aShell; return NS_OK;}
|
||||
NS_IMETHOD SetShell(nsCalendarShell* aShell);
|
||||
NS_IMETHOD SetCurl(const JulianString& s);
|
||||
NS_IMETHOD GetCurl(JulianString& s);
|
||||
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "nsCoreCIID.h"
|
||||
|
||||
#include "nsLayer.h"
|
||||
#include "nsLayerCollection.h"
|
||||
#include "nsCalendarUser.h"
|
||||
#include "nsCalendarModel.h"
|
||||
|
||||
@ -30,6 +31,7 @@ static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
|
||||
static NS_DEFINE_IID(kICalUSerIID, NS_ICALENDAR_USER_IID);
|
||||
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);
|
||||
|
||||
@ -120,6 +122,8 @@ nsresult nsCoreFactory::CreateInstance(nsISupports *aOuter,
|
||||
|
||||
if (mClassID.Equals(kCLayerCID)) {
|
||||
inst = (nsISupports *)new nsLayer(aOuter);
|
||||
} else if (mClassID.Equals(kCLayerCollectionCID)) {
|
||||
inst = (nsISupports *)(nsILayerCollection*) new nsLayerCollection(aOuter);
|
||||
} else if (mClassID.Equals(kCCalendarUserCID)) {
|
||||
inst = (nsISupports *)new nsCalendarUser(aOuter);
|
||||
} else if (mClassID.Equals(kCCalendarModelCID)) {
|
||||
|
@ -258,14 +258,6 @@ nsresult nsLayer::FetchEventsByRange(
|
||||
/*
|
||||
* Set up the range of time for which we'll pull events...
|
||||
*/
|
||||
#if 0
|
||||
int iOffset = 30;
|
||||
d.prevDay(iOffset);
|
||||
psDTStart = d.toISO8601().toCString("");
|
||||
d.nextDay(2 * iOffset);
|
||||
psDTEnd = d.toISO8601().toCString("");
|
||||
#endif
|
||||
|
||||
psDTStart = aStart->toISO8601().toCString("");
|
||||
psDTEnd = aStop->toISO8601().toCString("");
|
||||
|
||||
@ -288,7 +280,7 @@ nsresult nsLayer::FetchEventsByRange(
|
||||
0);
|
||||
|
||||
capiStatus = pCapi->CAPI_SetStreamCallbacks(
|
||||
mpShell->mCAPISession, &RcvStream, 0,0,RcvData, pCalStreamReader,0);
|
||||
pSession->m_Session, &RcvStream, 0,0,RcvData, pCalStreamReader,0);
|
||||
|
||||
if (CAPI_ERR_OK != capiStatus)
|
||||
return 1; /* XXX: really need to fix this up */
|
||||
@ -298,7 +290,7 @@ nsresult nsLayer::FetchEventsByRange(
|
||||
* local capi can take a null list or as soon as
|
||||
* cs&t capi can take a list.
|
||||
*/
|
||||
nsCurlParser sessionURL(mpShell->msCalURL);
|
||||
nsCurlParser sessionURL(msCurl);
|
||||
char** asList = gasViewPropList;
|
||||
int iListSize = giViewPropListCount;
|
||||
|
||||
@ -308,10 +300,24 @@ nsresult nsLayer::FetchEventsByRange(
|
||||
iListSize = 0;
|
||||
}
|
||||
|
||||
CAPIHandle h = 0;
|
||||
JulianString sHandle(sessionURL.GetCSID());
|
||||
|
||||
/*
|
||||
* The handle name may be a file name. We need to make sure that
|
||||
* the characters are in URL form. That is "C|/bla" instead of
|
||||
* "C:/bla"
|
||||
*/
|
||||
nsCurlParser::ConvertToURLFileChars(sHandle);
|
||||
capiStatus = pCapi->CAPI_GetHandle(
|
||||
pSession->m_Session,
|
||||
sHandle.GetBuffer(),0,&h);
|
||||
if (0 != capiStatus)
|
||||
return 1; /* XXX really need to fix this */
|
||||
capiStatus = pCapi->CAPI_FetchEventsByRange(
|
||||
mpShell->mCAPISession, &mpShell->mCAPIHandle, 1, 0,
|
||||
psDTStart, psDTEnd,
|
||||
asList, iListSize, RcvStream);
|
||||
pSession->m_Session, &h, 1, 0,
|
||||
psDTStart, psDTEnd,
|
||||
asList, iListSize, RcvStream);
|
||||
}
|
||||
|
||||
if (CAPI_ERR_OK != capiStatus)
|
||||
@ -344,7 +350,15 @@ nsresult nsLayer::FetchEventsByRange(
|
||||
{
|
||||
pEvent = (ICalComponent*)pEventList->GetAt(j);
|
||||
if (0 != pEvent)
|
||||
{
|
||||
#if 0
|
||||
UnicodeString usFmt("%(yyyy-MMM-dd hh:mma)B-%(hh:mma)e %S"); // XXX this needs to be put in a resource, then a variable that can be switched
|
||||
char *psBuf = pEvent->toStringFmt(usFmt).toCString("");
|
||||
delete psBuf;
|
||||
#endif
|
||||
anArray->Add(pEvent);
|
||||
mpShell->mpCalendar->addEvent(pEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,13 +20,16 @@
|
||||
#include "nscore.h"
|
||||
#include "jdefines.h"
|
||||
#include "ptrarray.h"
|
||||
#include "julnstr.h"
|
||||
#include "nsLayerCollection.h"
|
||||
#include "nsCurlParser.h"
|
||||
#include "nsCoreCIID.h"
|
||||
#include "nsxpfcCIID.h"
|
||||
|
||||
static NS_DEFINE_IID(kILayerIID, NS_ILAYER_IID);
|
||||
static NS_DEFINE_IID(kILayerCollectionIID, NS_ILAYER_COLLECTION_IID);
|
||||
static NS_DEFINE_IID(kCLayerCollectionCID, NS_LAYER_COLLECTION_CID);
|
||||
static NS_DEFINE_IID(kILayerIID, NS_ILAYER_IID);
|
||||
static NS_DEFINE_IID(kILayerCollectionIID, NS_ILAYER_COLLECTION_IID);
|
||||
static NS_DEFINE_IID(kCLayerCollectionCID, NS_LAYER_COLLECTION_CID);
|
||||
static NS_DEFINE_IID(kCLayerCID, NS_LAYER_CID);
|
||||
|
||||
nsLayerCollection::nsLayerCollection(nsISupports* outer)
|
||||
{
|
||||
@ -116,13 +119,112 @@ nsresult nsLayerCollection :: RemoveLayer(nsILayer * aLayer)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsLayerCollection::SetCurl(const JulianString& s)
|
||||
/**
|
||||
* Remove any existing layers, and create a layer for each
|
||||
* of the supplied urls.
|
||||
* @param sCurl A string of space-delimited calendar urls
|
||||
* that form the layer list.
|
||||
* @return NS_OK on success
|
||||
*/
|
||||
nsresult nsLayerCollection::SetCurl(const JulianString& sC)
|
||||
{
|
||||
nsILayer* pLayer;
|
||||
nsresult res;
|
||||
JulianString sCurl = sC;
|
||||
|
||||
/*
|
||||
* Delete all layers we currently hold...
|
||||
*/
|
||||
while (mLayers->Count() > 0 )
|
||||
{
|
||||
pLayer = (nsILayer*)mLayers->ElementAt(0);
|
||||
RemoveLayer(pLayer);
|
||||
mLayers->RemoveAt(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Now build up the layers based on what we have...
|
||||
*/
|
||||
JulianString s;
|
||||
int32 i,j;
|
||||
for (i = 0; i >= 0 && i < (PRInt32)sCurl.GetStrlen(); i = j + 1 )
|
||||
{
|
||||
while (' ' == sCurl.GetBuffer()[i] && i < (PRInt32)sCurl.GetStrlen())
|
||||
++i;
|
||||
if (i >= (PRInt32)sCurl.GetStrlen())
|
||||
break;
|
||||
/*
|
||||
* XXX:
|
||||
* this is a complete hack. I want to use the commented out
|
||||
* lines below. But if I
|
||||
* do we get library link errors. Maybe it will go away when we make
|
||||
* the big changeover to nsString.
|
||||
*/
|
||||
|
||||
#if 0
|
||||
if (-1 == (j = sCurl.Strpbrk(i," \t")))
|
||||
j = sCurl.GetStrlen()-1;
|
||||
s = sCurl(i,j-i+1);
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
{
|
||||
/*
|
||||
* XXX: REMOVE this code when replacing the string.
|
||||
*/
|
||||
char sBuf[1024];
|
||||
int k;
|
||||
char c;
|
||||
for ( k = 0, j = i;
|
||||
(' ' != (c = sCurl.GetBuffer()[j])) && (j < (PRInt32)sCurl.GetStrlen());
|
||||
j++, k++)
|
||||
{
|
||||
sBuf[k] = c;
|
||||
}
|
||||
sBuf[k] = 0;
|
||||
s = sBuf;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* create a new layer for this curl
|
||||
*/
|
||||
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(s);
|
||||
AddLayer(pLayer);
|
||||
}
|
||||
return (NS_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a string containing all the layers in this collection.
|
||||
* @param s the returned string
|
||||
* @return NS_OK on success.
|
||||
*/
|
||||
nsresult nsLayerCollection::GetCurl(JulianString& s)
|
||||
{
|
||||
PRInt32 i;
|
||||
PRInt32 iSize = mLayers->Count();
|
||||
JulianString sTmp;
|
||||
nsILayer* pLayer;
|
||||
nsresult res;
|
||||
|
||||
s = "";
|
||||
for ( i = 0; i < (PRInt32)mLayers->Count(); i++)
|
||||
{
|
||||
pLayer = (nsILayer*)mLayers->ElementAt(i);
|
||||
if ( NS_OK != (res = pLayer->GetCurl(sTmp)))
|
||||
return res;
|
||||
if (i > 0)
|
||||
s += " ";
|
||||
s += sTmp;
|
||||
}
|
||||
return (NS_OK);
|
||||
}
|
||||
|
||||
@ -211,3 +313,22 @@ nsresult nsLayerCollection::URLMatch(const JulianString& aUrl, PRBool& aMatch)
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param aShell the shell object
|
||||
*
|
||||
* @return NS_OK on success
|
||||
*/
|
||||
nsresult nsLayerCollection::SetShell(nsCalendarShell* aShell)
|
||||
{
|
||||
mpShell = aShell;
|
||||
PRInt32 i;
|
||||
PRInt32 iSize = mLayers->Count();
|
||||
nsILayer *pLayer;
|
||||
for ( i = 0; i < iSize; i++)
|
||||
{
|
||||
pLayer = (nsILayer*)mLayers->ElementAt(i);
|
||||
pLayer->SetShell(aShell);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
@ -50,6 +50,7 @@
|
||||
|
||||
#include "nsCoreCIID.h"
|
||||
#include "nsLayer.h"
|
||||
#include "nsLayerCollection.h"
|
||||
#include "nsCalUser.h"
|
||||
#include "nsCalendarUser.h"
|
||||
#include "nsCalendarModel.h"
|
||||
@ -95,6 +96,7 @@ 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(kILayerCollectionIID, NS_ILAYER_COLLECTION_IID);
|
||||
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);
|
||||
@ -244,6 +246,13 @@ nsresult nsCalendarShell::Logon()
|
||||
if (NS_OK != (res = mpLoggedInUser->QueryInterface(kIUserIID,(void**)&pUser)))
|
||||
return res ;
|
||||
|
||||
|
||||
/*
|
||||
* THIS WHOLE AREA NEEDS TO BE MOVED INTO USERMGR. Have it
|
||||
* create the user, etc based on a curl or curllist.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Getting the first calendar by user name should be reviewed.
|
||||
*/
|
||||
@ -307,6 +316,15 @@ nsresult nsCalendarShell::Logon()
|
||||
//mScheduler.InitialLoadData();
|
||||
mpLoggedInUser->GetLayer(pLayer);
|
||||
NS_ASSERTION(0 != pLayer,"null pLayer");
|
||||
{
|
||||
char sBuf[2048];
|
||||
int iBufSize = sizeof(sBuf);
|
||||
JulianString sTmp;
|
||||
mShellInstance->GetPreferences()->GetCharPref(CAL_STRING_PREF_PREFERRED_ADDR,sBuf, &iBufSize );
|
||||
sTmp = sBuf;
|
||||
EnvVarsToValues(sTmp);
|
||||
pLayer->SetCurl(sTmp);
|
||||
}
|
||||
pLayer->SetShell(this);
|
||||
pLayer->FetchEventsByRange(&d,&d1,&EventList);
|
||||
pLayer->SetCal(mpCalendar);
|
||||
@ -521,9 +539,9 @@ nsresult nsCalendarShell::LoadPreferences()
|
||||
*/
|
||||
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
|
||||
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**)&pLayer)))
|
||||
return 1; // XXX fix this
|
||||
pLayer->Init();
|
||||
|
@ -186,14 +186,14 @@ public:
|
||||
*
|
||||
* <pre>
|
||||
* JulianString x("012345");
|
||||
* x[2,4] returns a JulianString containing "234"
|
||||
* x.indexSubstr(2,4) returns a JulianString containing "234"
|
||||
* </pre>
|
||||
*
|
||||
* @param i index of first character of the sub
|
||||
* @param j index of the last character of the sub
|
||||
* @return a JulianString
|
||||
* @param iStart index of first character of the sub
|
||||
* @param iStop index of the last character of the sub
|
||||
* @return a JulianString
|
||||
*/
|
||||
JulianString indexSubstr(int32 iIndex, int32 iCount);
|
||||
JulianString indexSubstr(int32 iStart, int32 iStop);
|
||||
|
||||
/**
|
||||
* Encode illegal characters to something suitable for a URL
|
||||
|
@ -20,13 +20,15 @@
|
||||
/**
|
||||
* This class manages a string in one of the following forms:
|
||||
*
|
||||
* protocol://user:password@host.domain[:port]/CSID[:extra]
|
||||
* protocol://[user[:password]@]host.domain[:port]/CSID[:extra]
|
||||
* mailto:user@host.domain
|
||||
*
|
||||
* Examples:
|
||||
* capi://calendar-1.mcom.com/sman
|
||||
* capi://jason:badguy@calendar-1.mcom.com/sman
|
||||
* capi://localhost/c|/temp/junk.ics
|
||||
* capi://guest@calendar-1.mcom.com/sman
|
||||
* file://localhost/c|/temp/junk.ics
|
||||
* file:///c|/temp/junk.ics
|
||||
* mailto:sman@netscape.com
|
||||
*
|
||||
* The component parts of a calendar URL are:
|
||||
@ -41,9 +43,14 @@
|
||||
* delimiting the extra stuff
|
||||
* extra: extra information that may be needed by a particular
|
||||
* server or service.
|
||||
* remainder: Anything past an embedded space. When the URL is parsed
|
||||
* it is expected not to include embedded spaces. When a
|
||||
* space is found, it could be that the string is
|
||||
* actually a list of URLs. The characters to the right
|
||||
* of the space are stored in remainder.
|
||||
*
|
||||
* This class provides quick access to these component parts.
|
||||
* Expected protocols are: CAPI, IRIP, MAILTO
|
||||
* Expected protocols are: CAPI, IRIP, MAILTO, FILE, HTTP, FTP, RESOURCE
|
||||
*
|
||||
* This code probably exists somewhere else.
|
||||
*
|
||||
@ -53,6 +60,7 @@
|
||||
* to platform specific file handle.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _NS_CURL_PARSER_H
|
||||
#define _NS_CURL_PARSER_H
|
||||
|
||||
@ -73,6 +81,7 @@ private:
|
||||
PRInt32 m_iPort;
|
||||
JulianString m_sCSID;
|
||||
JulianString m_sExtra;
|
||||
JulianString m_sRemainder;
|
||||
PRBool m_bParseNeeded;
|
||||
PRBool m_bAssemblyNeeded;
|
||||
|
||||
@ -97,6 +106,7 @@ public:
|
||||
JulianString GetCSID();
|
||||
JulianString GetPath();
|
||||
JulianString GetExtra();
|
||||
JulianString GetRemainder();
|
||||
|
||||
/**
|
||||
* @return a JulianString containing the fully qualified Calendar URL.
|
||||
|
@ -43,9 +43,14 @@
|
||||
* delimiting the extra stuff
|
||||
* extra: extra information that may be needed by a particular
|
||||
* server or service.
|
||||
* remainder: Anything past an embedded space. When the URL is parsed
|
||||
* it is expected not to include embedded spaces. When a
|
||||
* space is found, it could be that the string is
|
||||
* actually a list of URLs. The characters to the right
|
||||
* of the space are stored in remainder.
|
||||
*
|
||||
* This class provides quick access to these component parts.
|
||||
* Expected protocols are: CAPI, IRIP, MAILTO
|
||||
* Expected protocols are: CAPI, IRIP, MAILTO, FILE, HTTP, FTP, RESOURCE
|
||||
*
|
||||
* This code probably exists somewhere else.
|
||||
*
|
||||
@ -122,6 +127,7 @@ void nsCurlParser::Init()
|
||||
m_iPort = -1;
|
||||
m_sCSID = "";
|
||||
m_sExtra = "";
|
||||
m_sRemainder = "";
|
||||
m_bParseNeeded = PR_FALSE;
|
||||
m_bAssemblyNeeded = PR_FALSE;
|
||||
}
|
||||
@ -136,6 +142,7 @@ void nsCurlParser::Init(const nsCurlParser& that)
|
||||
m_iPort = that.m_iPort;
|
||||
m_sCSID = that.m_sCSID;
|
||||
m_sExtra = that.m_sExtra;
|
||||
m_sRemainder = that.m_sRemainder;
|
||||
m_bParseNeeded = that.m_bParseNeeded;
|
||||
m_bAssemblyNeeded = that.m_bAssemblyNeeded;
|
||||
}
|
||||
@ -188,7 +195,19 @@ void nsCurlParser::Parse()
|
||||
|
||||
Init();
|
||||
|
||||
/*
|
||||
* quick check: look for an embedded space. If one is found
|
||||
* all characters to the right are stored in m_sRemainder.
|
||||
*/
|
||||
if (-1 != (i = m_sCurl.Find(' ',0)))
|
||||
{
|
||||
m_sRemainder = m_sCurl.Right( m_sCurl.GetStrlen() - i );
|
||||
m_sCurl.GetBuffer()[i] = 0;
|
||||
m_sCurl.DoneWithBuffer();
|
||||
}
|
||||
|
||||
m_eProto = eUNKNOWN;
|
||||
|
||||
/*
|
||||
* Was a protocol specified?
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user