khronosfws/openmax_al/src/common/xadynintmgmtitf.c
author hgs
Fri, 25 Jun 2010 17:36:03 -0500
changeset 28 ebf79c79991a
parent 25 6f7ceef7b1d1
child 33 5e8b14bae8c3
permissions -rw-r--r--
201025
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/*
25
hgs
parents: 12
diff changeset
     2
 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
hgs
parents: 12
diff changeset
     3
 * All rights reserved.
hgs
parents: 12
diff changeset
     4
 * This component and the accompanying materials are made available
hgs
parents: 12
diff changeset
     5
 * under the terms of "Eclipse Public License v1.0"
hgs
parents: 12
diff changeset
     6
 * which accompanies this distribution, and is available
hgs
parents: 12
diff changeset
     7
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
hgs
parents: 12
diff changeset
     8
 *
hgs
parents: 12
diff changeset
     9
 * Initial Contributors:
hgs
parents: 12
diff changeset
    10
 * Nokia Corporation - initial contribution.
hgs
parents: 12
diff changeset
    11
 *
hgs
parents: 12
diff changeset
    12
 * Contributors:
hgs
parents: 12
diff changeset
    13
 *
hgs
parents: 12
diff changeset
    14
 * Description: Dynamic Management Interface Implementation
hgs
parents: 12
diff changeset
    15
 *
hgs
parents: 12
diff changeset
    16
 */
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    18
#include <stdlib.h>
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    19
#include <assert.h>
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    21
#include "openmaxalwrapper.h"
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    22
#include "xadynintmgmtitf.h"
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    23
#include "xadebug.h"
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    24
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    25
/* XADIMItfImpl* GetImpl(XADIMItf self)
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    26
 * Description: Validate interface pointer and cast it to implementation pointer.
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    27
 */
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    28
static XADIMItfImpl* GetImpl(XADynamicInterfaceManagementItf self)
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    29
    {
25
hgs
parents: 12
diff changeset
    30
    if (self)
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    31
        {
25
hgs
parents: 12
diff changeset
    32
        XADIMItfImpl* impl = (XADIMItfImpl*) (*self);
hgs
parents: 12
diff changeset
    33
        if (impl && (impl == impl->self))
hgs
parents: 12
diff changeset
    34
            {
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    35
            return impl;
25
hgs
parents: 12
diff changeset
    36
            }
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    37
        }
25
hgs
parents: 12
diff changeset
    38
    return NULL;
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    39
    }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    40
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    41
/**
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    42
 * Base Interface XADynamicInterfaceManagementItf implementation
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    43
 **/
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    44
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    45
/* XAresult XADIMItfImpl_AddInterface
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    46
 * Optionally asynchronous method for exposing an interface on an object.
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    47
 */
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    48
XAresult XADIMItfImpl_AddInterface(XADynamicInterfaceManagementItf self,
25
hgs
parents: 12
diff changeset
    49
        const XAInterfaceID iid, XAboolean async)
