pimappservices/calendar/client/src/calalarm.cpp
changeset 0 f979ecb2b13e
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     1 // Copyright (c) 2005-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 <calalarm.h>
       
    17 #include <calcontent.h>
       
    18 #include <asshddefs.h>
       
    19 
       
    20 
       
    21 /** Creates a new calendar alarm with no alarm sound name and
       
    22 an alarm time offset of 0 minutes, and no extended alarm action.
       
    23 
       
    24 @publishedAll
       
    25 @released
       
    26 @capability None
       
    27 @return CCalAlarm pointer
       
    28 */
       
    29 EXPORT_C CCalAlarm* CCalAlarm::NewL()
       
    30 	{
       
    31 	return ( new (ELeave) CCalAlarm() );
       
    32 	}
       
    33 
       
    34 CCalAlarm::CCalAlarm()
       
    35 	{
       
    36 	}
       
    37 
       
    38 /** A calendar alarm destructor.
       
    39 
       
    40 @publishedAll
       
    41 @released
       
    42 @capability None
       
    43  */
       
    44 EXPORT_C CCalAlarm::~CCalAlarm()
       
    45 	{
       
    46 	delete iAlarmName;
       
    47 	delete iAlarmAction;
       
    48 	}
       
    49 
       
    50 
       
    51 /** Sets a time offset for an alarm to occur prior to a scheduled event.
       
    52 
       
    53 The time offset is calculated as the number of minutes before the instance time of the event.
       
    54 - For non-todo entries, the instance time is the start date.
       
    55 - For todo entries, the instance time is the end date (the due date).
       
    56 Note that it is not possible to set an alarm on a todo without an end date.
       
    57 
       
    58 It is possible to have a negative offset provided that the alarm is on the same day (in local time) as the instance time; this means the alarm occurs after the event.
       
    59 Fixed entries cannot have negative alarm offsets, since then the current day will change depending on the time zone.
       
    60 @publishedAll
       
    61 @released
       
    62 @capability None
       
    63 @param aOffset The time offset in minutes for an alarm prior to an event.
       
    64 */
       
    65 EXPORT_C void CCalAlarm::SetTimeOffset(TTimeIntervalMinutes aOffset)
       
    66 	{
       
    67 	iOffset = aOffset;
       
    68 	}
       
    69 
       
    70 
       
    71 /** Gets the time offset for the alarm to occur prior to an event.
       
    72 
       
    73 @publishedAll
       
    74 @released
       
    75 @capability None
       
    76 @return The alarm offset (in minutes) prior to an event.
       
    77 */
       
    78 EXPORT_C TTimeIntervalMinutes CCalAlarm::TimeOffset() const
       
    79 	{
       
    80 	return ( iOffset );
       
    81 	}
       
    82 
       
    83 
       
    84 /** Sets the name of the alarm sound.
       
    85 
       
    86 Note: if the length of the new alarm sound name is greater than KMaxAlarmSoundName
       
    87 characters, it will be ignored.
       
    88 
       
    89 @publishedAll
       
    90 @released
       
    91 @capability None
       
    92 @param aAlarmSoundName The name of the alarm sound.
       
    93 */
       
    94 EXPORT_C void CCalAlarm::SetAlarmSoundNameL(const TDesC& aAlarmSoundName)
       
    95 	{
       
    96 	const TInt KLen = aAlarmSoundName.Length();
       
    97 	
       
    98 	if ( KLen > 0 && KLen <= KMaxAlarmSoundNameLength )
       
    99 		{
       
   100 		// delete and set always to NULL before AllocL because
       
   101 		// that call could leave and the pointer be not NULL
       
   102 
       
   103 		delete iAlarmName;
       
   104 		iAlarmName = NULL;
       
   105 	
       
   106 		iAlarmName = aAlarmSoundName.AllocL();
       
   107 		}		
       
   108 	}
       
   109 
       
   110 
       
   111 /** Gets a descripter of the alarm sound name.
       
   112 
       
   113 If there is no name set, KNullDesC will be returned.
       
   114 
       
   115 @publishedAll
       
   116 @released
       
   117 @capability None
       
   118 @return CCalAlarm descriptor reference
       
   119 */
       
   120 EXPORT_C const TDesC& CCalAlarm::AlarmSoundNameL() const
       
   121 	{
       
   122 	if ( iAlarmName )
       
   123 		{
       
   124 		return ( *iAlarmName );
       
   125 		}
       
   126 		
       
   127 	return ( KNullDesC() );
       
   128 	}
       
   129 
       
   130 
       
   131 /** Associates an action with the alarm. The action could be a link to an
       
   132 Internet radio station, or it could be a small animated icon.
       
   133 This class takes ownership of the alarm action.
       
   134 Any existing alarm action is deleted.
       
   135 
       
   136 @param aAlarmAction The data or link (url).
       
   137 @see CCalContent
       
   138 */
       
   139 EXPORT_C void CCalAlarm::SetAlarmAction(CCalContent* aAlarmAction)
       
   140 	{
       
   141 	delete iAlarmAction;
       
   142 	iAlarmAction = aAlarmAction;
       
   143 	}
       
   144 
       
   145 
       
   146 /** Returns the action associated with the alarm.  For example, the
       
   147 action could be a link to an Internet radio station, or it could be a
       
   148 small animated icon.
       
   149 
       
   150 @return The alarm action or a NULL pointer if there is no alarm action.
       
   151 @see CCalContent
       
   152 */
       
   153 EXPORT_C CCalContent* CCalAlarm::AlarmAction() const
       
   154 	{
       
   155 	return iAlarmAction;
       
   156 	}
       
   157 
       
   158