19
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#ifndef ALARMSERVERTEST_H
|
|
19 |
#define ALARMSERVERTEST_H
|
|
20 |
|
|
21 |
#include "startconsolealarmserver.h"
|
|
22 |
|
|
23 |
|
|
24 |
#include <calalarm.h>
|
|
25 |
#include <caluser.h>
|
|
26 |
|
|
27 |
#include "calendarconstants.h"
|
|
28 |
#include "calendarheader.h"
|
|
29 |
#include "EntryAttributes.h"
|
|
30 |
#include "calendarservice.h"
|
|
31 |
|
|
32 |
|
|
33 |
TInt AddAppointment(CCalendarService* aService, const TDesC& name, TUIDSet*& uids)
|
|
34 |
{
|
|
35 |
CEntryAttributes* entryObj = CEntryAttributes::NewL( KEntryAppt );
|
|
36 |
|
|
37 |
entryObj->SetDescriptionL(_L("SAPI weekly meeting"));
|
|
38 |
entryObj->SetLocationL(_L("Hara"));
|
|
39 |
entryObj->SetEntryStatusL(KStatusConfirmed);
|
|
40 |
entryObj->SetMethodL(KMethodNone);
|
|
41 |
entryObj->SetPriority(5);
|
|
42 |
entryObj->SetSummaryL(_L("Happens from 9 to 9:30"));
|
|
43 |
|
|
44 |
entryObj->SetStartTimeL( TTime(TDateTime(2007, EAugust, 8, 9, 0, 0, 0)) );
|
|
45 |
|
|
46 |
entryObj->SetEndTimeL(TTime(TDateTime(2007, EAugust, 8, 9, 30, 0, 0)));
|
|
47 |
|
|
48 |
TRAPD( errno, aService->AddL(name,entryObj,uids) );
|
|
49 |
delete entryObj;
|
|
50 |
return errno;
|
|
51 |
}
|
|
52 |
/*
|
|
53 |
EAppt An appointment, which has a start time and end time.
|
|
54 |
|
|
55 |
ETodo A to-do, which can have a start time and end time (the end time is the due date), or can be undated.
|
|
56 |
|
|
57 |
EEvent An event, which has a start time and end time.
|
|
58 |
|
|
59 |
EReminder A reminder, which has a start time only.
|
|
60 |
|
|
61 |
EAnniv An anniversary, which has a start time and end time.
|
|
62 |
*/
|
|
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
TInt AddToDo(CCalendarService* aService, const TDesC& name, TUIDSet*& uids)
|
|
69 |
{
|
|
70 |
CEntryAttributes* entryObj = CEntryAttributes::NewL( KEntryTodo );
|
|
71 |
|
|
72 |
entryObj->SetDescriptionL(_L("New todo entry created"));
|
|
73 |
entryObj->SetSummaryL(_L("TODO Entry"));
|
|
74 |
TTime endTime(TDateTime(2007, EAugust, 21, 0, 0, 0, 0));
|
|
75 |
entryObj->SetEndTimeL(endTime);
|
|
76 |
entryObj->SetReplicationL(KReplOpen);
|
|
77 |
entryObj->SetPriority(0);
|
|
78 |
|
|
79 |
TRAPD( errno, aService->AddL(name,entryObj,uids) );
|
|
80 |
delete entryObj;
|
|
81 |
return errno;
|
|
82 |
}
|
|
83 |
|
|
84 |
TInt RemoveCalendarFile(CCalendarService* aService, const TDesC& name)
|
|
85 |
{
|
|
86 |
TRAPD( err , aService->DeleteL( name ) );
|
|
87 |
return err ;
|
|
88 |
}
|
|
89 |
|
|
90 |
TInt AddCalendarFile(CCalendarService* aService, const TDesC& name)
|
|
91 |
{
|
|
92 |
TRAPD( err , aService->AddL( name ) );
|
|
93 |
return err ;
|
|
94 |
}
|
|
95 |
|
|
96 |
TInt DeleteAllCalendarEntry(CCalendarService* aService, const TDesC& name)
|
|
97 |
{
|
|
98 |
CCalendarFilter* filter = CCalendarFilter::NewL();
|
|
99 |
filter->SetDeleteAll();
|
|
100 |
TRAPD( err, aService->DeleteL( name, filter ) );
|
|
101 |
delete filter;
|
|
102 |
return err ;
|
|
103 |
}
|
|
104 |
|
|
105 |
TInt AddAppointmentWithAttendees(CCalendarService* aService, const TDesC& name, TUIDSet*& uids)
|
|
106 |
{
|
|
107 |
CEntryAttributes* entryObj = CEntryAttributes::NewL( KEntryAppt );
|
|
108 |
|
|
109 |
entryObj->SetDescriptionL(_L("SAPI weekly meeting"));
|
|
110 |
entryObj->SetLocationL(_L("Hara"));
|
|
111 |
entryObj->SetEntryStatusL(KStatusConfirmed);
|
|
112 |
|
|
113 |
entryObj->SetMethodL(KMethodNone);
|
|
114 |
CAttendeeInfo* organizer=CAttendeeInfo::NewL(_L("mcrasta@gmail.com"));
|
|
115 |
organizer->SetCommonNameL(_L("SAPI"));
|
|
116 |
entryObj->SetOrganizerDataL(organizer);
|
|
117 |
delete organizer;
|
|
118 |
|
|
119 |
entryObj->SetPhoneOwnerDataL(_L("h2s@gmail.com"));
|
|
120 |
|
|
121 |
entryObj->SetPriority(5);
|
|
122 |
entryObj->SetSummaryL(_L("Happens from 9 to 9:30"));
|
|
123 |
|
|
124 |
TTime stTime(TDateTime(2007, EAugust, 8, 9, 0, 0, 0));
|
|
125 |
entryObj->SetStartTimeL(stTime);
|
|
126 |
|
|
127 |
TTime endTime(TDateTime(2007, EAugust, 8, 9, 30, 0, 0));
|
|
128 |
entryObj->SetEndTimeL(endTime);
|
|
129 |
|
|
130 |
CCalAlarm* alarm = CCalAlarm::NewL();
|
|
131 |
TTime alarmTime(TDateTime(2007,EAugust, 8, 7, 30, 0, 0));
|
|
132 |
//entryObj->SetAlarm(alarmTime);
|
|
133 |
delete alarm;
|
|
134 |
CAttendeeInfo* attendee = CAttendeeInfo::NewL(_L("h2s@gmail.com"));
|
|
135 |
attendee->SetRoleL(KAttRoleReqParticipant);
|
|
136 |
attendee->SetStatusL(KAttStatusTentative);
|
|
137 |
attendee->SetRsvp(EFalse);
|
|
138 |
|
|
139 |
/*attendee = CCalAttendee::NewL(_L(""));
|
|
140 |
attendee->SetCommonNameL(_L("SAPI"));
|
|
141 |
attendee->SetRoleL(CCalAttendee::EReqParticipant);
|
|
142 |
attendee->SetStatusL(CCalAttendee::ETentative);
|
|
143 |
attendee->SetResponseRequested(EFalse);
|
|
144 |
|
|
145 |
attendees.Append(attendee);*/
|
|
146 |
|
|
147 |
entryObj->AddAttendeeL(attendee);
|
|
148 |
delete attendee;
|
|
149 |
|
|
150 |
TRAPD( errno, aService->AddL(name,entryObj,uids) );
|
|
151 |
|
|
152 |
delete entryObj;
|
|
153 |
|
|
154 |
return errno;
|
|
155 |
}
|
|
156 |
TInt AddAnny(CCalendarService* aService, const TDesC& name, TUIDSet*& uids)
|
|
157 |
{
|
|
158 |
|
|
159 |
CEntryAttributes* entryObj = CEntryAttributes::NewL( KEntryAnniv );
|
|
160 |
|
|
161 |
TTime stTime(TDateTime(2007, EDecember, 30, 0, 0, 0, 0));
|
|
162 |
entryObj->SetStartTimeL(stTime);
|
|
163 |
entryObj->SetReplicationL(KReplPrivate);
|
|
164 |
|
|
165 |
TCalTime startTime;
|
|
166 |
startTime.SetTimeLocalFloatingL( stTime );
|
|
167 |
/*TCalRRule rrule(TCalRRule::EYearly);
|
|
168 |
rrule.SetDtStart(startTime);
|
|
169 |
rrule.SetInterval(1);
|
|
170 |
|
|
171 |
TCalTime uTime;
|
|
172 |
uTime.SetTimeLocalFloatingL(TCalTime::MaxTime());
|
|
173 |
rrule.SetUntil(uTime);
|
|
174 |
|
|
175 |
entryObj->SetRepeatRule(rrule);*/
|
|
176 |
|
|
177 |
TRAPD( errno, aService->AddL(name,entryObj,uids) );
|
|
178 |
|
|
179 |
delete entryObj;
|
|
180 |
|
|
181 |
return errno;
|
|
182 |
}
|
|
183 |
|
|
184 |
TInt AddEvent(CCalendarService* aService, const TDesC& name, TUIDSet*& uids)
|
|
185 |
{
|
|
186 |
CEntryAttributes* entryObj = CEntryAttributes::NewL( KEntryEvent );
|
|
187 |
|
|
188 |
entryObj->SetDescriptionL(_L("New Event entry created"));
|
|
189 |
entryObj->SetSummaryL(_L("Event Entry"));
|
|
190 |
TTime stTime(TDateTime(2007, EJuly, 25, 0, 0, 0, 0));
|
|
191 |
entryObj->SetStartTimeL(stTime);
|
|
192 |
entryObj->SetReplicationL(KReplPrivate);
|
|
193 |
|
|
194 |
|
|
195 |
TRAPD( errno, aService->AddL(name,entryObj,uids) );
|
|
196 |
|
|
197 |
delete entryObj;
|
|
198 |
|
|
199 |
return errno;
|
|
200 |
}
|
|
201 |
|
|
202 |
TInt AddReminder(CCalendarService* aService, const TDesC& name, TUIDSet*& uids)
|
|
203 |
{
|
|
204 |
CEntryAttributes* entryObj = CEntryAttributes::NewL( KEntryReminder );
|
|
205 |
|
|
206 |
entryObj->SetDescriptionL(_L("New Reminder entry created"));
|
|
207 |
entryObj->SetSummaryL(_L("Reminder Entry"));
|
|
208 |
TTime stTime(TDateTime(2007, EJuly, 22, 10, 30, 0, 0));
|
|
209 |
entryObj->SetStartTimeL(stTime);
|
|
210 |
entryObj->SetReplicationL(KReplOpen);
|
|
211 |
|
|
212 |
TRAPD( errno, aService->AddL(name,entryObj,uids) );
|
|
213 |
delete entryObj;
|
|
214 |
|
|
215 |
return errno;
|
|
216 |
}
|
|
217 |
|
|
218 |
TInt AddRepeatingAppointmentEntryL(CCalendarService* aService, const TDesC& name, TUIDSet*& uids)
|
|
219 |
{
|
|
220 |
|
|
221 |
CEntryAttributes* entryObj = CEntryAttributes::NewL( KEntryAppt );
|
|
222 |
|
|
223 |
entryObj->SetDescriptionL(_L("SAPI weekly meeting"));
|
|
224 |
entryObj->SetLocationL(_L("Hara"));
|
|
225 |
entryObj->SetEntryStatusL(KStatusConfirmed);
|
|
226 |
|
|
227 |
entryObj->SetMethodL(KMethodNone);
|
|
228 |
CAttendeeInfo* organizer = CAttendeeInfo::NewL(_L("mcrasta@gmail.com"));
|
|
229 |
organizer->SetCommonNameL(_L("SAPI"));
|
|
230 |
entryObj->SetOrganizerDataL(organizer);
|
|
231 |
delete organizer;
|
|
232 |
|
|
233 |
entryObj->SetPhoneOwnerDataL(_L("h2s@gmail.com"));
|
|
234 |
|
|
235 |
entryObj->SetPriority(5);
|
|
236 |
entryObj->SetSummaryL(_L("Repeating entry"));
|
|
237 |
|
|
238 |
TTime stTime(TDateTime(2007, ESeptember, 15, 9, 0, 0, 0));
|
|
239 |
entryObj->SetStartTimeL(stTime);
|
|
240 |
|
|
241 |
TTime endTime(TDateTime(2007, ESeptember, 15, 9, 30, 0, 0));
|
|
242 |
entryObj->SetEndTimeL(endTime);
|
|
243 |
|
|
244 |
CCalAlarm* alarm = CCalAlarm::NewL();
|
|
245 |
TTime alarmTime(TDateTime(2007,ESeptember, 15, 7, 30, 0, 0));
|
|
246 |
//entryObj->SetAlarm(alarmTime);
|
|
247 |
delete alarm;
|
|
248 |
|
|
249 |
CAttendeeInfo* attendee = CAttendeeInfo::NewL(_L("h2s@gmail.com"));
|
|
250 |
attendee->SetRoleL(KAttRoleReqParticipant);
|
|
251 |
attendee->SetStatusL(KAttStatusTentative);
|
|
252 |
attendee->SetRsvp(EFalse);
|
|
253 |
entryObj->AddAttendeeL(attendee);
|
|
254 |
delete attendee;
|
|
255 |
|
|
256 |
attendee = CAttendeeInfo::NewL(_L("mdcosta@gmail.com"));
|
|
257 |
attendee->SetCommonNameL(_L("SAPI"));
|
|
258 |
attendee->SetRoleL(KAttRoleReqParticipant);
|
|
259 |
attendee->SetStatusL(KAttStatusTentative);
|
|
260 |
attendee->SetRsvp(EFalse);
|
|
261 |
entryObj->AddAttendeeL(attendee);
|
|
262 |
delete attendee;
|
|
263 |
|
|
264 |
CRepeatInfo* rrule = CRepeatInfo::NewL(TCalRRule::EDaily);
|
|
265 |
//TCalRRule rrule(TCalRRule::EDaily);
|
|
266 |
TCalTime startTime;
|
|
267 |
startTime.SetTimeUtcL(stTime);
|
|
268 |
rrule->SetStartTimeL(stTime);
|
|
269 |
TCalTime uTime;
|
|
270 |
uTime.SetTimeUtcL(TTime(TDateTime(2007, ESeptember, 29, 0, 0, 0, 0)));
|
|
271 |
rrule->SetUntilTimeL(TTime(TDateTime(2007, ESeptember, 29, 0, 0, 0, 0)));
|
|
272 |
rrule->SetWeekStart(EWednesday);
|
|
273 |
entryObj->SetRepeatRule(rrule);
|
|
274 |
delete rrule;
|
|
275 |
|
|
276 |
TTime exDate(TDateTime(2007, ESeptember, 20, 0, 0, 0, 0));
|
|
277 |
TCalTime exTime;
|
|
278 |
exTime.SetTimeUtcL(exDate);
|
|
279 |
entryObj->AddExceptionDateL(exDate);
|
|
280 |
|
|
281 |
TTime rDate(TDateTime(2007, EOctober, 0, 9, 0, 0, 0));
|
|
282 |
TCalTime rTime;
|
|
283 |
rTime.SetTimeUtcL(rDate);
|
|
284 |
entryObj->AddRepeatDateL(rDate);
|
|
285 |
|
|
286 |
TRAPD( errno, aService->AddL(name,entryObj,uids) );
|
|
287 |
delete entryObj;
|
|
288 |
return errno;
|
|
289 |
|
|
290 |
}
|
|
291 |
|
|
292 |
|
|
293 |
|
|
294 |
#endif
|