hgs
parents: 12
diff changeset
    50
    {
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    51
    XADIMItfImpl* impl = GetImpl(self);
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    52
    XAresult retval = XA_RESULT_SUCCESS;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    53
    DEBUG_API("->XADIMItfImpl_AddInterface");
25
hgs
parents: 12
diff changeset
    54
    if (!impl)
hgs
parents: 12
diff changeset
    55
        {
hgs
parents: 12
diff changeset
    56
        DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");DEBUG_API("<-XADIMItfImpl_AddInterface");
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    57
        return XA_RESULT_PARAMETER_INVALID;
25
hgs
parents: 12
diff changeset
    58
        }
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    59
25
hgs
parents: 12
diff changeset
    60
    if (async)
hgs
parents: 12
diff changeset
    61
        {
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    62
        /* invoke asynchronously */
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    63
        /* check if another async operation is processed */
25
hgs
parents: 12
diff changeset
    64
        if (impl->asyncOngoing)
hgs
parents: 12
diff changeset
    65
            {
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    66
            /* abort ongoing operation */
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    67
            XAImpl_CancelThread(impl->asyncThr);
25
hgs
parents: 12
diff changeset
    68
            }
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    69
        impl->asyncOngoing = XA_BOOLEAN_TRUE;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    70
        impl->asyncID = iid;
25
hgs
parents: 12
diff changeset
    71
        if (XAImpl_StartThread(impl->asyncThr, NULL,
hgs
parents: 12
diff changeset
    72
                &XADIMItfImpl_AsyncAddItf, (void*) (self)))
hgs
parents: 12
diff changeset
    73
            {
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    74
            impl->asyncOngoing = XA_BOOLEAN_FALSE;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    75
            retval = XA_RESULT_RESOURCE_ERROR;
25
hgs
parents: 12
diff changeset
    76
            }
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    77
        else
25
hgs
parents: 12
diff changeset
    78
            {
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    79
            retval = XA_RESULT_SUCCESS;
25
hgs
parents: 12
diff changeset
    80
            }
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    81
        }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    82
    else
25
hgs
parents: 12
diff changeset
    83
        {
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    84
        /* invoke synchronously */
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    85
        retval = XADIMItfImpl_DoAddItf(impl, iid);
25
hgs
parents: 12
diff changeset
    86
        }
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    87
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    88
    DEBUG_API_A1("<-XADIMItfImpl_AddInterface %lu", retval);
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    89
    return retval;
25
hgs
parents: 12
diff changeset
    90
    }
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    91
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    92
/* XAresult XADIMItfImpl_RemoveInterface
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    93
 * Synchronous method for removing a dynamically exposed interface on an object.
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    94
 */
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    95
XAresult XADIMItfImpl_RemoveInterface(XADynamicInterfaceManagementItf self,
25
hgs
parents: 12
diff changeset
    96
        const XAInterfaceID iid)
hgs
parents: 12
diff changeset
    97
    {
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    98
    XADIMItfImpl* impl = GetImpl(self);
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    99
    XAresult retval = XA_RESULT_SUCCESS;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   100
    DEBUG_API("->XADIMItfImpl_RemoveInterface");
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   101
25
hgs
parents: 12
diff changeset
   102
    if (impl)
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   103
        {
25
hgs
parents: 12
diff changeset
   104
        XAObjItfMapEntry *mapEntry = NULL;
hgs
parents: 12
diff changeset
   105
        if (impl->parent)
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   106
            {
25
hgs
parents: 12
diff changeset
   107
            mapEntry = XAObjectItfImpl_GetItfEntry(impl->parent, iid);
hgs
parents: 12
diff changeset
   108
            }
hgs
parents: 12
diff changeset
   109
        if (mapEntry && mapEntry->isDynamic)
hgs
parents: 12
diff changeset
   110
            {
hgs
parents: 12
diff changeset
   111
            if ((mapEntry->pItf))
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   112
                {
25
hgs
parents: 12
diff changeset
   113
                if (impl->DoRemoveItfImpl)
hgs
parents: 12
diff changeset
   114
                    {
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   115
                    retval = impl->DoRemoveItfImpl(impl->parent, mapEntry);
25
hgs
parents: 12
diff changeset
   116
                    }
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   117
                else
25
hgs
parents: 12
diff changeset
   118
                    {
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   119
                    DEBUG_ERR("XADIMItfImpl_RemoveInterface: Object has specified dynamic itfs but not implemented DoRemoveItfImpl!!!");
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   120
                    retval = XA_RESULT_INTERNAL_ERROR;
25
hgs
parents: 12
diff changeset
   121
                    }
hgs
parents: 12
diff changeset
   122
                }
hgs
parents: 12
diff changeset
   123
            else
hgs
parents: 12
diff changeset
   124
                {
hgs
parents: 12
diff changeset
   125
                DEBUG_ERR("XADIMItfImpl_RemoveInterface interface not exposed");
hgs
parents: 12
diff changeset
   126
                retval = XA_RESULT_PRECONDITIONS_VIOLATED;
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   127
                }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   128
            }
25
hgs
parents: 12
diff changeset
   129
        else /*( mapEntry && mapEntry->isDynamic )*/
hgs
parents: 12
diff changeset
   130
            { /* interface is not supported for dynamic management */
hgs
parents: 12
diff changeset
   131
            DEBUG_ERR("XADIMItfImpl_RemoveInterface interface not supported");
hgs
parents: 12
diff changeset
   132
            retval = XA_RESULT_FEATURE_UNSUPPORTED;
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   133
            }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   134
        }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   135
    else
25
hgs
parents: 12
diff changeset
   136
        {
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   137
        retval = XA_RESULT_PARAMETER_INVALID;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   138
        DEBUG_ERR("XADIMItfImpl_RemoveInterface: INVALID args");
25
hgs
parents: 12
diff changeset
   139
        }
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   140
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   141
    DEBUG_API_A1("<-XADIMItfImpl_RemoveInterface %lu", retval);
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   142
    return retval;
25
hgs
parents: 12
diff changeset
   143
    }
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   144
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   145
/* XAresult XADIMItfImpl_ResumeInterface
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   146
 * Optionally asynchronous method for resuming a dynamically exposed interface on the object.
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   147
 */
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   148
XAresult XADIMItfImpl_ResumeInterface(XADynamicInterfaceManagementItf self,
25
hgs
parents: 12
diff changeset
   149
        const XAInterfaceID iid, XAboolean async)
