qthighway/xqserviceutil/src/xqrequestutil.cpp
changeset 1 2b40d63a9c3d
child 8 71781823f776
equal deleted inserted replaced
0:cfcbf08528c4 1:2b40d63a9c3d
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 *
       
     5 * This program is free software: you can redistribute it and/or modify
       
     6 * it under the terms of the GNU Lesser General Public License as published by
       
     7 * the Free Software Foundation, version 2.1 of the License.
       
     8 * 
       
     9 * This program is distributed in the hope that it will be useful,
       
    10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    12 * GNU Lesser General Public License for more details.
       
    13 *
       
    14 * You should have received a copy of the GNU Lesser General Public License
       
    15 * along with this program.  If not, 
       
    16 * see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/".
       
    17 *
       
    18 * Description:                                                         
       
    19 *
       
    20 */
       
    21 
       
    22 #include "xqservicelog.h"
       
    23 #include "xqserviceerrdefs.h"
       
    24 
       
    25 #include "xqrequestutil.h"
       
    26    
       
    27 XQRequestUtil::XQRequestUtil()
       
    28 {
       
    29     XQSERVICE_DEBUG_PRINT("XQRequestUtil::XQRequestUtil");
       
    30 }
       
    31 
       
    32 XQRequestUtil::~XQRequestUtil()
       
    33 {
       
    34     XQSERVICE_DEBUG_PRINT("XQRequestUtil::~XQRequestUtil");
       
    35 }
       
    36 
       
    37 void XQRequestUtil::setSynchronous(bool on)
       
    38 {
       
    39     XQSERVICE_DEBUG_PRINT("XQRequestInfo::setSynchronous %d", on);
       
    40     mInfo.setInfo(XQServiceUtils::OptSynchronous, on);
       
    41 }
       
    42 
       
    43 
       
    44 const XQSharableFile *XQRequestUtil::getSharableFile(int index) const
       
    45 {
       
    46     if (index >= 0 && index < mSharableFileArgs.size())
       
    47     {
       
    48         return &mSharableFileArgs.at(index);
       
    49     }
       
    50 
       
    51     return 0;
       
    52 }
       
    53 
       
    54 void XQRequestUtil::setSecurityInfo(const quint32 sid, const quint32 vid, const quint32 caps )
       
    55 {
       
    56     XQSERVICE_DEBUG_PRINT("XQRequestUtil::setSecurityInfo");
       
    57 
       
    58     mInfo.setInfo(XQServiceUtils::InfoSID, sid);
       
    59     mInfo.setInfo(XQServiceUtils::InfoVID, vid);
       
    60     mInfo.setInfo(XQServiceUtils::InfoCap, caps);
       
    61 
       
    62 }
       
    63 
       
    64 
       
    65 int XQRequestUtil::mapError(int error)
       
    66 {
       
    67     XQSERVICE_DEBUG_PRINT("XQRequestUtil::mapError");
       
    68     XQSERVICE_DEBUG_PRINT("\terror=%d", error);
       
    69     
       
    70     int mappedError(XQService::ENoError);
       
    71 
       
    72     switch (error)
       
    73     {
       
    74         case KErrNone:
       
    75         {
       
    76             mappedError = XQService::ENoError;
       
    77             break;
       
    78         }
       
    79         
       
    80         case KErrPermissionDenied:
       
    81         case KErrServerTerminated:
       
    82         {
       
    83             mappedError = XQService::EConnectionClosed;
       
    84             break;
       
    85         }
       
    86         case KErrServerBusy:
       
    87         {
       
    88             mappedError = XQService::EConnectionError;
       
    89             break;
       
    90         }
       
    91         case KErrArgument:
       
    92         {
       
    93             mappedError = XQService::EArgumentError;
       
    94             break;
       
    95         }
       
    96 
       
    97         case KErrNoMemory:
       
    98         {
       
    99             mappedError = XQService::EIPCError;
       
   100             break;
       
   101         }
       
   102         case KErrNotFound:
       
   103         {
       
   104             mappedError = XQService::EServerNotFound;
       
   105             break;
       
   106         }
       
   107         
       
   108 
       
   109         default:
       
   110         {
       
   111             mappedError = error;  // Leave it as is
       
   112             break;
       
   113         }
       
   114     }
       
   115 
       
   116 
       
   117     XQSERVICE_DEBUG_PRINT("\tmapper error=%d", mappedError);
       
   118     return mappedError;
       
   119 
       
   120 }