-
Notifications
You must be signed in to change notification settings - Fork 0
/
activity.c
1013 lines (851 loc) · 20.8 KB
/
activity.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright (C) 2010,2011 by Milan Kazarka
*
* You may distribute under the terms of the Artistic License,
* as specified in the README file.
*
*/
/** activities should be viewed as ways of how to communicate between
* our applications and their managers - for example the rootController
*/
#include "activity.h"
#include "activityObject.h"
#include "rootControllerSync.h"
#include "os.h"
#include "system.h"
#include "config.h"
/** in general it's easier to sync the activities
* with the rootController's locking mechanism
*/
#define _ACTIVITY_LOCK_ON_ROOT_NO
/** the locking & unlocking of activity data should be
* done here for every access (todo if elsewhere)
*/
int activityLock( struct activity *act )
{
if (!act) return 1;
if (!act->sem) return 1;
#ifdef _ACTIVITY_LOCK_ON_ROOT
#ifdef _DEBUG
printf("activityLock.start\n");
#endif
rootControllerLock();
#ifdef _DEBUG
printf("activityLock.finish\n");
#endif
#else
binarySemaphoreWait(act->sem->id);
#endif
return 0;
}
int activityUnlock( struct activity *act )
{
if (!act) return 1;
if (!act->sem) return 1;
#ifdef _ACTIVITY_LOCK_ON_ROOT
#ifdef _DEBUG
printf("activityUnlock.start\n");
#endif
rootControllerUnlock();
#ifdef _DEBUG
printf("activityUnlock.finish\n");
#endif
#else
binarySemaphorePost(act->sem->id);
#endif
return 0;
}
/**
* register activity over socket
*/
int activityRegisterOverSocket(
struct activity *act
)
{
if (!act)
return -1;
#ifdef _DEBUG
printf("activityRegisterOverSocket start shm(%d) sem(%d)\n",
act->shm->id,act->sem->id);
#endif
trop_IPC *client = trop_IPCInit(NULL);
unsigned char msg[128];
sprintf((char*)msg,"NEWACT\nANAME %s\nSHMID %d\nSEMID %d\nSHMSZ %d\n",
(char*)act->name,
act->shm->id,
act->sem->id,
act->shm->size);
trop_IPCUdsHandshake(client,"./mika.sock",(char*)msg);
free(client);
#ifdef _DEBUG
printf("activityRegisterOverSocket finish\n");
#endif
return 0;
}
/** register the access to the activity to a file
*/
int activityRegisterAccess( struct activity *act, unsigned char *filename )
{
if (!act || !filename)
{
#ifdef _DEBUG
printf("activityRegisterAccess error, invalid arguments\n");
#endif
return 1;
}
unsigned char line[64];
FILE *out = fopen((char*)filename,"w");
if (out)
{
sprintf((char*)line,"%d\n",act->sem->id);
fwrite((char*)line,strlen((char*)line),1,out);
sprintf((char*)line,"%d\n",act->shm->id);
fwrite((char*)line,strlen((char*)line),1,out);
fclose(out);
}
return 0;
}
/** register an exposure event over a socket
*/
int activityEventExposeOverSocket(
struct activity *act
)
{
if (!act)
return -1;
#ifdef _DEBUG
printf("activityEventExposeOverSocket start\n");
#endif
trop_IPC *client = trop_IPCInit(NULL);
unsigned char msg[128];
sprintf((char*)msg,"EVEXP\n");
trop_IPCUdsHandshake(client,"./mika.sock",(char*)msg);
free(client);
#ifdef _DEBUG
printf("activityEventExposeOverSocket finish\n");
#endif
return 0;
}
struct activity *activityAlloc(
struct activity *act
)
{
if (!act)
{
act = (struct activity*)malloc(sizeof(struct activity));
}
act->shm = (struct rootShm*)malloc(sizeof(struct rootShm));
act->sem = (struct rootSem*)malloc(sizeof(struct rootSem));
return act;
}
/** parse activity data as string
*
*/
int activityInitData(
struct activity *act,
unsigned char *data
)
{
if (!act || !data)
return -1;
#ifdef _DEBUG
printf("activityInitData data(%s)\n",data);
#endif
int i;
int state = 0;
int pos = 0;
unsigned char line[32];
unsigned char tmp[32];
for(i = 0; i < strlen(data); i++)
{
if (data[i]=='\n')
{
strncpy((char*)line,data+pos,i-pos);
line[i-pos] = 0x00;
#ifdef _DEBUG
printf("activityInitData line(%s)\n",(char*)line);
#endif
if (state == 0)
{
if (strncmp((char*)line,"NEWACT",6)==0)
{
act->type = _ACTIVITY_TYPE_APP;
#ifdef _DEBUG
printf("activityInitData NEWACT\n");
#endif
state = 1;
pos = i+1;
continue;
}
else if (strncmp((char*)line,"EVEXP",5)==0)
{
act->type = _ACTIVITY_TYPE_EVENT;
#ifdef _DEBUG
printf("activityInitData EVEXP\n");
#endif
state = 2;
pos = i+1;
continue;
}
}
switch(state)
{
case 1:
if (strncmp((char*)line,"SHMID",5)==0)
{
strncpy((char*)tmp,(char*)line+6,strlen((char*)line)-6);
tmp[strlen((char*)line)-6] = 0x00;
act->shm->id = atoi((char*)tmp);
}
else if (strncmp((char*)line,"ANAME",5)==0)
{
strncpy((char*)tmp,(char*)line+6,strlen((char*)line)-6);
tmp[strlen((char*)line)-6] = 0x00;
strcpy((char*)act->name,(char*)tmp);
}
else if (strncmp((char*)line,"SHMSZ",5)==0)
{
strncpy((char*)tmp,(char*)line+6,strlen((char*)line)-6);
tmp[strlen((char*)line)-6] = 0x00;
act->shm->size = atoi((char*)tmp);
}
else if (strncmp((char*)line,"SEMID",5)==0)
{
strncpy((char*)tmp,(char*)line+6,strlen((char*)line)-6);
tmp[strlen((char*)line)-6] = 0x00;
act->sem->id = atoi((char*)tmp);
}
/** refactoring - insure that the SHM exists at this moment
*/
break;
case 2:
break;
}
pos = i+1;
}
}
return 0;
}
/** read activity attributes, needs to be synced - basically creates
* a copy of the activity attributes
*/
int activityInit(
struct activity *act,
unsigned char *path
)
{
FILE *fd = NULL;
unsigned char line[256];
unsigned char tmp[256];
if (!act || !path)
return -1;
if ((fd = fopen(path,"r"))==NULL)
{
#ifdef _DEBUG
printf("activityInit could not open file(%s)\n",
path);
#endif
return -1;
}
while(1)
{
fgets((char*)line,256,fd);
if (feof(fd))
break;
if (line[strlen((char*)line)-1])
{
line[strlen((char*)line)-1] = 0x00;
}
if (strlen((char*)line)>6)
{
if (strncmp((char*)line,"SHMID",5)==0)
{
strncpy((char*)tmp,(char*)line+6,strlen((char*)line)-6);
tmp[strlen((char*)line)-6] = 0x00;
act->shm->id = atoi((char*)tmp);
}
if (strncmp((char*)line,"SHMSZ",5)==0)
{
strncpy((char*)tmp,(char*)line+6,strlen((char*)line)-6);
tmp[strlen((char*)line)-6] = 0x00;
act->shm->size = atoi((char*)tmp);
}
if (strncmp((char*)line,"SEMID",5)==0)
{
strncpy((char*)tmp,(char*)line+6,strlen((char*)line)-6);
tmp[strlen((char*)line)-6] = 0x00;
act->sem->id = atoi((char*)tmp);
}
}
}
return 0;
}
/** create the rootShm of the activity & allocate all needd space
*/
int activitySHMCreate(
struct activity *act,
int surfaceSize
)
{
#ifdef _DEBUG
printf("activitySHMCreate surfaceSize(%d)\n",surfaceSize);
#endif
struct activityData *aData = NULL;
int size =
sizeof(struct activityData) +
surfaceSize;
if (
os_rshmAlloc(act->shm,size,act->type,(unsigned char*)act->name) == -1
)
{
#ifdef _DEBUG
printf("activitySHMCreate error\n");
#endif
return -1;
}
act->shm->data = shmat(act->shm->id,0,0);
aData = (struct activityData*)act->shm->data;
aData->surface = act->shm->data+
sizeof(struct activityData);
struct activityEvent *event;
event = &aData->event;
event->active = 0;
event->type = _ACTIVITY_EVENT_NONE;
activitySHMInitAttributes(act);
aData = NULL;
shmdt(act->shm->data);
#ifdef _DEBUG
printf("activitySHMCreate ptr finish\n");
#endif
return 0;
}
int activitySHMGetEvent( // activityData
struct activity *act,
struct activityEvent *event
)
{
struct activityData *aData = NULL;
#ifdef _DEBUG
printf("activitySHMGetEvent\n");
#endif
if (!act || !event)
return -1;
aData = (struct activityData*)act->shm->data;
struct activityEvent *_eventPtr = &aData->event; //(struct activityEvent *)act->shm->data;
if (!_eventPtr)
return -1;
if (_eventPtr->active==1)
{
event->type = _eventPtr->type;
}
#ifdef _DEBUG
printf("activitySHMGetEvent finish\n");
#endif
return 0;
}
/** use this only when we are creating the actual prototype
* of the activity
*/
int activitySHMInitAttributes(
struct activity *act
)
{
struct activityData *aData = NULL;
#ifdef _DEBUG
printf("activitySHMInitAttributes\n");
#endif
if (!act)
return -1;
aData = (struct activityData*)act->shm->data;
aData->attributes.w = 0;
aData->attributes.h = 0;
aData->attributes.x = 0;
aData->attributes.y = 0;
aData->attributes.movable = 1;
aData->attributes.visible = 1;
aData->attributes.toplevel = 0;
return 0;
}
int activitySHMGetAttributes(
struct activity *act,
struct activityAttributes *attributes
)
{
struct activityData *aData = NULL;
#ifdef _DEBUG
printf("activitySHMGetAttributes\n");
#endif
if (!act || !attributes)
return -1;
aData = (struct activityData*)act->shm->data;
struct activityAttributes *_attributesPtr = &aData->attributes;
memcpy(attributes,_attributesPtr,sizeof(struct activityAttributes));
#ifdef _DEBUG
printf("activitySHMGetAttributes (%dx%d) movable(%d) visible(%d) toplevel(%d) finish\n",
attributes->w,
attributes->h,
attributes->movable,
attributes->visible,
attributes->toplevel);
#endif
return 0;
}
int activitySHMSetAttributes(
struct activity *act,
struct activityAttributes *attributes
)
{
struct activityData *aData = NULL;
if (!act || !attributes)
return -1;
aData = (struct activityData*)act->shm->data;
struct activityAttributes *_attributesPtr = &aData->attributes;
if (!_attributesPtr)
return -1;
memcpy(_attributesPtr,attributes,sizeof(struct activityAttributes));
#ifdef _DEBUG
printf("activitySHMSetAttributes finish\n");
#endif
return 0;
}
/** set an event for the activity
*/
int activitySHMPutEvent( // activityData
struct activity *act,
struct activityEvent *event
)
{
struct activityData *aData = NULL;
#ifdef _DEBUG
printf("activitySHMPutEvent\n");
#endif
if (!act || !event)
return -1;
aData = (struct activityData*)act->shm->data;
struct activityEvent *_eventPtr = &aData->event;
if (!_eventPtr)
return -1;
event->active = 1;
memcpy(_eventPtr,event,sizeof(struct activityEvent));
#ifdef _DEBUG
printf("activitySHMPutEvent finish\n");
#endif
return 0;
}
/** get the pointer to the surface from the SHM data
*/
void *activitySHMGetSurface( // activityData
struct activity *act
)
{
struct activityData *aData = NULL;
void *surface;
#ifdef _DEBUG
printf("activitySHMGetSurface\n");
#endif
/** need to connect the shared memmory before this
* function (shmat) and (shmdt) afterwards
*/
aData = (struct activityData*)act->shm->data;
aData->surface = act->shm->data+
sizeof(struct activityData);
surface = aData->surface;
#ifdef _DEBUG
printf("activitySHMGetSurface ptr(%p) finish\n",surface);
#endif
return surface;
}
int _activity_add_event_button(
struct activityEvent *event,
int x,
int y
)
{
if (!event)
return -1;
event->button.x = x;
event->button.y = y;
event->active = 1;
return 0;
}
int activityAddEventButtonDown( // activityData
struct activity *act,
int x,
int y
)
{
struct activityEvent *event = NULL;
struct activityData *aData = NULL;
if (!act)
return -1;
#ifdef _DEBUG
printf("activityAddEventButtonDown EVENTFLOW\n");
#endif
void *data = shmat(act->shm->id,0,0);
aData = data;
event = &aData->event;
_activity_add_event_button(event,x,y);
event->type = _ACTIVITY_EVENT_BUTTONDOWN;
shmdt(data);
#ifdef _DEBUG
printf("activityAddEventButtonDown finish EVENTFLOW\n");
#endif
return 0;
}
int activityAddEventButtonUp( // activityData
struct activity *act,
int x,
int y
)
{
struct activityData *aData = NULL;
struct activityEvent *event = NULL;
if (!act)
return -1;
#ifdef _DEBUG
printf("activityAddEventButtonUp EVENTFLOW\n");
#endif
void *data = shmat(act->shm->id,0,0);
aData = data;
event = &aData->event;
_activity_add_event_button(event,x,y);
event->type = _ACTIVITY_EVENT_BUTTONUP;
shmdt(data);
#ifdef _DEBUG
printf("activityAddEventButtonUp finish EVENTFLOW\n");
#endif
return 0;
}
/** event for the desktop to repaint the surface
*/
int activityAddEventExpose( // activityData
struct activity *act
)
{
struct activityData *aData = NULL;
struct activityEvent *event = NULL;
if (!act)
return -1;
if (!act->shm)
return -1;
#ifdef _DEBUG
printf("activityAddEventExpose\n");
#endif
void *data = shmat(act->shm->id,0,0);
if (!data)
return -1;
aData = data;
event = &aData->event;
event->active = 1;
event->type = _ACTIVITY_EVENT_EXPOSE;
shmdt(data);
#ifdef _DEBUG
printf("activityAddEventExpose finish\n");
#endif
return 0;
}
/** event for the application to repaint it's surface
*/
int activityAddEventRepaint( // activityData
struct activity *act
)
{
struct activityEvent *event = NULL;
struct activityData *aData = NULL;
static int run = 0;
if (!act)
return -1;
#ifdef _DEBUG
printf("activityAddEventRepaint UEVENT %d\n",run);
#endif
void *data = shmat(act->shm->id,0,0);
aData = data;
event = &aData->event;
event->active = 1;
event->type = _ACTIVITY_EVENT_REPAINT;
shmdt(data);
#ifdef _DEBUG
printf("activityAddEventRepaint finish UEVENT %d\n",run);
#endif
run++;
return 0;
}
int activityEventActive( // activityData - needs to be synced
struct activity *act
)
{
int active = 0;
void *data = NULL;
struct activityEvent *event = NULL;
struct activityData *aData = NULL;
data = shmat(act->shm->id,0,0);
aData = (struct activityData*)data;
event = &aData->event;
active = event->active;
shmdt(data);
return active;
}
int activityEventGet( // activityData
struct activity *act,
struct activityEvent *remoteEvent
)
{
#ifdef _DEBUG
printf("activityEventGet\n");
#endif
void *data = NULL;
struct activityEvent *event = NULL;
struct activityData *aData = NULL;
data = shmat(act->shm->id,0,0);
aData = data;
event = &aData->event;
event->active = 0;
#ifdef _DEBUG
printf("activityEventGet ");
switch(event->type)
{
case _ACTIVITY_EVENT_REPAINT:
printf("_ACTIVITY_EVENT_REPAINT\n");
break;
case _ACTIVITY_EVENT_EXPOSE:
printf("_ACTIVITY_EVENT_EXPOSE\n");
break;
case _ACTIVITY_EVENT_BUTTONDOWN:
printf("_ACTIVITY_EVENT_BUTTONDOWN\n");
break;
case _ACTIVITY_EVENT_BUTTONUP:
printf("_ACTIVITY_EVENT_BUTTONUP\n");
break;
}
#endif
memcpy(remoteEvent,event,sizeof(struct activityEvent));
shmdt(data);
#ifdef _DEBUG
printf("activityEventGet finish\n");
#endif
return 0;
}
int activityEventIsEvent( // activityData - needs to be synced
struct activity *act,
int type
)
{
#ifdef _DEBUG
printf("activityEventIsEvent\n");
#endif
if (!act)
return 0;
void *data = NULL;
struct activityData *aData = NULL;
data = shmat(act->shm->id,0,0);
aData = data;
if (aData->event.type==type)
{
shmdt(data);
return 1;
}
shmdt(data);
return 0;
}
#define _OVERRIDE_ACTIVITY_ATTRIBUTES_NO
/** remake (to somin like a list of attributes..)
*/
int activitySetMovable( struct activity *act, int movable, int sync )
{
struct activityData *aData;
#ifdef _DEBUG
printf("activitySetMovable\n");
#endif
#ifdef _OVERRIDE_ACTIVITY_ATTRIBUTES
return 0;
#endif
if (!act) return 1;
if (sync==1) activityLock(act);
aData = (struct activityData*)shmat(act->shm->id,0,0);
aData->attributes.movable = movable;
shmdt(aData);
if (sync==1) activityUnlock(act);
#ifdef _DEBUG
printf("activitySetMovable finish\n");
#endif
return 0;
}
int activityGetMovable( struct activity *act, int sync )
{
struct activityData *aData;
#ifdef _DEBUG
printf("activityGetMovable\n");
#endif
#ifdef _OVERRIDE_ACTIVITY_ATTRIBUTES
return 1;
#endif
if (!act) return -1;
int movable = 0;
if (sync==1) activityLock(act);
aData = (struct activityData*)shmat(act->shm->id,0,0);
movable = aData->attributes.movable;
shmdt(aData);
if (sync==1) activityUnlock(act);
#ifdef _DEBUG
printf("activityGetMovable finish\n");
#endif
return movable;
}
int activitySetVisible( struct activity *act, int visible, int sync )
{
struct activityData *aData;
#ifdef _DEBUG
printf("activitySetVisible\n");
#endif
#ifdef _OVERRIDE_ACTIVITY_ATTRIBUTES
return 0;
#endif
if (!act) return 1;
if (sync==1) activityLock(act);
aData = (struct activityData*)shmat(act->shm->id,0,0);
aData->attributes.visible = visible;
shmdt(aData);
if (sync==1) activityUnlock(act);
#ifdef _DEBUG
printf("activitySetVisible finish\n");
#endif
return 0;
}
int activityGetVisible( struct activity *act, int sync )
{
struct activityData *aData;
#ifdef _OVERRIDE_ACTIVITY_ATTRIBUTES
return 1;
#endif
if (!act) return -1;
int visible = 0;
if (sync==1) activityLock(act);
aData = (struct activityData*)shmat(act->shm->id,0,0);
visible = aData->attributes.visible;
shmdt(aData);
if (sync==1) activityUnlock(act);
return visible;
}
int activitySetToplevel( struct activity *act, int toplevel, int sync )
{
struct activityData *aData;
#ifdef _DEBUG
printf("activitySetToplevel\n");
#endif
#ifdef _OVERRIDE_ACTIVITY_ATTRIBUTES
return 0;
#endif
if (!act) return 1;
if (sync==1) activityLock(act);
aData = (struct activityData*)shmat(act->shm->id,0,0);
aData->attributes.toplevel = toplevel;
shmdt(aData);
if (sync==1) activityUnlock(act);
#ifdef _DEBUG
printf("activitySetToplevel finish\n");
#endif
return 0;
}
int activityGetToplevel( struct activity *act, int sync )
{
struct activityData *aData;
#ifdef _DEBUG
printf("activityGetToplevel\n");
#endif
#ifdef _OVERRIDE_ACTIVITY_ATTRIBUTES
return 0;
#endif
if (!act) return -1;
int toplevel = 0;
if (sync==1) activityLock(act);
aData = (struct activityData*)shmat(act->shm->id,0,0);
toplevel = aData->attributes.toplevel;
shmdt(aData);
if (sync==1) activityUnlock(act);
#ifdef _DEBUG
printf("activityGetToplevel finish\n");
#endif
return toplevel;
}
int activitySetAngle( struct activity *act, int angle, int sync )
{
struct activityData *aData;
#ifdef _DEBUG
printf("activitySetAngle\n");
#endif
#ifdef _OVERRIDE_ACTIVITY_ATTRIBUTES
return 0;
#endif
if (!act) return 1;
if (sync==1) activityLock(act);
aData = (struct activityData*)shmat(act->shm->id,0,0);
aData->attributes.angle = angle;
shmdt(aData);
if (sync==1) activityUnlock(act);
#ifdef _DEBUG
printf("activitySetAngle finish\n");
#endif
return 0;
}
int activityGetAngle( struct activity *act, int sync )
{
struct activityData *aData;
#ifdef _DEBUG
printf("activityGetAngle\n");
#endif
#ifdef _OVERRIDE_ACTIVITY_ATTRIBUTES
return -1;
#endif
if (!act) return -1;
int angle = 0;
if (sync==1) activityLock(act);
aData = (struct activityData*)shmat(act->shm->id,0,0);
angle = aData->attributes.angle;
shmdt(aData);
if (sync==1) activityUnlock(act);
#ifdef _DEBUG
printf("activityGetAngle finish\n");
#endif
return angle;
}
int activitySetForceangle( struct activity *act, int angle, int sync )
{
struct activityData *aData;
#ifdef _DEBUG
printf("activitySetForceangle\n");
#endif
#ifdef _OVERRIDE_ACTIVITY_ATTRIBUTES
return 0;
#endif
if (!act) return 1;
if (sync==1) activityLock(act);
aData = (struct activityData*)shmat(act->shm->id,0,0);
aData->attributes.forceangle = angle;
shmdt(aData);
if (sync==1) activityUnlock(act);
#ifdef _DEBUG
printf("activitySetForecast finish\n");
#endif
return 0;
}
int activityGetForceangle( struct activity *act, int sync )
{
struct activityData *aData;
#ifdef _DEBUG
printf("activityGetForceangle\n");
#endif
#ifdef _OVERRIDE_ACTIVITY_ATTRIBUTES
return -1;
#endif
if (!act) return -1;