hgs
parents: 12
diff changeset
   150
    {
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   151
    XADIMItfImpl* impl = GetImpl(self);
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   152
    XAresult retval = XA_RESULT_SUCCESS;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   153
    DEBUG_API("->XADIMItfImpl_ResumeInterface");
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   154
25
hgs
parents: 12
diff changeset
   155
    if (!impl)
hgs
parents: 12
diff changeset
   156
        {
hgs
parents: 12
diff changeset
   157
        DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");DEBUG_API("<-XADIMItfImpl_ResumeInterface");
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   158
        return XA_RESULT_PARAMETER_INVALID;
25
hgs
parents: 12
diff changeset
   159
        }
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   160
25
hgs
parents: 12
diff changeset
   161
    if (async)
hgs
parents: 12
diff changeset
   162
        {
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   163
        /* invoke asynchronously */
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   164
        /* check if another async operation is processed */
25
hgs
parents: 12
diff changeset
   165
        if (impl->asyncOngoing)
hgs
parents: 12
diff changeset
   166
            {
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   167
            /* abort ongoing operation */
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   168
            XAImpl_CancelThread(impl->asyncThr);
25
hgs
parents: 12
diff changeset
   169
            }
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   170
        impl->asyncOngoing = XA_BOOLEAN_TRUE;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   171
        impl->asyncID = iid;
25
hgs
parents: 12
diff changeset
   172
        if (XAImpl_StartThread(impl->asyncThr, NULL,
hgs
parents: 12
diff changeset
   173
                &XADIMItfImpl_AsyncResumeItf, (void*) (self)))
hgs
parents: 12
diff changeset
   174
            {
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   175
            impl->asyncOngoing = XA_BOOLEAN_FALSE;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   176
            retval = XA_RESULT_RESOURCE_ERROR;
25
hgs
parents: 12
diff changeset
   177
            }
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   178
        else
25
hgs
parents: 12
diff changeset
   179
            {
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   180
            retval = XA_RESULT_SUCCESS;
25
hgs
parents: 12
diff changeset
   181
            }
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   182
        }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   183
    else
25
hgs
parents: 12
diff changeset
   184
        {
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   185
        /* invoke synchronously */
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   186
        retval = XADIMItfImpl_DoResumeItf(impl, iid);
25
hgs
parents: 12
diff changeset
   187
        }
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   188
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   189
    DEBUG_API_A1("<-XADIMItfImpl_ResumeInterface %lu", retval);
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   190
    return retval;
25
hgs
parents: 12
diff changeset
   191
    }
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   192
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   193
/* XAresult XADIMItfImpl_RegisterCallback
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   194
 * Registers a callback on the object
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   195
 */
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   196
XAresult XADIMItfImpl_RegisterCallback(XADynamicInterfaceManagementItf self,
25
hgs
parents: 12
diff changeset
   197
        xaDynamicInterfaceManagementCallback callback, void * pContext)
