Merge lp:~oif-team/geis/geis2-add-device into lp:geis

Proposed by Stephen M. Webb
Status: Merged
Merged at revision: 98
Proposed branch: lp:~oif-team/geis/geis2-add-device
Merge into: lp:geis
Diff against target: 1099 lines (+802/-161)
12 files modified
ChangeLog (+36/-0)
include/geis/geis.h (+230/-160)
libutouch-geis/Makefile.am (+1/-0)
libutouch-geis/geis_device.c (+273/-0)
libutouch-geis/geis_device.h (+104/-0)
libutouch-geis/libutouch-geis.ver (+7/-0)
testsuite/geis2/Makefile.am (+1/-0)
testsuite/geis2/check_device.c (+45/-0)
testsuite/geis2/check_geis2_api.c (+2/-0)
testsuite/libutouch-geis/Makefile.am (+2/-1)
testsuite/libutouch-geis/check_device.c (+99/-0)
testsuite/libutouch-geis/check_geis2_internals.c (+2/-0)
To merge this branch: bzr merge lp:~oif-team/geis/geis2-add-device
Reviewer Review Type Date Requested Status
Henrik Rydberg (community) Approve
Review via email: mp+44341@code.launchpad.net

Description of the change

Added GEIS v2.0 device module

To post a comment you must log in.
Revision history for this message
Henrik Rydberg (rydberg) wrote :

Are the region defines untouched in this branch? It seems like it from the logs, but there is quite a bit of diff touching the region header.

review: Needs Information
Revision history for this message
Stephen M. Webb (bregma) wrote :

I think you mean the geis.h header.

I had to rearrange a chunk of stuff in include/geis/geis.h to move the GeisEvent declarations before the GeisDevice declarations. It looks like a big diff because the diff machine saw this as moving everything else but the GeisEvent section around. the GeisRegion and GeisSubscriptions chunks are in fact unchanged.

Revision history for this message
Henrik Rydberg (rydberg) wrote :

