Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Archived:Implementing agenda observers using Symbian C++

From Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.



Article Metadata
Compatibility
Platform(s): S60 2nd Edition
S60 2nd Edition (initial release)
Article
Created: User:Technical writer 2 (30 Nov 2006)
Last edited: hamishwillee (14 Jun 2012)

Overview

Implementing agenda observers

Description

3rd-party applications may want to be notified whenever agenda entries are added, deleted, or modified by other applications. They may also want to know which event has occurred for which entry.
The solution below describes how to write an agenda observer DLL in S60 2nd Edition. For S60 3rd Edition, see the documentation on the Calendar Interim API.

Solution

1)  Create a separate DLL for an Agenda observer. For example a CAgendaObs class derived from CAgnObserver with CAgendaObs::NewL() function exported as the first ordinal.
Below are minimal example implementations for virtual methods from CAgnObserver:
CAgnObserver* CAgendaObs::CloneL()
    {
    if(!iClone)     // initial value (TBool) EFalse
        {
        // Log: Creating clone
        CAgendaObs* result = NewL();
        result->iClone = ETrue;
        return result;
        }
    }
void CAgendaObs::StartObserving()
    {
    if(iClone)
        {
        //Log: Start observing
        }
    }
void CAgendaObs::StopObserving()
    {
    if(iClone)
        {
        // Log: Stop observing
        }
    }
void CAgendaObs::Send(TInt aFunction, CAgnEntry *aEntry)
    {
    if(iClone)
        {
        switch(aFunction)
            {
            case ENotifyAddEntry:
                // Entry added
                break;
            case ENotifyDeleteEntry:
                // Entry deleted
                break;
            case ENotifyUpdateEntry:
                // Entry updated
                break;
            case ENotifyAddTodoList:
                // ToDo entry added
                break;
            case ENotifyDeleteTodoList:
                // ToDo entry deleted
                break;
            case ENotifyUpdateTodoList:
                // ToDo entry updated
                break;
            default:
                // Unexpected command
                break;
            }
       }
    }
void CAgendaObs::Send(TInt aFunction, CAgnTodoList *aTodoList)
    {
    if(iClone)
        {
        switch(aFunction)
            {
            case ENotifyAddEntry:
                // Entry added
                break;
            case ENotifyDeleteEntry:
                // Entry deleted
                break;
            case ENotifyUpdateEntry:
                // Entry updated
                break;
            case ENotifyAddTodoList:
                // ToDo entry added
                break;
            case ENotifyDeleteTodoList:
                // ToDo entry deleted
                break;
            case ENotifyUpdateTodoList:
                // ToDo entry updated
                break;
            default:
                // Unexpected command
                break;
            }
        }
    }
void CAgendaObs::ExternalizeL(RWriteStream &aStream) const
    {
    //write your code here
    if(iClone)
        {
        // Log: ExternalizeL called
        }
    //closing
    CAgnObserver::WriteEndMarkerL(aStream);
    }
void CAgendaObs::InternalizeL(RReadStream &aStream)
    {
    //write your code here
    if(iClone)
        {
        // Log: InternalizeL called
        }
    //closing
    CAgnObserver::ReadEndMarkerL(aStream);
    }
// The NewL of the DLL, to be exported
EXPORT_C CAgendaObs* CAgendaObs::NewL()
    {
    CAgendaObs* self = new (ELeave) CAgendaObs();
    CleanupStack::PushL(self);
    self->ConstructL();
    CleanupStack::Pop(self);
    return self;
    }
2) In another application register the observer using the following code:
#ifdef __WINS__
_LIT(KObserverFile,"agendaobs.dll");
#else
_LIT(KObserverFile,"c:\\system\\libs\\agendaobs.dll");
#endif
_LIT(KAgendaFile,"c:\\system\\data\\calendar");
// In ConstructL:
    RAgendaServ *iServer = RAgendaServ::NewL();
    iServer->Connect();
    CAgendaObs* iObserver = CAgendaObs::NewL();
    CAgnEntryModel *iModel = CAgnEntryModel::NewL(this);
    iModel->SetServer(iServer);
    iModel->OpenL(KAgendaFile);
// Call this method to register the observer DLL
void CSomeAppUi::Register()
    {
    if(iModel)
        {
        iModel->RegisterObserverL(TFileName(KObserverFile), iObserver);
        }
    }
// Before exiting, unregister the DLL
void CAgendaAppAppUi::Unregister()
{
    if(iModel)
        {
        iModel->UnregisterObserverL(TFileName(KObserverFile));
        }
}
Note: The observer DLL should use 0x10000135 as UID2 in MMP file.

This page was last modified on 14 June 2012, at 06:19.
53 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×