hgs
parents: 12
diff changeset
   198
    {
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   199
    XADIMItfImpl* impl = GetImpl(self);
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   200
    DEBUG_API("->XADIMItfImpl_RegisterCallback");
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   201
25
hgs
parents: 12
diff changeset
   202
    if (!impl)
hgs
parents: 12
diff changeset
   203
        {
hgs
parents: 12
diff changeset
   204
        DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");DEBUG_API("<-XADIMItfImpl_RegisterCallback");
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   205
        return XA_RESULT_PARAMETER_INVALID;
25
hgs
parents: 12
diff changeset
   206
        }
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   207
    impl->dimCb = callback;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   208
    impl->dimCbContext = pContext;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   209
    impl->dimCbPtrToSelf = self;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   210
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   211
    DEBUG_API("<-XADIMItfImpl_RegisterCallback");
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   212
    return XA_RESULT_SUCCESS;
25
hgs
parents: 12
diff changeset
   213
    }
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   214
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   215
/**
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   216
 * XADIMItfImpl -specific methods
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   217
 **/
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   218
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   219
/* XADIMItfImpl* XADIMItfImpl_Create()
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   220
 * Description: Allocate and initialize DIMItfImpl
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   221
 */
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   222
XADIMItfImpl* XADIMItfImpl_Create()
25
hgs
parents: 12
diff changeset
   223
    {
hgs
parents: 12
diff changeset
   224
    XADIMItfImpl *self = (XADIMItfImpl*) calloc(1, sizeof(XADIMItfImpl));
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   225
    DEBUG_API("->XADIMItfImpl_Create");
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   226
25
hgs
parents: 12
diff changeset
   227
    if (self)
hgs
parents: 12
diff changeset
   228
        {
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   229
        /* init itf default implementation */
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   230
        self->itf.AddInterface = XADIMItfImpl_AddInterface;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   231
        self->itf.RemoveInterface = XADIMItfImpl_RemoveInterface;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   232
        self->itf.ResumeInterface = XADIMItfImpl_ResumeInterface;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   233
        self->itf.RegisterCallback = XADIMItfImpl_RegisterCallback;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   234
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   235
        /* init variables */
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   236
        self->asyncOngoing = XA_BOOLEAN_FALSE;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   237
        self->dimCbPtrToSelf = NULL;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   238
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   239
        self->self = self;
25
hgs
parents: 12
diff changeset
   240
        if (XAImpl_CreateThreadHandle(&(self->asyncThr)) != XA_RESULT_SUCCESS)
hgs
parents: 12
diff changeset
   241
            {
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   242
            free(self);
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   243
            self = NULL;
25
hgs
parents: 12
diff changeset
   244
            }
hgs
parents: 12
diff changeset
   245
        }DEBUG_API("<-XADIMItfImpl_Create");
hgs
parents: 12
diff changeset
   246
    return self;
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   247
    }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   248
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   249
/* void XADIMItfImpl_Free(XADIMItfImpl* self)
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   250
 * Description: Free all resources reserved at XADIMItfImpl_Create
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   251
 */
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   252
void XADIMItfImpl_Free(XADIMItfImpl* self)
25
hgs
parents: 12
diff changeset
   253
    {
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   254
    DEBUG_API("->XADIMItfImpl_Free");
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   255
    assert(self==self->self);
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   256
    XAImpl_DeleteThreadHandle(self->asyncThr);
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   257
    free(self);
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   258
    DEBUG_API("<-XADIMItfImpl_Free");
25
hgs
parents: 12
diff changeset
   259
    }
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   260
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   261
/* void XADIMItfImpl_Init
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   262
 * Description: Initialize DIM interface. Mandatory to call if dynamic
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   263
 * interfaces are supported by object.
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   264
 */
25
hgs
parents: 12
diff changeset
   265
void XADIMItfImpl_Init(XADIMItfImpl* self, XAObjectItf parent,
hgs
parents: 12
diff changeset
   266
        xaDoAddItfImpl doAdd, xaDoResumeItfImpl doResume,
hgs
parents: 12
diff changeset
   267
        xaDoRemoveItfImpl doRemove)
