javamanager/javacaptain/inc/amcmessages.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:  amcmessages
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef AMCMESSAGES_H
       
    19 #define AMCMESSAGES_H
       
    20 
       
    21 #include "logger.h"
       
    22 #include "comms.h"
       
    23 #include "commsmessage.h"
       
    24 
       
    25 using namespace java::comms;
       
    26 
       
    27 namespace java
       
    28 {
       
    29 namespace captain
       
    30 {
       
    31 // Message IDs of all installer extension services
       
    32 const int AMC_MSG_ID_REQUEST    = JAVACAPTAIN_MESSAGE_ID_RANGE_START_C + 10;    // 110
       
    33 const int AMC_MSG_ID_RESPONSE   = AMC_MSG_ID_REQUEST + 1;                       // 111
       
    34 
       
    35 // Operations
       
    36 const int AMC_REQUEST_OPERATION_START   = 1;
       
    37 const int AMC_REQUEST_OPERATION_STOP    = 2;
       
    38 const int AMC_REQUEST_OPERATION_UPDATE  = 3;
       
    39 // Logging helper
       
    40 static const char* amcRequestOperation2String(const int& aOperation)
       
    41 {
       
    42     switch (aOperation)
       
    43     {
       
    44     case AMC_REQUEST_OPERATION_START:
       
    45         return "OPERATION_START";
       
    46 
       
    47     case AMC_REQUEST_OPERATION_STOP:
       
    48         return "OPERATION_STOP";
       
    49 
       
    50     case AMC_REQUEST_OPERATION_UPDATE:
       
    51         return "OPERATION_UPDATE";
       
    52 
       
    53     default:
       
    54         return "UNKNOWN!";
       
    55     }
       
    56 }
       
    57 
       
    58 // Options
       
    59 const int AMC_REQUEST_OPTIONS_NONE      = 0;
       
    60 const int AMC_REQUEST_OPTIONS_SILENT    = 1;
       
    61 // Logging helper
       
    62 static const char* amcRequestOptions2String(const int& aOptions)
       
    63 {
       
    64     switch (aOptions)
       
    65     {
       
    66     case AMC_REQUEST_OPTIONS_NONE:
       
    67         return "OPTIONS_NONE";
       
    68 
       
    69     case AMC_REQUEST_OPTIONS_SILENT:
       
    70         return "OPTIONS_SILENT";
       
    71 
       
    72     default:
       
    73         return "UNKNOWN!";
       
    74     }
       
    75 }
       
    76 
       
    77 inline void getAmcRequestParams(CommsMessage& aMessage, int& aOperation, int& aOptions)
       
    78 {
       
    79     if (aMessage.getMessageId() == AMC_MSG_ID_REQUEST)
       
    80     {
       
    81         aMessage >> aOperation >> aOptions;
       
    82     }
       
    83     else
       
    84     {
       
    85         ELOG2(EJavaCaptain, "wrong MessageId!: %d should be %d",
       
    86               aMessage.getMessageId(), AMC_MSG_ID_REQUEST);
       
    87     }
       
    88 }
       
    89 
       
    90 inline void setAmcRequestParams(CommsMessage& aMessage, const int& aOperation, const int& aOptions)
       
    91 {
       
    92     aMessage.setMessageId(AMC_MSG_ID_REQUEST);
       
    93     aMessage.setModuleId(PLUGIN_ID_AMC_C);
       
    94     aMessage << aOperation << aOptions;
       
    95 }
       
    96 
       
    97 inline void getAmcResponseParameters(CommsMessage& aMessage, int& aNumOfUids)
       
    98 {
       
    99     if (aMessage.getMessageId() == AMC_MSG_ID_RESPONSE)
       
   100     {
       
   101         aMessage >> aNumOfUids;
       
   102     }
       
   103     else
       
   104     {
       
   105         ELOG2(EJavaCaptain, "wrong MessageId!: %d should be %d",
       
   106               aMessage.getMessageId(), AMC_MSG_ID_RESPONSE);
       
   107     }
       
   108 }
       
   109 
       
   110 inline void setAmcResponseParamaters(CommsMessage& aMessage, int aNumOfUids)
       
   111 {
       
   112     aMessage.setMessageId(AMC_MSG_ID_RESPONSE);
       
   113     aMessage.setModuleId(PLUGIN_ID_AMC_C);
       
   114     aMessage << aNumOfUids;
       
   115 }
       
   116 
       
   117 } // namespace captain
       
   118 } // namespace java
       
   119 
       
   120 #endif // AMCMESSAGES_H
       
   121