javamanager/javacaptain/extensionplugins/mmc/inc/mmceventprovidermessages.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:  MmcEventProviderMessages
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef MMCEVENTPROVIDERMESSAGES_H
       
    19 #define MMCEVENTPROVIDERMESSAGES_H
       
    20 
       
    21 #include "logger.h"
       
    22 #include "commsmessage.h"
       
    23 #include "driveutilities.h"
       
    24 
       
    25 namespace java
       
    26 {
       
    27 namespace captain
       
    28 {
       
    29 
       
    30 using namespace java::util;
       
    31 using namespace java::comms;
       
    32 using namespace java::fileutils;
       
    33 
       
    34 const int MMC_EVENT_MESSAGE_ID_CHANGED_C = 20;
       
    35 
       
    36 const char MMC_EVENT_PROVIDER[] = "mmc";
       
    37 
       
    38 inline void getMmcChangedMessageParams(CommsMessage& aMessage,
       
    39                                        int& aOperation, driveInfo& aDriveInfo)
       
    40 {
       
    41     if (aMessage.getMessageId() == MMC_EVENT_MESSAGE_ID_CHANGED_C)
       
    42     {
       
    43         aMessage >> aOperation;
       
    44         aMessage >> aDriveInfo.iRootPath;
       
    45 
       
    46         int tempInt = 0;
       
    47         aMessage >> tempInt;
       
    48         aDriveInfo.iIsPresent = (tempInt == 1 ? true : false);
       
    49 
       
    50         aMessage >> tempInt;
       
    51         aDriveInfo.iIsRemovable = (tempInt == 1 ? true : false);
       
    52 
       
    53         aMessage >> tempInt;
       
    54         aDriveInfo.iIsLocal = (tempInt == 1 ? true : false);
       
    55 
       
    56         aMessage >> tempInt;
       
    57         aDriveInfo.iId = tempInt;
       
    58     }
       
    59     else
       
    60     {
       
    61         ELOG2(EJavaCaptain, "wrong MessageId!: %d should be %d",
       
    62               aMessage.getMessageId(), MMC_EVENT_MESSAGE_ID_CHANGED_C);
       
    63     }
       
    64 }
       
    65 
       
    66 inline void setMmcChangedMessageParams(CommsMessage& aMessage,
       
    67                                        const int& aOperation, const driveInfo& aDriveInfo)
       
    68 {
       
    69     aMessage.setMessageId(MMC_EVENT_MESSAGE_ID_CHANGED_C);
       
    70     aMessage << aOperation;
       
    71     aMessage << aDriveInfo.iRootPath;
       
    72     aMessage << (aDriveInfo.iIsPresent ? 1 : 0);
       
    73     aMessage << (aDriveInfo.iIsRemovable ? 1 : 0);
       
    74     aMessage << (aDriveInfo.iIsLocal ? 1 : 0);
       
    75     aMessage << (int) aDriveInfo.iId;
       
    76 }
       
    77 
       
    78 
       
    79 
       
    80 } // namespace captain
       
    81 } // namespace java
       
    82 
       
    83 #endif // MMCEVENTPROVIDERMESSAGES_H