utilities/serviceipcclient/serviceipcfactory.cpp
author hgs
Fri, 15 Oct 2010 17:30:59 -0400
changeset 16 3c88a81ff781
permissions -rw-r--r--
201041
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
16
hgs
parents:
diff changeset
     1
/**
hgs
parents:
diff changeset
     2
   This file is part of CWRT package **
hgs
parents:
diff changeset
     3
hgs
parents:
diff changeset
     4
   Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). **
hgs
parents:
diff changeset
     5
hgs
parents:
diff changeset
     6
   This program is free software: you can redistribute it and/or modify
hgs
parents:
diff changeset
     7
   it under the terms of the GNU (Lesser) General Public License as
hgs
parents:
diff changeset
     8
   published by the Free Software Foundation, version 2.1 of the License.
hgs
parents:
diff changeset
     9
   This program is distributed in the hope that it will be useful, but
hgs
parents:
diff changeset
    10
   WITHOUT ANY WARRANTY; without even the implied warranty of
hgs
parents:
diff changeset
    11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
hgs
parents:
diff changeset
    12
   (Lesser) General Public License for more details. You should have
hgs
parents:
diff changeset
    13
   received a copy of the GNU (Lesser) General Public License along
hgs
parents:
diff changeset
    14
   with this program. If not, see <http://www.gnu.org/licenses/>.
hgs
parents:
diff changeset
    15
*/
hgs
parents:
diff changeset
    16
hgs
parents:
diff changeset
    17
hgs
parents:
diff changeset
    18
#include "serviceipcfactory.h"
hgs
parents:
diff changeset
    19
#include "serviceipc_p.h"
hgs
parents:
diff changeset
    20
#ifndef __SYMBIAN32__
hgs
parents:
diff changeset
    21
#include "serviceipclocalsocket_p.h"
hgs
parents:
diff changeset
    22
#endif // Q_OS_WIN32
hgs
parents:
diff changeset
    23
#include "serviceipcsharedmem_p.h"
hgs
parents:
diff changeset
    24
hgs
parents:
diff changeset
    25
#ifdef __SYMBIAN32__
hgs
parents:
diff changeset
    26
#include "serviceipcsymbian_p.h"
hgs
parents:
diff changeset
    27
#endif // __SYMBIAN32__
hgs
parents:
diff changeset
    28
namespace WRT
hgs
parents:
diff changeset
    29
{
hgs
parents:
diff changeset
    30
/*!
hgs
parents:
diff changeset
    31
 \class ServiceFwIPCFactory
hgs
parents:
diff changeset
    32
hgs
parents:
diff changeset
    33
 Factory class for constructing the IPC backend
hgs
parents:
diff changeset
    34
 */
hgs
parents:
diff changeset
    35
hgs
parents:
diff changeset
    36
/*!
hgs
parents:
diff changeset
    37
 Constructor
hgs
parents:
diff changeset
    38
 */
hgs
parents:
diff changeset
    39
ServiceFwIPCFactory::ServiceFwIPCFactory()
hgs
parents:
diff changeset
    40
{
hgs
parents:
diff changeset
    41
}
hgs
parents:
diff changeset
    42
hgs
parents:
diff changeset
    43
/*!
hgs
parents:
diff changeset
    44
 Destructor
hgs
parents:
diff changeset
    45
 */
hgs
parents:
diff changeset
    46
ServiceFwIPCFactory::~ServiceFwIPCFactory()
hgs
parents:
diff changeset
    47
{
hgs
parents:
diff changeset
    48
}
hgs
parents:
diff changeset
    49
hgs
parents:
diff changeset
    50
/*!
hgs
parents:
diff changeset
    51
 Check to see if the particular IPC type is supported
hgs
parents:
diff changeset
    52
 @param aIPCType type of the IPC
hgs
parents:
diff changeset
    53
 @return true if the IPC type is supported, false otherwise
hgs
parents:
diff changeset
    54
 */
hgs
parents:
diff changeset
    55
bool ServiceFwIPCFactory::isIPCTypeSupported(TServiceIPCBackends aIPCType)
hgs
parents:
diff changeset
    56
{
hgs
parents:
diff changeset
    57
    bool supported(false);
hgs
parents:
diff changeset
    58
hgs
parents:
diff changeset
    59
#ifdef Q_OS_WIN32
hgs
parents:
diff changeset
    60
    if( aIPCType == ELocalSocket )
hgs
parents:
diff changeset
    61
    {
hgs
parents:
diff changeset
    62
        supported = true;
hgs
parents:
diff changeset
    63
    }
hgs
parents:
diff changeset
    64
#elif __SYMBIAN32__
hgs
parents:
diff changeset
    65
    if (aIPCType == ESymbianServer) {
hgs
parents:
diff changeset
    66
        supported = true;
hgs
parents:
diff changeset
    67
    }
hgs
parents:
diff changeset
    68
#else
hgs
parents:
diff changeset
    69
    //avoid compile warning
hgs
parents:
diff changeset
    70
    aIPCType = EDefaultIPC;
hgs
parents:
diff changeset
    71
    supported = false;
hgs
parents:
diff changeset
    72
#endif
hgs
parents:
diff changeset
    73
hgs
parents:
diff changeset
    74
    return supported;
hgs
parents:
diff changeset
    75
}
hgs
parents:
diff changeset
    76
hgs
parents:
diff changeset
    77
/*!
hgs
parents:
diff changeset
    78
 Create an instance of the Service IPC backend
hgs
parents:
diff changeset
    79
 @param aBackend Type of backend to create
hgs
parents:
diff changeset
    80
 @return ServiceFwIPCPrivate instance
hgs
parents:
diff changeset
    81
 */
hgs
parents:
diff changeset
    82
ServiceFwIPCPrivate* ServiceFwIPCFactory::createBackend(TServiceIPCBackends aBackend)
hgs
parents:
diff changeset
    83
{
hgs
parents:
diff changeset
    84
    ServiceFwIPCPrivate* backend(NULL);
hgs
parents:
diff changeset
    85
hgs
parents:
diff changeset
    86
#ifndef __SYMBIAN32__
hgs
parents:
diff changeset
    87
    // Local socket is default
hgs
parents:
diff changeset
    88
    if( aBackend == ELocalSocket || aBackend == EDefaultIPC )
hgs
parents:
diff changeset
    89
    {
hgs
parents:
diff changeset
    90
        backend = new ServiceLocalSocketIPC();
hgs
parents:
diff changeset
    91
    }
hgs
parents:
diff changeset
    92
#else
hgs
parents:
diff changeset
    93
    // Symbian server is default
hgs
parents:
diff changeset
    94
    if (aBackend == ESymbianServer || aBackend == EDefaultIPC) {
hgs
parents:
diff changeset
    95
        TRAP_IGNORE( backend = CServiceSymbianIPC::NewL() );
hgs
parents:
diff changeset
    96
    }
hgs
parents:
diff changeset
    97
#endif
hgs
parents:
diff changeset
    98
    return backend;
hgs
parents:
diff changeset
    99
}
hgs
parents:
diff changeset
   100
}
hgs
parents:
diff changeset
   101
// END OF FILE