uifw/AknGlobalUI/OldStyleNotif/Src/AknDynamicNotificationData.cpp
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2008 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 "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:  Dynamic soft notification data store
       
    15 *
       
    16 */
       
    17 
       
    18 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    19 #include <vwsdefpartner.h>
       
    20 #endif
       
    21 #include "AknDynamicNotificationData.h"
       
    22 
       
    23 //-----------------------------------------------------------------------------
       
    24 // CAknDynamicNotificationData::NewL
       
    25 //-----------------------------------------------------------------------------
       
    26 //   
       
    27 CAknDynamicNotificationData* CAknDynamicNotificationData::NewL( 
       
    28     RReadStream& aStream )
       
    29     {
       
    30     CAknDynamicNotificationData* self = NewLC( aStream );
       
    31     CleanupStack::Pop( self );
       
    32     return self;
       
    33     }
       
    34 
       
    35 //-----------------------------------------------------------------------------
       
    36 // CAknDynamicNotificationData::NewLC
       
    37 //-----------------------------------------------------------------------------
       
    38 //   
       
    39 CAknDynamicNotificationData* CAknDynamicNotificationData::NewLC( 
       
    40     RReadStream& aStream )
       
    41     {
       
    42     CAknDynamicNotificationData* self = new(ELeave) CAknDynamicNotificationData;
       
    43     CleanupStack::PushL( self );
       
    44     self->ConstructL( aStream );
       
    45     return self;
       
    46     }
       
    47     
       
    48 //-----------------------------------------------------------------------------
       
    49 // CAknDynamicNotificationData::CAknDynamicNotificationData
       
    50 //-----------------------------------------------------------------------------
       
    51 //   
       
    52 CAknDynamicNotificationData::CAknDynamicNotificationData()
       
    53     {
       
    54     }
       
    55 
       
    56 //-----------------------------------------------------------------------------
       
    57 // CAknDynamicNotificationData::~CAknDynamicNotificationData
       
    58 //-----------------------------------------------------------------------------
       
    59 //   
       
    60 CAknDynamicNotificationData::~CAknDynamicNotificationData()
       
    61     {
       
    62     delete iCustomMessage;
       
    63 
       
    64     // softkeys
       
    65     delete iLeftSoftkey;
       
    66     delete iRightSoftkey;
       
    67     
       
    68     // note labels
       
    69     delete iNoteSingularLabel;
       
    70     delete iNotePluralLabel;
       
    71     delete iGroupSingularLabel;
       
    72     delete iGroupPluralLabel;
       
    73 
       
    74     // Image data
       
    75     delete iImageData; 
       
    76     }
       
    77 
       
    78 //-----------------------------------------------------------------------------
       
    79 // CAknDynamicNotificationData::ConstructL
       
    80 //-----------------------------------------------------------------------------
       
    81 //   
       
    82 void CAknDynamicNotificationData::ConstructL( RReadStream& aStream )
       
    83     {
       
    84     aStream >> *this;
       
    85     }
       
    86 
       
    87 //-----------------------------------------------------------------------------
       
    88 // CAknDynamicNotificationData::SetId
       
    89 //-----------------------------------------------------------------------------
       
    90 //   
       
    91 void CAknDynamicNotificationData::SetId( TInt aId )
       
    92     {
       
    93     iNoteId = aId;
       
    94     }
       
    95 
       
    96 //-----------------------------------------------------------------------------
       
    97 // CAknDynamicNotificationData::Id
       
    98 //-----------------------------------------------------------------------------
       
    99 //   
       
   100 TInt CAknDynamicNotificationData::Id() const
       
   101     {
       
   102     return iNoteId;
       
   103     }
       
   104 
       
   105 //-----------------------------------------------------------------------------
       
   106 // CAknDynamicNotificationData::Priority
       
   107 //-----------------------------------------------------------------------------
       
   108 //   
       
   109 TInt CAknDynamicNotificationData::Priority() const
       
   110     {
       
   111     return iPriority;
       
   112     }
       
   113 
       
   114 //-----------------------------------------------------------------------------
       
   115 // CAknDynamicNotificationData::ViewId
       
   116 //-----------------------------------------------------------------------------
       
   117 //   
       
   118 CAknNoteDialog::TTone CAknDynamicNotificationData::Tone() const
       
   119     {
       
   120     return iTone;
       
   121     }
       
   122 
       
   123 //-----------------------------------------------------------------------------
       
   124 // CAknDynamicNotificationData::ViewId
       
   125 //-----------------------------------------------------------------------------
       
   126 //   
       
   127 TVwsViewId CAknDynamicNotificationData::ViewId() const
       
   128     {
       
   129     return iViewId;
       
   130     }
       
   131 
       
   132 //-----------------------------------------------------------------------------
       
   133 // CAknDynamicNotificationData::PluralViewId
       
   134 //-----------------------------------------------------------------------------
       
   135 //   
       
   136 TVwsViewId CAknDynamicNotificationData::PluralViewId() const
       
   137     {
       
   138     return iPluralViewId;
       
   139     }
       
   140 
       
   141 //-----------------------------------------------------------------------------
       
   142 // CAknDynamicNotificationData::CustomMsgUid
       
   143 //-----------------------------------------------------------------------------
       
   144 //   
       
   145 TUid CAknDynamicNotificationData::CustomMsgUid() const
       
   146     {
       
   147     return iCustomMessageId;
       
   148     }
       
   149 
       
   150 //-----------------------------------------------------------------------------
       
   151 // CAknDynamicNotificationData::CustomMsg
       
   152 //-----------------------------------------------------------------------------
       
   153 //   
       
   154 const TDesC8& CAknDynamicNotificationData::CustomMsg() const
       
   155     {
       
   156     return iCustomMessage ? *iCustomMessage : KNullDesC8();
       
   157     }
       
   158 
       
   159 //-----------------------------------------------------------------------------
       
   160 // CAknDynamicNotificationData::LeftSoftkey
       
   161 //-----------------------------------------------------------------------------
       
   162 //   
       
   163 const TDesC& CAknDynamicNotificationData::LeftSoftkey() const
       
   164     {
       
   165     return iLeftSoftkey ? *iLeftSoftkey : KNullDesC();
       
   166     }
       
   167 
       
   168 //-----------------------------------------------------------------------------
       
   169 // CAknDynamicNotificationData::RightSoftkey
       
   170 //-----------------------------------------------------------------------------
       
   171 //   
       
   172 const TDesC& CAknDynamicNotificationData::RightSoftkey() const
       
   173     {
       
   174     return iRightSoftkey ? *iRightSoftkey : KNullDesC();
       
   175     }
       
   176 
       
   177 //-----------------------------------------------------------------------------
       
   178 // CAknDynamicNotificationData::SingularLabel
       
   179 //-----------------------------------------------------------------------------
       
   180 //   
       
   181 const TDesC& CAknDynamicNotificationData::SingularLabel() const
       
   182     {
       
   183     return iNoteSingularLabel ? *iNoteSingularLabel : KNullDesC();
       
   184     }
       
   185 
       
   186 //-----------------------------------------------------------------------------
       
   187 // CAknDynamicNotificationData::PluralLabel
       
   188 //-----------------------------------------------------------------------------
       
   189 //   
       
   190 const TDesC& CAknDynamicNotificationData::PluralLabel() const
       
   191     {
       
   192     return iNotePluralLabel ? *iNotePluralLabel : KNullDesC();
       
   193     }
       
   194 
       
   195 //-----------------------------------------------------------------------------
       
   196 // CAknDynamicNotificationData::PluralLabelGroup
       
   197 //-----------------------------------------------------------------------------
       
   198 //   
       
   199 const TDesC& CAknDynamicNotificationData::SingularLabelGroup() const
       
   200     {
       
   201     return iGroupSingularLabel ? *iGroupSingularLabel : KNullDesC();
       
   202     }
       
   203 
       
   204 //-----------------------------------------------------------------------------
       
   205 // CAknDynamicNotificationData::PluralLabelGroup
       
   206 //-----------------------------------------------------------------------------
       
   207 //   
       
   208 const TDesC& CAknDynamicNotificationData::PluralLabelGroup() const
       
   209     {
       
   210     return iGroupPluralLabel ? *iGroupPluralLabel : KNullDesC();
       
   211     }
       
   212 
       
   213 //-----------------------------------------------------------------------------
       
   214 // CAknDynamicNotificationData::ImageData
       
   215 //-----------------------------------------------------------------------------
       
   216 //   
       
   217 const TDesC8& CAknDynamicNotificationData::ImageData() const
       
   218     {
       
   219     return iImageData ? *iImageData : KNullDesC8();
       
   220     }
       
   221     
       
   222 //-----------------------------------------------------------------------------
       
   223 // CAknDynamicNotificationData::EnableObserver
       
   224 //-----------------------------------------------------------------------------
       
   225 //   
       
   226 TBool CAknDynamicNotificationData::EnableObserver() const
       
   227     {
       
   228     return iEnableObserver;
       
   229     }    
       
   230 
       
   231 //-----------------------------------------------------------------------------
       
   232 // CAknDynamicNotificationData::ResetContent
       
   233 //-----------------------------------------------------------------------------
       
   234 //   
       
   235 void CAknDynamicNotificationData::ResetContent()
       
   236     {
       
   237     iNoteId = 0;
       
   238     iPriority = 0;
       
   239     iTone = CAknNoteDialog::ENoTone;
       
   240 
       
   241     // view activation related parameters
       
   242     iViewId = KNullViewId;
       
   243     iPluralViewId = KNullViewId;
       
   244     iCustomMessageId = KNullUid;
       
   245     delete iCustomMessage;
       
   246     iCustomMessage = NULL;
       
   247 
       
   248     // softkeys
       
   249     delete iLeftSoftkey;
       
   250     iLeftSoftkey = NULL;
       
   251     delete iRightSoftkey;
       
   252     iRightSoftkey = NULL;
       
   253     
       
   254     // parameters that would normally be read from a resource file
       
   255     delete iNoteSingularLabel;
       
   256     iNoteSingularLabel = NULL;
       
   257     delete iNotePluralLabel;
       
   258     iNotePluralLabel = NULL;
       
   259     delete iGroupSingularLabel;
       
   260     iGroupSingularLabel = NULL;
       
   261     delete iGroupPluralLabel;
       
   262     iGroupPluralLabel = NULL;
       
   263 
       
   264     // Image data
       
   265     delete iImageData;
       
   266     iImageData = NULL;
       
   267     }
       
   268 
       
   269 //-----------------------------------------------------------------------------
       
   270 // CAknDynamicNotificationData::InternalizeL
       
   271 //-----------------------------------------------------------------------------
       
   272 //   
       
   273 void CAknDynamicNotificationData::InternalizeL( RReadStream& aStream )
       
   274     {
       
   275     ResetContent();
       
   276     
       
   277     // From AknDynamicSoftNotifier (Client side) 
       
   278     iNoteId   = aStream.ReadInt32L();
       
   279     
       
   280     // NOTE: These steps needs to be equal to those in 
       
   281     // TAknDynamicSoftNotificationParams::ExternalizeL, so that the 
       
   282     // data won't be corrupted
       
   283     //    
       
   284     iPriority = aStream.ReadInt32L();
       
   285     iTone = (CAknNoteDialog::TTone)aStream.ReadInt32L();
       
   286     
       
   287     iViewId.iAppUid.iUid  = aStream.ReadUint32L();
       
   288     iViewId.iViewUid.iUid = aStream.ReadUint32L();
       
   289     iPluralViewId.iAppUid.iUid  = aStream.ReadUint32L();
       
   290     iPluralViewId.iViewUid.iUid = aStream.ReadUint32L();
       
   291     
       
   292     TInt messageUid = aStream.ReadInt32L();
       
   293     if( messageUid != KErrNotFound )
       
   294         {
       
   295         iCustomMessageId.iUid = messageUid;
       
   296         iCustomMessage = InternalizeText8L( aStream );
       
   297         }
       
   298 
       
   299     iLeftSoftkey  = InternalizeText16L( aStream );
       
   300     iRightSoftkey = InternalizeText16L( aStream );
       
   301     
       
   302     iNoteSingularLabel = InternalizeText16L( aStream );
       
   303     iNotePluralLabel   = InternalizeText16L( aStream );
       
   304     iGroupSingularLabel = InternalizeText16L( aStream );
       
   305     iGroupPluralLabel   = InternalizeText16L( aStream );
       
   306     
       
   307     iEnableObserver = aStream.ReadUint8L();
       
   308     
       
   309     iImageData = InternalizeText8L( aStream );
       
   310     }
       
   311     
       
   312 //-----------------------------------------------------------------------------
       
   313 // CAknDynamicNotificationData::ExternalizeL
       
   314 //-----------------------------------------------------------------------------
       
   315 //   
       
   316 void CAknDynamicNotificationData::ExternalizeL( RWriteStream& aStream ) const
       
   317     {
       
   318     aStream.WriteInt32L( iNoteId );
       
   319     aStream.WriteInt32L( iPriority );
       
   320     aStream.WriteInt32L( iTone );
       
   321     
       
   322     aStream.WriteUint32L( iViewId.iAppUid.iUid );
       
   323     aStream.WriteUint32L( iViewId.iViewUid.iUid );
       
   324     aStream.WriteUint32L( iPluralViewId.iAppUid.iUid );
       
   325     aStream.WriteUint32L( iPluralViewId.iViewUid.iUid );
       
   326     
       
   327     if( iViewId != KNullViewId )
       
   328         {
       
   329         aStream.WriteInt32L( iCustomMessageId.iUid );
       
   330         ExternalizeTextL( aStream, iCustomMessage );
       
   331         }
       
   332     else
       
   333         {
       
   334         aStream.WriteInt32L( KErrNotFound );
       
   335         }
       
   336 
       
   337     ExternalizeTextL( aStream, iLeftSoftkey );
       
   338     ExternalizeTextL( aStream, iRightSoftkey );
       
   339     
       
   340     ExternalizeTextL( aStream, iNoteSingularLabel );
       
   341     ExternalizeTextL( aStream, iNotePluralLabel );
       
   342     ExternalizeTextL( aStream, iGroupSingularLabel );
       
   343     ExternalizeTextL( aStream, iGroupPluralLabel );
       
   344     
       
   345     aStream.WriteUint8L(iEnableObserver);
       
   346     
       
   347     ExternalizeTextL( aStream, iImageData );
       
   348     }
       
   349     
       
   350 //-----------------------------------------------------------------------------
       
   351 // CAknDynamicNotificationData::InternalizeText16L
       
   352 //-----------------------------------------------------------------------------
       
   353 //
       
   354 HBufC16* CAknDynamicNotificationData::InternalizeText16L( 
       
   355     RReadStream& aStream ) const
       
   356     {
       
   357     HBufC16* text = NULL;
       
   358     TInt length = aStream.ReadInt32L();
       
   359     if( length > 0 )
       
   360         {
       
   361         text = HBufC16::NewL( aStream, length );
       
   362         }
       
   363     return text;    
       
   364     }
       
   365 
       
   366 //-----------------------------------------------------------------------------
       
   367 // CAknDynamicNotificationData::InternalizeText8L
       
   368 //-----------------------------------------------------------------------------
       
   369 //
       
   370 HBufC8* CAknDynamicNotificationData::InternalizeText8L( 
       
   371     RReadStream& aStream ) const
       
   372     {
       
   373     HBufC8* text = NULL;
       
   374     TInt length = aStream.ReadInt32L();
       
   375     if( length > 0 )
       
   376         {
       
   377         text = HBufC8::NewL( aStream, length );
       
   378         }
       
   379     return text;    
       
   380     }
       
   381 
       
   382 //-----------------------------------------------------------------------------
       
   383 // CAknDynamicNotificationData::ExternalizeTextL
       
   384 //-----------------------------------------------------------------------------
       
   385 //
       
   386 void CAknDynamicNotificationData::ExternalizeTextL( 
       
   387     RWriteStream& aStream, 
       
   388     const TDesC16* aText ) const
       
   389     {
       
   390     TInt length = aText ? aText->Length() : 0;
       
   391     if( length > 0 )
       
   392         {
       
   393         aStream.WriteInt32L( aText->Length() );
       
   394         aStream << *aText;
       
   395         }
       
   396     else
       
   397         {
       
   398         aStream.WriteInt32L( KErrNotFound );
       
   399         }
       
   400     }
       
   401 
       
   402 //-----------------------------------------------------------------------------
       
   403 // CAknDynamicNotificationData::ExternalizeTextL
       
   404 //-----------------------------------------------------------------------------
       
   405 //
       
   406 void CAknDynamicNotificationData::ExternalizeTextL( 
       
   407     RWriteStream& aStream, 
       
   408     const TDesC8* aText ) const
       
   409     {
       
   410     TInt length = aText ? aText->Length() : 0;
       
   411     if( length > 0 )
       
   412         {
       
   413         aStream.WriteInt32L( aText->Length() );
       
   414         aStream << *aText;
       
   415         }
       
   416     else
       
   417         {
       
   418         aStream.WriteInt32L( KErrNotFound );
       
   419         }
       
   420     }
       
   421 
       
   422 //  End of File