~ubuntu-branches/ubuntu/vivid/freerdp/vivid

« back to all changes in this revision

Viewing changes to libfreerdp/rail/window_list.c

  • Committer: Package Import Robot
  • Author(s): Iain Lane
  • Date: 2014-11-11 12:20:50 UTC
  • mfrom: (1.1.9) (9.1.17 sid)
  • Revision ID: package-import@ubuntu.com-20141111122050-wyr8hrnwco9fcmum
Tags: 1.1.0~git20140921.1.440916e+dfsg1-2ubuntu1
* Merge with Debian unstable, remaining changes
  - Disable ffmpeg support
* Disable gstreamer support, this relies on gstreamer 0.10 and we don't want
  to add any more deps on that.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * FreeRDP: A Remote Desktop Protocol Implementation
 
3
 * RAIL Window List
 
4
 *
 
5
 * Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
 
6
 *
 
7
 * Licensed under the Apache License, Version 2.0 (the "License");
 
8
 * you may not use this file except in compliance with the License.
 
9
 * You may obtain a copy of the License at
 
10
 *
 
11
 *     http://www.apache.org/licenses/LICENSE-2.0
 
12
 *
 
13
 * Unless required by applicable law or agreed to in writing, software
 
14
 * distributed under the License is distributed on an "AS IS" BASIS,
 
15
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
16
 * See the License for the specific language governing permissions and
 
17
 * limitations under the License.
 
18
 */
 
19
 
 
20
#ifdef HAVE_CONFIG_H
 
21
#include "config.h"
 
22
#endif
 
23
 
 
24
#include <winpr/crt.h>
 
25
 
 
26
#include <winpr/stream.h>
 
27
 
 
28
#include "librail.h"
 
29
 
 
30
#include <freerdp/rail/window_list.h>
 
31
 
 
32
void window_list_rewind(rdpWindowList* list)
 
33
{
 
34
        list->iterator = list->head;
 
35
}
 
36
 
 
37
BOOL window_list_has_next(rdpWindowList* list)
 
38
{
 
39
        if (list->iterator != NULL)
 
40
        {
 
41
                if (list->iterator != NULL)
 
42
                        return TRUE;
 
43
        }
 
44
 
 
45
        return FALSE;
 
46
}
 
47
 
 
48
rdpWindow* window_list_get_next(rdpWindowList* list)
 
49
{
 
50
        rdpWindow* next = NULL;
 
51
 
 
52
        if (list->iterator != NULL)
 
53
        {
 
54
                next = list->iterator;
 
55
                list->iterator = list->iterator->next;
 
56
        }
 
57
 
 
58
        return next;
 
59
}
 
60
 
 
61
rdpWindow* window_list_get_by_extra_id(rdpWindowList* list, void* extraId)
 
62
{
 
63
        rdpWindow* window;
 
64
 
 
65
        window = list->head;
 
66
 
 
67
        if (window == NULL)
 
68
                return NULL;
 
69
 
 
70
        while (window != NULL)
 
71
        {
 
72
                if (window->extraId == extraId)
 
73
                        return window;
 
74
 
 
75
                window = window->next;
 
76
        }
 
77
 
 
78
        return NULL;
 
79
}
 
80
 
 
81
rdpWindow* window_list_get_by_id(rdpWindowList* list, UINT32 windowId)
 
82
{
 
83
        rdpWindow* window;
 
84
 
 
85
        window = list->head;
 
86
 
 
87
        if (window == NULL)
 
88
                return NULL;
 
89
 
 
90
        while (window != NULL)
 
91
        {
 
92
                if (window->windowId == windowId)
 
93
                        return window;
 
94
 
 
95
                window = window->next;
 
96
        }
 
97
 
 
98
        return NULL;
 
99
}
 
100
 
 
101
void window_list_create(rdpWindowList* list, WINDOW_ORDER_INFO* orderInfo, WINDOW_STATE_ORDER* window_state)
 
