creator/engine/src/creator_note.cpp
changeset 31 e7a04a6385be
parent 30 d8e625c87f33
child 48 da3ec8478e66
equal deleted inserted replaced
30:d8e625c87f33 31:e7a04a6385be
    19 #include "engine.h"
    19 #include "engine.h"
    20 #include "enginewrapper.h"
    20 #include "enginewrapper.h"
    21 
    21 
    22 #include "creator_note.h" 
    22 #include "creator_note.h" 
    23 #include "creator_traces.h"
    23 #include "creator_traces.h"
       
    24 
    24 
    25 
    25 const TInt KCreatorDiskSpaceNeededForSingleDeletion( 8192 );
    26 const TInt KCreatorDiskSpaceNeededForSingleDeletion( 8192 );
    26 _LIT( KCreatorNotepadFile, "c:Notepad.dat" );
    27 _LIT( KCreatorNotepadFile, "c:Notepad.dat" );
    27 
    28 
    28 // @see \s60\app\organizer\notepad\notepad1\LibSrc\NpdCoreModel.cpp KSecureUid.Name()
    29 // @see \s60\app\organizer\notepad\notepad1\LibSrc\NpdCoreModel.cpp KSecureUid.Name()
    69 void CCreatorNotepad::ConstructL(CCreatorEngine* aEngine)
    70 void CCreatorNotepad::ConstructL(CCreatorEngine* aEngine)
    70     {
    71     {
    71     LOGSTRING("Creator: CCreatorNotepad::ConstructL");
    72     LOGSTRING("Creator: CCreatorNotepad::ConstructL");
    72 
    73 
    73     iEngine = aEngine;
    74     iEngine = aEngine;
    74     iAgendaUtil = new AgendaUtil();
    75     iNotepadWrapper = CCreatorNotepadWrapper::NewL();
    75     //iNotepadApi = new NotesEditor(iAgendaUtil);
       
    76     //iNotepadApi = CNotepadApi::NewL();
       
    77     }
    76     }
    78 
    77 
    79 CCreatorNotepad::~CCreatorNotepad()
    78 CCreatorNotepad::~CCreatorNotepad()
    80     {
    79     {
    81     LOGSTRING("Creator: CCreatorNotepad::~CCreatorNotepad");
    80     LOGSTRING("Creator: CCreatorNotepad::~CCreatorNotepad");
    82  
       
    83  /*   
       
    84     if(iNotepadApi)
       
    85         {
       
    86         delete iNotepadApi;
       
    87         iNotepadApi = NULL;
       
    88         }
       
    89 */    
       
    90     if(iAgendaUtil)
       
    91         {
       
    92         delete iAgendaUtil;
       
    93         iAgendaUtil = NULL;
       
    94         }
       
    95     
    81     
    96     if (iParameters)
    82     if (iParameters)
    97         {
    83         {
    98         delete iParameters;
    84         delete iParameters;
    99         iParameters = NULL;
    85         iParameters;
   100         }
    86         }
       
    87     
       
    88     if (iNotepadWrapper)
       
    89     	{
       
    90 		delete iNotepadWrapper;
       
    91     	}
   101     }
    92     }
   102 
    93 
   103 //----------------------------------------------------------------------------
    94 //----------------------------------------------------------------------------
   104 
    95 
   105 TBool CCreatorNotepad::AskDataFromUserL(TInt aCommand)
    96 TBool CCreatorNotepad::AskDataFromUserL(TInt aCommand)
   140         parameters->iNoteText->Des() = iEngine->RandomString(CCreatorEngine::EMessageText);
   131         parameters->iNoteText->Des() = iEngine->RandomString(CCreatorEngine::EMessageText);
   141         }
   132         }
   142     
   133     
   143     TInt err = KErrNone;
   134     TInt err = KErrNone;
   144 
   135 
   145     //iNotepadApi->AddContentL(parameters->iNoteText->Des());
   136     iNotepadWrapper->CreateNoteL(parameters->iNoteText->Des());
   146     QString textNote = QString::fromUtf16(parameters->iNoteText->Ptr(),parameters->iNoteText->Length());
       
   147     iNotepadApi->edit(textNote, iAgendaUtil);
       
   148     iNotepadApi->close(NotesEditorInterface::CloseWithSave, iAgendaUtil);
       
   149     
   137     
   150     return err;
   138     return err;
   151     }
   139     }
   152 
   140 
   153 //----------------------------------------------------------------------------
   141 //----------------------------------------------------------------------------
   154 void CCreatorNotepad::DeleteAllL()
   142 void CCreatorNotepad::DeleteAllL()
   155     {
   143     {
   156     LOGSTRING("Creator: CCreatorNotepad::DeleteAllL");
   144     LOGSTRING("Creator: CCreatorNotepad::DeleteAllL");
   157     QList<AgendaEntry> ael;
   145     iNotepadWrapper->DeleteAllL();
   158     AgendaUtil::FilterFlags filter = AgendaUtil::FilterFlags(AgendaUtil::IncludeNotes);
       
   159 
       
   160     ael = iAgendaUtil->fetchAllEntries(filter);
       
   161     for(int i=0 ; i<ael.count() ; i++)
       
   162     	{
       
   163         iAgendaUtil->deleteEntry(ael[i].id());
       
   164     	}
       
   165     
       
   166     // Open Notes db
       
   167  /*   RDbs dbs;
       
   168     User::LeaveIfError( dbs.Connect() );
       
   169     CleanupClosePushL( dbs );
       
   170     RDbNamedDatabase db;
       
   171     TInt openErr( db.Open( dbs, KCreatorNotepadFile, KCreatorNotepadFormat ) );
       
   172     CleanupClosePushL( db );
       
   173     
       
   174     if ( openErr && openErr !=  KErrNotFound )
       
   175         {
       
   176         User::Leave( openErr );
       
   177         }
       
   178     
       
   179     // do not leave if openErr == KErrNotFound, 
       
   180     // it means there is no notes (file) created -> no need to delete
       
   181     
       
   182     if ( openErr !=  KErrNotFound )
       
   183         {
       
   184         TInt retval = iFs.ReserveDriveSpace( KDefaultDrive, KCreatorDiskSpaceNeededForSingleDeletion );
       
   185         if ( retval == KErrNone )
       
   186             {
       
   187             retval = iFs.GetReserveAccess( KDefaultDrive );
       
   188             }
       
   189 
       
   190         // Delete all Notes. Ignore rowCount returnvalue
       
   191         db.Execute( KCreatorNotepadDeleteAllSQL );            
       
   192         
       
   193         User::LeaveIfError( db.Compact() );
       
   194         
       
   195         if ( retval == KErrNone )
       
   196             {
       
   197             retval = iFs.ReleaseReserveAccess( KDefaultDrive );
       
   198             }
       
   199         }
       
   200     
       
   201     CleanupStack::PopAndDestroy( &db );
       
   202     CleanupStack::PopAndDestroy( &dbs );*/
       
   203     }
   146     }
   204 
   147 
   205 //----------------------------------------------------------------------------
   148 //----------------------------------------------------------------------------
   206 void CCreatorNotepad::DeleteAllCreatedByCreatorL()
   149 void CCreatorNotepad::DeleteAllCreatedByCreatorL()
   207     {
   150     {