1 /* |
|
2 * Copyright (c) 2009 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <string.h> |
|
19 #include "XALEDArrayAdaptCtx.h" |
|
20 #include "XAAdaptation.h" |
|
21 |
|
22 /* |
|
23 * XALEDArrayAdaptationCtx* XALEDArrayAdapt_Create() |
|
24 * Allocates memory for LEDArray Adaptation Context and makes 1st phase initialization |
|
25 * @returns XALEDArrayAdaptationCtx* - Pointer to created context |
|
26 */ |
|
27 XAAdaptationBaseCtx* XALEDArrayAdapt_Create(XAuint32 deviceID) |
|
28 { |
|
29 XALEDArrayAdaptationCtx *pSelf = calloc(1, sizeof(XALEDArrayAdaptationCtx)); |
|
30 DEBUG_API("->XALEDArrayAdapt_Create"); |
|
31 |
|
32 if ( pSelf) |
|
33 { |
|
34 if( XAAdaptationBase_Init(&(pSelf->baseObj),XALedArrayAdaptation) |
|
35 != XA_RESULT_SUCCESS ) |
|
36 { |
|
37 DEBUG_ERR("Failed to init base context!!!"); |
|
38 free(pSelf); |
|
39 pSelf = NULL; |
|
40 } |
|
41 else |
|
42 { |
|
43 pSelf->deviceID = deviceID; |
|
44 |
|
45 } |
|
46 } |
|
47 |
|
48 DEBUG_API("<-XALEDArrayAdapt_Create"); |
|
49 return (XAAdaptationBaseCtx*)pSelf; |
|
50 } |
|
51 |
|
52 /* |
|
53 * XAresult XALEDArrayAdapt_PostInit() |
|
54 * 2nd phase initialization of LEDArray Adaptation Context |
|
55 */ |
|
56 XAresult XALEDArrayAdapt_PostInit(XAAdaptationBaseCtx* bCtx) |
|
57 { |
|
58 XAresult ret = XA_RESULT_SUCCESS; |
|
59 XALEDArrayAdaptationCtx* ctx = NULL; |
|
60 DEBUG_API("->XALEDArrayAdapt_PostInit"); |
|
61 if(bCtx == NULL || bCtx->ctxId != XALedArrayAdaptation ) |
|
62 { |
|
63 DEBUG_ERR("Invalid parameter!!"); |
|
64 DEBUG_API("<-XALEDArrayAdapt_PostInit"); |
|
65 return XA_RESULT_PARAMETER_INVALID; |
|
66 } |
|
67 ctx = (XALEDArrayAdaptationCtx*)bCtx; |
|
68 if ( !ctx ) |
|
69 { |
|
70 return XA_RESULT_INTERNAL_ERROR; |
|
71 } |
|
72 |
|
73 XAAdaptationBase_PostInit( &(ctx->baseObj) ); |
|
74 |
|
75 DEBUG_API("<-XALEDArrayAdapt_PostInit"); |
|
76 return ret; |
|
77 } |
|
78 |
|
79 /* |
|
80 * void XALEDArrayAdapt_Destroy(XALEDArrayAdaptationCtx* ctx) |
|
81 * Destroys LEDArray Adaptation Context |
|
82 * @param ctx - LEDArray Adaptation context to be destroyed |
|
83 */ |
|
84 void XALEDArrayAdapt_Destroy(XAAdaptationBaseCtx* bCtx) |
|
85 { |
|
86 XALEDArrayAdaptationCtx* ctx = NULL; |
|
87 DEBUG_API("->XALEDArrayAdapt_Destroy"); |
|
88 if(bCtx == NULL || bCtx->ctxId != XALedArrayAdaptation ) |
|
89 { |
|
90 DEBUG_ERR("Invalid parameter!!"); |
|
91 DEBUG_API("<-XALEDArrayAdapt_Destroy"); |
|
92 return; |
|
93 } |
|
94 ctx = (XALEDArrayAdaptationCtx*)bCtx; |
|
95 DEBUG_API("->XALEDArrayAdapt_Destroy"); |
|
96 |
|
97 XAAdaptationBase_Free(&(ctx->baseObj)); |
|
98 |
|
99 |
|
100 free(ctx); |
|
101 ctx = NULL; |
|
102 |
|
103 DEBUG_API("<-XALEDArrayAdapt_Destroy"); |
|
104 } |
|