102
{
 
103
        rdpWindow* window;
 
104
 
 
105
        /* See if the window already exists */
 
106
        window = window_list_get_by_id(list, orderInfo->windowId);
 
107
         
 
108
        /* If the window already exists, just update the existing window */
 
109
        if (window != NULL)
 
110
        {
 
111
                window_list_update(list, orderInfo, window_state);
 
112
                return;
 
113
        }
 
114
 
 
115
        window = (rdpWindow*) malloc(sizeof(rdpWindow));
 
116
 
 
117
        if (window == NULL)
 
118
                return;
 
119
 
 
120
        ZeroMemory(window, sizeof(rdpWindow));
 
121
 
 
122
        window->windowId = orderInfo->windowId;
 
123
 
 
124
        if (list->head == NULL)
 
125
        {
 
126
                list->head = list->tail = window;
 
127
                window->prev = NULL;
 
128
                window->next = NULL;
 
129
        }
 
130
        else
 
131
        {
 
132
                window->prev = list->tail;
 
133
                list->tail->next = window;
 
134
                window->next = NULL;
 
135
                list->tail = window;
 
136
        }
 
137
 
 
138
        window->windowId = orderInfo->windowId;
 
139
 
 
140
        window_state_update(window, orderInfo, window_state);
 
141
 
 
142
        rail_CreateWindow(list->rail, window);
 
143
}
 
144
 
 
145
void window_list_update(rdpWindowList* list, WINDOW_ORDER_INFO* orderInfo, WINDOW_STATE_ORDER* window_state)
 
146
{
 
147
        rdpWindow* window;
 
148
 
 
149
        window = window_list_get_by_id(list, orderInfo->windowId);
 
150
 
 
151
        if (window == NULL)
 
152
                return;
 
153
 
 
154
        window_state_update(window, orderInfo, window_state);
 
155
 
 
156
        rail_UpdateWindow(list->rail, window);
 
157
}
 
158
 
 
159
void window_list_delete(rdpWindowList* list, WINDOW_ORDER_INFO* orderInfo)
 
160
{
 
161
        rdpWindow* prev;
 
162
        rdpWindow* next;
 
163
        rdpWindow* window;
 
164
 
 
165
        window = window_list_get_by_id(list, orderInfo->windowId);
 
166
 
 
167
        if (window == NULL)
 
168
                return;
 
169
 
 
170
        prev = window->prev;
 
171
        next = window->next;
 
172
 
 
173
        if (prev != NULL)
 
174
                prev->next = next;
 
175
 
 
176
        if (next != NULL)
 
177
                next->prev = prev;
 
178
 
 
179
        if (list->head == list->tail)
 
180
        {
 
181
                list->head = list->tail = NULL;
 
182
        }
 
183
        else
 
184
        {
 
185
                if (list->head == window)
 
186
                        list->head = next;
 
187
 
 
188
                if (list->tail == window)
 
189
                        list->tail = prev;
 
190
        }
 
191
 
 
192
        rail_DestroyWindow(list->rail, window);
 
193
}
 
194
 
 
195
void window_list_clear(rdpWindowList* list)
 
196
{
 
197
       rdpWindow* current = list->head;
 
198
 
 
199
       while (current != NULL)
 
200
       {
 
201
               list->head = current->next;
 
202
               rail_DestroyWindow(list->rail, current);
 
203
               current = list->head;
 
204
       }       
 
205
       
 
206
       list->tail = NULL;
 
207
}
 
208
 
 
209
rdpWindowList* window_list_new(rdpRail* rail)
 
210
{
 
211
        rdpWindowList* list;
 
212
 
 
213
        list = (rdpWindowList*) malloc(sizeof(rdpWindowList));
 
214
 
 
215
        if (list != NULL)
 
216
        {
 
217
                ZeroMemory(list, sizeof(rdpWindowList));
 
218
 
 
219
                list->head = NULL;
 
220
                list->tail = NULL;
 
221
                list->rail = rail;
 
222
        }
 
223
 
 
224
        return list;
 
225
}
 
226
 
 
227
void window_list_free(rdpWindowList* list)
 
228
{
 
229
        if (list != NULL)
 
230
        {
 
231
                free(list);
 
232
        }
 
233
}