pimappservices/calendar/tsrc/T_VCAL2.CPP
changeset 0 f979ecb2b13e
child 31 97232defd20e
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include <e32test.h>
       
    17 #include <s32file.h>
       
    18 
       
    19 #include <caldataexchange.h>
       
    20 #include <caldataformat.h>
       
    21 #include <calentryview.h>
       
    22 #include <calalarm.h>
       
    23 #include <caliterator.h>
       
    24 
       
    25 #include <tz.h> //Conversion between local and UTC times
       
    26 
       
    27 #include "caltestlib.h"
       
    28 #include "caltestoom.h"
       
    29 
       
    30 LOCAL_D RTest test(_L("T_VCAL2"));
       
    31 #define KMaxDateStringLength	30
       
    32 
       
    33 _LIT(KTestCalendarFile,"c:t_vcal2");
       
    34 
       
    35 _LIT(KLongSoundNameExportFile,"vCalLongSoundNameExport.vcs");
       
    36 
       
    37 
       
    38 _LIT8(KOOMEntry, 	"BEGIN:VCALENDAR\r\n"
       
    39 					"VERSION:1.0\r\n"
       
    40 					"BEGIN:VEVENT\r\n"
       
    41 					"DESCRIPTION:description\r\n"
       
    42 					"ATTACH:attachment\r\n"
       
    43 					"SUMMARY:summary\r\n"
       
    44 					"CLASS:PUBLIC\r\n"
       
    45 					"DTSTART:19990915T090000Z\r\n"
       
    46 					"DTEND:19990915T100000Z\r\n"
       
    47 					"END:VEVENT\r\n"
       
    48 					"END:VCALENDAR\r\n");
       
    49 
       
    50 //From EXT-5G2CUY "SyncML/versit: Updated VCALENDAR with empty RRULE crash the phone"
       
    51 _LIT8(KMissingRRule, "BEGIN:VCALENDAR\r\n"
       
    52 					 "VERSION:1.0\r\n"
       
    53 					 "BEGIN:VEVENT\r\n"
       
    54 					 "UID:4\r\n"
       
    55 					 "SUMMARY:test\r\n"
       
    56 					 "DTSTART:20021120T090000Z\r\n"
       
    57 					 "DTEND:20021120T100000Z\r\n"
       
    58 					 "X-EPOCAGENDAENTRYTYPE:APPOINTMENT\r\n"
       
    59 					 "CLASS:PUBLIC\r\n"
       
    60 					 "DCREATED:20021120T000000Z\r\n"
       
    61 					 "RRULE:\r\n"
       
    62 					 "LAST-MODIFIED:20021120T122700Z\r\n"
       
    63 					 "PRIORITY:0\r\n"
       
    64 					 "STATUS:NEEDS ACTION\r\n"
       
    65 					 "END:VEVENT\r\n"
       
    66 					 "END:VCALENDAR\r\n");
       
    67 					
       
    68 _LIT8(KEmptyAlarm,	"BEGIN:VCALENDAR\r\n"
       
    69                     "VERSION:1.0\r\n"
       
    70                     "BEGIN:VEVENT\r\n"
       
    71 					"UID:8\r\n"
       
    72 					"SUMMARY:empty alarm\r\n"
       
    73 					"DTSTART:20020916T090000Z\r\n"
       
    74 					"DTEND:20020916T100000Z\r\n"
       
    75 					"X-EPOCAGENDAENTRYTYPE:APPOINTMENT\r\n"
       
    76 					"AALARM:\r\n"
       
    77 					"CLASS:PUBLIC\r\n"
       
    78 					"DCREATED:20020919T000000Z\r\n"
       
    79 					"LAST-MODIFIED:20020919T082100Z\r\n"
       
    80 					"PRIORITY:0\r\n"
       
    81 					"STATUS:NEEDS ACTION\r\n"
       
    82 					"END:VEVENT\r\n"
       
    83                     "END:VCALENDAR\r\n");
       
    84 
       
    85 _LIT8(KTodoCompletedEntry,	"BEGIN:VCALENDAR\r\n"
       
    86 							"VERSION:1.0\r\n"
       
    87 							"BEGIN:VTODO\r\n"
       
    88 							"DUE:20001224T120000Z\r\n"
       
    89 							"SUMMARY:Buy Christmas Presents\r\n"
       
    90 							"STATUS:COMPLETED\r\n"
       
    91 							"PRIORITY:3\r\n"
       
    92 							"END:VTODO\r\n"
       
    93 							"END:VCALENDAR\r\n");
       
    94 
       
    95 _LIT8(KLongSoundNameAlarmExport, "AALARM;TYPE=X-EPOCSOUND:20020809T083900Z;;;");
       
    96 _LIT8(KLongSoundName,	"BEGIN:VCALENDAR\r\n"
       
    97 						"VERSION:1.0\r\n"
       
    98 						"TZ:+00\r\n"
       
    99 						"DAYLIGHT:TRUE;+01;20020407T010000;20021031T020000;-05;-04\r\n"
       
   100 						"BEGIN:VEVENT\r\n"
       
   101 						"DTSTART:20040809T090000Z\r\n"
       
   102 						"DTEND:20040809T100000Z\r\n"
       
   103 						"LAST-MODIFIED:20040804T060600Z\r\n"
       
   104 						"PRIORITY:4\r\n"
       
   105 						"CLASS:CONFIDENTIAL\r\n"
       
   106 						"SUMMARY:An event\r\n"
       
   107 						"AALARM;TYPE=X-EPOCSOUND:20020809T093900;;0;BigSoundNamewwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww.mp3\r\n"
       
   108 						"END:VEVENT\r\n"
       
   109 						"END:VCALENDAR\r\n");
       
   110 
       
   111 _LIT8(KAlarmedEntry, 	"BEGIN:VCALENDAR\r\n"
       
   112 						"VERSION:1.0\r\n" 
       
   113 						"BEGIN:VEVENT\r\n"
       
   114 						"CLASS:PUBLIC\r\n"
       
   115 						"DTSTART:20010607T090000\r\n"
       
   116 						"DTEND:20010607T093000\r\n"
       
   117 						"AALARM:20010607T084500\r\n"
       
   118 						"SUMMARY:SUMMARY\r\n"
       
   119 						"DESCRIPTION:DESCRIPTION\r\n"
       
   120 						"END:VEVENT\r\n"
       
   121 						"END:VCALENDAR\r\n");
       
   122 
       
   123 
       
   124 _LIT8(KPtr,				 "BEGIN:VCALENDAR\r\n" "PRODID:-//Microsoft Corporation//Outlook MIMEDIR//EN\r\n"
       
   125                          "VERSION:1.0\r\n"
       
   126 						 "BEGIN:VEVENT\r\n"
       
   127 						 "STATUS:ACCEPTED\r\n"
       
   128 						 "DTSTART:20010418T120000Z\r\n"
       
   129 						 "DTEND:20010418T130000Z\r\n"
       
   130 						 "LOCATION:Pub\r\n"
       
   131 						 "SUMMARY:Eat lunch\r\n"
       
   132 						 "DESCRIPTION:Working lunch with Example Team. Discuss the preliminary work for new Gee-Whiz promo.\r\n"
       
   133 						 "PRIORITY:2\r\n"
       
   134 						 "ATTACH:memo\r\n"
       
   135                          "END:VEVENT\r\n"
       
   136 						 "BEGIN:VEVENT\r\n"
       
   137 						 "STATUS:CONFIRMED\r\n"
       
   138 						 "DTSTART:20010418T120000Z\r\n"
       
   139 						 "DTEND:20010418T130000Z\r\n"
       
   140 						 "LOCATION:Trendy Night Club\r\n"
       
   141 						 "SUMMARY:Party!!!\r\n"
       
   142 						 "DESCRIPTION:Get your glad rags on for the night of the year. Get down to the Example Night Club. Starts 8.00pm. \r\n"
       
   143 						 "PRIORITY:2\r\n"
       
   144 						 "ATTACH:memo\r\n"
       
   145                          "END:VEVENT\r\n"
       
   146 						 "BEGIN:VEVENT\r\n"
       
   147 						 "STATUS:DECLINED\r\n"
       
   148 						 "DTSTART:20010418T120000Z\r\n"
       
   149 						 "DTEND:20010418T130000Z\r\n"
       
   150 						 "LOCATION:Lecture Hall\r\n"
       
   151 						 "SUMMARY:Train Timetables Lecture \r\n"
       
   152 						 "DESCRIPTION:An exciting journey through the history of railway timetables.\r\n"
       
   153 						 "PRIORITY:2\r\n"
       
   154 						 "ATTACH:memo\r\n"
       
   155                          "END:VEVENT\r\n"
       
   156 						 "BEGIN:VTODO\r\n"					// todo entry
       
   157 						 "X-EPOCAGENDAENTRYTYPE:TODO\r\n"
       
   158 						 "STATUS:TENTATIVE\r\n"
       
   159 						 "DESCRIPTION:to-do item with priority 1\r\n"
       
   160 						 "CLASS:PUBLIC\r\n"
       
   161 						 "DCREATED:20000113T000000Z\r\n"
       
   162 						 "LAST-MODIFIED:20000113T115900Z\r\n"
       
   163 						 "PRIORITY:1\r\n"
       
   164 						 "END:VTODO\r\n"
       
   165 						 "BEGIN:VTODO\r\n"					// todo entry
       
   166 						 "X-EPOCAGENDAENTRYTYPE:TODO\r\n"
       
   167 						 "STATUS:SENT\r\n"
       
   168 						 "SUMMARY:to-do item with priority 2\r\n"
       
   169 						 "CLASS:PUBLIC\r\n"
       
   170 						 "DCREATED:20000113T000000Z\r\n"
       
   171 						 "LAST-MODIFIED:20000113T115900Z\r\n"
       
   172 						 "PRIORITY:2\r\n"
       
   173 						 "END:VTODO\r\n"
       
   174 						 "BEGIN:VTODO\r\n"					// Holiday todo entry - completed
       
   175 						 "STATUS:COMPLETED\r\n"
       
   176 						 "X-EPOCAGENDAENTRYTYPE:TODO\r\n"
       
   177 						 "SUMMARY:Book Holiday\r\n"
       
   178 						 "DESCRIPTION:Need a holiday. Book somewhere nice and warm.\r\n"
       
   179 						 "CLASS:PUBLIC\r\n"
       
   180 						 "DCREATED:20010113T000000Z\r\n"
       
   181 						 "COMPLETED:20010125T113000Z\r\n"
       
   182 						 "LAST-MODIFIED:20000113T115900Z\r\n"
       
   183 						 "PRIORITY:1\r\n"
       
   184 						 "END:VTODO\r\n"
       
   185 						 "BEGIN:VTODO\r\n"					// Holiday todo entry - uncompleted
       
   186 						 "X-EPOCAGENDAENTRYTYPE:TODO\r\n"
       
   187 						 "STATUS:DELEGATED\r\n"
       
   188 						 "DESCRIPTION:Pack Holiday clothes todo\r\n"
       
   189 						 "CLASS:PUBLIC\r\n"
       
   190 						 "DCREATED:20010420T000000Z\r\n"
       
   191 						 "LAST-MODIFIED:20010313T115900Z\r\n"
       
   192 						 "PRIORITY:3\r\n"
       
   193 						 "END:VTODO\r\n"
       
   194 						 "BEGIN:VTODO\r\n"					// todo entry
       
   195 						 "X-EPOCAGENDAENTRYTYPE:TODO\r\n"
       
   196 						 "STATUS:NEEDS ACTION\r\n"
       
   197 						 "SUMMARY:Gas Bill\r\n"
       
   198 						 "DESCRIPTION:Pay this before they cut us off!\r\n"
       
   199 						 "CLASS:PUBLIC\r\n"
       
   200 						 "DCREATED:20000213T000000Z\r\n"
       
   201 						 "LAST-MODIFIED:20000213T115900Z\r\n"
       
   202 						 "PRIORITY:4\r\n"
       
   203                          "END:VTODO\r\n"
       
   204  						 "BEGIN:VTODO\r\n"
       
   205  						 "UID:6\r\n"
       
   206  						 "X-EPOCAGENDAENTRYTYPE:TODO\r\n"
       
   207  						 "DTSTART:19991101T100000\r\n" //no duedate  - should not cause a problem when retrieving
       
   208  						 "END:VTODO\r\n"
       
   209  						 "BEGIN:VTODO\r\n"
       
   210  						 "UID:7\r\n"
       
   211  						 "X-EPOCAGENDAENTRYTYPE:TODO\r\n"
       
   212  						 "END:VTODO\r\n"
       
   213  						 "BEGIN:VEVENT\r\n"
       
   214 						 "STATUS:NEEDS ACTION\r\n"
       
   215 						 "DTSTART:20010421T120000Z\r\n"
       
   216 						 "DTEND:20010421T180000Z\r\n"
       
   217 						 "LOCATION:Cardiff\r\n"
       
   218 						 "DESCRIPTION:\r\n"  // This should not cause a problem!!
       
   219 						 "SUMMARY: FOOTBALL MATCH FINAL\r\n"
       
   220 						 "PRIORITY:2\r\n"
       
   221 						 "ATTACH:memo\r\n"
       
   222                          "END:VEVENT\r\n"
       
   223  						 "BEGIN:VEVENT\r\n"
       
   224 						 "STATUS:NEEDS ACTION\r\n"
       
   225 						 "DTSTART:20010421T120000Z\r\n"
       
   226 						 "DTEND:20010421T180000Z\r\n"
       
   227 						 "LOCATION:Meeting Room 1\r\n"
       
   228 						 "SUMMARY:MIME Lecture\r\n"
       
   229 						 "DESCRIPTION;ENCODING=QUOTED-PRINTABLE:"
       
   230 						 "  MIME (Multipurpose Internet Mail Extensions) Part Two:=0D=0A"
       
   231 						 "  Message Header Extensions for Non-ASCII Text=0D=0A"
       
   232 						 "  Status of this Memo =0D=0A="
       
   233 						 "  This RFC specifies an Internet standards track protocol for the Interne="
       
   234 						 "  t community, and requests discussion and suggestions for improvements. ="
       
   235 						 "  Please refer to the current edition of the Internet Official Protocol S="
       
   236 						 "  tandards for the standardization state and status of this protocol.  Di="
       
   237 						 "  stribution of this memo is unlimited.=0D=0AAbstract=0D=0A"
       
   238 						 "  This memo describes an extension to the message format defined in RFC 1="
       
   239 						 "  521 [1], to allow the representation of character sets other than ASCII="
       
   240 						 "  in RFC 822 (STD 11) message headers.  The extensions described were des="
       
   241 						 "  igned to be highly compatible with existing Internet mailhandling softw="
       
   242 						 "  are, and to be easily implemented in mail readers that support RFC 1521="
       
   243 						 "  .=0D=0A   1. Introduction =0D=0A"
       
   244 						 "  RFC 1521 describes a mechanism for denoting textual body parts which are="
       
   245 						 "  coded in various character sets, as well as methods for encoding such bo="
       
   246 						 "  dy parts as sequences of printable ASCII characters.  This memo describe="
       
   247 						 "  s similar techniques to allow the encoding of non-ASCII text in various ="
       
   248 						 "  portions of a RFC 822 [2] message header, in a manner which is unlikely ="
       
   249 						 "  to confuse existing message handling software. Like the encoding techniq="
       
   250 						 "  ues described in RFC 1521, the techniques outlined here were designed to="
       
   251 						 "  allow the use of non-ASCII characters in message headers in a way which ="
       
   252 						 "  is unlikely to be disturbed by the quirks of existing Internet mail hand="
       
   253 						 "  ling programs.  In particular, some mail relaying programs are known to ="
       
   254 						 "  (a) delete some message header fields while retaining others, (b) rearra="
       
   255 						 "  nge the order of addresses in To or Cc fields, (c) rearrange the (vertic="
       
   256 						 "  al) order of header fields, and/or (d) \"wrap\" message headers at diffe="
       
   257 						 "  rent places than those in the original message.  In addition, some mail ="
       
   258 						 "  reading programs are known to have difficulty correctly parsing message=0D=0A"
       
   259 						 "  headers which, while legal according to RFC 822, make use of backslash-q="
       
   260 						 "  uoting to \"hide\" special characters such as \"<\", \",\", or \":\", or="
       
   261 						 "  which exploit other infrequently-used features of that  specification.=0D=0A"
       
   262 						 "  While it is unfortunate that these programs do not correctly interpret R="
       
   263 						 "  FC 822 headers, to \"break\" these programs would cause severe operation="
       
   264 						 "  al problems for the Internet mail system.  The extensions described in t="
       
   265 						 "  his memo therefore do not rely on little- used features of RFC 822. Inst="
       
   266 						 "  ead, certain sequences of \"ordinary\" printable ASCII characters (known="
       
   267 						 "  as \"encoded-words\") are reserved for use as encoded data.  The syntax ="
       
   268 						 "  of encoded-words is such that they are unlikely to \"accidentally\" appe="
       
   269 						 "  ar as normal text in message headers. Furthermore, the characters used i="
       
   270 						 "  n encoded-words are restricted to those which do not have special meanin="
       
   271 						 "  gs in the context in which the encoded-word appears.Generally,an \"encod="
       
   272 						 "  ed-word\" is a sequence of printable ASCII characters that begins with \"="
       
   273 						 "  =? \", ends with \"?=\", and has two \"?\"s in between.  It specifies a ="
       
   274 						 "  character set and an encoding method, and also includes the original tex="
       
   275 						 "  t encoded as graphic ASCII characters, according to the rules for that e="
       
   276 						 "  ncoding method.=0D=0A"
       
   277 						 "  A mail composer that implements this specification will provide a means ="
       
   278 						 "  of inputting non-ASCII text in header fields, but will translate these f="
       
   279 						 "  ields (or appropriate portions of these fields) into encoded-words befor="
       
   280 						 "  e inserting them into the message header. A mail reader that implements ="
       
   281 						 "  this specification will recognize encoded-words when they appear in cert="
       
   282 						 "  ain portions of the message header.  Instead of displaying the encoded-w="
       
   283 						 "  ord \"as is\", it will reverse the encoding and display the original tex="
       
   284 						 "  t in the designated character set.\r\n"
       
   285 						 "PRIORITY:2\r\n"
       
   286 						 "ATTACH:memo\r\n"
       
   287                          "END:VEVENT\r\n"
       
   288 						 "BEGIN:VEVENT\r\n"
       
   289 						 "STATUS:NEEDS ACTION\r\n"
       
   290 						 "DTSTART:20010421T120000Z\r\n"
       
   291 						 "DTEND:20010421T180000Z\r\n"
       
   292 						 "LOCATION:Example Restaurant\r\n"
       
   293 						 "SUMMARY:Meal for 4\r\n"
       
   294 						 "DESCREPTION:Book early to get a good table and reservation time.\r\n"
       
   295 						 "PRIORITY:2\r\n"
       
   296 						 "ATTACH:memo\r\n"
       
   297                          "END:VEVENT\r\n"
       
   298                          "END:VCALENDAR\r\n");
       
   299                          
       
   300 _LIT8(KPtr2,			"BEGIN:VCALENDAR\r\n"	//Entry for Japan's time zone
       
   301                          "VERSION:1.0\r\n"
       
   302                          "TZ:+09\r\n"
       
   303                          "BEGIN:VEVENT\r\n"
       
   304                          "DTSTART:20020201T040000Z\r\n"
       
   305                          "DTEND:20020201T050000Z\r\n"
       
   306                          "AALARM:20020201T035000Z;;1;\r\n"
       
   307                          "LAST-MODIFIED:20020513T154705Z\r\n"
       
   308                          "PRIORITY:4\r\n"
       
   309                          "CLASS:CONFIDENTIAL\r\n"
       
   310                          "SUMMARY:S1\r\n"
       
   311                          "ATTENDEE;STATUS=CONFIRMED;RSVP=NO:Example Company\r\n"
       
   312                          "END:VEVENT\r\n"
       
   313                          "BEGIN:VEVENT\r\n"
       
   314                          "DTSTART:20020501T040000Z\r\n"
       
   315                          "DTEND:20020501T050000Z\r\n"
       
   316                          "AALARM:20020501T035000Z;;2;\r\n"
       
   317                          "LAST-MODIFIED:20020513T154734Z\r\n"
       
   318                          "PRIORITY:4\r\n"
       
   319                          "CLASS:CONFIDENTIAL\r\n"
       
   320                          "SUMMARY:S1\r\n"
       
   321                          "ATTENDEE;STATUS=CONFIRMED;RSVP=NO:Example Company\r\n"
       
   322                          "END:VEVENT\r\n"
       
   323                          "END:VCALENDAR\r\n\r\n"		//End of entry for Japan
       
   324                          "BEGIN:VCALENDAR\r\n"			//Entry for UK's time zone
       
   325                          "VERSION:1.0\r\n"
       
   326                          "TZ:+00\r\n"
       
   327                          "DAYLIGHT:TRUE;+01;20020331T000000;20021031T020000;+00;+01\r\n"
       
   328                          "BEGIN:VEVENT\r\n"
       
   329                          "DTSTART:20020202T040000Z\r\n"
       
   330                          "DTEND:20020202T050000Z\r\n"
       
   331                          "AALARM:20020202T035000Z;;1;\r\n"
       
   332                          "LAST-MODIFIED:20020513T155829Z\r\n"
       
   333                          "PRIORITY:4\r\n"
       
   334                          "CLASS:CONFIDENTIAL\r\n"
       
   335                          "SUMMARY:S1\r\n"
       
   336                          "ATTENDEE;STATUS=CONFIRMED;RSVP=NO:Example Company\r\n"
       
   337                          "END:VEVENT\r\n"
       
   338                          "BEGIN:VEVENT\r\n"
       
   339                          "DTSTART:20020502T040000Z\r\n"
       
   340                          "DTEND:20020502T050000Z\r\n"
       
   341                          "AALARM:20020502T035000Z;;2;\r\n"
       
   342                          "LAST-MODIFIED:20020513T155906Z\r\n"
       
   343                          "PRIORITY:4\r\n"
       
   344                          "CLASS:CONFIDENTIAL\r\n"
       
   345                          "SUMMARY:S1\r\n"
       
   346                          "ATTENDEE;STATUS=CONFIRMED;RSVP=NO:Example Company\r\n"
       
   347                          "END:VEVENT\r\n"
       
   348                          "END:VCALENDAR\r\n\r\n"		//End of entry for UK
       
   349                          "BEGIN:VCALENDAR\r\n"			//Entry for New York's time zone
       
   350                          "VERSION:1.0\r\n"
       
   351                          "TZ:-05\r\n"
       
   352                          "DAYLIGHT:TRUE;-04;20020407T010000;20021031T020000;-05;-04\r\n"
       
   353                          "BEGIN:VEVENT\r\n"
       
   354                          "DTSTART:20020203T040000Z\r\n"
       
   355                          "DTEND:20020203T050000Z\r\n"
       
   356                          "AALARM:20020203T035000Z;;1;\r\n"
       
   357                          "LAST-MODIFIED:20020513T161055Z\r\n"
       
   358                          "PRIORITY:4\r\n"
       
   359                          "CLASS:CONFIDENTIAL\r\n"
       
   360                          "SUMMARY:S1\r\n"
       
   361                          "ATTENDEE;STATUS=CONFIRMED;RSVP=NO:Example Company\r\n"
       
   362                          "END:VEVENT\r\n"
       
   363                          "BEGIN:VEVENT\r\n"
       
   364                          "DTSTART:20020503T040000Z\r\n"
       
   365                          "DTEND:20020503T050000Z\r\n"
       
   366                          "AALARM:20020503T035000Z;;2;\r\n"
       
   367                          "LAST-MODIFIED:20020513T161133Z\r\n"
       
   368                          "PRIORITY:4\r\n"
       
   369                          "CLASS:CONFIDENTIAL\r\n"
       
   370                          "SUMMARY:S1\r\n"
       
   371                          "ATTENDEE;STATUS=CONFIRMED;RSVP=NO:Example Company\r\n"
       
   372                          "END:VEVENT\r\n"
       
   373                          "END:VCALENDAR\r\n");			//End of entry for New York
       
   374 
       
   375 //This vcal caused a leave with KerrNotSupported when a new entry
       
   376 //whose datetime has not been set is used to setalarm
       
   377 _LIT8(KAlarmVCal,     "BEGIN:VCALENDAR\r\n"
       
   378                         "VERSION:1.0\r\n"
       
   379                         "BEGIN:VTODO\r\n"
       
   380                         "X-EPOCAGENDAENTRYTYPE:TODO\r\n"
       
   381                         "SUMMARY:Task2\r\n"
       
   382                         "DTSTART:20090520T000000\r\n"
       
   383                         "DUE:20090522T000000\r\n"
       
   384                         "CLASS:PUBLIC\r\n"
       
   385                         "PRIORITY:2\r\n"
       
   386                         "AALARM:20090522T080000;;;\r\n"
       
   387                         "STATUS:NEEDS ACTION\r\n"
       
   388                         "END:VTODO\r\n"
       
   389                         "END:VCALENDAR\r\n");
       
   390 
       
   391 class CTestApp : public CBase , public MCalTestOomCallBack
       
   392 	{
       
   393 public:
       
   394 	static CTestApp* NewL();
       
   395 	~CTestApp();
       
   396 	
       
   397 	void DoImportL(const TDesC8& aVCalendar);
       
   398 	void DoTodoCompletedImportL(const TDesC8& aVCalendar);
       
   399 	void DoTZImportL(const TDesC8& aVCalendar, RPointerArray<CCalEntry>& aReadStream);
       
   400 	void DoSyncMLImportL(const TDesC8& aVCalendar);
       
   401 	void DoLongSoundNameImportL(const TDesC& aExportFileName, const TDesC8& aVCalendar);
       
   402 	void OomImportL(const TDesC8& aVCalendarFile);
       
   403 	void DoImportInvalidAlarmL(const TDesC& aFileName, const TDesC8& aVCalendar);
       
   404 	void DoTodoNullDueDateImportL();
       
   405 	
       
   406 private:
       
   407 	void ConstructL();
       
   408 	
       
   409 public: // from MCalOomTestCallBack
       
   410 	void OomTestL(TType /*aType*/, TInt /*aFailAt*/);
       
   411 	
       
   412 private:
       
   413 	CCalTestLibrary* iCalTestLib;
       
   414 	CCalDataExchange* iCalDataExchange;
       
   415 	
       
   416 	TDesC8* iVCalendar; // used in oom test
       
   417 	TDesC* iFileName; // used in oom test
       
   418 	};
       
   419 	
       
   420 CTestApp* CTestApp::NewL()
       
   421 	{
       
   422 	CTestApp* self = new(ELeave) CTestApp;
       
   423 	CleanupStack::PushL(self);
       
   424 	self->ConstructL();
       
   425 	CleanupStack::Pop(self);
       
   426 	return self;
       
   427 	}
       
   428 	
       
   429 void CTestApp::ConstructL()
       
   430 	{
       
   431 	iCalTestLib = CCalTestLibrary::NewL();
       
   432 	iCalTestLib->ReplaceFileL(KTestCalendarFile);
       
   433 	iCalTestLib->OpenFileL(KTestCalendarFile);
       
   434 	iCalDataExchange = CCalDataExchange::NewL(iCalTestLib->GetSession());
       
   435 	}
       
   436 	
       
   437 CTestApp::~CTestApp()
       
   438 	{
       
   439 	TRAP_IGNORE(iCalTestLib->DeleteFileL(KTestCalendarFile, ETrue));
       
   440 	delete iCalDataExchange;
       
   441 	delete iCalTestLib;
       
   442 	}
       
   443 
       
   444 void CTestApp::DoImportL(const TDesC8& aVCalendar)
       
   445 	{
       
   446 	RPointerArray<CCalEntry> entryArray;
       
   447 	CleanupResetAndDestroyPushL(entryArray);
       
   448 	
       
   449 	iCalTestLib->ImportL(aVCalendar, entryArray);
       
   450 	
       
   451 	TInt numSuc;
       
   452 	iCalTestLib->SynCGetEntryViewL().StoreL(entryArray, numSuc);
       
   453 	
       
   454 	CleanupStack::PopAndDestroy(&entryArray);
       
   455 	}
       
   456 
       
   457 
       
   458 void CTestApp::DoTodoCompletedImportL(const TDesC8& aVCalendar)
       
   459 	{
       
   460 	test.Next(_L("Importing All entries - doTodoCompletedImportL"));
       
   461 
       
   462 	
       
   463 	// Create ptr array for new entries
       
   464 	RPointerArray<CCalEntry> entryArray;
       
   465 	CleanupResetAndDestroyPushL(entryArray);
       
   466 	
       
   467 	iCalTestLib->ImportL(aVCalendar, entryArray);
       
   468 
       
   469 	const TInt KSize = entryArray.Count(); //must be one
       
   470 	for (TInt i(0) ; i < KSize; ++i)
       
   471 		{
       
   472 		CCalEntry* entry = entryArray[i];
       
   473 		test(entry->CompletedTimeL().TimeLocalL() != Time::NullTTime() && (entry->StatusL() == CCalEntry::ETodoCompleted));
       
   474 		}
       
   475 
       
   476 	CleanupStack::PopAndDestroy(&entryArray);	// entryArray.Close()
       
   477 	}
       
   478 
       
   479 void CTestApp::DoTodoNullDueDateImportL()
       
   480  	{
       
   481     test.Next(_L("doTodoNullDueDateImportL"));
       
   482 
       
   483  	_LIT(KDateString,"%*E%*D%X%*N%*Y %1 %2 '%3");
       
   484  	TBuf<KMaxDateStringLength> dateString;
       
   485  	
       
   486  	CCalIter* calIter = CCalIter::NewL(iCalTestLib->GetSession());
       
   487  	CleanupStack::PushL(calIter);
       
   488  	
       
   489  	TInt iCount = 0;
       
   490  	
       
   491  	for (TDesC8* guid = &const_cast<TDesC8&>(calIter->FirstL());
       
   492  			guid->Compare(KNullDesC8) != 0;
       
   493  			guid = &const_cast<TDesC8&>(calIter->NextL()))
       
   494  		{
       
   495  		test.Printf(_L("Retrieving Start and End Dates"));
       
   496  		iCount++;
       
   497  		
       
   498  		RPointerArray<CCalEntry> entryArray;
       
   499  		CleanupResetAndDestroyPushL(entryArray);
       
   500  		iCalTestLib->SynCGetEntryViewL().FetchL(*guid, entryArray);
       
   501  
       
   502  		// Extract EndDate and StartDate
       
   503  		TTime tenddate = entryArray[0]->EndTimeL().TimeLocalL();
       
   504  		TTime tstartdate = entryArray[0]->StartTimeL().TimeLocalL();
       
   505  		if (tstartdate == Time::NullTTime())
       
   506  			{
       
   507  			test.Printf(_L("Start date is NullTTime"));
       
   508  			}
       
   509  		else
       
   510  			{
       
   511  			tstartdate.FormatL(dateString,KDateString);
       
   512  		  	test.Printf(_L("Start date is  %S"), &dateString);
       
   513  			}
       
   514  		if (tenddate == Time::NullTTime())
       
   515  			{
       
   516  			test.Printf(_L("End date is NullTTime"));
       
   517  			}
       
   518  		else
       
   519  			{
       
   520  			tenddate.FormatL(dateString,KDateString);
       
   521  		  	test.Printf(_L("End date is  %S"), &dateString);
       
   522  			}
       
   523  
       
   524  		CleanupStack::PopAndDestroy(&entryArray);
       
   525  
       
   526  		test.Printf(_L("\n"));
       
   527  		}
       
   528  	CleanupStack::PopAndDestroy(calIter);
       
   529  	}
       
   530  
       
   531 void CTestApp::DoTZImportL(const TDesC8& aVCalendar, RPointerArray<CCalEntry>& aEntryArray)
       
   532 	{
       
   533 	const TInt KMinPerHour=60;
       
   534 	// Create array for new entries
       
   535 	
       
   536 	iCalTestLib->ImportL(aVCalendar, aEntryArray);
       
   537 
       
   538 	const TInt KSize = aEntryArray.Count();
       
   539 	
       
   540 	for (TInt i(0); i < KSize; ++i)
       
   541 		{
       
   542 		CCalEntry* entry = aEntryArray[i];
       
   543 		
       
   544 		TTime ttime = entry->StartTimeL().TimeUtcL(); //system local time
       
   545 		TInt minutes = ttime.DateTime().Hour() * KMinPerHour + ttime.DateTime().Minute();
       
   546 		test(minutes == 4*KMinPerHour);
       
   547 	
       
   548 		ttime = entry->EndTimeL().TimeUtcL(); // system local
       
   549 		minutes = ttime.DateTime().Hour() * KMinPerHour + ttime.DateTime().Minute();
       
   550 		test(minutes == 5*KMinPerHour);
       
   551 		
       
   552 		CCalAlarm* alarm = entry->AlarmL();
       
   553 		CleanupStack::PushL(alarm);
       
   554 		TDateTime alarmTime = (entry->StartTimeL().TimeUtcL() - alarm->TimeOffset()).DateTime();
       
   555 		test(alarmTime.Hour()==3 && alarmTime.Minute()==50);
       
   556 		CleanupStack::PopAndDestroy(alarm);
       
   557 		}
       
   558 
       
   559 	}
       
   560 
       
   561 
       
   562 void CTestApp::DoSyncMLImportL(const TDesC8& aVCalendar)
       
   563 	{
       
   564 	RPointerArray<CCalEntry> entryArray;
       
   565 	CleanupClosePushL(entryArray);
       
   566 	
       
   567 	iCalTestLib->ImportL(aVCalendar, entryArray);
       
   568 
       
   569 	TLocale locale;
       
   570 
       
   571 	test.Next(_L("Importing1: JAPAN"));
       
   572 
       
   573 	
       
   574 	DoTZImportL(aVCalendar, entryArray);
       
   575 
       
   576 	test.Next(_L("Importing2: UK"));
       
   577 
       
   578 	DoTZImportL(aVCalendar, entryArray);
       
   579 
       
   580 	test.Next(_L("Importing3: New York"));
       
   581 
       
   582 	DoTZImportL(aVCalendar, entryArray);
       
   583 	
       
   584 	CleanupStack::PopAndDestroy(&entryArray);
       
   585 
       
   586 	locale.Set();
       
   587 	}
       
   588 
       
   589 /*
       
   590 In a vCal entry if the sound file name is too long then the given name will be
       
   591 ignored and alarm entry will be added with empty sound name.
       
   592 
       
   593 1. Import vCal file with long sound name
       
   594 2. Export the same entry into another file
       
   595 3. Open the exported file and check for sound name, should be empty.
       
   596 */
       
   597 
       
   598 
       
   599 void CTestApp::DoLongSoundNameImportL(const TDesC& aExportFileName, const TDesC8& aVCalendar)
       
   600 	{
       
   601 	test.Next(_L("Import with too long sound file name"));
       
   602 
       
   603 	
       
   604 	RPointerArray<CCalEntry> entryArray;
       
   605 	CleanupResetAndDestroyPushL(entryArray);
       
   606 	
       
   607 	iCalTestLib->ImportL(aVCalendar, entryArray);
       
   608 	
       
   609 	const TInt KSize = entryArray.Count();
       
   610 	test(KSize == 1);
       
   611 	TLocale locale;
       
   612 
       
   613 	// Export the entry into another file
       
   614 	iCalTestLib->ExportL(aExportFileName, entryArray);
       
   615 	locale.Set();
       
   616 
       
   617 	// Read exported entry and search for sound name, should be empty
       
   618 	// get the file size
       
   619 	RFile exportFile;
       
   620 	iCalTestLib->TestRegister().OpenTempFileLC(exportFile, aExportFileName);
       
   621 	TInt pos = 0;
       
   622 	exportFile.Seek(ESeekEnd,pos);
       
   623 	TInt fileLength = pos;
       
   624 	pos = 0;
       
   625 	exportFile.Seek(ESeekStart,pos);
       
   626 
       
   627 	HBufC8* buff = HBufC8::NewLC(fileLength);
       
   628 	TPtr8 pBuff(buff->Des());
       
   629 	exportFile.Read(pBuff,fileLength);
       
   630 	TInt err = pBuff.Find(KLongSoundNameAlarmExport());
       
   631 	test(err != KErrNotFound);
       
   632 
       
   633 	CleanupStack::PopAndDestroy(buff);
       
   634 	CleanupStack::PopAndDestroy(&exportFile);
       
   635 	CleanupStack::PopAndDestroy(&entryArray);
       
   636 	}
       
   637 	
       
   638 void CTestApp::OomImportL(const TDesC8& aVCalendar)
       
   639 	{
       
   640 	iVCalendar = const_cast<TDesC8*>(&aVCalendar);
       
   641 	CCalSession& calSession = iCalTestLib->GetSession();
       
   642 	CalTestOom::OutOfMemoryTestL(*this, EClient, calSession);
       
   643 	CalTestOom::OutOfMemoryTestL(*this, EServer, calSession);
       
   644 	}
       
   645 	
       
   646 void CTestApp::OomTestL(TType /*aType*/, TInt /*aFailAt*/)
       
   647 	{
       
   648 	test.Printf(_L("."));
       
   649 	DoImportL(*iVCalendar);
       
   650 	}
       
   651 
       
   652 static void DoMainL()
       
   653 	{
       
   654 	CTestApp* testApp = CTestApp::NewL();
       
   655 	CleanupStack::PushL(testApp);
       
   656 
       
   657 	test.Printf(_L("Import under normal conditions\n"));
       
   658 	testApp->DoImportL(KPtr);
       
   659 	
       
   660 	test.Printf(_L("Import as if from SX_syncml \n"));
       
   661 	testApp->DoImportL(KAlarmedEntry);
       
   662 	
       
   663 	test.Printf(_L("Importing todo completed entry\n"));
       
   664 	testApp->DoTodoCompletedImportL(KTodoCompletedEntry);
       
   665 
       
   666 	test.Printf(_L("Importing todo nullduedate entry\n"));
       
   667  	testApp->DoTodoNullDueDateImportL();
       
   668 
       
   669 	test.Printf(_L("Import an empty alarm\n"));
       
   670 	testApp->DoImportL(KEmptyAlarm);
       
   671 	
       
   672 	test.Printf(_L("Missing RRULE property\n"));
       
   673 	testApp->DoImportL(KMissingRRule);
       
   674 	
       
   675 	test.Printf(_L("Import as if from SyncML Server\n"));
       
   676 	testApp->DoSyncMLImportL(KPtr2);
       
   677 	
       
   678 	test.Printf(_L("Import with too long sound file name\n"));
       
   679 	testApp->DoLongSoundNameImportL(KLongSoundNameExportFile, KLongSoundName);
       
   680 	
       
   681 	test.Printf(_L("Import with simulated heap failure\n"));
       
   682 	testApp->OomImportL(KOOMEntry);
       
   683 	
       
   684 	//This vcal caused a leave with KerrNotSupported when a new entry
       
   685 	//whose datetime has not been set is used to setalarm	
       
   686 	test.Printf(_L("Import a vcal with alarm information\n"));
       
   687 	testApp->DoImportL(KAlarmVCal);
       
   688 	
       
   689 	CleanupStack::PopAndDestroy(testApp);
       
   690 	}
       
   691 
       
   692 
       
   693 /**
       
   694 
       
   695 @SYMTestCaseID     PIM-T-VCAL2-0001
       
   696 
       
   697 */
       
   698 
       
   699 TInt E32Main()
       
   700 	{
       
   701 	__UHEAP_MARK;
       
   702 	test.Start(_L("@SYMTESTCaseID:PIM-T-VCAL2-0001 T_VCAL2"));
       
   703 
       
   704 	test.Title();
       
   705 	
       
   706 	CActiveScheduler* scheduler=new CActiveScheduler;
       
   707 	CActiveScheduler::Install(scheduler);
       
   708 	
       
   709 	CTrapCleanup* theCleanup = CTrapCleanup::New();
       
   710 	
       
   711 	TRAPD(ret, DoMainL());
       
   712 	
       
   713 	test(ret==KErrNone);
       
   714 	
       
   715 	delete theCleanup;
       
   716 	delete scheduler;
       
   717 	
       
   718 	test.End();
       
   719 	test.Close();
       
   720 	
       
   721 	__UHEAP_MARKEND;
       
   722 	return KErrNone;
       
   723 	}
       
   724