creator/engine/src/creator_note.cpp
branchRCL_3
changeset 21 b3cee849fa46
equal deleted inserted replaced
20:48060abbbeaf 21:b3cee849fa46
       
     1 /*
       
     2 * Copyright (c) 2010 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: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "engine.h"
       
    20 #include "enginewrapper.h"
       
    21 
       
    22 #include "creator_note.h" 
       
    23 #include "creator_traces.h"
       
    24 
       
    25 
       
    26 const TInt KCreatorDiskSpaceNeededForSingleDeletion( 8192 );
       
    27 _LIT( KCreatorNotepadFile, "c:Notepad.dat" );
       
    28 
       
    29 // @see \s60\app\organizer\notepad\notepad1\LibSrc\NpdCoreModel.cpp KSecureUid.Name()
       
    30 _LIT( KCreatorNotepadFormat, "SECURE[101F8878]" ); 
       
    31 _LIT( KCreatorNotepadDeleteAllSQL, "DELETE FROM Table1");
       
    32 
       
    33 //----------------------------------------------------------------------------
       
    34 
       
    35 CNotepadParameters::CNotepadParameters()
       
    36     {
       
    37     LOGSTRING("Creator: CNotepadParameters::CNotepadParameters");
       
    38 
       
    39     iNoteText = HBufC::New(KNotepadFieldLength);
       
    40     }
       
    41 
       
    42 CNotepadParameters::~CNotepadParameters()
       
    43     {
       
    44     LOGSTRING("Creator: CNotepadParameters::~CNotepadParameters");
       
    45 
       
    46     delete iNoteText;
       
    47     }
       
    48 
       
    49 //----------------------------------------------------------------------------
       
    50 
       
    51 CCreatorNotepad* CCreatorNotepad::NewL(CCreatorEngine* aEngine)
       
    52     {
       
    53     CCreatorNotepad* self = CCreatorNotepad::NewLC(aEngine);
       
    54     CleanupStack::Pop(self);
       
    55     return self;
       
    56     }
       
    57 
       
    58 CCreatorNotepad* CCreatorNotepad::NewLC(CCreatorEngine* aEngine)
       
    59     {
       
    60     CCreatorNotepad* self = new (ELeave) CCreatorNotepad;
       
    61     CleanupStack::PushL(self);
       
    62     self->ConstructL(aEngine);
       
    63     return self;
       
    64     }
       
    65 
       
    66 CCreatorNotepad::CCreatorNotepad() : iFs ( CEikonEnv::Static()->FsSession() )
       
    67     {
       
    68     }
       
    69 
       
    70 void CCreatorNotepad::ConstructL(CCreatorEngine* aEngine)
       
    71     {
       
    72     LOGSTRING("Creator: CCreatorNotepad::ConstructL");
       
    73 
       
    74     iEngine = aEngine;
       
    75     iNotepadWrapper = CCreatorNotepadWrapper::NewL();
       
    76     }
       
    77 
       
    78 CCreatorNotepad::~CCreatorNotepad()
       
    79     {
       
    80     LOGSTRING("Creator: CCreatorNotepad::~CCreatorNotepad");
       
    81     
       
    82     if (iParameters)
       
    83         {
       
    84         delete iParameters;
       
    85         iParameters;
       
    86         }
       
    87     
       
    88     if (iNotepadWrapper)
       
    89     	{
       
    90 		delete iNotepadWrapper;
       
    91     	}
       
    92     }
       
    93 
       
    94 //----------------------------------------------------------------------------
       
    95 
       
    96 TBool CCreatorNotepad::AskDataFromUserL(TInt aCommand)
       
    97     {
       
    98     LOGSTRING("Creator: CCreatorNotepad::AskDataFromUserL");
       
    99 
       
   100     CCreatorModuleBase::AskDataFromUserL(aCommand);
       
   101         
       
   102     if ( aCommand == ECmdDeleteNotes )
       
   103         {
       
   104         return iEngine->GetEngineWrapper()->YesNoQueryDialog( _L("Delete all Notes?"), this, ECreatorModuleDelete );
       
   105         }
       
   106     
       
   107     // By Creator not supported because 
       
   108     // note id is not available via Notepad API
       
   109 
       
   110     return iEngine->GetEngineWrapper()->EntriesQueryDialog( &iEntriesToBeCreated, _L("How many entries to create?"), EFalse,  this, ECreatorModuleStart );
       
   111     }
       
   112 
       
   113 
       
   114 //----------------------------------------------------------------------------
       
   115 
       
   116 TInt CCreatorNotepad::CreateNoteEntryL(CNotepadParameters *aParameters)
       
   117     {
       
   118     LOGSTRING("Creator: CCreatorNotepad::CreateNoteEntryL");
       
   119 
       
   120     // clear any existing parameter definations
       
   121     delete iParameters;
       
   122     iParameters = NULL;
       
   123     
       
   124     CNotepadParameters* parameters = aParameters;
       
   125     
       
   126     // random data needed if no predefined data available
       
   127     if (!parameters)
       
   128         {
       
   129         iParameters = new(ELeave) CNotepadParameters;
       
   130         parameters = iParameters;
       
   131         parameters->iNoteText->Des() = iEngine->RandomString(CCreatorEngine::EMessageText);
       
   132         }
       
   133     
       
   134     TInt err = KErrNone;
       
   135 
       
   136     iNotepadWrapper->CreateNoteL(parameters->iNoteText->Des());
       
   137     
       
   138     return err;
       
   139     }
       
   140 
       
   141 //----------------------------------------------------------------------------
       
   142 void CCreatorNotepad::DeleteAllL()
       
   143     {
       
   144     LOGSTRING("Creator: CCreatorNotepad::DeleteAllL");
       
   145     iNotepadWrapper->DeleteAllL();
       
   146     }
       
   147 
       
   148 //----------------------------------------------------------------------------
       
   149 void CCreatorNotepad::DeleteAllCreatedByCreatorL()
       
   150     {
       
   151     LOGSTRING("Creator: CCreatorNotepad::DeleteAllCreatedByCreatorL");
       
   152     // Not supported because note id is not available via Notepad API
       
   153     User::Leave( KErrNotSupported );
       
   154     }