hgs
parents: 12
diff changeset
   268
    {
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   269
    DEBUG_API("->XADIMItfImpl_Init");
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   270
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   271
    assert(self==self->self && parent && doAdd && doResume && doRemove);
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   272
    self->parent = parent;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   273
    self->DoAddItfImpl = doAdd;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   274
    self->DoResumeItfImpl = doResume;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   275
    self->DoRemoveItfImpl = doRemove;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   276
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   277
    DEBUG_API("<-XADIMItfImpl_Init");
25
hgs
parents: 12
diff changeset
   278
    }
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   279
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   280
/* void XADIMItfImpl_SendCbEvent
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   281
 * Description: Object can use this method to send resource events
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   282
 */
25
hgs
parents: 12
diff changeset
   283
void XADIMItfImpl_SendCbEvent(XADIMItfImpl* self, XAuint32 event,
hgs
parents: 12
diff changeset
   284
        XAresult result, const XAInterfaceID iid)
hgs
parents: 12
diff changeset
   285
    {
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   286
    DEBUG_API("->XADIMItfImpl_SendCbEvent");
25
hgs
parents: 12
diff changeset
   287
    if (self->dimCb)
hgs
parents: 12
diff changeset
   288
        {
hgs
parents: 12
diff changeset
   289
        self->dimCb((XADynamicInterfaceManagementItf) (self),
hgs
parents: 12
diff changeset
   290
                self->dimCbContext, event, result, iid);
hgs
parents: 12
diff changeset
   291
        }DEBUG_API("<-XADIMItfImpl_SendCbEvent");
hgs
parents: 12
diff changeset
   292
    }
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   293
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   294
/* void* XADIMItfImpl_AsyncAddItf
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   295
 * Description: Launch AddItf from async thread.
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   296
 */
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   297
void* XADIMItfImpl_AsyncAddItf(void* args)
25
hgs
parents: 12
diff changeset
   298
    {
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   299
    XAresult retval = XA_RESULT_SUCCESS;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   300
    XADIMItfImpl* impl = GetImpl(args);
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   301
    DEBUG_API("->XADIMItfImpl_AsyncAddItf");
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   302
25
hgs
parents: 12
diff changeset
   303
    if (impl)
hgs
parents: 12
diff changeset
   304
        {
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   305
        retval = XADIMItfImpl_DoAddItf(impl, impl->asyncID);
25
hgs
parents: 12
diff changeset
   306
        if (impl->dimCb)
hgs
parents: 12
diff changeset
   307
            {
hgs
parents: 12
diff changeset
   308
            impl->dimCb((XADynamicInterfaceManagementItf) (args),
hgs
parents: 12
diff changeset
   309
                    impl->dimCbContext,
hgs
parents: 12
diff changeset
   310
                    XA_DYNAMIC_ITF_EVENT_ASYNC_TERMINATION, retval,
hgs
parents: 12
diff changeset
   311
                    impl->asyncID);
hgs
parents: 12
diff changeset
   312
            }
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   313
        impl->asyncOngoing = XA_BOOLEAN_FALSE;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   314
        XAImpl_ExitThread(impl->asyncThr);
25
hgs
parents: 12
diff changeset
   315
        }
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   316
    else
25
hgs
parents: 12
diff changeset
   317
        {
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   318
        DEBUG_ERR("XADIMItfImpl_AsyncAddItf: INVALID args");
25
hgs
parents: 12
diff changeset
   319
        }
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   320
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   321
    DEBUG_API("<-XADIMItfImpl_AsyncAddItf");
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   322
    return NULL;
25
hgs
parents: 12
diff changeset
   323
    }
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   324
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   325
/* XAresult XADIMItfImpl_DoAddItf
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   326
 * Description: Handle Itf dynamic addition and call object-specific parts.
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   327
 *              Launched either from async thread or directly.
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   328
 */
25
hgs
parents: 12
diff changeset
   329
