Search in Agenda

Login to reply to this topic.
Mon, 2005-04-18 21:11
Joined: 2004-06-17
Forum posts: 47
Hi,

could someone help with searching in Agenda Server, how does Model->FindNextInstanceL work exactly?

Do I have to iterate through all days, and this function finds specific entries inside this day or does it finds directly the days?
What exactly is returnd?

Thanks a lot for your help
Regards
Max

Tue, 2005-04-19 08:31
Joined: 2004-12-16
Forum posts: 50
Search in Agenda
FindNextInstanceL()

void FindNextInstanceL(CAgnDayList<TAgnInstanceId>* aMatchedInstanceList, const TDesC& aSearchText, const TTime& aStartDate, const TTime& aEndDate, const TAgnFilter& aFilter, const TTime& aToday) const;

Description in SDK

Populates a day list with instance IDs for instances whose rich text matches a search string. A match is made if the instance's rich text is an exact match for the search string, or is a subset of it.

After a match is made, other instances on that day are searched. When there are no more instances on that day to search, the function returns.

Only dates within the date range specified are searched, and the entry types to be used in the search are specified using a filter.
Tue, 2005-04-19 08:38
Joined: 2004-06-17
Forum posts: 47
Search in Agenda
I have read this of course too, but it is unclear to me, that's why I asked in this forum.

So do I get instances of a single day, and have to call FindNextInstanceL over and over again?

lkz633
Tue, 2005-04-19 09:21
Joined: 2005-04-19
Forum posts: 13
Search in Agenda
You get a list
_LIT(KAppointment, "My filter text" );

agnModel->FindNextInstanceL(iDayList,KAppointment,aDay,aDay,filter,aDay);
   TInt numberOfEntryesToEdit = iDayList->Count();
   CAgnEntry* entry;
   if (numberOfEntryesToEdit > 0) {
      for (TInt i=0; i<numberOfEntryesToEdit; i++)
      {
         entry=agnModel->FetchInstanceL((*iDayList)[i]);

...
Tue, 2005-04-19 19:04
Joined: 2004-06-17
Forum posts: 47
Search in Agenda
Hi,

I always get an Agenda Model 10 error.

Do I have to cycle through all days, and then find specific instances with FindNextInstanceL?
Then I would not understand why to set date region in this function.

Or should I call FindNextInstanceL as long as NULL is not returned to get all days including a matching instance?
If this is the case, what date should I set in the constructor of CAgnDayList

Thanks for any help
Max
Wed, 2005-04-20 07:01
Joined: 2005-04-19
Forum posts: 13
Search in Agenda
You make a CAgnDayList :
CAgnDayList<TAgnInstanceId>* dayList;

you initialize it (aDay can be what you want, depending on what you are going to do with the list):
dayList=CAgnDayList<TAgnInstanceId>::NewL(aDay.DateTime());

You make i filter (dont have to use it if you dont want to it has to be given to FindNextInstanceL):
TAgnFilter filter;

Make a textfiler :
_LIT(KTextFilter, "YO MAN - MY FILTER" );

Fetch the instanses you are interested in :
agnModel->FindNextInstanceL(dayList,KTextFilter,start,end,filter,today);

Do what you like whit the results :
TInt numberOfEntryesToEdit = dayList->Count();
CAgnEntry* entry;
if (numberOfEntryesToEdit > 0) {
for (TInt i=0; i<numberOfEntryesToEdit; i++) {
}
}

This gives you the instance IDs for the instances that fit the filter and the Textfilter, if their dates 'd' are;     start<= d <=end

Kjetil
Wed, 2005-04-20 12:37
Joined: 2004-06-17
Forum posts: 47
Search in Agenda
Hi,

thanks a lot for your help.

I had similar code before, but was always crashing.
This code crashes with Agenda Model 10, why?

Code:
 TAgnFilter aFilter;
 CAgnDayList<TAgnInstanceId>* iDayList =CAgnDayList<TAgnInstanceId>::NewL(TTime(20050420));  // any date? what to set here???
 iAgnModel->FindNextInstanceL(iDayList,SearchText, TTime(20050418),TTime(20051231), aFilter, TTime(20050420) );

The SDK about this error:
10 Attempted to set a date outside of the valid agenda model date range.

But what does it mean in this context? What I am doing wrong in the code above?


Before this, I have following code, which seems to work fine:

Code:
 RAgendaServ *iAgnServer = RAgendaServ::NewL();
 iAgnServer->Connect();
 RFs theFs;
 User::LeaveIfError(theFs.Connect());
 CAgnModel *iAgnModel = CAgnModel::NewL(NULL);
 iAgnModel->SetServer(iAgnServer);
 iAgnModel->SetMode(CAgnEntryModel::EClient);
 iAgnModel->OpenL(_L("C:\\system\\data\\Calendar"),0,0,0);
 iAgnServer->WaitUntilLoaded();
   

Best regards
Max
Wed, 2005-04-20 13:41
Joined: 2005-04-19
Forum posts: 13
Search in Agenda
Probably the way you set the TTime

You have the following options :

TTime();
TTime(const TInt64& aTime);    (Microsecond value to which to initialise the TTime object)
TTime(const TDesC& aString);  (Date and time string to which to initialize the TTime object)
TTime(const TDateTime& aDateTime); (Date and time to which to initialise the TTime object)

You use the microsecond version with a value that look to me as if it is a date. Try using TTime(const TDesC& aString)

see :
http://www.cs.tut.fi/~mobo/Symbianv6onedocs/devlib/Common/APIReference/DateTimeHandling/UsingTTime.guide.html
Wed, 2005-04-20 13:55
Joined: 2005-04-19
Forum posts: 13
Search in Agenda
eks:

_LIT(KYoMan,"20050319:100000.000000");
TTime time(KYoMan);

will give you today 20.04.2005 kl 10:00

then use time in FindNextInstanceL

Instead of using KYoMan you can create two TTime's; startTime and endTime and use them in FindNextInstanceL.

Kjetil
Wed, 2005-04-20 14:19
Joined: 2004-06-17
Forum posts: 47
Search in Agenda
Hi,

thanks again so much, the TTime values were wrong, now it is working fine.

One last thing, do you know how to get the current day and assign it to a TTime? I did not find this in the SDK

Best regards
lkz633
Wed, 2005-04-20 19:22
Joined: 2004-06-17
Forum posts: 47
Search in Agenda
Sorry, found a solution

If anyone knows about the current day, this would be great.

lkz633
Fri, 2005-04-29 09:17
Joined: 2005-01-11
Forum posts: 44
Search in Agenda
you can get the current time use TTime method HomeTime();
  • Login to reply to this topic.