javacommons/fileutils/src/driveobserverserver.h
branchRCL_3
changeset 19 04becd199f91
equal deleted inserted replaced
16:f5050f1da672 19: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:  DriveObserverServer
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef DRIVEOBSERVERSERVER_H
       
    19 #define DRIVEOBSERVERSERVER_H
       
    20 
       
    21 #include <list>
       
    22 
       
    23 #include "javaosheaders.h"
       
    24 #include "commslistener.h"
       
    25 
       
    26 #include "driveutilities.h"
       
    27 
       
    28 namespace java
       
    29 {
       
    30 namespace comms
       
    31 {
       
    32 class CommsEndpoint;
       
    33 }
       
    34 namespace fileutils
       
    35 {
       
    36 
       
    37 class DriveChangedEventGenerator;
       
    38 
       
    39 OS_NONSHARABLE_CLASS(DriveObserverServer) : public DriveObserverServerInterface,
       
    40         public DriveListenerInterface,
       
    41         public java::comms::CommsListener
       
    42 {
       
    43 public:
       
    44     DriveObserverServer();
       
    45     virtual ~DriveObserverServer();
       
    46 
       
    47     // DriveObserverServerInterface
       
    48     virtual void startServer(java::comms::CommsEndpoint*);
       
    49     virtual void stopServer();
       
    50 
       
    51     virtual void registerListener(DriveListenerInterface* aListener);
       
    52     virtual void unregisterListener(DriveListenerInterface* aListener);
       
    53 
       
    54     // DriveListenerInterface
       
    55     virtual void driveChanged(const int& aOperation, const driveInfo& aDriveInfo);
       
    56 
       
    57     // CommsListener
       
    58     virtual void processMessage(java::comms::CommsMessage& aMessage);
       
    59 
       
    60 private:
       
    61     void registerSubscriber(java::comms::CommsMessage& aMessage);
       
    62     void unregisterSubscriber(java::comms::CommsMessage& aMessage);
       
    63 
       
    64     void getDrives(java::comms::CommsMessage& aMessage);
       
    65 
       
    66     void enableEvents();
       
    67     void disableEventsIfNotNeeded();
       
    68 
       
    69     typedef std::list<DriveListenerInterface*> listeners;
       
    70     typedef std::list<DriveListenerInterface*>::iterator listenersIter;
       
    71     listeners iListeners;
       
    72 
       
    73     OS_NONSHARABLE_STRUCT(subscriberData)
       
    74     {
       
    75         subscriberData(int aModuleId, int aSubscriberAddress)
       
    76                 :iModuleId(aModuleId), iSubscriberAddress(aSubscriberAddress)
       
    77         {}
       
    78 
       
    79         int iModuleId;
       
    80         int iSubscriberAddress;
       
    81     };
       
    82 
       
    83     typedef std::list<subscriberData*> subscribers;
       
    84     typedef std::list<subscriberData*>::iterator subscribersIter;
       
    85     subscribers iSubscribers;
       
    86 
       
    87     java::comms::CommsEndpoint*  iComms;
       
    88 
       
    89     DriveChangedEventGenerator*  iEventGenerator;
       
    90 };
       
    91 
       
    92 } // end of namespace fileutils
       
    93 } // end of namespace java
       
    94 
       
    95 #endif // DRIVEOBSERVERSERVER_H