javamanager/javacaptain/extensionplugins/mmc/src/mmceventprovider.cpp
branchRCL_3
changeset 14 04becd199f91
equal deleted inserted replaced
13:f5050f1da672 14:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 2008 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:  MmcEventProvider
       
    15 *
       
    16 */
       
    17 
       
    18 #include "logger.h"
       
    19 
       
    20 #include "coreinterface.h"
       
    21 //#include "eventproviderinterface.h"
       
    22 #include "eventconsumerinterface.h"
       
    23 
       
    24 #include "mmceventprovider.h"
       
    25 #include "mmceventprovidermessages.h"
       
    26 
       
    27 namespace java
       
    28 {
       
    29 namespace captain
       
    30 {
       
    31 
       
    32 MmcEventProvider::MmcEventProvider()
       
    33         :mCore(0), mDOServer(0)
       
    34 {
       
    35     JELOG2(EJavaCaptain);
       
    36 }
       
    37 
       
    38 MmcEventProvider::~MmcEventProvider()
       
    39 {
       
    40     JELOG2(EJavaCaptain);
       
    41 }
       
    42 
       
    43 void MmcEventProvider::startPlugin(CoreInterface* aCore)
       
    44 {
       
    45     JELOG2(EJavaCaptain);
       
    46     mCore = aCore;
       
    47 
       
    48     mDOServer = DriveUtilities::getDriveObserverServer();
       
    49     if (mDOServer)
       
    50     {
       
    51         mDOServer->registerListener(this);
       
    52         mDOServer->startServer(mCore->getComms());
       
    53     }
       
    54 }
       
    55 
       
    56 void MmcEventProvider::stopPlugin()
       
    57 {
       
    58     JELOG2(EJavaCaptain);
       
    59     if (mDOServer)
       
    60     {
       
    61         mDOServer->stopServer();
       
    62         delete mDOServer;
       
    63         mDOServer = 0;
       
    64     }
       
    65     mCore = 0;
       
    66 }
       
    67 
       
    68 void MmcEventProvider::driveChanged(const int& aOperation, const driveInfo& aDriveInfo)
       
    69 {
       
    70     JELOG2(EJavaCaptain);
       
    71     switch (aOperation)
       
    72     {
       
    73     case DriveListenerInterface::REMOVABLE_MEDIA_INSERTED_C:
       
    74         LOG1(EJavaCaptain, EInfo, "driveChanged() operation=REMOVABLE_MEDIA_INSERTED_C drive.id==%u", aDriveInfo.iId);
       
    75         break;
       
    76 
       
    77     case DriveListenerInterface::REMOVABLE_MEDIA_REMOVED_C:
       
    78         LOG1(EJavaCaptain, EInfo, "driveChanged() operation=REMOVABLE_MEDIA_REMOVED_C drive.id==%u", aDriveInfo.iId);
       
    79         break;
       
    80 
       
    81     default:
       
    82         LOG1(EJavaCaptain, EInfo, "driveChanged() operation=UNKNOWN drive.id==%u", aDriveInfo.iId);
       
    83         break;
       
    84     }
       
    85 
       
    86     CommsMessage msg;
       
    87     setMmcChangedMessageParams(msg, aOperation, aDriveInfo);
       
    88     mCore->getEventDispatcher()->event(MMC_EVENT_PROVIDER, msg);
       
    89 }
       
    90 
       
    91 } // namespace captain
       
    92 } // namespace java
       
    93