XAresult XADIMItfImpl_DoAddItf(XADIMItfImpl* impl, const XAInterfaceID iid)
hgs
parents: 12
diff changeset
   330
    {
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   331
    XAresult retval = XA_RESULT_SUCCESS;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   332
    DEBUG_API("->XADIMItfImpl_DoAddItf");
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   333
25
hgs
parents: 12
diff changeset
   334
    if (impl)
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   335
        {
25
hgs
parents: 12
diff changeset
   336
        XAObjItfMapEntry *mapEntry = NULL;
hgs
parents: 12
diff changeset
   337
        if (impl->parent)
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   338
            {
25
hgs
parents: 12
diff changeset
   339
            mapEntry = XAObjectItfImpl_GetItfEntry(impl->parent, iid);
hgs
parents: 12
diff changeset
   340
            }
hgs
parents: 12
diff changeset
   341
        if (mapEntry && mapEntry->isDynamic)
hgs
parents: 12
diff changeset
   342
            {
hgs
parents: 12
diff changeset
   343
            if (!(mapEntry->pItf))
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   344
                {
25
hgs
parents: 12
diff changeset
   345
                if (impl->DoAddItfImpl)
hgs
parents: 12
diff changeset
   346
                    {
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   347
                    retval = impl->DoAddItfImpl(impl->parent, mapEntry);
25
hgs
parents: 12
diff changeset
   348
                    }
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   349
                else
25
hgs
parents: 12
diff changeset
   350
                    {
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   351
                    DEBUG_ERR("XADIMItfImpl_DoAddItf: Object has specified dynamic itfs but not implemented DoAddItfImpl!!!");
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   352
                    retval = XA_RESULT_INTERNAL_ERROR;
25
hgs
parents: 12
diff changeset
   353
                    }
hgs
parents: 12
diff changeset
   354
                }
hgs
parents: 12
diff changeset
   355
            else
hgs
parents: 12
diff changeset
   356
                {
hgs
parents: 12
diff changeset
   357
                DEBUG_ERR("XADIMItfImpl_DoAddItf interface already exposed");
hgs
parents: 12
diff changeset
   358
                retval = XA_RESULT_PRECONDITIONS_VIOLATED;
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   359
                }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   360
            }
25
hgs
parents: 12
diff changeset
   361
        else /*( mapEntry && mapEntry->isDynamic )*/
hgs
parents: 12
diff changeset
   362
            { /* interface is not supported for dynamic management */
hgs
parents: 12
diff changeset
   363
            DEBUG_ERR("XADIMItfImpl_DoAddItf interface not supported");
hgs
parents: 12
diff changeset
   364
            retval = XA_RESULT_FEATURE_UNSUPPORTED;
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   365
            }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   366
        }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   367
    else
25
hgs
parents: 12
diff changeset
   368
        {
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   369
        retval = XA_RESULT_INTERNAL_ERROR;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   370
        DEBUG_ERR("XADIMItfImpl_DoAddItf: INVALID args");
25
hgs
parents: 12
diff changeset
   371
        }
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   372
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   373
    DEBUG_API("<-XADIMItfImpl_DoAddItf");
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   374
    return retval;
25
hgs
parents: 12
diff changeset
   375
    }
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   376
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   377
/* void* XADIMItfImpl_AsyncResumeItf
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   378
 * Description: Launch ResumeItf from async thread.
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   379
 */
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   380
void* XADIMItfImpl_AsyncResumeItf(void* args)
25
hgs
parents: 12
diff changeset
   381
    {
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   382
    XAresult retval = XA_RESULT_SUCCESS;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   383
    XADIMItfImpl* impl = GetImpl(args);
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   384
    DEBUG_API("->XADIMItfImpl_AsyncResumeItf");
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   385
25
hgs
parents: 12
diff changeset
   386
    if (impl)
hgs
parents: 12
diff changeset
   387
        {
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   388
        retval = XADIMItfImpl_DoResumeItf(impl, impl->asyncID);
25
hgs
parents: 12
diff changeset
   389
        if (impl->dimCb)
hgs
parents: 12
diff changeset
   390
            {
hgs
parents: 12
diff changeset
   391
            impl->dimCb((XADynamicInterfaceManagementItf) (args),
hgs
parents: 12
diff changeset
   392
                    impl->dimCbContext,
hgs
parents: 12
diff changeset
   393
                    XA_DYNAMIC_ITF_EVENT_ASYNC_TERMINATION, retval,
hgs
parents: 12
diff changeset
   394
                    impl->asyncID);
hgs
parents: 12
diff changeset
   395
            }
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   396
        impl->asyncOngoing = XA_BOOLEAN_FALSE;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   397
        XAImpl_ExitThread(impl->asyncThr);
25
hgs
parents: 12
diff changeset
   398
        }
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   399
    else
25
hgs
parents: 12
diff changeset
   400
        {
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   401
        DEBUG_ERR("XADIMItfImpl_AsyncResumeItf: INVALID args");
25
hgs
parents: 12
diff changeset
   402
        }
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   403
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   404
    DEBUG_API("<-XADIMItfImpl_AsyncResumeItf");
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   405
    return NULL;
25
hgs
parents: 12
diff changeset
   406
    }
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   407
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   408
/* void XADIMItfImpl_DoResumeItf
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   409
 * Description: Handle Itf dynamic resuming and call object-specific parts.
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   410
 *              Launched either from async thread or directly.
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   411
 */
