examples/SFExamples/PIM/AgendaPeople/src/AgendaPeopleAppUi.cpp

00001 // 
00002 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
00003 // All rights reserved.
00004 // This component and the accompanying materials are made available
00005 // under the terms of the License "Eclipse Public License v1.0"
00006 // which accompanies this distribution, and is available
00007 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
00008 // 
00009 // Initial Contributors:
00010 // Nokia Corporation - initial contribution.
00011 // 
00012 // Contributors:
00013 // 
00014 // Description:
00015 // 
00016 
00017 #include <eikapp.h>
00018 #include <AgendaPeople.rsg>
00019 
00020 #include "AgendaPeopleAppUi.h"
00021 #include "AgendaPeopleMainView.h"
00022 #include "CalRead.h"
00023 #include "AgendaPeople.hrh"
00024 
00025 void CAgendaPeopleAppUi::ConstructL()
00026         {
00027         BaseConstructL(EAknEnableSkin);
00028         iMainView = CAgendaPeopleMainView::NewL(ClientRect());
00029 
00030         iCalendarReader = CCalRead::NewL();
00031         }
00032         
00033 CAgendaPeopleAppUi::~CAgendaPeopleAppUi()
00034     {
00035     delete iCalendarReader;
00036 #ifdef __SERIES60_3X__
00037         delete iMainView;
00038 #endif
00039     }
00040 
00041 void CAgendaPeopleAppUi::HandleCommandL(TInt aCommand)
00042         {
00043         switch ( aCommand )
00044                 {
00045 #ifdef __SERIES60_3X__
00046                 case EAknSoftkeyExit:
00047 #endif
00048                 case EEikCmdExit:
00049                         {
00050                         User::Exit(0);
00051                         break;
00052                         }
00053                 case EAgendaPeople:
00054                         {
00055                         CCalEntryView& calView = iCalendarReader->CalView();
00056                         // Let's find a recently modified celendar entry.
00057                         // with any luck, it will be one created by
00058                         // \PIM\PopulateAgenda
00059                         RArray<TCalLocalUid> calIds;
00060                         CleanupClosePushL(calIds);
00061                         // start with entries modified in the last day. keep going
00062                         // back in time one day at a time until we find at least 1 entry
00063                         TTime backThen;
00064                         TTimeIntervalDays oneDay(1);
00065                         backThen.UniversalTime();
00066                         backThen -= oneDay;
00067                         TCalTime daysBack;
00068                         // worst case scenario, we only go back 1 month.
00069                         // just do something once in a while, will you please ?
00070                         TTime lastMonth;
00071                         lastMonth.UniversalTime();
00072                         lastMonth -= TTimeIntervalMonths(1);
00073                         while (calIds.Count() < 1 && backThen > lastMonth)
00074                                 {
00075                                 daysBack.SetTimeUtcL(backThen);
00076                                 calView.GetIdsModifiedSinceDateL(daysBack, calIds);
00077                                 backThen -= oneDay;
00078                                 }
00079                         
00080                         if (calIds.Count() > 0)
00081                                 {
00082                                 CDesCArray* result = NULL;
00083                                 TRAPD(error, result = iCalendarReader->GetAttendeesL(calIds[0]));
00084                                 // report error on the Label control
00085                                 if (KErrNone == error)
00086                                         {
00087                                         if (NULL != result && result->MdcaCount() > 0)
00088                                                 {
00089                                                 TBuf<256> resultBuf;
00090                                                 _LIT(KFound, "Found People: ");
00091                                                 resultBuf.Append(KFound());
00092                                                 // display up to 3 attendees.
00093                                                 for (TInt ii = 0 ; ii < result->MdcaCount() && ii < 3 ; ++ii)
00094                                                         {
00095                                                         resultBuf.Append(result->MdcaPoint(ii));
00096                                                         }
00097                                                 iMainView->SetTextL(resultBuf);
00098                                                 }
00099                                         else
00100                                                 {
00101                                                 _LIT(KNoOne, "No Attendees");
00102                                                 iMainView->SetTextL(KNoOne());
00103                                                 }
00104                                         }
00105                                 else
00106                                         {
00107                                         _LIT(KErrorMsg, "Symbian Error Code = %D");
00108                                         TBuf<32> errorBuf;
00109                                         errorBuf.Format(KErrorMsg(), error);
00110                                         iMainView->SetTextL(errorBuf);
00111                                         }
00112                                 }
00113                         else
00114                                 {
00115                                 _LIT(KNotFound, "Nothing done for a month");
00116                                 iMainView->SetTextL(KNotFound());
00117                                 }
00118                         CleanupStack::PopAndDestroy(&calIds);
00119                         break;
00120                         }
00121                 default:
00122                         break;
00123                 }
00124         }
00125 
00126         
00127 #ifdef __SERIES60_3X__
00128 
00129 void CAgendaPeopleAppUi::HandleResourceChangeL(TInt aType)
00130         {
00131         CAknAppUi::HandleResourceChangeL(aType);
00132         iMainView->SetRect(ClientRect());
00133         }
00134 
00135 #endif
00136         
00137 // End of File

Generated by  doxygen 1.6.2