messagingapp/msgnotifications/msgerrorwatcher/src/msgcenrepobserver.cpp
author hgs
Tue, 31 Aug 2010 18:53:38 +0530
changeset 56 f42d9a78f435
permissions -rw-r--r--
201033_02
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
56
f42d9a78f435 201033_02
hgs
parents:
diff changeset
     1
/*
f42d9a78f435 201033_02
hgs
parents:
diff changeset
     2
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
f42d9a78f435 201033_02
hgs
parents:
diff changeset
     3
* All rights reserved.
f42d9a78f435 201033_02
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
f42d9a78f435 201033_02
hgs
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
f42d9a78f435 201033_02
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
f42d9a78f435 201033_02
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
f42d9a78f435 201033_02
hgs
parents:
diff changeset
     8
*
f42d9a78f435 201033_02
hgs
parents:
diff changeset
     9
* Initial Contributors:
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    11
*
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    12
* Contributors:
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    13
*
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    14
* Description:  
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    15
*          CMsgCenRepObserver implementation file
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    16
*
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    17
*/
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    18
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    19
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    20
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    21
// INCLUDE FILES
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    22
//#include    <es_sock.h>
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    23
#include <centralrepository.h>
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    24
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    25
#include "msgerrorwatcher_p.h"
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    26
#include "msgcenrepobserver.h"
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    27
 
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    28
#include "MmsEngineInternalCRKeys.h"
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    29
#include "debugtraces.h"
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    30
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    31
// ================= MEMBER FUNCTIONS =======================
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    32
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    33
// ---------------------------------------------------------
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    34
// C++ constructor
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    35
// ---------------------------------------------------------
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    36
//
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    37
CMsgCenRepObserver::CMsgCenRepObserver(CMsgErrorWatcherPrivate& aWatcher)
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    38
    :CActive ( EPriorityStandard),
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    39
    iWatcher(aWatcher),
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    40
    iRepositoryUid( KCRUidMmsEngine ),
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    41
    iKey( KMmsAccesspointArrayBase/*KMmsEngineAccessPointCount*/ )
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    42
    {
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    43
    QDEBUG_WRITE("CMsgCenRepObserver:CMsgCenRepObserver : Enter");
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    44
    QDEBUG_WRITE("CMsgCenRepObserver:CMsgCenRepObserver : Exit");
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    45
    }
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    46
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    47
// ---------------------------------------------------------
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    48
// ConstructL
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    49
// ---------------------------------------------------------
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    50
//
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    51
void CMsgCenRepObserver::ConstructL()
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    52
    {
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    53
    QDEBUG_WRITE("CMsgCenRepObserver:ConstructL : Enter");
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    54
    CActiveScheduler::Add( this );
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    55
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    56
    // Connect CenRep
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    57
    TRAPD( err, iRepository = CRepository::NewL( iRepositoryUid ) );
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    58
    if( err != KErrNone )
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    59
        {
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    60
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    61
        QDEBUG_WRITE( "Error in connecting to CenRep!" );
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    62
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    63
        return;
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    64
        }
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    65
    QDEBUG_WRITE("CMsgCenRepObserver:ConstructL : Exit");  
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    66
    }
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    67
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    68
// ---------------------------------------------------------
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    69
// Symbian two-phased constructor
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    70
// ---------------------------------------------------------
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    71
//
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    72
CMsgCenRepObserver* CMsgCenRepObserver::NewL( CMsgErrorWatcherPrivate& aWatcher )
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    73
    {
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    74
    QDEBUG_WRITE("CMsgCenRepObserver:NewL : Enter");
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    75
    CMsgCenRepObserver* self = new ( ELeave ) CMsgCenRepObserver( aWatcher );
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    76
    CleanupStack::PushL( self );
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    77
    self->ConstructL();
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    78
    CleanupStack::Pop( self );
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    79
    QDEBUG_WRITE("CMsgCenRepObserver:NewL : Exit");
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    80
    return self;
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    81
    }
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    82
    
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    83
// ---------------------------------------------------------
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    84
// Destructor
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    85
// ---------------------------------------------------------
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    86
//
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    87
CMsgCenRepObserver::~CMsgCenRepObserver()
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    88
    {
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    89
    QDEBUG_WRITE("CMsgCenRepObserver:~CMsgCenRepObserver : Enter");
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    90
    Cancel();
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    91
    if( iRepository )
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    92
        {
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    93
        delete iRepository;
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    94
        }
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    95
    QDEBUG_WRITE("CMsgCenRepObserver:~CMsgCenRepObserver : Exit");
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    96
    }
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    97
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    98
// ---------------------------------------------------------
f42d9a78f435 201033_02
hgs
parents:
diff changeset
    99
// SubscribeNotification
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   100
// ---------------------------------------------------------
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   101
//
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   102
void CMsgCenRepObserver::SubscribeNotification( )
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   103
    {
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   104
    QDEBUG_WRITE("CMsgCenRepObserver:SubscribeNotification : Enter");
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   105
    // Subscribe
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   106
    iRepository->NotifyRequest( iKey, iStatus );
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   107
    SetActive();
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   108
    QDEBUG_WRITE("CMsgCenRepObserver:SubscribeNotification : Exit");
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   109
    }
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   110
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   111
// ---------------------------------------------------------
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   112
// RunL
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   113
// ---------------------------------------------------------
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   114
//
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   115
void CMsgCenRepObserver::RunL()
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   116
    {
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   117
    QDEBUG_WRITE("CMsgCenRepObserver:RunL : Enter");
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   118
    iWatcher.HandleCenRepNotificationL();    
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   119
    QDEBUG_WRITE("CMsgCenRepObserver:RunL : Exit");
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   120
    }
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   121
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   122
// ---------------------------------------------------------
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   123
// RunError
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   124
// ---------------------------------------------------------
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   125
//
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   126
TInt CMsgCenRepObserver::RunError( TInt /*aError*/ )
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   127
    {
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   128
    QDEBUG_WRITE("CMsgCenRepObserver:RunError : Enter");
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   129
    QDEBUG_WRITE("CMsgCenRepObserver:RunError : Exit");
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   130
	return KErrNone;	
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   131
    }
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   132
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   133
// ---------------------------------------------------------
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   134
// DoCancel
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   135
// ---------------------------------------------------------
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   136
//
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   137
void CMsgCenRepObserver::DoCancel()
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   138
    {
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   139
    QDEBUG_WRITE("CMsgCenRepObserver:DoCancel : Enter");
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   140
    iRepository->NotifyCancel( iKey );
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   141
    QDEBUG_WRITE("CMsgCenRepObserver:DoCancel : Exit");
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   142
    }
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   143
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   144
// ================= OTHER EXPORTED FUNCTIONS ==============
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   145
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   146
//  End of File  
f42d9a78f435 201033_02
hgs
parents:
diff changeset
   147