25
hgs
parents: 12
diff changeset
   412
XAresult XADIMItfImpl_DoResumeItf(XADIMItfImpl* impl, const XAInterfaceID iid)
hgs
parents: 12
diff changeset
   413
    {
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   414
    XAresult retval = XA_RESULT_SUCCESS;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   415
    DEBUG_API("->XADIMItfImpl_DoResumeItf");
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   416
25
hgs
parents: 12
diff changeset
   417
    if (impl)
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   418
        {
25
hgs
parents: 12
diff changeset
   419
        XAObjItfMapEntry *mapEntry = XAObjectItfImpl_GetItfEntry(
hgs
parents: 12
diff changeset
   420
                impl->parent, iid);
hgs
parents: 12
diff changeset
   421
        if (mapEntry && mapEntry->isDynamic)
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   422
            {
25
hgs
parents: 12
diff changeset
   423
            if ((!mapEntry->pItf))
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   424
                {
25
hgs
parents: 12
diff changeset
   425
                if (impl->DoResumeItfImpl)
hgs
parents: 12
diff changeset
   426
                    {
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   427
                    retval = impl->DoResumeItfImpl(impl->parent, mapEntry);
25
hgs
parents: 12
diff changeset
   428
                    }
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   429
                else
25
hgs
parents: 12
diff changeset
   430
                    {
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   431
                    DEBUG_ERR("XADIMItfImpl_DoResumeItf: Object has specified dynamic itfs but not implemented DoResumeItfImpl!!!");
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   432
                    retval = XA_RESULT_INTERNAL_ERROR;
25
hgs
parents: 12
diff changeset
   433
                    }
hgs
parents: 12
diff changeset
   434
                }
hgs
parents: 12
diff changeset
   435
            else
hgs
parents: 12
diff changeset
   436
                {
hgs
parents: 12
diff changeset
   437
                DEBUG_ERR("XADIMItfImpl_DoResumeItf interface already exposed");
hgs
parents: 12
diff changeset
   438
                retval = XA_RESULT_PRECONDITIONS_VIOLATED;
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   439
                }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   440
            }
25
hgs
parents: 12
diff changeset
   441
        else /*( mapEntry && mapEntry->isDynamic )*/
hgs
parents: 12
diff changeset
   442
            { /* interface is not supported for dynamic management */
hgs
parents: 12
diff changeset
   443
            DEBUG_ERR("XADIMItfImpl_DoResumeItf interface not supported");
hgs
parents: 12
diff changeset
   444
            retval = XA_RESULT_FEATURE_UNSUPPORTED;
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   445
            }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   446
        }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   447
    else
25
hgs
parents: 12
diff changeset
   448
        {
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   449
        retval = XA_RESULT_INTERNAL_ERROR;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   450
        DEBUG_ERR("XADIMItfImpl_DoResumeItf: INVALID args");
25
hgs
parents: 12
diff changeset
   451
        }
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   452
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   453
    DEBUG_API("<-XADIMItfImpl_DoResumeItf");
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   454
    return retval;
25
hgs
parents: 12
diff changeset
   455
    }
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   456