Ok.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'ChangeLog'
--- ChangeLog 2010-12-20 18:06:36 +0000
+++ ChangeLog 2010-12-21 14:03:26 +0000
@@ -1,5 +1,41 @@
12010-12-20 Stephen M. Webb <stephen.webb@canonical.com>12010-12-20 Stephen M. Webb <stephen.webb@canonical.com>
22
3 Added GEIS v2.0 input device implementation.
4
5 * libutouch-geis/geis_device.h (GeisDeviceBag): new type
6 (geis_device_bag_new): new function
7 (geis_device_bag_delete): new function
8 (geis_device_bag_count): new function
9 (geis_device_bag_device): new function
10 (geis_device_bag_insert): new function
11 (geis_device_bag_remove): new function
12 * libutouch-geis/geis_device.c: implemented new functions
13 * testsuite/libutouch-geis/check_device.c: new test suite
14 * testsuite/libutouch-geis/Makefile.am: added new test suite
15 * testsuite/libutouch-geis/check_geis2_internals.c: added new test suite
16
172010-12-20 Stephen M. Webb <stephen.webb@canonical.com>
18
19 Added GEIS v2.0 input device API
20
21 * libutouch-geis/geis_device.c: new file
22 * libutouch-geis/geis_device.h: new file
23 * testsuite/geis2/check_device.c: new test suite
24 * include/geis/geis.h (GeisDevice): new type
25 (geis_register_device_callback): new function
26 (geis_device_ref): new function
27 (geis_device_unref): new function
28 (geis_device_name): new function
29 (geis_device_id): new function
30 (geis_device_attr_count): new function
31 (geis_device_attr): new function
32 * libutouch-geis/Makefile.am: added new files
33 * libutouch-geis/libutouch-geis.ver: added new API symbols
34 * testsuite/geis2/Makefile.am: added new test suite
35 * testsuite/geis2/check_geis2_api.c: added new test suite
36
372010-12-20 Stephen M. Webb <stephen.webb@canonical.com>
38
3 Updates to match new GEIS v2.0 spec release of 2010.12.20.39 Updates to match new GEIS v2.0 spec release of 2010.12.20.
4 - added a pointer type to the GEIS attr module40 - added a pointer type to the GEIS attr module
5 - added additional required GEIS initialization arguments41 - added additional required GEIS initialization arguments
642
=== modified file 'include/geis/geis.h'
--- include/geis/geis.h 2010-12-20 18:06:36 +0000
+++ include/geis/geis.h 2010-12-21 14:03:26 +0000
@@ -658,166 +658,6 @@
658/* @} */658/* @} */
659659
660/**660/**
661 * @defgroup geis2_region Gesture Regions (GEIS v2.0)
662 * @{
663 */
664
665typedef struct _GeisRegion *GeisRegion;
666
667/**
668 * @defgroup geis2_region_init_args Gesture Region Initialization Arguments
669 *
670 * Gesture regions are created to describe a particular display/feedback region.
671 * The type of the region can not be changed after creation (just create a new
672 * region for that). The types of regions are platform specific and each type
673 * may require addition arguments.
674 *
675 * The following region initialization argument names are required by the
676 * GEIS v2.0 specification.
677 *
678 * @{
679 */
680#define GEIS_REGION_X11_ROOT "org.libgeis.region.x11.root"
681#define GEIS_REGION_X11_WINDOWID "org.libgeis.region.x11.windowid"
682
683/* @} */
684
685/**
686 * Creates a new GEIS v2.0 region.
687 *
688 * @param[in] geis The GEIS API instance.
689 * @param[in] name A name. Used for diagnostics.
690 * @param[in] init_arg_name The name of the first initialization argument.
691 *
692 * The initialization argument list must be terminated by a NULL.
693 *
694 * @returns a newly created region, or NULL on failure.
695 */
696GEIS_API GeisRegion geis_region_new(Geis geis,
697 GeisString name,
698 GeisString init_arg_name, ...);
699
700/**
701 * Destroys a GEIS v2.0 region.
702 *
703 * @param[in] region The region.
704 */
705GEIS_API GeisStatus geis_region_delete(GeisRegion region);
706
707/**
708 * Gets the name of a GEIS v2.0 region.
709 *
710 * @param[in] region The region.
711 *
712 * Returns the @p name value used when creating the region.
713 */
714GEIS_API GeisString geis_region_name(GeisRegion region);
715
716/* @} */
717
718/**
719 * @defgroup geis2_subscription Gesture Subscription (GEIS v2.0)
720 * @{
721 */
722
723typedef struct _GeisFilter *GeisFilter;
724typedef struct _GeisSubscription *GeisSubscription;
725
726/**
727 * Flags to refine the behaviour of the gesture subscription.
728 */
729typedef enum _GeisSubscriptionFlags
730{
731 GEIS_SUBSCRIPTION_NONE = 0x0000,
732 GEIS_SUBSCRIPTION_GRAB = 0x0001,
733 GEIS_SUBSCRIPTION_CONT = 0x0002
734} GeisSubscriptionFlags;
735
736/**
737 * Creates a new subscription.
738 *
739 * @param[in] geis The GEIS API instance.
740 * @param[in] name A name.
741 * @param[in] flags Some flags.
742 *
743 * @returns a GeisSubscription object or NULL on failure.
744 *
745 * A gesture subscription is required for any gesture events to be delivered
746 * from the GEIS API.
747 */
748GEIS_API GeisSubscription geis_subscription_new(Geis geis,
749 GeisString name,
750 GeisSubscriptionFlags flags);
751
752/**
753 * Destroys a GEIS v2.0 subscription object.
754 *
755 * @param[in] subscription The subscription.
756 */
757GEIS_API GeisStatus geis_subscription_delete(GeisSubscription subscription);
758
759/**
760 * Activates a subscription.
761 *
762 * @param[in] subscription The subscription.
763 *
764 * Puts the subscription into the active state. Gesture events will be
765 * delivered for this subscription.
766 */
767GEIS_API GeisStatus geis_subscription_activate(GeisSubscription subscription);
768
769/**
770 * Deactivates a subscription.
771 *
772 * @param[in] subscription The subscription.
773 *
774 * Puts the subscription into the inactive state. Gesture events will not be
775 * delivered for this subscription.
776 */
777GEIS_API GeisStatus geis_subscription_deactivate(GeisSubscription subscription);
778
779/**
780 * Gets the name given to a subscription when it was created.
781 *
782 * @param[in] subscription The subscription.
783 */
784GEIS_API GeisString geis_subscription_name(GeisSubscription subscription);
785
786/**
787 * Gets the ID assigned to a subscription when it was created.
788 *
789 * @param[in] subscription The subscription.
790 */
791GEIS_API GeisInteger geis_subscription_id(GeisSubscription subscription);
792
793/**
794 * Adds a filter to a subscription.
795 *
796 * @param[in] subscription The subscription.
797 * @param[in] filter The filter to be added to the subscription.
798 *
799 * Thye effect of filters are ANDed together so that, for example, a
800 * subscription that has a filter for 3-finger gestures and drag gestures will
801 * produce events only for 3-finger drag gestures.
802 *
803 * The default is no filters: that is, all possible gesture events will be
804 * reported.
805 */
806GEIS_API GeisStatus geis_subscription_add_filter(GeisSubscription subscription,
807 GeisFilter filter);
808
809/**
810 * Removes a filter from a subscription.
811 *
812 * @param[in] subscription The subscription.
813 * @param[in] filter The filter to be removed from the subscription.
814 */
815GEIS_API GeisStatus geis_subscription_remove_filter(GeisSubscription subscription,
816 GeisFilter filter);
817
818/* @} */
819
820/**
821 * @defgroup geis2_event_control Event Control (GEIS v2.0)661 * @defgroup geis2_event_control Event Control (GEIS v2.0)
822 *662 *
823 * These functions are used to dispatch events generated from the various other663 * These functions are used to dispatch events generated from the various other
@@ -978,6 +818,236 @@
978818
979/* @} */819/* @} */
980820
821/**
822 * @defgroup geis2_device Gesture Input Devices (GEIS v2.0)
823 * @{
824 */
825
826/**
827 * An opaque pointer type representing a gesture-capable input device.
828 *
829 * GeisDevice objects are created by the GEIS API and are reference counted.
830 */
831typedef struct _GeisDevice *GeisDevice;
832
833GEIS_API void geis_register_device_callback(Geis geis,
834 GeisEventCallback event_callback,
835 void *context);
836
837/**
838 * Adds a reference count to a device.
839 *
840 * @param[in] device The device.
841 *
842 * An application that wishes to guarantee the device object remains valid
843 * should add a reference using this call, and unref when the object is no
844 * longer needed.
845 */
846GEIS_API void geis_device_ref(GeisDevice device);
847
848/**
849 * Removes a reference count from a device.
850 *
851 * @param[in] device The device.
852 *
853 * This function decrements the number of references to the device and, if the
854 * number of references hits zero, deletes the device.
855 */
856GEIS_API void geis_device_unref(GeisDevice device);
857
858/**
859 * Gets the name of teh input device.
860 *
861 * @param[in] device The device.
862 */
863GEIS_API GeisString geis_device_name(GeisDevice device);
864
865/**
866 * Gets the system identifier of the iput device.
867 *
868 * @param[in] device The device.
869 *
870 * The system-defined device identifier is system- and possibly
871 * device-dependent.
872 */
873GEIS_API GeisInteger geis_device_id(GeisDevice device);
874
875/**
876 * Gets the number of attributes of the device.
877 *
878 * @param[in] device The device.
879 */
880GEIS_API GeisSize geis_device_attr_count(GeisDevice device);
881
882/**
883 * Gets the indicated attribute of the device.
884 *
885 * @param[in] device The device.
886 */
887GEIS_API GeisAttr geis_device_attr(GeisDevice device, GeisSize index);
888
889/* @} */
890
891/**
892 * @defgroup geis2_region Gesture Regions (GEIS v2.0)
893 * @{
894 */
895
896typedef struct _GeisRegion *GeisRegion;
897
898/**
899 * @defgroup geis2_region_init_args Gesture Region Initialization Arguments
900 *
901 * Gesture regions are created to describe a particular display/feedback region.
902 * The type of the region can not be changed after creation (just create a new
903 * region for that). The types of regions are platform specific and each type
904 * may require addition arguments.
905 *
906 * The following region initialization argument names are required by the
907 * GEIS v2.0 specification.
908 *
909 * @{
910 */
911#define GEIS_REGION_X11_ROOT "org.libgeis.region.x11.root"
912#define GEIS_REGION_X11_WINDOWID "org.libgeis.region.x11.windowid"
913
914/* @} */
915
916/**
917 * Creates a new GEIS v2.0 region.
918 *
919 * @param[in] geis The GEIS API instance.
920 * @param[in] name A name. Used for diagnostics.
921 * @param[in] init_arg_name The name of the first initialization argument.
922 *
923 * The initialization argument list must be terminated by a NULL.
924 *
925 * @returns a newly created region, or NULL on failure.
926 */
927GEIS_API GeisRegion geis_region_new(Geis geis,
928 GeisString name,
929 GeisString init_arg_name, ...);
930
931/**
932 * Destroys a GEIS v2.0 region.
933 *
934 * @param[in] region The region.
935 */
936GEIS_API GeisStatus geis_region_delete(GeisRegion region);
937
938/**
939 * Gets the name of a GEIS v2.0 region.
940 *
941 * @param[in] region The region.
942 *
943 * Returns the @p name value used when creating the region.
944 */
945GEIS_API GeisString geis_region_name(GeisRegion region);
946
947/* @} */
948
949/**
950 * @defgroup geis2_subscription Gesture Subscription (GEIS v2.0)
951 * @{
952 */
953
954typedef struct _GeisFilter *GeisFilter;
955typedef struct _GeisSubscription *GeisSubscription;
956
957/**
958 * Flags to refine the behaviour of the gesture subscription.
959 */
960typedef enum _GeisSubscriptionFlags
961{
962 GEIS_SUBSCRIPTION_NONE = 0x0000,
963 GEIS_SUBSCRIPTION_GRAB = 0x0001,
964 GEIS_SUBSCRIPTION_CONT = 0x0002
965} GeisSubscriptionFlags;
966
967/**
968 * Creates a new subscription.
969 *
970 * @param[in] geis The GEIS API instance.
971 * @param[in] name A name.
972 * @param[in] flags Some flags.
973 *
974 * @returns a GeisSubscription object or NULL on failure.
975 *
976 * A gesture subscription is required for any gesture events to be delivered
977 * from the GEIS API.
978 */
979GEIS_API GeisSubscription geis_subscription_new(Geis geis,
980 GeisString name,
981 GeisSubscriptionFlags flags);
982
983/**
984 * Destroys a GEIS v2.0 subscription object.
985 *
986 * @param[in] subscription The subscription.
987 */
988GEIS_API GeisStatus geis_subscription_delete(GeisSubscription subscription);
989
990/**
991 * Activates a subscription.
992 *
993 * @param[in] subscription The subscription.
994 *
995 * Puts the subscription into the active state. Gesture events will be
996 * delivered for this subscription.
997 */
998GEIS_API GeisStatus geis_subscription_activate(GeisSubscription subscription);
999
1000/**
1001 * Deactivates a subscription.
1002 *
1003 * @param[in] subscription The subscription.
1004 *
1005 * Puts the subscription into the inactive state. Gesture events will not be
1006 * delivered for this subscription.
1007 */
1008GEIS_API GeisStatus geis_subscription_deactivate(GeisSubscription subscription);
1009
1010/**
1011 * Gets the name given to a subscription when it was created.
1012 *
1013 * @param[in] subscription The subscription.
1014 */
1015GEIS_API GeisString geis_subscription_name(GeisSubscription subscription);
1016
1017/**
1018 * Gets the ID assigned to a subscription when it was created.
1019 *
1020 * @param[in] subscription The subscription.
1021 */
1022GEIS_API GeisInteger geis_subscription_id(GeisSubscription subscription);
1023
1024/**
1025 * Adds a filter to a subscription.
1026 *
1027 * @param[in] subscription The subscription.
1028 * @param[in] filter The filter to be added to the subscription.
1029 *
1030 * Thye effect of filters are ANDed together so that, for example, a
1031 * subscription that has a filter for 3-finger gestures and drag gestures will
1032 * produce events only for 3-finger drag gestures.
1033 *
1034 * The default is no filters: that is, all possible gesture events will be
1035 * reported.
1036 */
1037GEIS_API GeisStatus geis_subscription_add_filter(GeisSubscription subscription,
1038 GeisFilter filter);
1039
1040/**
1041 * Removes a filter from a subscription.
1042 *
1043 * @param[in] subscription The subscription.
1044 * @param[in] filter The filter to be removed from the subscription.
1045 */
1046GEIS_API GeisStatus geis_subscription_remove_filter(GeisSubscription subscription,
1047 GeisFilter filter);
1048
1049/* @} */
1050
981#ifdef __cplusplus1051#ifdef __cplusplus
982} // extern "C"1052} // extern "C"
983#endif1053#endif
9841054
=== modified file 'libutouch-geis/Makefile.am'
--- libutouch-geis/Makefile.am 2010-12-20 18:06:36 +0000
+++ libutouch-geis/Makefile.am 2010-12-21 14:03:26 +0000
@@ -28,6 +28,7 @@
28 geis_backend_protected.h \28 geis_backend_protected.h \
29 geis_backend_multiplexor.h geis_backend_multiplexor.c \29 geis_backend_multiplexor.h geis_backend_multiplexor.c \
30 geis_backend_test_fixture.h geis_backend_test_fixture.c \30 geis_backend_test_fixture.h geis_backend_test_fixture.c \
31 geis_device.h geis_device.c \
31 geis_error.h geis_error.c \32 geis_error.h geis_error.c \
32 geis_event.h geis_event.c \33 geis_event.h geis_event.c \
33 geis_event_queue.h geis_event_queue.c \34 geis_event_queue.h geis_event_queue.c \
3435
=== added file 'libutouch-geis/geis_device.c'
--- libutouch-geis/geis_device.c 1970-01-01 00:00:00 +0000
+++ libutouch-geis/geis_device.c 2010-12-21 14:03:26 +0000
@@ -0,0 +1,273 @@
1/**
2 * @file libutouch-geis/geis_region.c
3 * @brief implementation of the uTouch GEIS v2.0 API Input Device module
4 *
5 * Copyright 2010 Canonical Ltd.
6 *
7 * This library is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU Lesser General Public License as published by the Free
9 * Software Foundation; either version 3 of the License, or (at your option) any
10 * later version.
11 *
12 * This library is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
15 * details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21#include "geis_config.h"
22#include "geis_device.h"
23
24#include "geis_attr.h"
25#include "geis_logging.h"
26#include <stdlib.h>
27#include <string.h>
28
29
30struct _GeisDevice
31{
32 GeisSize ref_count;
33 GeisString name;
34 GeisInteger id;
35 GeisAttrBag attr_bag;
36};
37
38struct _GeisDeviceBag
39{
40 GeisDevice *device_store;
41 GeisSize device_store_size;
42 GeisSize device_count;
43};
44
45static const int device_bag_growth_constant = 2;
46
47
48GeisDeviceBag
49geis_device_bag_new()
50{
51 GeisDeviceBag bag = calloc(1, sizeof(struct _GeisDeviceBag));
52 if (!bag)
53 {
54 geis_error("error allocating device bag");
55 goto final_exit;
56 }
57
58 bag->device_store = calloc(1, sizeof(struct _GeisDevice));
59 if (!bag->device_store)
60 {
61 geis_error("error allocating device bag store");
62 goto unwind_bag;
63 }
64
65 bag->device_store_size = 1;
66 bag->device_count = 0;
67 goto final_exit;
68
69unwind_bag:
70 free(bag);
71 bag = NULL;
72final_exit:
73 return bag;
74}
75
76
77void
78geis_device_bag_delete(GeisDeviceBag bag)
79{
80 GeisSize i;
81 for (i = bag->device_count; i > 0; --i)
82 {
83 geis_device_unref(bag->device_store[i-1]);
84 }
85 free(bag->device_store);
86 free(bag);
87}
88
89
90GeisSize
91geis_device_bag_count(GeisDeviceBag bag)
92{
93 return bag->device_count;
94}
95
96
97GeisDevice
98geis_device_bag_device(GeisDeviceBag bag, GeisSize index)
99{
100 GeisDevice device = NULL;
101 if (index >= bag->device_count)
102 {
103 geis_warning("device bag index out of range");
104 }
105 else
106 {
107 device = bag->device_store[index];
108 }
109 return device;
110}
111
112
113GeisStatus
114geis_device_bag_insert(GeisDeviceBag bag, GeisDevice device)
115{
116 GeisStatus status = GEIS_STATUS_UNKNOWN_ERROR;
117 if (bag->device_count >= bag->device_store_size)
118 {
119 GeisSize new_store_size = bag->device_store_size * device_bag_growth_constant;
120 GeisDevice *new_store = realloc(bag->device_store,
121 new_store_size * sizeof(struct _GeisDevice));
122 if (!new_store)
123 {
124 geis_error("failed to reallocate device bag");
125 goto error_exit;
126 }
127 bag->device_store = new_store;
128 bag->device_store_size = new_store_size;
129 }
130 bag->device_store[bag->device_count++] = device;
131 status = GEIS_STATUS_SUCCESS;
132
133error_exit:
134 return status;
135}
136
137GeisStatus
138geis_device_bag_remove(GeisDeviceBag bag, GeisDevice device)
139{
140 GeisSize i;
141 GeisStatus status = GEIS_STATUS_SUCCESS;
142 for (i = 0; i < bag->device_count; ++i)
143 {
144 if (bag->device_store[i] == device)
145 {
146 GeisSize j;
147 geis_device_unref(bag->device_store[i]);
148 --bag->device_count;
149 for (j = i; j < bag->device_count; ++j)
150 {
151 bag->device_store[j] = bag->device_store[j+1];
152 }
153 break;
154 }
155 }
156 return status;
157}
158
159
160/*
161 * Creates a new, empty device.
162 */
163GeisDevice
164geis_device_new(GeisString name, GeisInteger id)
165{
166 GeisDevice device = calloc(1, sizeof(struct _GeisDevice));
167 if (!device)
168 {
169 geis_error("error allocating input device");
170 goto final_exit;
171 }
172
173 device->attr_bag = geis_attr_bag_new(4);
174 if (!device->attr_bag)
175 {
176 geis_debug("error allocating attr bag");
177 goto unwind_device;
178 }
179
180 device->name = strdup(name);
181 if (!device->name)
182 {
183 geis_debug("error allocating device name");
184 goto unwind_attrs;
185 }
186
187 device->id = id;
188 geis_device_ref(device);
189 goto final_exit;
190
191unwind_attrs:
192 geis_attr_bag_delete(device->attr_bag);
193unwind_device:
194 free(device);
195 device = NULL;
196final_exit:
197 return device;
198}
199
200
201/*
202 * Destroys a device.
203 */
204static void
205_device_delete(GeisDevice device)
206{
207 free((char *)device->name);
208 free(device);
209}
210
211
212/*
213 * Adds a reference count to a device.
214 */
215void
216geis_device_ref(GeisDevice device)
217{
218 __sync_add_and_fetch(&device->ref_count, 1);
219}
220
221
222/*
223 * Removes a reference count from a device.
224 */
225void
226geis_device_unref(GeisDevice device)
227{
228 if (0 == __sync_sub_and_fetch(&device->ref_count, 1))
229 {
230 _device_delete(device);
231 }
232}
233
234
235/*
236 * Gets the name of teh input device.
237 */
238GeisString
239geis_device_name(GeisDevice device)
240{
241 return device->name;
242}
243
244
245/*
246 * Gets the system identifier of the iput device.
247 */
248GeisInteger
249geis_device_id(GeisDevice device)
250{
251 return device->id;
252}
253
254
255/*
256 * Gets the number of attributes of the device.
257 */
258GeisSize
259geis_device_attr_count(GeisDevice device)
260{
261 return geis_attr_bag_count(device->attr_bag);
262}
263
264
265/*
266 * Gets the indicated attribute of the device.
267 */
268GeisAttr
269geis_device_attr(GeisDevice device, GeisSize index)
270{
271 return geis_attr_bag_attr(device->attr_bag, index);
272}
273
0274
=== added file 'libutouch-geis/geis_device.h'
--- libutouch-geis/geis_device.h 1970-01-01 00:00:00 +0000
+++ libutouch-geis/geis_device.h 2010-12-21 14:03:26 +0000
@@ -0,0 +1,104 @@
1/**
2 * @file geis_device.h
3 * @brief internal uTouch Geis Input Device module private interface
4 *
5 * Copyright 2010 Canonical Ltd.
6 *
7 * This library is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU Lesser General Public License as published by the Free
9 * Software Foundation; either version 3 of the License, or (at your option) any
10 * later version.
11 *
12 * This library is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
15 * details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21#ifndef GEIS_DEVICE_H_
22#define GEIS_DEVICE_H_
23
24#include "geis/geis.h"
25
26/**
27 * @defgroup utouch_geis_device_container A Device Container
28 * @{
29 */
30
31/**
32 * An unsorted container for holding devices.
33 */
34typedef struct _GeisDeviceBag *GeisDeviceBag;
35
36/**
37 * Creates a new device bag,
38 */
39GeisDeviceBag geis_device_bag_new();
40
41/**
42 * Destroys a device bag.
43 *
44 * @param[in] bag The device bag,
45 */
46void geis_device_bag_delete(GeisDeviceBag bag);
47
48/**
49 * Gets the number of devices in the bag.
50 *
51 * @param[in] bag The device bag,
52 */
53GeisSize geis_device_bag_count(GeisDeviceBag bag);
54
55/**
56 * Gets an indicated device from a bag.
57 *
58 * @param[in] bag The device bag.
59 * @param[in] index The index.
60 */
61GeisDevice geis_device_bag_device(GeisDeviceBag bag, GeisSize index);
62
63/**
64 * Inserts a device in teh bag.
65 *
66 * @param[in] bag The device bag.
67 * @param[in] device The device to insert.
68 */
69GeisStatus geis_device_bag_insert(GeisDeviceBag bag, GeisDevice device);
70
71/**
72 * Remoes a device from the bag.
73 *
74 * @param[in] bag The device bag.
75 * @param[in] device The device to remove.
76 */
77GeisStatus geis_device_bag_remove(GeisDeviceBag bag, GeisDevice device);
78
79/** @} */
80
81/**
82 * @defgroup utouch_geis_device Internal Device Functions
83 * @{
84 */
85
86/**
87 * Creates a new device.
88 *
89 * @param[in] name A system-specific device name.
90 * @param[in] id A system-specific device identifier.
91 */
92GeisDevice geis_device_new(GeisString name, GeisInteger id);
93
94/**
95 * Inserts an attr into a device.
96 *
97 * @param[in] device A device.
98 * @param[in] attr An attr.
99 */
100void geis_device_add_attr(GeisDevice device, GeisAttr attr);
101
102/* @} */
103
104#endif /* GEIS_DEVICE_H_ */
0105
=== modified file 'libutouch-geis/libutouch-geis.ver'
--- libutouch-geis/libutouch-geis.ver 2010-12-20 18:06:36 +0000
+++ libutouch-geis/libutouch-geis.ver 2010-12-21 14:03:26 +0000
@@ -21,6 +21,12 @@
21 geis_attr_value_to_pointer;21 geis_attr_value_to_pointer;
22 geis_attr_value_to_string;22 geis_attr_value_to_string;
23 geis_delete;23 geis_delete;
24 geis_device_attr;
25 geis_device_attr_count;
26 geis_device_id;
27 geis_device_name;
28 geis_device_ref;
29 geis_device_unref;
24 geis_dispatch_events;30 geis_dispatch_events;
25 geis_error_code;31 geis_error_code;
26 geis_error_count;32 geis_error_count;
@@ -31,6 +37,7 @@
31 geis_region_delete;37 geis_region_delete;
32 geis_region_name;38 geis_region_name;
33 geis_region_new;39 geis_region_new;
40 geis_register_device_callback;
34 geis_register_event_callback;41 geis_register_event_callback;
35 geis_set_configuration;42 geis_set_configuration;
36 geis_subscription_activate;43 geis_subscription_activate;
3744
=== modified file 'testsuite/geis2/Makefile.am'
--- testsuite/geis2/Makefile.am 2010-12-20 18:06:36 +0000
+++ testsuite/geis2/Makefile.am 2010-12-21 14:03:26 +0000
@@ -16,6 +16,7 @@
16check_geis2_api_SOURCES = \16check_geis2_api_SOURCES = \
17 check_attr.c \17 check_attr.c \
18 check_config.c \18 check_config.c \
19 check_device.c \
19 check_error_codes.c \20 check_error_codes.c \
20 check_event.c \21 check_event.c \
21 check_geis_new.c \22 check_geis_new.c \
2223
=== added file 'testsuite/geis2/check_device.c'
--- testsuite/geis2/check_device.c 1970-01-01 00:00:00 +0000
+++ testsuite/geis2/check_device.c 2010-12-21 14:03:26 +0000
@@ -0,0 +1,45 @@
1/**
2 * Unit tests for GEIS v2.0 Input Device Module.
3 */
4#include <check.h>
5
6#include <geis/geis.h>
7
8/* Compile-time test to ensure types are defined */
9START_TEST(geis_device_types)
10{
11 GeisEventType type;
12}
13END_TEST
14
15/* Compile-and-link-time test to verify required functions exist */
16START_TEST(geis_device_functions)
17{
18 Geis geis;
19 GeisEventCallback callback;
20 GeisDevice device;
21 geis_register_device_callback(geis, callback, NULL);
22
23 geis_device_ref(device);
24 geis_device_unref(device);
25 GeisString n = geis_device_name(device);
26 GeisInteger i = geis_device_id(device);
27 GeisSize s = geis_device_attr_count(device);
28 GeisAttr a = geis_device_attr(device, 0);
29}
30END_TEST
31
32
33/* boilerplate */
34Suite *
35geis2_device_suite_new()
36{
37 Suite *s = suite_create("geis2_device");
38
39 TCase *device = tcase_create("geis2_device");
40 tcase_add_test(device, geis_device_types);
41 suite_add_tcase(s, device);
42
43 return s;
44}
45
046
=== modified file 'testsuite/geis2/check_geis2_api.c'
--- testsuite/geis2/check_geis2_api.c 2010-12-20 18:06:36 +0000
+++ testsuite/geis2/check_geis2_api.c 2010-12-21 14:03:26 +0000
@@ -7,6 +7,7 @@
7extern Suite *make_version_macro_suite();7extern Suite *make_version_macro_suite();
8extern Suite *geis2_general_types_suite_new();8extern Suite *geis2_general_types_suite_new();
9extern Suite *geis2_error_codes_suite_new();9extern Suite *geis2_error_codes_suite_new();
10extern Suite *geis2_device_suite_new();
10extern Suite *geis2_geis_new_suite_new();11extern Suite *geis2_geis_new_suite_new();
11extern Suite *geis2_config_suite_new();12extern Suite *geis2_config_suite_new();
12extern Suite *geis2_attr_suite_new();13extern Suite *geis2_attr_suite_new();
@@ -29,6 +30,7 @@
29 srunner_add_suite(sr, geis2_config_suite_new());30 srunner_add_suite(sr, geis2_config_suite_new());
30 srunner_add_suite(sr, geis2_attr_suite_new()); 31 srunner_add_suite(sr, geis2_attr_suite_new());
31 srunner_add_suite(sr, geis2_region_suite_new()); 32 srunner_add_suite(sr, geis2_region_suite_new());
33 srunner_add_suite(sr, geis2_device_suite_new());
32 srunner_add_suite(sr, geis2_subscription_suite_new()); 34 srunner_add_suite(sr, geis2_subscription_suite_new());
33 srunner_add_suite(sr, geis2_event_suite_new()); 35 srunner_add_suite(sr, geis2_event_suite_new());
3436
3537
=== modified file 'testsuite/libutouch-geis/Makefile.am'
--- testsuite/libutouch-geis/Makefile.am 2010-12-20 18:06:36 +0000
+++ testsuite/libutouch-geis/Makefile.am 2010-12-21 14:03:26 +0000
@@ -32,10 +32,11 @@
3232
33check_geis2_internals_SOURCES = \33check_geis2_internals_SOURCES = \
34 check_attr.c \34 check_attr.c \
35 check_geis_private.c \
36 check_backend_multiplexor.c \35 check_backend_multiplexor.c \
36 check_device.c \
37 check_error_reporting.c \37 check_error_reporting.c \
38 check_event_queue.c \38 check_event_queue.c \
39 check_geis_private.c \
39 check_region.c \40 check_region.c \
40 check_subscription.c \41 check_subscription.c \
41 check_geis2_internals.c42 check_geis2_internals.c
4243
=== added file 'testsuite/libutouch-geis/check_device.c'
--- testsuite/libutouch-geis/check_device.c 1970-01-01 00:00:00 +0000
+++ testsuite/libutouch-geis/check_device.c 2010-12-21 14:03:26 +0000
@@ -0,0 +1,99 @@
1/**
2 * unit tests for the geis device module
3 */
4#include <check.h>
5
6#include "libutouch-geis/geis_device.h"
7
8
9/* fixtures */
10static GeisDeviceBag g_device_bag;
11static GeisString g_device_name = "device";
12static GeisInteger g_device_id = 12;
13
14/* fixture setup */
15static void
16construct_bag()
17{
18 g_device_bag = geis_device_bag_new();
19}
20
21/* fixture teardown */
22static void
23destroy_bag()
24{
25 geis_device_bag_delete(g_device_bag);
26}
27
28/* verify bag construction/destruction */
29START_TEST(construct)
30{
31 GeisDeviceBag bag = geis_device_bag_new();
32 fail_unless(bag != NULL, "failed to create device bag");
33 geis_device_bag_delete(bag);
34}
35END_TEST
36
37/* verify bag insertion */
38START_TEST(insert)
39{
40 GeisDevice device = geis_device_new(g_device_name, g_device_id);
41 geis_device_bag_insert(g_device_bag, device);
42 fail_unless(geis_device_bag_count(g_device_bag) == 1,
43 "unexpected bag size after insertion");
44}
45END_TEST
46
47/* verify bag removal */
48START_TEST(remove)
49{
50 GeisDevice device = geis_device_new(g_device_name, g_device_id);
51 geis_device_bag_insert(g_device_bag, device);
52 fail_unless(geis_device_bag_count(g_device_bag) == 1,
53 "unexpected bag size after insertion");
54 geis_device_bag_remove(g_device_bag, device);
55 fail_unless(geis_device_bag_count(g_device_bag) == 0,
56 "unexpected bag size after removal");
57}
58END_TEST
59
60START_TEST(expand)
61{
62 int i;
63 for (i = 0; i < 24; ++i)
64 {
65 GeisSize count;
66 char name[32];
67 sprintf(name, "%04d", i);
68 GeisDevice device = geis_device_new(name, i);
69 geis_device_bag_insert(g_device_bag, device);
70 count = geis_device_bag_count(g_device_bag);
71 fail_unless(count == (i+1),
72 "unexpected bag size %ld after insertion, expected %d",
73 count, i+1);
74 }
75}
76END_TEST
77
78
79
80/* boilerplate */
81Suite *
82make_device_suite()
83{
84 Suite *s = suite_create("utouch-geis2-device");
85
86 TCase *create = tcase_create("device-bag-creation");
87 tcase_add_test(create, construct);
88 suite_add_tcase(s, create);
89
90 TCase *usage = tcase_create("device-bag-usage");
91 tcase_add_checked_fixture(usage, construct_bag, destroy_bag);
92 tcase_add_test(usage, insert);
93 tcase_add_test(usage, remove);
94 tcase_add_test(usage, expand);
95 suite_add_tcase(s, usage);
96
97 return s;
98}
99
0100
=== modified file 'testsuite/libutouch-geis/check_geis2_internals.c'
--- testsuite/libutouch-geis/check_geis2_internals.c 2010-12-17 02:56:43 +0000
+++ testsuite/libutouch-geis/check_geis2_internals.c 2010-12-21 14:03:26 +0000
@@ -8,6 +8,7 @@
8extern Suite *make_attr_suite();8extern Suite *make_attr_suite();
9extern Suite *make_backend_event_posting_suite();9extern Suite *make_backend_event_posting_suite();
10extern Suite *make_backend_multiplexor_suite();10extern Suite *make_backend_multiplexor_suite();
11extern Suite *make_device_suite();
11extern Suite *make_error_reporting_suite();12extern Suite *make_error_reporting_suite();
12extern Suite *make_event_queue_suite();13extern Suite *make_event_queue_suite();
13extern Suite *make_region_suite();14extern Suite *make_region_suite();
@@ -27,6 +28,7 @@
27 srunner_add_suite(sr, make_event_queue_suite());28 srunner_add_suite(sr, make_event_queue_suite());
28 srunner_add_suite(sr, make_backend_multiplexor_suite());29 srunner_add_suite(sr, make_backend_multiplexor_suite());
29 srunner_add_suite(sr, make_backend_event_posting_suite());30 srunner_add_suite(sr, make_backend_event_posting_suite());
31 srunner_add_suite(sr, make_device_suite());
30 srunner_add_suite(sr, make_region_suite());32 srunner_add_suite(sr, make_region_suite());
31 srunner_add_suite(sr, make_subscription_suite());33 srunner_add_suite(sr, make_subscription_suite());
3234

Subscribers

People subscribed via source and target branches

to all changes: